| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- /**
- * Shared HTML fragments for the public site and the admin backoffice.
- * Public pages sit in the document root and admin pages in admin/, so asset
- * paths differ: public pages use 'assets/...', admin pages use '../assets/...'.
- */
- declare(strict_types=1);
- function public_header(string $title, string $active = '', string $bodyClass = ''): void
- {
- $site = site_get();
- $name = $site['intro_title'] ?: config('site.name', 'Portfolio');
- ?><!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title><?= e($title) ?></title>
- <link rel="stylesheet" href="assets/site.css">
- </head>
- <body class="<?= e($bodyClass) ?>">
- <header class="nav" id="nav">
- <a class="nav-brand" href="./"><?= e($name) ?></a>
- <nav class="nav-links">
- <a href="./" class="<?= $active === 'home' ? 'active' : '' ?>">Home</a>
- <a href="showreel.php" class="<?= $active === 'showreel' ? 'active' : '' ?>">Showreel</a>
- </nav>
- </header>
- <?php
- }
- function public_footer(): void
- {
- ?><footer class="footer">
- <span>© <?= date('Y') ?> <?= e(site_get()['intro_title'] ?: config('site.name', '')) ?></span>
- </footer>
- <script src="assets/site.js"></script>
- </body>
- </html>
- <?php
- }
- function admin_header(string $title, string $active = ''): void
- {
- ?><!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title><?= e($title) ?> · Admin</title>
- <link rel="stylesheet" href="../assets/site.css">
- </head>
- <body class="admin">
- <header class="admin-nav">
- <a class="nav-brand" href="index.php">Backoffice</a>
- <nav class="nav-links">
- <a href="frontpage.php" class="<?= $active === 'frontpage' ? 'active' : '' ?>">Front page</a>
- <a href="showreel.php" class="<?= $active === 'showreel' ? 'active' : '' ?>">Showreel</a>
- <a href="galleries.php" class="<?= $active === 'galleries' ? 'active' : '' ?>">Galleries</a>
- <a href="settings.php" class="<?= $active === 'settings' ? 'active' : '' ?>">Settings</a>
- <a href="../" target="_blank" rel="noopener">View site ↗</a>
- <a href="logout.php">Log out</a>
- </nav>
- </header>
- <main class="admin-main">
- <?php
- }
- function admin_footer(): void
- {
- ?></main>
- </body>
- </html>
- <?php
- }
- /** One-shot status message helpers (flash messages via session). */
- function flash_set(string $msg, string $kind = 'ok'): void
- {
- session_boot();
- $_SESSION['flash'] = ['msg' => $msg, 'kind' => $kind];
- }
- function flash_render(): void
- {
- session_boot();
- if (!empty($_SESSION['flash'])) {
- $f = $_SESSION['flash'];
- unset($_SESSION['flash']);
- echo '<div class="flash flash-' . e($f['kind']) . '">' . e($f['msg']) . '</div>';
- }
- }
|