99 lines
2.9 KiB
PHP
99 lines
2.9 KiB
PHP
<?php
|
||
// public/partials/layout_start.php
|
||
|
||
// Erwartet (vor require):
|
||
// - $lang (de|en|it|fr) – bereits validiert
|
||
// - $pageTitle (string)
|
||
// - $pageDescription (string, optional)
|
||
// - $userInitials (optional, kann null sein)
|
||
|
||
// Fallbacks:
|
||
if (!isset($lang) || !in_array($lang, ['de', 'en', 'it', 'fr'], true)) {
|
||
$lang = 'en';
|
||
}
|
||
|
||
if (!isset($pageTitle) || !is_string($pageTitle) || $pageTitle === '') {
|
||
$pageTitle = 'usbcheck.it';
|
||
}
|
||
|
||
if (!isset($pageDescription) || !is_string($pageDescription)) {
|
||
$pageDescription = '';
|
||
}
|
||
|
||
tpl_add_script('/assets/js/header-user-menu.js', 'footer', true, false, '', null);
|
||
|
||
// Kann später genutzt werden, falls du host-spezifische Sachen brauchst
|
||
$host = $_SERVER['HTTP_HOST'] ?? '';
|
||
?>
|
||
<!DOCTYPE html>
|
||
<html lang="<?= htmlspecialchars($lang) ?>">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title><?= htmlspecialchars($pageTitle) ?></title>
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
|
||
<?php if ($pageDescription !== ''): ?>
|
||
<meta name="description" content="<?= htmlspecialchars($pageDescription) ?>">
|
||
<?php endif; ?>
|
||
|
||
<!-- Fonts -->
|
||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Montserrat:wght@600;700;800&display=swap" rel="stylesheet">
|
||
<?php
|
||
// CSS im Header
|
||
foreach ($GLOBALS['page_styles'] as $style) {
|
||
if ($style['pos'] !== 'header') {
|
||
continue;
|
||
}
|
||
|
||
$href = $style['href'];
|
||
if (!empty($style['version'])) {
|
||
$href .= (str_contains($href, '?') ? '&' : '?') . 'v=' . urlencode($style['version']);
|
||
}
|
||
|
||
echo '<link rel="stylesheet" href="' . htmlspecialchars($href) . '">' . PHP_EOL;
|
||
}
|
||
|
||
// Scripts im Header
|
||
foreach ($GLOBALS['page_header_scripts'] as $script) {
|
||
$src = $script['src'];
|
||
if (!empty($script['version'])) {
|
||
$src .= (str_contains($src, '?') ? '&' : '?') . 'v=' . urlencode($script['version']);
|
||
}
|
||
|
||
$attr = '';
|
||
if ($script['async']) {
|
||
$attr .= ' async';
|
||
} elseif ($script['defer']) {
|
||
$attr .= ' defer';
|
||
}
|
||
if ($script['type']) {
|
||
$attr .= ' type="' . htmlspecialchars($script['type']) . '"';
|
||
}
|
||
|
||
echo '<script src="' . htmlspecialchars($src) . '"' . $attr . '></script>' . PHP_EOL;
|
||
}
|
||
?>
|
||
|
||
<!-- Tailwind (Dev) -->
|
||
<script src="https://cdn.tailwindcss.com"></script>
|
||
<script>
|
||
window.currentLang = "<?= htmlspecialchars($lang) ?>";
|
||
window.assetsBase = "/assets"; // falls du das noch nicht hast
|
||
</script>
|
||
<!-- Eigenes CSS -->
|
||
<link rel="stylesheet" href="/assets/css/main.css">
|
||
</head>
|
||
|
||
<body class="bg-brand-bg text-brand-text font-sans antialiased scroll-smooth">
|
||
<div class="min-h-screen flex flex-col">
|
||
|
||
<!-- HEADER -->
|
||
<?php
|
||
tpl('header'); // structure/header.php
|
||
?>
|
||
|
||
<!-- MAIN CONTENT -->
|
||
<main class="flex-1">
|