feat: Füge Rundenansicht mit Spielanzeige hinzu
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
parent
4bf3bbb978
commit
4377106919
2 changed files with 68 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ require_once __DIR__ . '/../src/autoload.php';
|
|||
use App\Core\Database;
|
||||
use App\Models\Game;
|
||||
use App\Models\Tipp;
|
||||
use App\Models\Round;
|
||||
|
||||
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||
|
||||
|
|
@ -54,6 +55,20 @@ if ($uri === '/' || $uri === '/index.php') {
|
|||
} elseif ($uri === '/api/status') {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(['status' => 'ok', 'version' => '2027.1']);
|
||||
} elseif (preg_match('/^\/round\/(\d+)$/', $uri, $matches)) {
|
||||
$roundId = $matches[1];
|
||||
$round = Round::getById($roundId);
|
||||
|
||||
if (!$round) {
|
||||
http_response_code(404);
|
||||
echo "404 Not Found: Runde nicht gefunden.";
|
||||
exit;
|
||||
}
|
||||
|
||||
$games = Game::getGamesByRound($roundId);
|
||||
|
||||
// Lade das View-Template für die Rundenansicht
|
||||
require __DIR__ . '/../src/Views/round.php';
|
||||
} else {
|
||||
http_response_code(404);
|
||||
echo "404 Not Found";
|
||||
|
|
|
|||
53
src/Views/round.php
Normal file
53
src/Views/round.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
// Stellt sicher, dass die benötigten Variablen vorhanden sind
|
||||
if (!isset($round) || !isset($games)) {
|
||||
echo "Fehler: Daten für die Rundenansicht nicht gefunden.";
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Tippspiel 2027 - <?php echo htmlspecialchars($round['name']); ?></title>
|
||||
<style>
|
||||
body { font-family: sans-serif; margin: 2em; }
|
||||
table { border-collapse: collapse; width: 100%; max-width: 800px; margin-top: 1em;}
|
||||
th, td { border: 1px solid #ccc; padding: 8px; text-align: left; }
|
||||
th { background-color: #f4f4f4; }
|
||||
tr:nth-child(even) { background-color: #f9f9f9; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1><?php echo htmlspecialchars($round['name']); ?></h1>
|
||||
|
||||
<?php if (!empty($games)): ?>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Anpfiff</th>
|
||||
<th>Heim</th>
|
||||
<th>Gast</th>
|
||||
<th>Ergebnis</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($games as $game): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars((new DateTime($game['kickoff']))->format('d.m.Y H:i')); ?></td>
|
||||
<td><?php echo htmlspecialchars($game['team1']); ?></td>
|
||||
<td><?php echo htmlspecialchars($game['team2']); ?></td>
|
||||
<td><?php echo App\Models\Game::getResultString($game['score1'], $game['score2'], $game['kickoff']); ?></td>
|
||||
<td><?php echo App\Models\Game::isLocked($game['kickoff']) ? 'Gesperrt' : 'Offen'; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
<p>Für diese Runde wurden keine Spiele gefunden.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<p><a href="/">Zurück zur Startseite</a></p>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue