This commit is contained in:
2025-11-25 00:53:25 +01:00
parent 804b7da7f0
commit f0153dda4a
5 changed files with 284 additions and 206 deletions

View File

@@ -6,6 +6,7 @@
// - $pageTitle (string)
// - $pageDescription (string, optional)
// - $userInitials (optional, kann null sein)
// - optional: $canonical (string) → überschreibt die automatisch berechnete Canonical-URL
// Fallbacks:
if (!isset($lang) || !in_array($lang, ['de', 'en', 'it', 'fr'], true)) {
@@ -19,12 +20,26 @@ if (!isset($pageTitle) || !is_string($pageTitle) || $pageTitle === '') {
if (!isset($pageDescription) || !is_string($pageDescription)) {
$pageDescription = '';
}
// Standard-Script für Header-Interaktionen
if (function_exists('tpl_add_script')) {
tpl_add_script('/assets/js/header.js', 'footer', true, false, '', null);
}
// Scheme + Host + Request-URI für Canonical & sonstige Host-bezogene Dinge
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'] ?? app_primary_domain();
$requestUri = $_SERVER['REQUEST_URI'] ?? '/';
// Canonical bestimmen:
// - Wenn $canonical gesetzt ist (z. B. auf einer Landingpage explizit)
// → diese URL verwenden
// - Sonst: aktuelle URL ohne Query-Parameter (alles hinter '?')
$effectiveCanonical = isset($canonical) && is_string($canonical) && $canonical !== ''
? $canonical
: ($scheme . '://' . $host . strtok($requestUri, '?'));
// Kann später genutzt werden, falls du host-spezifische Sachen brauchst
$host = $_SERVER['HTTP_HOST'] ?? '';
?>
<!DOCTYPE html>
<html lang="<?= htmlspecialchars($lang) ?>">
@@ -37,18 +52,17 @@ $host = $_SERVER['HTTP_HOST'] ?? '';
<meta name="description" content="<?= htmlspecialchars($pageDescription) ?>">
<?php endif; ?>
<!-- Canonical URL -->
<link rel="canonical" href="<?= htmlspecialchars($effectiveCanonical) ?>">
<!-- 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">
<script>
window.fakecheckBaseUrl = <?= json_encode($GLOBALS['usb_base_url'] ?? '') ?>;
window.fakecheckLocale = <?= json_encode($lang ?? 'en') ?>;
window.fakecheckApiBaseUrl = <?= json_encode($GLOBALS['usb_api_base'] ?? 'https://api.usbcheck.it') ?>;
</script>
<?php tpl('app_config', 'structure'); ?>
<?php
// CSS im Header
foreach ($GLOBALS['page_styles'] as $style) {
if ($style['pos'] !== 'header') {
@@ -114,16 +128,8 @@ foreach ($GLOBALS['page_header_scripts'] as $script) {
</script>
<!-- Tailwind (Dev) -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
window.currentLang = "<?= htmlspecialchars($lang) ?>";
window.assetsBase = "/assets"; // falls du das noch nicht hast
window.appDomains = <?= json_encode([
'primaryDomain' => app_primary_domain(),
'primaryUrl' => app_primary_url(),
'fakecheckDomain' => app_fakecheck_domain(),
'fakecheckUrl' => app_fakecheck_url(),
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) ?>;
</script>
<!-- Eigenes CSS -->
<link rel="stylesheet" href="/assets/css/main.css">
</head>
@@ -132,9 +138,7 @@ foreach ($GLOBALS['page_header_scripts'] as $script) {
<div class="min-h-screen flex flex-col">
<!-- HEADER -->
<?php
tpl('header'); // structure/header.php
?>
<?php tpl('header'); ?>
<!-- MAIN CONTENT -->
<main class="flex-1">