version 0.8.0
This commit is contained in:
parent
f22007003a
commit
e5ca9ef194
95 changed files with 5601 additions and 4042 deletions
34
app/Core/Controller.php
Normal file
34
app/Core/Controller.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Basis für Seiten-Controller. Rendert eine View – optional im gemeinsamen
|
||||
* Layout (Startseite/Regeln/Legal) oder als eigenständiges Dokument
|
||||
* (Spiel/Login/Profil/Admin, die eigene Nav + noindex mitbringen).
|
||||
*/
|
||||
abstract class Controller
|
||||
{
|
||||
/** @param array<string,mixed> $meta */
|
||||
protected function view(string $page, array $meta = [], bool $layout = true): void
|
||||
{
|
||||
$viewFile = BSB_BASE . '/app/Views/pages/' . $page . '.php';
|
||||
if (!is_file($viewFile)) {
|
||||
http_response_code(500);
|
||||
echo 'View fehlt: ' . htmlspecialchars($page, ENT_QUOTES);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$layout) {
|
||||
require $viewFile;
|
||||
return;
|
||||
}
|
||||
|
||||
// Variablen für app/Views/layout.php
|
||||
$title = (string) ($meta['title'] ?? 'Black Sheep Bluff');
|
||||
$description = (string) ($meta['description'] ?? '');
|
||||
$cssFiles = (array) ($meta['css'] ?? []);
|
||||
$jsFiles = (array) ($meta['js'] ?? []);
|
||||
$bodyClass = (string) ($meta['bodyClass'] ?? '');
|
||||
require BSB_BASE . '/app/Views/layout.php';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue