Files
tsv08kulmbach-website/app/components/matchcenter-season.php

55 lines
2.4 KiB
PHP
Raw Normal View History

<?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>