Stadionzeitung gegen ASV Marktschorgast vorbereiten

This commit is contained in:
2026-08-28 13:11:43 +02:00
parent 736a588a88
commit f88b5f1dd1
40 changed files with 873 additions and 8 deletions

View File

@@ -988,10 +988,12 @@ function stadionzeitung_build_snapshot(array $issue): array
{
$date = (string) ($issue['date'] ?? '');
$issueTeam = (string) ($issue['team_key'] ?? '');
$issueOpponent = trim((string) ($issue['opponent'] ?? ''));
$tabellen = [];
$ergebnisse = [];
$vorschau = [];
$gegner = null;
foreach (json_load('matchcenter')['teams'] ?? [] as $team) {
$key = (string) ($team['key'] ?? '');
if ($key === '') {
@@ -1004,6 +1006,44 @@ function stadionzeitung_build_snapshot(array $issue): array
'table' => $team['table'] ?? [],
];
// Gegnerseite der tragenden Mannschaft: ausschließlich aus demselben
// Matchcenter-Datensatz wie die Tabelle ableiten. So gibt es keinen
// zweiten BFV-Abruf und der Stand wird beim Veröffentlichen zusammen
// mit den übrigen Live-Daten eingefroren.
if ($key === $issueTeam && $issueOpponent !== '') {
$table = is_array($team['table'] ?? null) ? $team['table'] : [];
$ownRow = null;
$opponentRow = null;
foreach ($table as $row) {
if (!empty($row['is_own_club'])) {
$ownRow = $row;
}
if (strcasecmp(trim((string) ($row['club'] ?? '')), $issueOpponent) === 0) {
$opponentRow = $row;
}
}
$fixture = null;
foreach ($team['next_matches'] ?? [] as $match) {
$matchDate = substr((string) ($match['kickoff'] ?? ''), 0, 10);
$clubs = [(string) ($match['home'] ?? ''), (string) ($match['away'] ?? '')];
if ($matchDate === $date && in_array($issueOpponent, $clubs, true)) {
$fixture = $match;
break;
}
}
$gegner = [
'team_name' => (string) ($team['name'] ?? ''),
'opponent' => $issueOpponent,
'league' => (string) ($team['league'] ?? ''),
'season' => (string) ($team['season'] ?? ''),
'fixture' => $fixture,
'own' => $ownRow,
'opponent_stats' => $opponentRow,
];
}
// Nur Spiele mit erfasstem Ergebnis — ein Testspiel ohne Tore ist
// kein Rückblick (dieselbe Regel wie im News-Feed).
$withScore = array_values(array_filter(
@@ -1058,6 +1098,7 @@ function stadionzeitung_build_snapshot(array $issue): array
return [
'tabellen' => $tabellen,
'gegner' => $gegner,
'ergebnisse' => $ergebnisse,
'vorschau' => $vorschau,
// Fünf statt sechs: mit den größeren Überschriften + CTA-Fuß braucht