Files
nexus/partials/structure/layout_start.php
Lars Gebhardt-Kusche 2c1a751e82
All checks were successful
Deploy / deploy-staging (push) Successful in 6s
Deploy / deploy-production (push) Has been skipped
aasdsd
2026-05-04 01:23:43 +02:00

114 lines
5.0 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 = '';
$headerTitle = $currentModule
? (string)($currentModule['title'] ?? $currentModuleName)
: ('Nexus' . ($isStagingHost ? ' (staging)' : ''));
$headerText = $currentModule ? (string)($currentModule['description'] ?? '') : '';
$headerTitle = isset($GLOBALS['layout_header_title']) && is_string($GLOBALS['layout_header_title']) && trim($GLOBALS['layout_header_title']) !== ''
? trim($GLOBALS['layout_header_title'])
: $headerTitle;
$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();
?>
<!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>
<main class="main-shell">
<section class="home-hero app-header" 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) ?></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>