<?php
/*** This text should be at the top of all code files ***
 * app-header.php – used for shared HTML head and navigation
 * Made by: Morten Pilekær
 * Rev. 0.4.0 Owner: Morten Pilekær
 * Location: /qr-app-lite/app-header.php
 ***/
declare(strict_types=1);

require_once __DIR__ . '/app-config.php';

$pageTitle = isset($pageTitle) ? (string)$pageTitle : 'QR App Lite';
$activePage = isset($activePage) ? (string)$activePage : '';
$appVersion = isset($appVersion) ? (string)$appVersion : QR_APP_VERSION;

if (!function_exists('appActiveClass')) {
    function appActiveClass(string $current, string $active): string
    {
        return $current === $active ? ' active' : '';
    }
}

if (!function_exists('appAriaCurrent')) {
    function appAriaCurrent(string $current, string $active): string
    {
        return $current === $active ? ' aria-current="page"' : '';
    }
}
?>
<!doctype html>
<html lang="da">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title><?= appE($pageTitle) ?></title>
  <link rel="stylesheet" href="css/bootstrap.min.css">
  <link rel="stylesheet" href="css/app.css">
</head>
<body>
  <nav class="navbar navbar-expand-lg navbar-dark bg-dark border-bottom border-secondary">
    <div class="container py-1">
      <a class="navbar-brand fw-semibold d-flex align-items-center gap-2" href="index.php">
        <span class="app-logo-mark" aria-hidden="true">QR</span>
        <span>QR App Lite</span>
      </a>
      <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mainNav" aria-controls="mainNav" aria-expanded="false" aria-label="Vis/skjul menu">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="mainNav">
        <ul class="navbar-nav ms-auto mb-2 mb-lg-0">
          <li class="nav-item"><a class="nav-link<?= appActiveClass('generator', $activePage) ?>"<?= appAriaCurrent('generator', $activePage) ?> href="index.php">Generator</a></li>
          <li class="nav-item"><a class="nav-link<?= appActiveClass('scanner', $activePage) ?>"<?= appAriaCurrent('scanner', $activePage) ?> href="qr-scanner.php">Scanner</a></li>
          <li class="nav-item"><a class="nav-link<?= appActiveClass('vejledning', $activePage) ?>"<?= appAriaCurrent('vejledning', $activePage) ?> href="vejledning.php">Vejledning</a></li>
        </ul>
      </div>
    </div>
  </nav>
  <?php if (isQrPublicDemo()): ?>
    <div class="container mt-3">
      <div class="alert alert-warning mb-0" role="alert">
        <strong>Online demo:</strong> QR-koder og scanningsresultater gemmes ikke. Download den genererede QR-kode eller kopiér scanningsresultatet, før du forlader siden.
      </div>
    </div>
  <?php endif; ?>
