127 lines
5.9 KiB
PHP
Executable File
127 lines
5.9 KiB
PHP
Executable File
<?php
|
|
$requestPath = app()->request()->path();
|
|
$currentModuleName = current_module_name();
|
|
if ($currentModuleName === null && preg_match('~^/modules/(?:setup|access)/([a-zA-Z0-9_-]+)~', $requestPath, $moduleMatch)) {
|
|
$currentModuleName = $moduleMatch[1];
|
|
}
|
|
$currentModule = $currentModuleName !== null ? modules()->get($currentModuleName) : null;
|
|
$isStagingHost = defined('APP_DOMAIN_PRIMARY') && str_starts_with((string) APP_DOMAIN_PRIMARY, 'staging.');
|
|
$headerEyebrow = '';
|
|
$defaultHeaderTitle = $currentModule
|
|
? (string)($currentModule['title'] ?? $currentModuleName)
|
|
: ('Nexus' . ($isStagingHost ? ' (staging)' : ''));
|
|
$headerText = $currentModule ? (string)($currentModule['description'] ?? '') : '';
|
|
$headerBaseTitle = isset($GLOBALS['layout_header_base_title']) && is_string($GLOBALS['layout_header_base_title']) && trim($GLOBALS['layout_header_base_title']) !== ''
|
|
? trim($GLOBALS['layout_header_base_title'])
|
|
: $defaultHeaderTitle;
|
|
$headerTitle = isset($GLOBALS['layout_header_title']) && is_string($GLOBALS['layout_header_title']) && trim($GLOBALS['layout_header_title']) !== ''
|
|
? trim($GLOBALS['layout_header_title'])
|
|
: $headerBaseTitle;
|
|
$headerContext = isset($GLOBALS['layout_header_context']) && is_string($GLOBALS['layout_header_context'])
|
|
? trim($GLOBALS['layout_header_context'])
|
|
: '';
|
|
$headerText = isset($GLOBALS['layout_header_text']) && is_string($GLOBALS['layout_header_text'])
|
|
? trim($GLOBALS['layout_header_text'])
|
|
: $headerText;
|
|
$headerActions = isset($GLOBALS['layout_header_actions']) && is_array($GLOBALS['layout_header_actions'])
|
|
? $GLOBALS['layout_header_actions']
|
|
: [];
|
|
$auth = app()->auth();
|
|
$authUser = $auth->user();
|
|
$isDebugAdmin = auth_is_admin();
|
|
$isNexusDebugEnabled = $isDebugAdmin && nexus_debug_enabled();
|
|
?>
|
|
<!doctype html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Nexus</title>
|
|
<script>
|
|
(() => {
|
|
const moduleName = <?= json_encode($currentModuleName) ?>;
|
|
const read = (key, fallback) => {
|
|
try { return localStorage.getItem(key) || fallback; } catch (error) { return fallback; }
|
|
};
|
|
const mainTheme = read('nexus.theme', 'day');
|
|
const mainAccent = read('nexus.accent', 'logo');
|
|
const moduleTheme = moduleName ? read(`nexus.module.${moduleName}.theme`, 'inherit') : mainTheme;
|
|
const moduleAccent = moduleName ? read(`nexus.module.${moduleName}.accent`, 'inherit') : mainAccent;
|
|
document.documentElement.dataset.module = moduleName || '';
|
|
document.documentElement.dataset.theme = moduleTheme === 'inherit' ? mainTheme : moduleTheme;
|
|
document.documentElement.dataset.accent = moduleAccent === 'inherit' ? mainAccent : moduleAccent;
|
|
})();
|
|
</script>
|
|
<link rel="stylesheet" href="<?= e(app()->assets()->versioned('/assets/css/app.css')) ?>">
|
|
<?php asset_styles(); ?>
|
|
<?php asset_scripts('header'); ?>
|
|
</head>
|
|
<body data-nexus-debug-admin="<?= $isDebugAdmin ? '1' : '0' ?>" data-nexus-debug-enabled="<?= $isNexusDebugEnabled ? '1' : '0' ?>">
|
|
<main class="main-shell">
|
|
<section class="home-hero app-header main-header-box" data-module-name="<?= e((string)($currentModuleName ?? '')) ?>">
|
|
<a class="brand-mark" href="/" aria-label="Nexus">
|
|
<img src="/assets/images/logo.png" alt="Nexus Logo">
|
|
</a>
|
|
<div class="brand-copy">
|
|
<?php if ($headerEyebrow !== ''): ?>
|
|
<span class="eyebrow"><?= e($headerEyebrow) ?></span>
|
|
<?php endif; ?>
|
|
<h1>
|
|
<?= e($headerTitle) ?>
|
|
<?php if ($headerContext !== ''): ?>
|
|
<span class="module-page-context"> / <?= e($headerContext) ?></span>
|
|
<?php endif; ?>
|
|
</h1>
|
|
<?php if ($headerText !== ''): ?>
|
|
<p><?= e($headerText) ?></p>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="theme-switcher" aria-label="Darstellung">
|
|
<?php if ($headerActions !== []): ?>
|
|
<div class="header-actions">
|
|
<?php foreach ($headerActions as $headerAction): ?>
|
|
<?php
|
|
if (!is_array($headerAction)) {
|
|
continue;
|
|
}
|
|
$actionHref = trim((string) ($headerAction['href'] ?? ''));
|
|
$actionLabel = trim((string) ($headerAction['label'] ?? ''));
|
|
if ($actionHref === '' || $actionLabel === '') {
|
|
continue;
|
|
}
|
|
?>
|
|
<a class="nav-link" href="<?= e($actionHref) ?>"><?= e($actionLabel) ?></a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if ($auth->isEnabled()): ?>
|
|
<a class="auth-pill" href="<?= $authUser === null ? '/auth/login' : '/auth/logout' ?>">
|
|
<?= $authUser === null ? 'Login' : 'Logout ' . e((string)($authUser['username'] ?? $authUser['name'] ?? '')) ?>
|
|
</a>
|
|
<?php endif; ?>
|
|
<label>
|
|
<span>Modus</span>
|
|
<select data-theme-mode data-theme-scope="<?= $currentModuleName !== null ? 'module' : 'main' ?>">
|
|
<?php if ($currentModuleName !== null): ?>
|
|
<option value="inherit">Wie Hauptsystem</option>
|
|
<?php endif; ?>
|
|
<option value="day">Day</option>
|
|
<option value="night">Night</option>
|
|
</select>
|
|
</label>
|
|
<label>
|
|
<span>Farbe</span>
|
|
<select data-theme-accent data-theme-scope="<?= $currentModuleName !== null ? 'module' : 'main' ?>">
|
|
<?php if ($currentModuleName !== null): ?>
|
|
<option value="inherit">Wie Hauptsystem</option>
|
|
<?php endif; ?>
|
|
<option value="logo">Logo</option>
|
|
<option value="pink">Pink</option>
|
|
<option value="cyan">Cyan</option>
|
|
<option value="orange">Orange</option>
|
|
<option value="green">Gruen</option>
|
|
</select>
|
|
</label>
|
|
</div>
|
|
</section>
|