asa
This commit is contained in:
@@ -3,56 +3,73 @@
|
||||
|
||||
// Host-Infos ermitteln (für URLs / Redirects etc.)
|
||||
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
||||
$host = $_SERVER['HTTP_HOST'] ?? app_primary_domain();
|
||||
$host = $_SERVER['HTTP_HOST'] ?? (function_exists('app_primary_domain') ? app_primary_domain() : 'localhost');
|
||||
$requestUri = $_SERVER['REQUEST_URI'] ?? '/';
|
||||
|
||||
// Aktuelle Sprache & Sprachen aus den GLOBALS (fileload.php)
|
||||
$currentLang = $GLOBALS['lang'] ?? ($lang ?? 'en');
|
||||
$allAvailable = $GLOBALS['availableLangs'] ?? [];
|
||||
// Aktuelle Sprache & Sprachen aus den GLOBALS (kommen aus fileload.php / i18n.php)
|
||||
$currentLang = $GLOBALS['lang'] ?? ($lang ?? 'en');
|
||||
$allAvailable = $GLOBALS['availableLangs'] ?? [];
|
||||
|
||||
// Optional: Environment aus config.php (du hattest $env → $GLOBALS['app_env'])
|
||||
$env = $GLOBALS['app_env'] ?? 'prod';
|
||||
// Environment & Basis-URLs aus config.php / fileload.php
|
||||
$appEnv = $GLOBALS['app_env'] ?? (defined('APP_ENV') ? APP_ENV : 'prod');
|
||||
$appBaseUrl = $GLOBALS['app_base_url'] ?? ($scheme . '://' . $host);
|
||||
$appApiBase = $GLOBALS['app_api_base'] ?? ($scheme . '://api.' . ($host));
|
||||
|
||||
// Optional: Helfer-Funktionen nutzen, falls vorhanden
|
||||
$primaryDomain = function_exists('app_primary_domain') ? app_primary_domain() : $host;
|
||||
$primaryUrl = function_exists('app_primary_url') ? app_primary_url() : ($scheme . '://' . $primaryDomain);
|
||||
$fakecheckDomain = function_exists('app_fakecheck_domain') ? app_fakecheck_domain() : null;
|
||||
$fakecheckUrl = function_exists('app_fakecheck_url') ? app_fakecheck_url() : null;
|
||||
|
||||
// i18n-Config aus deiner zentralen i18n-Logik
|
||||
$i18nConfig = function_exists('app_i18n_get_frontend_config')
|
||||
? app_i18n_get_frontend_config()
|
||||
: [
|
||||
'available' => $allAvailable,
|
||||
'current' => $currentLang,
|
||||
];
|
||||
|
||||
// -----------------------------------------------
|
||||
// USBCheck JavaScript-Konfiguration
|
||||
// -----------------------------------------------
|
||||
$usbConfig = [
|
||||
'lang' => $currentLang,
|
||||
'lang' => $currentLang,
|
||||
|
||||
// Basis-Pfade
|
||||
'assetsBase' => '/assets',
|
||||
'assetsBase' => '/assets',
|
||||
|
||||
// Versionierung für JS/CSS
|
||||
'assetVersion'=> defined('ASSET_VERSION') ? ASSET_VERSION : null,
|
||||
'assetVersion' => defined('ASSET_VERSION') ? ASSET_VERSION : null,
|
||||
|
||||
// Environment (prod, staging, dev)
|
||||
'env' => $env,
|
||||
'env' => $appEnv,
|
||||
|
||||
// Domains
|
||||
'domains' => [
|
||||
'primaryDomain' => app_primary_domain(),
|
||||
'primaryUrl' => app_primary_url(),
|
||||
'fakecheckDomain' => app_fakecheck_domain(),
|
||||
'fakecheckUrl' => app_fakecheck_url(),
|
||||
'domains' => [
|
||||
'primaryDomain' => $primaryDomain,
|
||||
'primaryUrl' => $primaryUrl,
|
||||
'fakecheckDomain' => $fakecheckDomain,
|
||||
'fakecheckUrl' => $fakecheckUrl,
|
||||
],
|
||||
|
||||
// Fakecheck-Tool-Config
|
||||
'fakecheck' => [
|
||||
'baseUrl' => $GLOBALS['app_url'] ?? '',
|
||||
'apiBaseUrl' => $GLOBALS['app_api_url'] ?? 'https://api.usbcheck.it',
|
||||
'fakecheck' => [
|
||||
'baseUrl' => $appBaseUrl,
|
||||
'apiBaseUrl' => $appApiBase,
|
||||
'locale' => $currentLang,
|
||||
],
|
||||
'i18n' => app_i18n_get_frontend_config(),
|
||||
// i18n-Konfiguration
|
||||
'i18n' => [
|
||||
'available' => $allAvailable,
|
||||
'current' => $currentLang,
|
||||
],
|
||||
|
||||
// i18n-Konfiguration (zentrale Struktur)
|
||||
'i18n' => $i18nConfig,
|
||||
];
|
||||
?>
|
||||
<script>
|
||||
window.usbConfig = <?= json_encode(
|
||||
// Zentrales JS-Config-Objekt für deine Tools
|
||||
window.usbcheck = <?= json_encode(
|
||||
$usbConfig,
|
||||
JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_SUBSTITUTE
|
||||
) ?>;
|
||||
|
||||
// Alias für eventuelle ältere Stellen
|
||||
window.usbConfig = window.usbcheck;
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user