62 lines
2.3 KiB
PHP
62 lines
2.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* „Nächste Spiele"-Band (teamübergreifend): abgesetzte dunklere Fläche mit roter
|
||
|
|
* Oberkante, links der Aufmacher (das zeitlich nächste Spiel aller Mannschaften),
|
||
|
|
* rechts die folgenden Termine als kompakte, anklickbare Zeilen. Props:
|
||
|
|
* $matches data/matchcenter.json → upcoming[] (chronologisch)
|
||
|
|
* $teams data/matchcenter.json → teams[] (liefert Liganame + Sprungmarke)
|
||
|
|
* Leer → nichts rendern.
|
||
|
|
*/
|
||
|
|
$matches = $matches ?? [];
|
||
|
|
$teams = $teams ?? [];
|
||
|
|
if ($matches === []) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Liganame und Sprungmarke je Mannschaft vorbereiten, damit die Karten nicht
|
||
|
|
// selbst in den Teams suchen müssen. Anker wie in matchcenter-section.php.
|
||
|
|
$leagues = [];
|
||
|
|
$anchors = [];
|
||
|
|
foreach ($teams as $t) {
|
||
|
|
$key = (string) ($t['key'] ?? '');
|
||
|
|
if ($key === '') {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
$leagues[$key] = (string) ($t['league'] ?? '');
|
||
|
|
$anchors[$key] = '#team-' . preg_replace('/[^a-z0-9-]+/', '', strtolower($key));
|
||
|
|
}
|
||
|
|
|
||
|
|
$feature = array_shift($matches);
|
||
|
|
$featureKey = (string) ($feature['team_key'] ?? '');
|
||
|
|
?>
|
||
|
|
<section class="section section--sunken next-matches" id="naechste-spiele">
|
||
|
|
<div class="container">
|
||
|
|
<h2 class="next-matches__title">Nächste Spiele</h2>
|
||
|
|
<div class="next-matches__grid">
|
||
|
|
<?php component('match-feature', [
|
||
|
|
'match' => $feature,
|
||
|
|
'team_name' => $feature['team_name'] ?? '',
|
||
|
|
'league' => $leagues[$featureKey] ?? '',
|
||
|
|
'href' => $anchors[$featureKey] ?? null,
|
||
|
|
]); ?>
|
||
|
|
<?php if ($matches !== []): ?>
|
||
|
|
<div class="next-matches__list">
|
||
|
|
<h3 class="next-matches__list-title">Danach</h3>
|
||
|
|
<ul class="match-list match-list--plain">
|
||
|
|
<?php foreach ($matches as $m): ?>
|
||
|
|
<?php component('match-row', [
|
||
|
|
'match' => $m,
|
||
|
|
'meta' => $m['team_name'] ?? '',
|
||
|
|
'href' => $anchors[(string) ($m['team_key'] ?? '')] ?? null,
|
||
|
|
]); ?>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</ul>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</section>
|