Stadionzeitung gegen ASV Marktschorgast vorbereiten
This commit is contained in:
88
app/components/stadionzeitung-gegner.php
Normal file
88
app/components/stadionzeitung-gegner.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?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>
|
||||
@@ -10,7 +10,7 @@ declare(strict_types=1);
|
||||
* $entry Eintrag aus issue.images[]:
|
||||
* type 'image' (base/widths/alt),
|
||||
* type 'live' (page: cover|vorwort|interview|aufruf|tabelle|termine|
|
||||
* news|ergebnisse|vorschau|kontakt; tabelle optional
|
||||
* news|ergebnisse|gegner|vorschau|kontakt; tabelle optional
|
||||
* mit team: Team-Key aus matchcenter.json),
|
||||
* type 'leer' (weiße Füllseite, nur Druckfassung — hält die
|
||||
* Seitenzahl auf einem Vielfachen von 4)
|
||||
@@ -55,6 +55,9 @@ $type = $entry['type'] ?? 'image';
|
||||
<?php case 'ergebnisse': ?>
|
||||
<?php component('stadionzeitung-ergebnisse', ['groups' => $data['ergebnisse'] ?? []]); ?>
|
||||
<?php break; ?>
|
||||
<?php case 'gegner': ?>
|
||||
<?php component('stadionzeitung-gegner', ['info' => $data['gegner'] ?? null]); ?>
|
||||
<?php break; ?>
|
||||
<?php case 'vorschau': ?>
|
||||
<?php component('stadionzeitung-vorschau', ['items' => $data['vorschau'] ?? []]); ?>
|
||||
<?php break; ?>
|
||||
|
||||
@@ -8,7 +8,7 @@ declare(strict_types=1);
|
||||
* (Kicker + Überschrift über einblendendem Vereinsfoto), aber mit einer
|
||||
* Icon-Liste statt Fließtext.
|
||||
*
|
||||
* Die drei Termine sind KEIN Live-Abruf: bin/stadionzeitung-add.php friert
|
||||
* Die Termine sind KEIN Live-Abruf: bin/stadionzeitung-add.php friert
|
||||
* sie beim Anlegen der Ausgabe einmalig ein (`termine_snapshot`, siehe dort
|
||||
* und termine_build_lists()) — eine gedruckte Ausgabe zeigt dauerhaft, was
|
||||
* am Spieltag anstand, nicht was von "heute" aus gesehen ansteht.
|
||||
@@ -60,6 +60,8 @@ $termineLink = club_domain('termine');
|
||||
} elseif (!$isMatch && !empty($item['location'])) {
|
||||
$parts[] = (string) $item['location'];
|
||||
}
|
||||
$title = (string) ($item['title'] ?? '');
|
||||
$meta = implode(' · ', $parts);
|
||||
?>
|
||||
<li class="stadionzeitung-termine__item">
|
||||
<?php /* Icon nach Termin-Art (Wunsch Felix 29.07.2026): Spiele bekommen die
|
||||
@@ -67,8 +69,8 @@ $termineLink = club_domain('termine');
|
||||
Blick unterscheidbar. */ ?>
|
||||
<span class="stadionzeitung-termine__icon" aria-hidden="true"><?= icon($isMatch ? 'trophy' : 'calendar-event') ?></span>
|
||||
<div class="stadionzeitung-termine__body">
|
||||
<p class="stadionzeitung-termine__title"><?= e((string) ($item['title'] ?? '')) ?></p>
|
||||
<p class="stadionzeitung-termine__meta"><?= e(implode(' · ', $parts)) ?></p>
|
||||
<p class="stadionzeitung-termine__title" title="<?= e($title) ?>"><?= e($title) ?></p>
|
||||
<p class="stadionzeitung-termine__meta" title="<?= e($meta) ?>"><?= e($meta) ?></p>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
|
||||
Reference in New Issue
Block a user