Files
intranet/web/intranet_repo/projects/adminpanel/_tabs.php
T

33 lines
1.4 KiB
PHP

<?php
/* Zentrale Reiternavigation des Adminpanels.
* Erwartet: $pdo (PDO) und optional $adminActiveTab.
*/
$adminActiveTab = $adminActiveTab ?? '';
$adminInboxBadgeCount = 0;
try {
$adminInboxBadgeCount = (int)$pdo->query("SELECT COUNT(*) FROM admin_messages WHERE status = 'pending'")->fetchColumn();
} catch (Throwable $e) {
// Die Navigation soll auch dann benutzbar bleiben, wenn das Postfach temporär nicht verfügbar ist.
$adminInboxBadgeCount = 0;
}
$adminTabs = [
'users' => ['label' => 'Nutzerverwaltung', 'href' => 'admin.php'],
'inbox' => ['label' => 'Postfach', 'href' => 'admin_inbox.php', 'badge' => $adminInboxBadgeCount],
'kalli' => ['label' => 'Kalli', 'href' => 'admin_kalli.php'],
'brandschutz' => ['label' => 'Brandschutz', 'href' => 'admin_brandschutz.php'],
'notices' => ['label' => 'Meldungen', 'href' => 'admin_notices.php'],
];
?>
<div class="content-tab-bar">
<?php foreach ($adminTabs as $tabKey => $tab): ?>
<a class="content-tab-bar__item<?= $adminActiveTab === $tabKey ? ' active' : '' ?>" href="<?= htmlspecialchars($tab['href'], ENT_QUOTES, 'UTF-8') ?>">
<?= htmlspecialchars($tab['label'], ENT_QUOTES, 'UTF-8') ?>
<?php if (!empty($tab['badge'])): ?>
<span class="content-tab-bar__badge"><?= (int)$tab['badge'] ?></span>
<?php endif; ?>
</a>
<?php endforeach; ?>
</div>