Matchcenter: Saison-Tabs, Vorsaison-Archiv & gehärteter Cache-Write
- Sync schreibt Cache jetzt fehlersicher: json_encode mit JSON_THROW_ON_ERROR + Rückgabeprüfung von file_put_contents/rename → ein defektes UTF-8-Zeichen aus der BFV-API kann den guten Cache nicht mehr leerschreiben (alter Cache bleibt via $fail unangetastet) - Vorsaison wird bei erkanntem compoundId-Wechsel einmalig archiviert (previous), pro Team compound_id + abgeleitetes season-Label + stale-Flag persistiert - Aktuelle Saison ist immer sichtbar (auch leer), Wechsel zur Vorsaison über wiederverwendete Stripe-Tabbar (group-tabs); neue Komponente matchcenter-season - Leere aktuelle Saison zeigt Hinweis statt leerer Fläche Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
54
app/components/matchcenter-season.php
Normal file
54
app/components/matchcenter-season.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Eine Saison einer Matchcenter-Mannschaft: Tabelle (2/3 links) + anstehende Spiele
|
||||
* und letzte Ergebnisse (1/3 rechts). Wiederverwendet von matchcenter-section.php
|
||||
* für die aktuelle Saison und (per Tab) für die Vorsaison.
|
||||
* Props:
|
||||
* $next array anstehende Spiele (bei Vorsaison leer/ignoriert)
|
||||
* $results array letzte Ergebnisse
|
||||
* $table array Liga-Tabelle (teams[].table[])
|
||||
* $caption string Tabellen-Beschriftung für Screenreader
|
||||
* $is_previous bool true = abgelaufene Saison (keine „Nächsten Spiele")
|
||||
* Leere Blöcke verstecken sich selbst; ist die aktuelle Saison komplett leer
|
||||
* (Saisonstart/-pause), erscheint ein freundlicher Hinweis statt einer leeren Fläche.
|
||||
*/
|
||||
$next = $is_previous ?? false ? [] : ($next ?? []);
|
||||
$results = $results ?? [];
|
||||
$table = $table ?? [];
|
||||
$caption = (string) ($caption ?? 'Tabelle');
|
||||
$isPrevious = (bool) ($is_previous ?? false);
|
||||
?>
|
||||
<div class="matchcenter-team__grid">
|
||||
<?php if ($table !== []): ?>
|
||||
<div class="matchcenter-team__main">
|
||||
<?php /* Sichtbare Überschrift bewusst weggelassen; <caption> labelt die Tabelle für Screenreader. */ ?>
|
||||
<?php component('league-table', ['table' => $table, 'caption' => $caption]); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($next !== [] || $results !== []): ?>
|
||||
<aside class="matchcenter-team__aside">
|
||||
<?php if ($next !== []): ?>
|
||||
<h3 class="visually-hidden">Nächste Spiele</h3>
|
||||
<ul class="match-list">
|
||||
<?php foreach ($next as $m): ?>
|
||||
<?php component('match-row', ['match' => $m]); ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?php if ($results !== []): ?>
|
||||
<h3 class="visually-hidden">Letzte Ergebnisse</h3>
|
||||
<ul class="match-list">
|
||||
<?php foreach ($results as $m): ?>
|
||||
<?php component('match-row', ['match' => $m]); ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</aside>
|
||||
<?php endif; ?>
|
||||
<?php if (!$isPrevious && $table === [] && $next === [] && $results === []): ?>
|
||||
<p class="matchcenter-team__empty">Spiele folgen, sobald die Saison startet.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -4,22 +4,31 @@ declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Matchcenter-Sektion einer Mannschaft (kicker-Stil): Kopf (Name + Liga + Link zur
|
||||
* Mannschaftsseite), darunter zweispaltig — Tabelle 2/3 links, anstehende Spiele +
|
||||
* letzte Ergebnisse als kompakte Liste 1/3 rechts. Auf schmalen Screens gestapelt.
|
||||
* Props: $team (data/matchcenter.json → teams[]). Leere Blöcke verstecken sich selbst.
|
||||
* Mannschaftsseite), darunter die aktuelle Saison (Tabelle + Spiele) via
|
||||
* matchcenter-season. Liegt eine archivierte Vorsaison vor, sind beide Saisons über
|
||||
* eine Stripe-Tabbar umschaltbar (wiederverwendetes group-tabs-Pattern, ohne JS
|
||||
* gestapelt sichtbar). Props: $team (data/matchcenter.json → teams[]).
|
||||
*/
|
||||
$team = $team ?? [];
|
||||
$next = $team['next_matches'] ?? [];
|
||||
$results = $team['last_results'] ?? [];
|
||||
$table = $team['table'] ?? [];
|
||||
$league = $team['league'] ?? null;
|
||||
$name = (string) ($team['name'] ?? '');
|
||||
$season = (string) ($team['season'] ?? '');
|
||||
$previous = $team['previous'] ?? null;
|
||||
$hasPrevious = is_array($previous)
|
||||
&& (($previous['last_results'] ?? []) !== [] || ($previous['table'] ?? []) !== []);
|
||||
$key = preg_replace('/[^a-z0-9-]+/', '', strtolower((string) ($team['key'] ?? '')));
|
||||
|
||||
$curCaption = 'Tabelle ' . $name . ($season !== '' ? ' · ' . $season : ($league ? ' · ' . $league : ''));
|
||||
$tabCur = $season !== '' ? $season : 'Aktuelle Saison';
|
||||
?>
|
||||
<section class="section matchcenter-team" id="team-<?= e($key) ?>">
|
||||
<div class="container">
|
||||
<div class="matchcenter-team__head">
|
||||
<div class="matchcenter-team__heading">
|
||||
<h2><?= e($team['name'] ?? '') ?></h2>
|
||||
<h2><?= e($name) ?></h2>
|
||||
<?php if ($league): ?>
|
||||
<p class="matchcenter-team__league"><?= icon('trophy', 'matchcenter-team__league-icon') ?><?= e($league) ?></p>
|
||||
<?php endif; ?>
|
||||
@@ -28,33 +37,40 @@ $key = preg_replace('/[^a-z0-9-]+/', '', strtolower((string) ($team['key'] ?? ''
|
||||
<a class="btn btn--outline" href="<?= e(url($team['slug'])) ?>">Zur Mannschaft</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="matchcenter-team__grid">
|
||||
<?php if ($table !== []): ?>
|
||||
<div class="matchcenter-team__main">
|
||||
<?php /* Sichtbare Überschrift bewusst weggelassen; <caption> labelt die Tabelle für Screenreader. */ ?>
|
||||
<?php component('league-table', ['table' => $table, 'caption' => 'Tabelle ' . ($team['name'] ?? '') . ($league ? ' · ' . $league : '')]); ?>
|
||||
<?php if (!$hasPrevious): ?>
|
||||
<?php component('matchcenter-season', [
|
||||
'next' => $next, 'results' => $results, 'table' => $table, 'caption' => $curCaption,
|
||||
]); ?>
|
||||
<?php else: ?>
|
||||
<?php
|
||||
$prevSeason = (string) ($previous['season'] ?? '');
|
||||
$prevLeague = $previous['league'] ?? $league;
|
||||
$tabPrev = $prevSeason !== '' ? $prevSeason : 'Vorsaison';
|
||||
$prevCaption = 'Tabelle ' . $name . ($prevSeason !== '' ? ' · ' . $prevSeason : '');
|
||||
?>
|
||||
<div class="matchcenter-team__seasons group-tabs" data-group-tabs>
|
||||
<div class="group-tabs__bar matchcenter-team__seasons-bar" role="tablist" aria-label="Saison wählen – <?= e($name) ?>">
|
||||
<button class="group-tabs__tab" role="tab" type="button"
|
||||
id="mc-tab-<?= e($key) ?>-cur" aria-controls="mc-panel-<?= e($key) ?>-cur" aria-selected="true"
|
||||
><?= e($tabCur) ?></button>
|
||||
<button class="group-tabs__tab" role="tab" type="button"
|
||||
id="mc-tab-<?= e($key) ?>-prev" aria-controls="mc-panel-<?= e($key) ?>-prev" aria-selected="false"
|
||||
><?= e($tabPrev) ?></button>
|
||||
</div>
|
||||
<div class="matchcenter-team__season-panel" role="tabpanel"
|
||||
id="mc-panel-<?= e($key) ?>-cur" aria-labelledby="mc-tab-<?= e($key) ?>-cur" tabindex="0">
|
||||
<?php component('matchcenter-season', [
|
||||
'next' => $next, 'results' => $results, 'table' => $table, 'caption' => $curCaption,
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="matchcenter-team__season-panel" role="tabpanel"
|
||||
id="mc-panel-<?= e($key) ?>-prev" aria-labelledby="mc-tab-<?= e($key) ?>-prev" tabindex="0">
|
||||
<?php component('matchcenter-season', [
|
||||
'results' => $previous['last_results'] ?? [], 'table' => $previous['table'] ?? [],
|
||||
'caption' => $prevCaption, 'is_previous' => true,
|
||||
]); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($next !== [] || $results !== []): ?>
|
||||
<aside class="matchcenter-team__aside">
|
||||
<?php if ($next !== []): ?>
|
||||
<h3 class="visually-hidden">Nächste Spiele</h3>
|
||||
<ul class="match-list">
|
||||
<?php foreach ($next as $m): ?>
|
||||
<?php component('match-row', ['match' => $m]); ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?php if ($results !== []): ?>
|
||||
<h3 class="visually-hidden">Letzte Ergebnisse</h3>
|
||||
<ul class="match-list">
|
||||
<?php foreach ($results as $m): ?>
|
||||
<?php component('match-row', ['match' => $m]); ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</aside>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user