89 lines
4.0 KiB
PHP
89 lines
4.0 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
declare(strict_types=1);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Gegnerstatistik der Stadionzeitung. Alle Werte stammen aus dem bereits
|
|||
|
|
* aufgebauten Stadionzeitungs-Snapshot; die Komponente rendert nur. Dadurch
|
|||
|
|
* sind Entwurf und veröffentlichte Druckausgabe konsistent und archivfest.
|
|||
|
|
*
|
|||
|
|
* Props: $info stadionzeitung_live_data($issue)['gegner']
|
|||
|
|
*/
|
|||
|
|
$info = is_array($info ?? null) ? $info : [];
|
|||
|
|
$fixture = is_array($info['fixture'] ?? null) ? $info['fixture'] : [];
|
|||
|
|
$own = is_array($info['own'] ?? null) ? $info['own'] : null;
|
|||
|
|
$opponent = is_array($info['opponent_stats'] ?? null) ? $info['opponent_stats'] : null;
|
|||
|
|
$opponentName = (string) ($info['opponent'] ?? 'Unser Gegner');
|
|||
|
|
|
|||
|
|
$kickoff = (string) ($fixture['kickoff'] ?? '');
|
|||
|
|
$kickoffDate = $kickoff !== '' ? substr($kickoff, 0, 10) : '';
|
|||
|
|
$kickoffTime = $kickoff !== '' ? substr($kickoff, 11, 5) : '';
|
|||
|
|
|
|||
|
|
$rows = [
|
|||
|
|
['label' => 'Tabellenplatz', 'key' => 'rank'],
|
|||
|
|
['label' => 'Spiele', 'key' => 'played'],
|
|||
|
|
['label' => 'Siege', 'key' => 'won'],
|
|||
|
|
['label' => 'Unentschieden', 'key' => 'drawn'],
|
|||
|
|
['label' => 'Niederlagen', 'key' => 'lost'],
|
|||
|
|
['label' => 'Tordifferenz', 'key' => 'goal_diff', 'signed' => true],
|
|||
|
|
['label' => 'Punkte', 'key' => 'points'],
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
$format = static function (?array $row, string $key, bool $signed = false): string {
|
|||
|
|
if ($row === null || !array_key_exists($key, $row)) {
|
|||
|
|
return '–';
|
|||
|
|
}
|
|||
|
|
$value = (int) $row[$key];
|
|||
|
|
return $signed && $value > 0 ? '+' . $value : (string) $value;
|
|||
|
|
};
|
|||
|
|
?>
|
|||
|
|
<div class="stadionzeitung-gegner">
|
|||
|
|
<header class="stadionzeitung-page__head">
|
|||
|
|
<p class="stadionzeitung-page__kicker">Unser Gegner</p>
|
|||
|
|
<h2 class="stadionzeitung-page__heading"><?= e($opponentName) ?></h2>
|
|||
|
|
<?php if (!empty($info['league']) || !empty($info['season'])): ?>
|
|||
|
|
<p class="stadionzeitung-page__sub"><?= e(trim(implode(' · ', array_filter([(string) ($info['league'] ?? ''), (string) ($info['season'] ?? '')])))) ?></p>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
</header>
|
|||
|
|
<span class="stadionzeitung-page__rule" aria-hidden="true"></span>
|
|||
|
|
|
|||
|
|
<div class="stadionzeitung-gegner__duell">
|
|||
|
|
<div class="stadionzeitung-gegner__club stadionzeitung-gegner__club--own">
|
|||
|
|
<?php component('crest', ['src' => $fixture['home_crest'] ?? $own['crest'] ?? null, 'name' => $fixture['home'] ?? 'TSV 08 Kulmbach']); ?>
|
|||
|
|
<strong><?= e((string) ($fixture['home'] ?? 'TSV 08 Kulmbach')) ?></strong>
|
|||
|
|
</div>
|
|||
|
|
<div class="stadionzeitung-gegner__match">
|
|||
|
|
<span>gegen</span>
|
|||
|
|
<?php if ($kickoffDate !== ''): ?>
|
|||
|
|
<strong><?= e(german_date($kickoffDate)) ?></strong>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
<?php if ($kickoffTime !== ''): ?>
|
|||
|
|
<span><?= e($kickoffTime) ?> Uhr</span>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
</div>
|
|||
|
|
<div class="stadionzeitung-gegner__club">
|
|||
|
|
<?php component('crest', ['src' => $fixture['away_crest'] ?? $opponent['crest'] ?? null, 'name' => $fixture['away'] ?? $opponentName]); ?>
|
|||
|
|
<strong><?= e((string) ($fixture['away'] ?? $opponentName)) ?></strong>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<?php if ($own !== null && $opponent !== null): ?>
|
|||
|
|
<div class="stadionzeitung-gegner__vergleich" role="table" aria-label="Tabellenvergleich">
|
|||
|
|
<div class="stadionzeitung-gegner__vergleich-head" role="row">
|
|||
|
|
<span role="columnheader">TSV 08</span>
|
|||
|
|
<span role="columnheader">Vergleich</span>
|
|||
|
|
<span role="columnheader">ASV</span>
|
|||
|
|
</div>
|
|||
|
|
<?php foreach ($rows as $row): ?>
|
|||
|
|
<div class="stadionzeitung-gegner__vergleich-row" role="row">
|
|||
|
|
<strong role="cell"><?= e($format($own, (string) $row['key'], (bool) ($row['signed'] ?? false))) ?></strong>
|
|||
|
|
<span role="rowheader"><?= e((string) $row['label']) ?></span>
|
|||
|
|
<strong role="cell"><?= e($format($opponent, (string) $row['key'], (bool) ($row['signed'] ?? false))) ?></strong>
|
|||
|
|
</div>
|
|||
|
|
<?php endforeach; ?>
|
|||
|
|
</div>
|
|||
|
|
<?php else: ?>
|
|||
|
|
<p class="stadionzeitung-gegner__empty">Die aktuellen Vergleichsdaten waren beim letzten Abruf nicht verfügbar.</p>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
</div>
|