Neue Unterseite /matchcenter ersetzt die alten BFV-Widget-Embeds (verstoßen
gegen CSP) durch eine self-hostete Lösung: Cron-Scraper holt die Daten aus der
öffentlichen BFV-Widget-JSON-API, schreibt data/matchcenter.json und lädt die
Vereinswappen lokal — Besucher kontaktieren nur unsere Domain.
- bin/matchcenter-sync.php: CLI/Cron-Scraper (Muster wie instagram-sync), JSON-API
team/{id}/matches + competition/{compoundId}/table, Wappen via getLogo lokal,
atomarer Write, Fail-safe. Auto-Saison: Tabellen-compoundId wird aus der
Matches-API abgeleitet (team_id ist saison-stabil). Per-Team-Cache-Fallback bei
Fetch-Fehlern, damit Sektionen nie leeren.
- Seite app/pages/matchcenter.php + Route + Nav-Eintrag (unter Fußball).
- Komponenten: match-slider (nächste Spiele), match-card, match-row, league-table
(mit Auf-/Abstiegszonen), matchcenter-section (kicker-Layout: Tabelle 2/3 +
Spiele 1/3), matchcenter-empty, crest (weißes Chip + Initialen-Fallback).
- carousel.js: banner.js zum generischen [data-carousel]-Antrieb verallgemeinert
(Banner- und Match-Slider teilen ihn); crest.js: Logo-Fallback im Browser.
- helpers.php: sportsevent_nodes() für SportsEvent-JSON-LD.
- Icons calendar-event; config.example + .gitignore + CLAUDE.md ergänzt.
- Responsive geprüft (kein Seiten-Overflow 360–1280, Tabelle scrollt in der Karte).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0192vTfGmGpoWeyUse4TuQFj
83 lines
4.0 KiB
PHP
83 lines
4.0 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);
|
|
?>
|
|
<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 (!empty($row['zone'])) {
|
|
$trClass[] = 'zone-' . e($row['zone']);
|
|
}
|
|
$diff = (int) ($row['goal_diff'] ?? 0);
|
|
?>
|
|
<tr<?= $trClass !== [] ? ' class="' . implode(' ', $trClass) . '"' : '' ?>>
|
|
<td class="league-table__rank"><?= (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>
|
|
<?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; ?>
|