Files
papa-kind-treff.info/partials/structure/nav.php
Lars Gebhardt-Kusche 2e800d4839
All checks were successful
Deploy / deploy (push) Successful in 51s
new build
2026-07-22 21:40:34 +02:00

75 lines
3.0 KiB
PHP
Executable File

<?php
$app = app();
$isLoggedIn = isset($_SESSION['user_id']);
$displayName = 'Profil';
$profileInitial = 'P';
if ($isLoggedIn) {
try {
$pdo = $app->pdo();
if ($pdo) {
$stmt = $pdo->prepare('SELECT display_name, first_name FROM user_profiles WHERE user_id = :id LIMIT 1');
$stmt->execute(['id' => (int)$_SESSION['user_id']]);
$profileRow = $stmt->fetch(PDO::FETCH_ASSOC) ?: [];
$displayName = trim((string)($profileRow['display_name'] ?? '')) ?: trim((string)($profileRow['first_name'] ?? '')) ?: 'Profil';
$firstChar = mb_substr($displayName, 0, 1);
if ($firstChar !== '') {
$profileInitial = mb_strtoupper($firstChar);
}
}
} catch (\Throwable) {
$displayName = 'Profil';
$profileInitial = 'P';
}
}
?>
<header class="site-header">
<div class="container nav-row">
<div class="brand">
<img data-logo-img src="/assets/bilder/logo_male.png" alt="Papa-Kind-Treff Logo" class="brand__logo">
<div class="brand__text">
<span class="brand__name">Papa-Kind-Treff</span>
<span class="brand__tag">Väter vernetzen</span>
</div>
</div>
<nav class="nav-links" aria-label="Hauptmenü">
<a href="/">Home</a>
<a href="/search">Suche</a>
<a href="/community">Community</a>
</nav>
<div class="nav-actions">
<?php if ($isLoggedIn): ?>
<div class="profile-menu" data-profile-menu>
<button class="profile-menu__trigger" type="button" aria-haspopup="menu" aria-expanded="false" data-profile-menu-trigger>
<span class="profile-menu__avatar" aria-hidden="true"><?= htmlspecialchars($profileInitial, ENT_QUOTES) ?></span>
<span class="profile-menu__name"><?= htmlspecialchars($displayName, ENT_QUOTES) ?></span>
</button>
<div class="profile-menu__dropdown" role="menu">
<a href="/dashboard" role="menuitem">Übersicht</a>
<a href="/dashboard" role="menuitem">Mitgliederbereich</a>
<a href="/logout" role="menuitem">Abmelden</a>
</div>
</div>
<?php else: ?>
<a class="btn ghost" href="/login">Anmelden</a>
<a class="btn" href="/register">Kostenlos registrieren</a>
<?php endif; ?>
<button class="menu-toggle" aria-label="Menü öffnen">☰</button>
</div>
</div>
<div class="mobile-menu" id="mobileMenu">
<a href="/">Home</a>
<a href="/search">Suche</a>
<a href="/community">Community</a>
<?php if ($isLoggedIn): ?>
<a class="btn ghost" href="/dashboard">Übersicht</a>
<a class="btn ghost" href="/dashboard">Mitgliederbereich</a>
<a class="btn block" href="/logout">Abmelden</a>
<?php else: ?>
<a class="btn ghost" href="/login">Anmelden</a>
<a class="btn block" href="/register">Kostenlos registrieren</a>
<?php endif; ?>
</div>
</header>
<div id="headerSentinel" class="header-sentinel" aria-hidden="true"></div>