oh gott was mach ich nur

This commit is contained in:
2025-11-25 03:21:52 +01:00
parent b8471bff3e
commit 888ab3dfa7
21 changed files with 2664 additions and 794 deletions

View File

@@ -2,44 +2,62 @@
// 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)
// - optional: $canonical (string) → überschreibt die automatisch berechnete Canonical-URL
// - $pageKey (string) Seiten-Key für i18n, z. B. 'landing', 'fakecheck', 'login', 'dashboard'
// - $lang (2-letter ISO, z. B. 'de', 'en', 'it', 'fr'), möglichst bereits aus fileload.php
// - optional: $pageTitle (string)
// - optional: $pageDescription (string)
// - optional: $canonical (string)
// - optional: $userInitials (string|null)
// Fallbacks:
if (!isset($lang) || !in_array($lang, ['de', 'en', 'it', 'fr'], true)) {
$lang = 'en';
// -----------------------------------------------------------
// Fallbacks & i18n Title/Description
// -----------------------------------------------------------
// Sicherstellen, dass availableLangs existiert (kommt aus fileload.php)
$availableLangs = $availableLangs ?? [];
// Page-Key Fallback
if (!isset($pageKey) || !is_string($pageKey) || $pageKey === '') {
$pageKey = 'landing';
}
// Fallback für Sprache: lieber auf $availableLangs statt feste Liste
if (!isset($lang) || !isset($availableLangs[$lang])) {
$lang = array_key_first($availableLangs) ?: 'en';
}
// Title aus i18n, falls nichts explizit gesetzt wurde
if (!isset($pageTitle) || !is_string($pageTitle) || $pageTitle === '') {
$pageTitle = app_primary_domain();
// pages.{pageKey}.meta.title
$pageTitle = i18n_get("pages.$pageKey.meta.title", app_primary_domain());
}
if (!isset($pageDescription) || !is_string($pageDescription)) {
$pageDescription = '';
// Description aus i18n, falls nichts explizit gesetzt wurde
if (!isset($pageDescription) || !is_string($pageDescription) || $pageDescription === '') {
// pages.{pageKey}.meta.description
$pageDescription = i18n_get("pages.$pageKey.meta.description", '');
}
// -----------------------------------------------------------
// Standard-Script für Header-Interaktionen
// -----------------------------------------------------------
if (function_exists('tpl_add_script')) {
// header.js kommt wie gehabt in den Footer
tpl_add_script('/assets/js/header.js', 'footer', true, false, '', null);
}
// Scheme + Host + Request-URI für Canonical & sonstige Host-bezogene Dinge
// -----------------------------------------------------------
// Canonical-URL bestimmen
// -----------------------------------------------------------
$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 '?')
// Wenn $canonical gesetzt → verwenden, sonst aktuelle URL ohne Query-String
$effectiveCanonical = isset($canonical) && is_string($canonical) && $canonical !== ''
? $canonical
: ($scheme . '://' . $host . strtok($requestUri, '?'));
// Kann später genutzt werden, falls du host-spezifische Sachen brauchst
?>
<!DOCTYPE html>
<html lang="<?= htmlspecialchars($lang) ?>">
@@ -59,44 +77,45 @@ $effectiveCanonical = isset($canonical) && is_string($canonical) && $canonical !
<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 tpl('app_config', 'structure'); ?>
<?php
<?php
// App-Config (usbConfig + i18n.available/current) ins Fenster schreiben
tpl('app_config', 'structure');
// CSS im Header
foreach ($GLOBALS['page_styles'] as $style) {
if ($style['pos'] !== 'header') {
continue;
// CSS im Header aus der zentralen Registry
foreach ($GLOBALS['page_styles'] as $style) {
if (($style['pos'] ?? 'header') !== '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;
}
$href = $style['href'];
if (!empty($style['version'])) {
$href .= (str_contains($href, '?') ? '&' : '?') . 'v=' . urlencode($style['version']);
}
// Scripts im Header aus der zentralen Registry
foreach ($GLOBALS['page_header_scripts'] as $script) {
$src = $script['src'];
if (!empty($script['version'])) {
$src .= (str_contains($src, '?') ? '&' : '?') . 'v=' . urlencode($script['version']);
}
echo '<link rel="stylesheet" href="' . htmlspecialchars($href) . '">' . PHP_EOL;
}
$attr = '';
if (!empty($script['async'])) {
$attr .= ' async';
} elseif (!empty($script['defer'])) {
$attr .= ' defer';
}
if (!empty($script['type'])) {
$attr .= ' type="' . htmlspecialchars($script['type']) . '"';
}
// 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']);
echo '<script src="' . htmlspecialchars($src) . '"' . $attr . '></script>' . PHP_EOL;
}
$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;
}
?>
?>
<script>
window.tailwind = window.tailwind || {};
@@ -129,8 +148,7 @@ foreach ($GLOBALS['page_header_scripts'] as $script) {
<!-- Tailwind (Dev) -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Eigenes CSS -->
<!-- Eigenes CSS (falls du das irgendwann auch versionieren willst, gerne über tpl_add_style) -->
<link rel="stylesheet" href="/assets/css/main.css">
</head>