lniks
This commit is contained in:
@@ -232,3 +232,95 @@ function app_i18n_get_frontend_config(): array
|
|||||||
'available' => $GLOBALS['availableLangs'] ?? [],
|
'available' => $GLOBALS['availableLangs'] ?? [],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Komplette JSON-Struktur für eine Sprache laden.
|
||||||
|
* Nutzt einfachen Request-Cache, damit pro Sprache nur einmal von Platte gelesen wird.
|
||||||
|
*/
|
||||||
|
function app_i18n_load_lang_json(string $lang): array
|
||||||
|
{
|
||||||
|
static $cache = [];
|
||||||
|
|
||||||
|
$lang = strtolower(substr($lang, 0, 5));
|
||||||
|
|
||||||
|
if (isset($cache[$lang])) {
|
||||||
|
return $cache[$lang];
|
||||||
|
}
|
||||||
|
|
||||||
|
$baseDir = realpath(__DIR__ . '/../public/assets/i18n');
|
||||||
|
if ($baseDir === false) {
|
||||||
|
$cache[$lang] = [];
|
||||||
|
return $cache[$lang];
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $baseDir . '/' . $lang . '.json';
|
||||||
|
if (!is_file($path)) {
|
||||||
|
// Fallback: en.json, falls vorhanden
|
||||||
|
$fallback = $baseDir . '/en.json';
|
||||||
|
if (is_file($fallback)) {
|
||||||
|
$json = @file_get_contents($fallback);
|
||||||
|
$data = json_decode($json, true);
|
||||||
|
$cache[$lang] = is_array($data) ? $data : [];
|
||||||
|
return $cache[$lang];
|
||||||
|
}
|
||||||
|
|
||||||
|
$cache[$lang] = [];
|
||||||
|
return $cache[$lang];
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = @file_get_contents($path);
|
||||||
|
$data = json_decode($json, true);
|
||||||
|
$cache[$lang] = is_array($data) ? $data : [];
|
||||||
|
|
||||||
|
return $cache[$lang];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nav-Anker für eine Seite aus der Sprachdatei holen.
|
||||||
|
*
|
||||||
|
* Erwartete Struktur im JSON:
|
||||||
|
* "pages": {
|
||||||
|
* "landing": {
|
||||||
|
* "meta": { ... },
|
||||||
|
* "anchors": {
|
||||||
|
* "how": "So funktioniert USBCheck",
|
||||||
|
* "problem": "Warum gefälschte USB-Sticks gefährlich sind",
|
||||||
|
* ...
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* Rückgabe-Format:
|
||||||
|
* [
|
||||||
|
* [ 'href' => '#how', 'label' => 'So funktioniert USBCheck' ],
|
||||||
|
* [ 'href' => '#problem', 'label' => 'Warum gefälschte USB-Sticks gefährlich sind' ],
|
||||||
|
* ...
|
||||||
|
* ]
|
||||||
|
*/
|
||||||
|
function app_get_nav_anchors(string $pageKey): array
|
||||||
|
{
|
||||||
|
$lang = $GLOBALS['lang'] ?? 'en';
|
||||||
|
$data = app_i18n_load_lang_json($lang);
|
||||||
|
|
||||||
|
$nav = $data['pages'][$pageKey]['anchors'] ?? null;
|
||||||
|
if (!is_array($nav)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$anchors = [];
|
||||||
|
foreach ($nav as $id => $label) {
|
||||||
|
$id = trim((string)$id);
|
||||||
|
$label = trim((string)$label);
|
||||||
|
|
||||||
|
if ($id === '' || $label === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$anchors[] = [
|
||||||
|
'href' => '#' . $id,
|
||||||
|
'label' => $label,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $anchors;
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,10 +6,17 @@ $scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https'
|
|||||||
$host = $_SERVER['HTTP_HOST'] ?? app_primary_domain();
|
$host = $_SERVER['HTTP_HOST'] ?? app_primary_domain();
|
||||||
$baseUrl = $scheme . '://' . $host;
|
$baseUrl = $scheme . '://' . $host;
|
||||||
|
|
||||||
// Wenn $navAnchors NICHT gesetzt ist → leeres Array
|
// Aktueller Page-Key (z.B. 'landing', 'fakecheck', 'dashboard')
|
||||||
|
$pageKey = $GLOBALS['pageKey'] ?? null;
|
||||||
|
|
||||||
|
// Nav-Anker: wenn nicht explizit gesetzt, aus der i18n-JSON holen
|
||||||
if (!isset($navAnchors) || !is_array($navAnchors)) {
|
if (!isset($navAnchors) || !is_array($navAnchors)) {
|
||||||
|
if ($pageKey && function_exists('app_get_nav_anchors')) {
|
||||||
|
$navAnchors = app_get_nav_anchors($pageKey); // ['href' => '#how', 'label' => '...']
|
||||||
|
} else {
|
||||||
$navAnchors = [];
|
$navAnchors = [];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Session sollte in config/fileload.php bereits gestartet sein.
|
// Session sollte in config/fileload.php bereits gestartet sein.
|
||||||
// Falls nicht, hier Fallback:
|
// Falls nicht, hier Fallback:
|
||||||
@@ -112,14 +119,16 @@ function build_lang_url(string $code, string $path, array $query): string
|
|||||||
<div class="flex items-center gap-6">
|
<div class="flex items-center gap-6">
|
||||||
|
|
||||||
<!-- Hauptnavigation -->
|
<!-- Hauptnavigation -->
|
||||||
|
<?php if (!empty($navAnchors)): ?>
|
||||||
<nav class="flex flex-wrap items-center gap-4 sm:gap-6 text-xs font-medium text-brand-muted uppercase tracking-[0.18em]">
|
<nav class="flex flex-wrap items-center gap-4 sm:gap-6 text-xs font-medium text-brand-muted uppercase tracking-[0.18em]">
|
||||||
<?php foreach ($navAnchors as $item): ?>
|
<?php foreach ($navAnchors as $item): ?>
|
||||||
<a href="<?= htmlspecialchars($item['href']) ?>"
|
<a href="<?= htmlspecialchars($item['href'] ?? '#') ?>"
|
||||||
class="hover:text-brand-primary transition-colors"
|
class="hover:text-brand-primary transition-colors">
|
||||||
data-i18n="<?= htmlspecialchars($item['key']) ?>">
|
<?= htmlspecialchars($item['label'] ?? '') ?>
|
||||||
</a>
|
</a>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</nav>
|
</nav>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<!-- Language Switcher -->
|
<!-- Language Switcher -->
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
|
|||||||
@@ -9,9 +9,25 @@
|
|||||||
"landing": {
|
"landing": {
|
||||||
"meta": {
|
"meta": {
|
||||||
"title": "KEIN TITEL"
|
"title": "KEIN TITEL"
|
||||||
|
},
|
||||||
|
,
|
||||||
|
"anchors": {
|
||||||
|
"how": "So funktioniert USBCheck",
|
||||||
|
"problem": "Warum gefälschte USB-Sticks gefährlich sind",
|
||||||
|
"features": "Funktionen",
|
||||||
|
"security": "Sicherheit",
|
||||||
|
"faq": "FAQ"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"main": {
|
"main": {
|
||||||
|
,
|
||||||
|
"anchors": {
|
||||||
|
"how": "So funktioniert USBCheck",
|
||||||
|
"problem": "Warum gefälschte USB-Sticks gefährlich sind",
|
||||||
|
"features": "Funktionen",
|
||||||
|
"security": "Sicherheit",
|
||||||
|
"faq": "FAQ"
|
||||||
|
},
|
||||||
"sections": {
|
"sections": {
|
||||||
"security": {
|
"security": {
|
||||||
"security_kicker": "Sicherheit & Datenschutz",
|
"security_kicker": "Sicherheit & Datenschutz",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
$pageKey = 'landing';
|
$pageKey = 'landing';
|
||||||
|
$GLOBALS['pageKey'] = $pageKey;
|
||||||
require_once dirname(__DIR__) . '/config/fileload.php';
|
require_once dirname(__DIR__) . '/config/fileload.php';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
// public/dashboard/index.php
|
// public/dashboard/index.php
|
||||||
$pageKey = 'dashboard';
|
$pageKey = 'dashboard';
|
||||||
|
$GLOBALS['pageKey'] = $pageKey;
|
||||||
require_once $_SERVER['DOCUMENT_ROOT']. '/../config/fileload.php';
|
require_once $_SERVER['DOCUMENT_ROOT']. '/../config/fileload.php';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
$pageKey = 'fakecheck';
|
$pageKey = 'fakecheck';
|
||||||
|
$GLOBALS['pageKey'] = $pageKey;
|
||||||
/*
|
/*
|
||||||
* USBCheck Fake USB Check - Landingpage
|
* USBCheck Fake USB Check - Landingpage
|
||||||
* --------------------------------------*/
|
* --------------------------------------*/
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
$pageKey = 'login';
|
$pageKey = 'login';
|
||||||
|
$GLOBALS['pageKey'] = $pageKey;
|
||||||
require_once $_SERVER['DOCUMENT_ROOT']. '/../config/fileload.php';
|
require_once $_SERVER['DOCUMENT_ROOT']. '/../config/fileload.php';
|
||||||
|
|
||||||
tpl_add_script('/assets/js/auth.js', 'footer', true, false, '', 'auth-1');
|
tpl_add_script('/assets/js/auth.js', 'footer', true, false, '', 'auth-1');
|
||||||
|
|||||||
Reference in New Issue
Block a user