Panel/Panel/modules/website/includes/navigation.php

83 lines
4.2 KiB
PHP

<?php
declare(strict_types=1);
$activePage = $activePage ?? '';
$currentUser = website_current_user();
$cartCount = website_cart_count();
$publicLinks = [
['key' => 'home', 'label' => 'Home', 'href' => website_url('index.php')],
['key' => 'servers', 'label' => 'Game Servers', 'href' => website_url('serverlist.php')],
['key' => 'pricing', 'label' => 'Pricing', 'href' => website_url('pricing.php')],
['key' => 'locations', 'label' => 'Locations', 'href' => website_url('locations.php')],
['key' => 'docs', 'label' => 'Documentation', 'href' => website_url('docs.php')],
['key' => 'support', 'label' => 'Support', 'href' => website_url('support.php')],
];
if ($currentUser) {
$accountLinks = [
['key' => 'account', 'label' => 'My Account', 'href' => website_url('my_account.php')],
['key' => 'orders', 'label' => 'My Orders', 'href' => website_url('my_orders.php')],
['key' => 'servers', 'label' => 'My Servers', 'href' => website_url('my_servers.php')],
['key' => 'cart', 'label' => 'Cart' . ($cartCount > 0 ? ' (' . $cartCount . ')' : ''), 'href' => website_cart_url()],
['key' => 'logout', 'label' => 'Logout', 'href' => website_url('logout.php')],
];
} else {
$accountLinks = [
['key' => 'account', 'label' => 'Login', 'href' => website_login_url()],
['key' => 'register', 'label' => 'Create Account', 'href' => website_register_url()],
['key' => 'cart', 'label' => 'Cart' . ($cartCount > 0 ? ' (' . $cartCount . ')' : ''), 'href' => website_cart_url()],
];
}
$staffLinks = ($currentUser && website_current_user_is_staff()) ? [
['key' => 'staff', 'label' => 'Staff Dashboard', 'href' => website_url('staff.php')],
] : [];
?>
<header class="site-header">
<div class="container header-shell">
<a class="brand" href="<?= website_escape(website_url('index.php')) ?>">
<img src="<?= website_escape(website_asset('images/dark-logo.png')) ?>" alt="Gameservers.World logo" class="brand-logo">
<span class="brand-copy">
<span class="brand-name"><?= website_escape(website_config('site_name')) ?></span>
<span class="brand-tagline">Developer-backed game hosting</span>
</span>
</a>
<button class="nav-toggle" type="button" aria-expanded="false" aria-controls="primary-nav" data-nav-toggle>
<span></span>
<span></span>
<span></span>
<span class="sr-only">Toggle navigation</span>
</button>
<nav class="primary-nav" id="primary-nav" data-nav-menu aria-label="Primary navigation">
<div class="nav-group nav-group-public">
<?php foreach ($publicLinks as $link): ?>
<a class="nav-link<?= $activePage === $link['key'] ? ' is-active' : '' ?>" href="<?= website_escape($link['href']) ?>">
<?= website_escape($link['label']) ?>
</a>
<?php endforeach; ?>
</div>
<div class="nav-group nav-group-account" aria-label="Account navigation">
<?php foreach ($accountLinks as $link): ?>
<a class="nav-link<?= $activePage === $link['key'] ? ' is-active' : '' ?>" href="<?= website_escape($link['href']) ?>">
<?= website_escape($link['label']) ?>
</a>
<?php endforeach; ?>
</div>
<?php if (!empty($staffLinks)): ?>
<div class="nav-group nav-group-staff" aria-label="Staff navigation">
<?php foreach ($staffLinks as $link): ?>
<a class="nav-link<?= $activePage === $link['key'] ? ' is-active' : '' ?>" href="<?= website_escape($link['href']) ?>">
<?= website_escape($link['label']) ?>
</a>
<?php endforeach; ?>
</div>
<?php endif; ?>
</nav>
<div class="header-actions" data-header-actions>
<a class="button button-secondary" href="<?= website_escape(website_custom_project_url()) ?>">Custom Projects</a>
<a class="button button-primary" href="<?= website_escape(website_control_panel_url()) ?>">Control Panel</a>
</div>
</div>
</header>