Die Tabelle der Frauenmannschaft sah kaputt aus (zehn Mannschaften auf Platz 1, alle grün als Aufstiegszone, überall 0), obwohl sie korrekt war: die Liga startet erst am 06.09., und das einzige Ergebnis war ein Freundschaftsspiel. Beides kommt so vom BFV — vor dem ersten Spieltag liefert die API jeder Mannschaft Rang 1 und dieselbe Zone. league-table erkennt das jetzt an der Summe der gespielten Spiele: Rangspalte zeigt „–", Zonenfarben und Legende entfallen, darüber steht der Hinweis, dass ab dem 1. Spieltag gewertet wird. Tabellen mit laufender Saison (Kreisklasse) bleiben unverändert. Spielzeilen tragen zusätzlich „Freundschaftsspiel" (match_competition_label), damit sichtbar ist, warum ein Testspiel-Ergebnis nicht in der Tabelle steht. Ligaspiele bleiben unbeschriftet — die Sektion nennt die Liga schon. Enthält außerdem den Rahmen um den Tabellen-Scroller (table-scroll-frame), der im Arbeitsstand lag. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
101 lines
4.9 KiB
PHP
101 lines
4.9 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
/**
|
||
* Liga-Tabelle. Props: $table (data/matchcenter.json → teams[].table[]),
|
||
* $caption (Beschriftung für Screenreader/Region, z. B. "Tabelle Kreisklasse").
|
||
* Die eigene Vereinszeile wird hervorgehoben; Auf-/Abstiegszonen über farbige
|
||
* Randmarkierungen (Legende darunter). Horizontal scrollbar auf schmalen Screens
|
||
* (fokussierbare Region, WCAG). Spaltenköpfe in Abel (Coolvetica wäre zu klein).
|
||
*/
|
||
$table = $table ?? [];
|
||
$caption = (string) ($caption ?? 'Tabelle');
|
||
if ($table === []) {
|
||
return;
|
||
}
|
||
$zones = array_column($table, 'zone');
|
||
$hasPromo = in_array('promotion', $zones, true);
|
||
$hasPromoPlayoff = in_array('promotion-playoff', $zones, true);
|
||
$hasRelegPlayoff = in_array('relegation-playoff', $zones, true);
|
||
$hasReleg = in_array('relegation', $zones, true);
|
||
|
||
// Vor dem 1. Spieltag liefert der BFV für JEDE Mannschaft Platz 1 und dieselbe
|
||
// Auf-/Abstiegszone. Beides ist dann bedeutungslos und lässt die Tabelle kaputt
|
||
// aussehen (zehn Erste, alles grün) — deshalb Ränge und Zonen unterdrücken und
|
||
// stattdessen sagen, dass noch nichts gewertet ist. Testspiele zählen hier nicht
|
||
// mit, ein Freundschaftsspiel-Ergebnis ändert die Tabelle also zu Recht nicht.
|
||
$notStarted = array_sum(array_map(
|
||
static fn (array $r): int => (int) ($r['played'] ?? 0),
|
||
$table
|
||
)) === 0;
|
||
if ($notStarted) {
|
||
$hasPromo = $hasPromoPlayoff = $hasRelegPlayoff = $hasReleg = false;
|
||
}
|
||
?>
|
||
<?php if ($notStarted): ?>
|
||
<p class="league-table__note">Die Liga hat noch nicht begonnen – gewertet wird ab dem 1. Spieltag.</p>
|
||
<?php endif; ?>
|
||
<div class="table-scroll-frame">
|
||
<div class="table-scroll" role="region" aria-label="<?= e($caption) ?>" tabindex="0">
|
||
<table class="league-table">
|
||
<caption class="visually-hidden"><?= e($caption) ?></caption>
|
||
<thead>
|
||
<tr>
|
||
<th scope="col" class="league-table__rank">#</th>
|
||
<th scope="col" class="league-table__club">Verein</th>
|
||
<th scope="col"><abbr title="Spiele">Sp</abbr></th>
|
||
<th scope="col"><abbr title="Siege">S</abbr></th>
|
||
<th scope="col"><abbr title="Unentschieden">U</abbr></th>
|
||
<th scope="col"><abbr title="Niederlagen">N</abbr></th>
|
||
<th scope="col"><abbr title="Tordifferenz">Diff</abbr></th>
|
||
<th scope="col"><abbr title="Punkte">Pkt</abbr></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php foreach ($table as $row): ?>
|
||
<?php
|
||
$trClass = [];
|
||
if (!empty($row['is_own_club'])) {
|
||
$trClass[] = 'is-own';
|
||
}
|
||
if (!$notStarted && !empty($row['zone'])) {
|
||
$trClass[] = 'zone-' . e($row['zone']);
|
||
}
|
||
$diff = (int) ($row['goal_diff'] ?? 0);
|
||
?>
|
||
<tr<?= $trClass !== [] ? ' class="' . implode(' ', $trClass) . '"' : '' ?>>
|
||
<td class="league-table__rank"><?= $notStarted ? '–' : (int) ($row['rank'] ?? 0) ?></td>
|
||
<th scope="row" class="league-table__club">
|
||
<?php component('crest', ['src' => $row['crest'] ?? null, 'name' => $row['club'] ?? '']); ?>
|
||
<span class="league-table__name" title="<?= e($row['club'] ?? '') ?>"><?= e($row['club'] ?? '') ?></span>
|
||
</th>
|
||
<td><?= (int) ($row['played'] ?? 0) ?></td>
|
||
<td><?= (int) ($row['won'] ?? 0) ?></td>
|
||
<td><?= (int) ($row['drawn'] ?? 0) ?></td>
|
||
<td><?= (int) ($row['lost'] ?? 0) ?></td>
|
||
<td><?= ($diff > 0 ? '+' : '') . $diff ?></td>
|
||
<td class="league-table__pts"><?= (int) ($row['points'] ?? 0) ?></td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<?php if ($hasPromo || $hasPromoPlayoff || $hasRelegPlayoff || $hasReleg): ?>
|
||
<ul class="league-table__legend">
|
||
<?php if ($hasPromo): ?>
|
||
<li class="league-table__legend-item zone-promotion">Aufstieg</li>
|
||
<?php endif; ?>
|
||
<?php if ($hasPromoPlayoff): ?>
|
||
<li class="league-table__legend-item zone-promotion-playoff">Aufstiegsrelegation</li>
|
||
<?php endif; ?>
|
||
<?php if ($hasRelegPlayoff): ?>
|
||
<li class="league-table__legend-item zone-relegation-playoff">Abstiegsrelegation</li>
|
||
<?php endif; ?>
|
||
<?php if ($hasReleg): ?>
|
||
<li class="league-table__legend-item zone-relegation">Abstieg</li>
|
||
<?php endif; ?>
|
||
</ul>
|
||
<?php endif; ?>
|