159 lines
6.5 KiB
PHP
159 lines
6.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Turnierplan-Seite der Stadionzeitung (Live-Seite, Sportfest-Ausgabe): EIN
|
||
|
|
* Jugendturnier pro Seite — Kopf (Veranstaltung · Tag / „Turnier F1-Jugend" /
|
||
|
|
* Beginn · Spieldauer · Felder · Modus), Teilnehmer, Spielplan mit LEERER
|
||
|
|
* Ergebnisspalte und eine leere Abschlusstabelle. Das Blatt ist zum
|
||
|
|
* Beschreiben gedacht: am Platz trägt man Ergebnisse und Plätze von Hand ein.
|
||
|
|
*
|
||
|
|
* Quelle ist AUSSCHLIESSLICH data/veranstaltungen.json → turniere[] der
|
||
|
|
* Veranstaltung, auf die die Ausgabe zeigt (`veranstaltung`-Feld); welches
|
||
|
|
* Turnier, sagt der `turnier`-Key des Seiteneintrags. Bewusst live, kein
|
||
|
|
* Snapshot (chat-gepflegte Daten, wie kontakt/aufruf/programm).
|
||
|
|
*
|
||
|
|
* Eintrag: key, title, date, start, spieldauer (Minuten), felder? (Zahl),
|
||
|
|
* modus? (Freitext), teams[], spiele[]{nr, zeit, feld?, heim, gast}
|
||
|
|
*
|
||
|
|
* Eigenes Team wie league-table tr.is-own hervorgehoben (Tönung + Abel-Fett);
|
||
|
|
* erkannt über den Vereinsnamen aus data/club.json als Präfix, damit auch
|
||
|
|
* „TSV 08 Kulmbach 2" getroffen wird.
|
||
|
|
*
|
||
|
|
* Props: $issue (Eintrag aus data/stadionzeitung.json), $turnier (Key)
|
||
|
|
*/
|
||
|
|
$issue = $issue ?? [];
|
||
|
|
$turnierKey = trim((string) ($turnier ?? ''));
|
||
|
|
$v = veranstaltung_find((string) ($issue['veranstaltung'] ?? ''));
|
||
|
|
$t = null;
|
||
|
|
foreach ($v['turniere'] ?? [] as $eintrag) {
|
||
|
|
if (is_array($eintrag) && (string) ($eintrag['key'] ?? '') === $turnierKey) {
|
||
|
|
$t = $eintrag;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if ($v === null || $t === null) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
$clubName = trim((string) (json_load('club')['name'] ?? 'TSV 08 Kulmbach'));
|
||
|
|
$isOwn = static fn (string $team): bool => $clubName !== ''
|
||
|
|
&& str_starts_with(mb_strtolower(trim($team)), mb_strtolower($clubName));
|
||
|
|
|
||
|
|
$date = (string) ($t['date'] ?? '');
|
||
|
|
$weekday = $date !== '' ? german_weekday($date) : '';
|
||
|
|
$kicker = trim(implode(' · ', array_filter([
|
||
|
|
(string) ($v['title'] ?? ''),
|
||
|
|
trim(($weekday !== '' ? $weekday . ', ' : '') . ($date !== '' ? german_date($date) : '')),
|
||
|
|
])));
|
||
|
|
|
||
|
|
$teams = array_values(array_filter(
|
||
|
|
array_map(static fn ($x): string => trim((string) $x), $t['teams'] ?? []),
|
||
|
|
static fn (string $x): bool => $x !== ''
|
||
|
|
));
|
||
|
|
$spiele = array_values(array_filter($t['spiele'] ?? [], 'is_array'));
|
||
|
|
$felder = (int) ($t['felder'] ?? 0);
|
||
|
|
$hatFeld = $felder > 1;
|
||
|
|
|
||
|
|
$meta = [];
|
||
|
|
if (!empty($t['start'])) {
|
||
|
|
$meta[] = 'Beginn ' . (string) $t['start'] . ' Uhr';
|
||
|
|
}
|
||
|
|
if (!empty($t['spieldauer'])) {
|
||
|
|
$meta[] = 'Spieldauer ' . (int) $t['spieldauer'] . ' Min.';
|
||
|
|
}
|
||
|
|
if ($hatFeld) {
|
||
|
|
$meta[] = $felder . ' Felder';
|
||
|
|
}
|
||
|
|
if (!empty($t['modus'])) {
|
||
|
|
$meta[] = (string) $t['modus'];
|
||
|
|
}
|
||
|
|
$sub = trim(implode(' · ', $meta));
|
||
|
|
$title = trim((string) ($t['title'] ?? $turnierKey));
|
||
|
|
// Ab neun Spielen (E-Jugend: zehn) rücken die Zeilen enger, sonst läuft der
|
||
|
|
// Spielplan mit der Abschlusstabelle über die Blattkante.
|
||
|
|
$dicht = count($spiele) > 8;
|
||
|
|
?>
|
||
|
|
<div class="stadionzeitung-turnier<?= $dicht ? ' stadionzeitung-turnier--dicht' : '' ?>">
|
||
|
|
<header class="stadionzeitung-page__head">
|
||
|
|
<?php if ($kicker !== ''): ?>
|
||
|
|
<p class="stadionzeitung-page__kicker"><?= e($kicker) ?></p>
|
||
|
|
<?php endif; ?>
|
||
|
|
<h2 class="stadionzeitung-page__heading"><?= e('Turnier ' . $title) ?></h2>
|
||
|
|
<?php if ($sub !== ''): ?>
|
||
|
|
<p class="stadionzeitung-page__sub"><?= e($sub) ?></p>
|
||
|
|
<?php endif; ?>
|
||
|
|
</header>
|
||
|
|
<span class="stadionzeitung-page__rule" aria-hidden="true"></span>
|
||
|
|
<?php if ($teams !== []): ?>
|
||
|
|
<p class="stadionzeitung-turnier__label">Teilnehmer</p>
|
||
|
|
<p class="stadionzeitung-turnier__teams">
|
||
|
|
<?php foreach ($teams as $i => $team): ?>
|
||
|
|
<?= $i > 0 ? ' · ' : '' ?><span class="stadionzeitung-turnier__team<?= $isOwn($team) ? ' is-own' : '' ?>"><?= e($team) ?></span>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</p>
|
||
|
|
<?php endif; ?>
|
||
|
|
<?php if ($spiele !== []): ?>
|
||
|
|
<table class="stadionzeitung-turnier__spiele">
|
||
|
|
<?php /* Sichtbares Label IST die Tabellenbeschriftung (caption), nicht zusätzlich
|
||
|
|
eine versteckte: sonst liest ein Screenreader beides und damit doppelt. */ ?>
|
||
|
|
<caption class="stadionzeitung-turnier__label">Spielplan</caption>
|
||
|
|
<thead>
|
||
|
|
<tr>
|
||
|
|
<th scope="col">Nr.</th>
|
||
|
|
<th scope="col">Zeit</th>
|
||
|
|
<?php if ($hatFeld): ?>
|
||
|
|
<th scope="col">Feld</th>
|
||
|
|
<?php endif; ?>
|
||
|
|
<th scope="col">Begegnung</th>
|
||
|
|
<th scope="col" class="stadionzeitung-turnier__ergebnis">Ergebnis</th>
|
||
|
|
</tr>
|
||
|
|
</thead>
|
||
|
|
<tbody>
|
||
|
|
<?php foreach ($spiele as $i => $spiel): ?>
|
||
|
|
<?php
|
||
|
|
$heim = trim((string) ($spiel['heim'] ?? ''));
|
||
|
|
$gast = trim((string) ($spiel['gast'] ?? ''));
|
||
|
|
$zeit = trim((string) ($spiel['zeit'] ?? ''));
|
||
|
|
?>
|
||
|
|
<tr>
|
||
|
|
<td class="stadionzeitung-turnier__nr"><?= e((string) ($spiel['nr'] ?? ($i + 1))) ?></td>
|
||
|
|
<td class="stadionzeitung-turnier__zeit"><?php if ($zeit !== ''): ?><time datetime="<?= e($date !== '' ? $date . 'T' . $zeit : $zeit) ?>"><?= e($zeit) ?></time><?php endif; ?></td>
|
||
|
|
<?php if ($hatFeld): ?>
|
||
|
|
<td class="stadionzeitung-turnier__nr"><?= e((string) ($spiel['feld'] ?? '')) ?></td>
|
||
|
|
<?php endif; ?>
|
||
|
|
<td class="stadionzeitung-turnier__paarung"><span class="stadionzeitung-turnier__team<?= $isOwn($heim) ? ' is-own' : '' ?>"><?= e($heim) ?></span> <span class="stadionzeitung-turnier__vs">gegen</span> <span class="stadionzeitung-turnier__team<?= $isOwn($gast) ? ' is-own' : '' ?>"><?= e($gast) ?></span></td>
|
||
|
|
<td class="stadionzeitung-turnier__ergebnis"><span class="stadionzeitung-turnier__blank" aria-hidden="true"></span><span class="stadionzeitung-turnier__colon">:</span><span class="stadionzeitung-turnier__blank" aria-hidden="true"></span></td>
|
||
|
|
</tr>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</tbody>
|
||
|
|
</table>
|
||
|
|
<?php endif; ?>
|
||
|
|
<?php if ($teams !== []): ?>
|
||
|
|
<table class="stadionzeitung-turnier__tabelle">
|
||
|
|
<caption class="stadionzeitung-turnier__label">Platzierung zum Eintragen</caption>
|
||
|
|
<thead>
|
||
|
|
<tr>
|
||
|
|
<th scope="col">Pl.</th>
|
||
|
|
<th scope="col">Teilnehmer</th>
|
||
|
|
<th scope="col"><abbr title="Tore">T</abbr></th>
|
||
|
|
<th scope="col"><abbr title="Tordifferenz">TD</abbr></th>
|
||
|
|
<th scope="col"><abbr title="Punkte">Pkt</abbr></th>
|
||
|
|
</tr>
|
||
|
|
</thead>
|
||
|
|
<tbody>
|
||
|
|
<?php for ($i = 1; $i <= count($teams); $i++): ?>
|
||
|
|
<tr>
|
||
|
|
<td class="stadionzeitung-turnier__nr"><?= $i ?>.</td>
|
||
|
|
<td></td>
|
||
|
|
<td></td>
|
||
|
|
<td></td>
|
||
|
|
<td></td>
|
||
|
|
</tr>
|
||
|
|
<?php endfor; ?>
|
||
|
|
</tbody>
|
||
|
|
</table>
|
||
|
|
<?php endif; ?>
|
||
|
|
</div>
|