1<?php
2/**
3 * Top navigation for the default theme.
4 *
5 * The links come from the database and are managed in Admin Panel > Menus, so
6 * adding one no longer means editing this file - and every theme shares the
7 * same navigation instead of carrying its own copy.
8 *
9 * The markup is still entirely this theme's business: theme_menu_items() only
10 * hands over the data, already filtered for the current visitor. An entry
11 * marked "Admins only" is absent from the array, not hidden with CSS.
12 *
13 * A theme that would rather hardcode its menu simply does not call this.
14 */
15
16$menuItems = theme_menu_items('main');
17$menuLive = function_exists('theme_menu_available') ? theme_menu_available() : (bool)$menuItems;
18$menuLabel = static function ($value): string {
19 return htmlspecialchars(function_exists('theme_menu_label') ? theme_menu_label((string)$value) : (string)$value, ENT_QUOTES, 'UTF-8');
20};
21
22// A site that has not run the menu migration yet gets the old hardcoded links,
23// so upgrading never leaves someone with no navigation at all.
24$menuFallback = !$menuLive;
25?>
26<nav>
27 <div class="container">
28
29 <!-- Menu left aligned -->
30 <div class="pull-left">
31 <?php if (!$menuFallback): ?>
32 <ul>
33 <?php foreach ($menuItems as $item): ?>
34 <li>
35 <?php // A category carries no URL: it opens its children, it does not navigate. ?>
36 <?php if ($item['url'] === ''): ?>
37 <span class="menuCategory">
38 <?php if ($item['icon'] !== ''): ?>
39 <i class="fa <?= htmlspecialchars($item['icon'], ENT_QUOTES, 'UTF-8') ?>"></i>
40 <?php endif; ?>
41 <?= $menuLabel($item['label']) ?>
42 </span>
43 <?php else: ?>
44 <a href="<?= htmlspecialchars($item['url'], ENT_QUOTES, 'UTF-8') ?>"
45 <?= $item['target'] !== '' ? 'target="' . htmlspecialchars($item['target'], ENT_QUOTES, 'UTF-8') . '" rel="noopener"' : '' ?>>
46 <?php if ($item['icon'] !== ''): ?>
47 <i class="fa <?= htmlspecialchars($item['icon'], ENT_QUOTES, 'UTF-8') ?>"></i>
48 <?php endif; ?>
49 <?= $menuLabel($item['label']) ?>
50 </a>
51 <?php endif; ?>
52
53 <?php if ($item['children']): ?>
54 <ul>
55 <?php foreach ($item['children'] as $child): ?>
56 <li>
57 <a href="<?= htmlspecialchars($child['url'], ENT_QUOTES, 'UTF-8') ?>"
58 <?= $child['target'] !== '' ? 'target="' . htmlspecialchars($child['target'], ENT_QUOTES, 'UTF-8') . '" rel="noopener"' : '' ?>>
59 <?= $menuLabel($child['label']) ?>
60 </a>
61 </li>
62 <?php endforeach; ?>
63 </ul>
64 <?php endif; ?>
65 </li>
66 <?php endforeach; ?>
67 </ul>
68 <?php else: ?>
69 <ul>
70 <li><a href="/"><i class="fa fa-home"></i> <?= h(t('nav.home')) ?></a></li>
71 <li><a id="accountLink" href="myaccount.php"><i class="fa fa-user-circle"></i> <?= h(t('nav.account')) ?></a></li>
72 <li><a href="onlinelist.php"><i class="fa fa-users"></i> <?= h(t('nav.community')) ?></a></li>
73 <li><a href="serverinfo.php"><i class="fa fa-book"></i> <?= h(t('nav.library')) ?></a></li>
74 <li><a href="support.php"><i class="fa fa-info-circle"></i> <?= h(t('nav.support')) ?></a></li>
75 <li><a href="shop.php"><i class="fa fa-shopping-cart"></i> <?= h(t('nav.shop')) ?></a></li>
76 </ul>
77 <?php endif; ?>
78 </div>
79
80 <!-- Menu right aligned -->
81 <div class="pull-right">
82 <ul>
83 <?php if (user_logged_in() === true): ?>
84 <li><a href="myaccount.php"><i class="fa fa-user"></i> <?= htmlspecialchars($user_data['name'] ?? '', ENT_QUOTES, 'UTF-8') ?></a></li>
85 <li><a href="logout.php"><i class="fa fa-sign-out"></i> <?= h(t('nav.logout')) ?></a></li>
86 <?php else: ?>
87 <li><a href="#loginContainer" class="modIcon loginBtn"><i class="fa fa-lock"></i><i class="fa fa-unlock"></i> <?= h(t('nav.login')) ?></a></li>
88 <li><a href="register.php"><i class="fa fa-key"></i> <?= h(t('nav.register')) ?></a></li>
89 <?php endif; ?>
90 </ul>
91 </div>
92
93 </div>
94</nav>
95