Files
netwatch/app/templates/header.php
fixclean f4ce7f360d feat: implement package 1 session and validation feedback
- add session validation_errors bootstrap initialization

- render global flash + validation messages in header

- remove footer alert-based flash handling

- persist structured validation errors across save handlers

- mark NEXT_STEPS package 1 tasks as done
2026-02-18 09:40:59 +01:00

124 lines
3.9 KiB
PHP

<?php
/**
* header.php
*
* HTML-Kopf, CSS / JS einbinden, Navigation
* Wird am Anfang jeder Seite eingebunden
*/
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Netwatch - Netzwerk-Dokumentation und Verkabelungsverwaltung">
<title>Netzwerk-Dokumentation</title>
<link rel="icon" type="image/svg+xml" href="/assets/icons/favicon.svg">
<!-- CSS -->
<link rel="stylesheet" href="/assets/css/app.css">
<link rel="stylesheet" href="/assets/css/device-type-edit.css">
<!-- JS -->
<script src="/assets/js/app.js" defer></script>
<script src="/assets/js/dashboard.js" defer></script>
<script src="/assets/js/svg-editor.js" defer></script>
<script src="/assets/js/network-view.js" defer></script>
</head>
<body>
<header class="app-header">
<div class="app-header__brand">
<span class="app-header__eyebrow">Netzwerk</span>
<h1 class="app-header__title">Dokumentation</h1>
</div>
<?php
$currentModule = $_GET['module'] ?? 'dashboard';
$navItems = [
'dashboard' => 'Dashboard',
'locations' => 'Standorte',
'device_types' => 'Gerätetypen',
'port_types' => 'Porttypen',
'devices' => 'Geräte',
'racks' => 'Racks',
'floor_infrastructure' => 'Infrastruktur',
'connections' => 'Verbindungen',
];
?>
<nav class="main-nav">
<ul class="main-nav__list">
<?php foreach ($navItems as $navModule => $label): ?>
<?php
$active = ($currentModule === $navModule) ? 'active' : '';
?>
<li class="main-nav__item <?= $active ?>">
<a href="?module=<?= $navModule ?>&action=list" class="main-nav__link">
<?= $label ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</nav>
</header>
<?php
$flashMessages = [];
$successMessage = trim((string)($_SESSION['success'] ?? ''));
if ($successMessage !== '') {
$flashMessages[] = [
'type' => 'success',
'text' => $successMessage,
];
}
$errorMessage = trim((string)($_SESSION['error'] ?? ''));
if ($errorMessage !== '') {
$flashMessages[] = [
'type' => 'error',
'text' => $errorMessage,
];
}
$validationErrors = $_SESSION['validation_errors'] ?? [];
if (!is_array($validationErrors)) {
$validationErrors = [];
}
$validationErrors = array_values(array_filter(array_map(static function ($entry) {
return trim((string)$entry);
}, $validationErrors), static function ($entry) {
return $entry !== '';
}));
if (!empty($validationErrors)) {
$flashMessages[] = [
'type' => 'error',
'text' => 'Bitte pruefe die Eingaben:',
'details' => $validationErrors,
];
}
unset($_SESSION['success'], $_SESSION['error'], $_SESSION['validation_errors']);
?>
<main>
<?php if (!empty($flashMessages)): ?>
<section class="flash-stack" aria-live="polite">
<?php foreach ($flashMessages as $message): ?>
<article class="flash-message flash-message--<?php echo htmlspecialchars((string)$message['type']); ?>">
<p class="flash-message__text"><?php echo htmlspecialchars((string)($message['text'] ?? '')); ?></p>
<?php if (!empty($message['details']) && is_array($message['details'])): ?>
<ul class="flash-message__list">
<?php foreach ($message['details'] as $detail): ?>
<li><?php echo htmlspecialchars((string)$detail); ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</article>
<?php endforeach; ?>
</section>
<?php endif; ?>