This commit is contained in:
@@ -1,7 +1,27 @@
|
||||
<?php
|
||||
$app = app();
|
||||
$isLoggedIn = isset($_SESSION['user_id']);
|
||||
$isDebug = defined('APP_DEBUG') && APP_DEBUG === true;
|
||||
$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">
|
||||
@@ -15,16 +35,21 @@ $isDebug = defined('APP_DEBUG') && APP_DEBUG === true;
|
||||
<nav class="nav-links" aria-label="Hauptmenü">
|
||||
<a href="/">Home</a>
|
||||
<a href="/search">Suche</a>
|
||||
<a href="/#events" data-nav-events>Termine</a>
|
||||
<a href="/community">Community</a>
|
||||
</nav>
|
||||
<div class="nav-actions">
|
||||
<?php if ($isLoggedIn): ?>
|
||||
<a class="btn ghost" href="/dashboard">Dashboard</a>
|
||||
<a class="btn ghost" href="/logout">Logout</a>
|
||||
<?php if ($isDebug): ?>
|
||||
<a class="btn ghost" href="/debug">Debug</a>
|
||||
<?php endif; ?>
|
||||
<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>
|
||||
@@ -35,14 +60,11 @@ $isDebug = defined('APP_DEBUG') && APP_DEBUG === true;
|
||||
<div class="mobile-menu" id="mobileMenu">
|
||||
<a href="/">Home</a>
|
||||
<a href="/search">Suche</a>
|
||||
<a href="/#events" data-nav-events>Termine</a>
|
||||
<a href="/community">Community</a>
|
||||
<?php if ($isLoggedIn): ?>
|
||||
<a class="btn ghost" href="/dashboard">Dashboard</a>
|
||||
<a class="btn block" href="/logout">Logout</a>
|
||||
<?php if ($isDebug): ?>
|
||||
<a class="btn ghost block" href="/debug">Debug</a>
|
||||
<?php endif; ?>
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user