146 lines
5.8 KiB
PHP
146 lines
5.8 KiB
PHP
|
|
<?php
|
||
|
|
use Core\Services\Nav;
|
||
|
|
use Core\Services\Plugins;
|
||
|
|
use Core\Services\Settings;
|
||
|
|
|
||
|
|
$links = Nav::links();
|
||
|
|
$activeLinks = array_values(array_filter($links, static function ($link): bool {
|
||
|
|
return (int)($link['is_active'] ?? 0) === 1;
|
||
|
|
}));
|
||
|
|
if (!$activeLinks) {
|
||
|
|
$activeLinks = [
|
||
|
|
['label' => 'Home', 'url' => '/'],
|
||
|
|
['label' => 'Artists', 'url' => '/artists'],
|
||
|
|
['label' => 'Releases', 'url' => '/releases'],
|
||
|
|
['label' => 'Store', 'url' => '/store'],
|
||
|
|
['label' => 'Contact', 'url' => '/contact'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
$storeEnabled = Plugins::isEnabled('store');
|
||
|
|
$cartCount = 0;
|
||
|
|
$cartTotal = 0.0;
|
||
|
|
$customerLoggedIn = false;
|
||
|
|
$hasAccountLink = false;
|
||
|
|
foreach ($activeLinks as $link) {
|
||
|
|
$linkUrl = trim((string)($link['url'] ?? ''));
|
||
|
|
if ($linkUrl === '/account') {
|
||
|
|
$hasAccountLink = true;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if ($storeEnabled) {
|
||
|
|
if (session_status() !== PHP_SESSION_ACTIVE) {
|
||
|
|
session_start();
|
||
|
|
}
|
||
|
|
$customerLoggedIn = !empty($_SESSION['ac_store_customer_email']);
|
||
|
|
$cart = $_SESSION['ac_cart'] ?? [];
|
||
|
|
if (is_array($cart)) {
|
||
|
|
foreach ($cart as $item) {
|
||
|
|
if (!is_array($item)) {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
$qty = max(1, (int)($item['qty'] ?? 1));
|
||
|
|
$price = (float)($item['price'] ?? 0);
|
||
|
|
$cartCount += $qty;
|
||
|
|
$cartTotal += ($price * $qty);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$headerTitle = Settings::get('site_header_title', 'AudioCore V1.5');
|
||
|
|
$headerTagline = Settings::get('site_header_tagline', 'Core CMS for DJs & Producers');
|
||
|
|
$headerBadgeText = Settings::get('site_header_badge_text', 'Independent catalog');
|
||
|
|
$headerBrandMode = Settings::get('site_header_brand_mode', 'default');
|
||
|
|
$headerMarkMode = Settings::get('site_header_mark_mode', 'text');
|
||
|
|
$headerMarkText = Settings::get('site_header_mark_text', 'AC');
|
||
|
|
$headerMarkIcon = preg_replace('/[^a-zA-Z0-9\\-\\s]/', '', Settings::get('site_header_mark_icon', 'fa-solid fa-music')) ?? 'fa-solid fa-music';
|
||
|
|
$headerMarkIcon = trim($headerMarkIcon);
|
||
|
|
if ($headerMarkIcon === '' || strpos($headerMarkIcon, 'fa-') === false) {
|
||
|
|
$headerMarkIcon = 'fa-solid fa-music';
|
||
|
|
}
|
||
|
|
$headerMarkBgStart = Settings::get('site_header_mark_bg_start', '#22f2a5');
|
||
|
|
$headerMarkBgEnd = Settings::get('site_header_mark_bg_end', '#10252e');
|
||
|
|
$headerLogoUrl = Settings::get('site_header_logo_url', '');
|
||
|
|
|
||
|
|
$effectiveMarkMode = $headerMarkMode;
|
||
|
|
if ($effectiveMarkMode === 'logo' && $headerLogoUrl === '') {
|
||
|
|
$effectiveMarkMode = 'icon';
|
||
|
|
}
|
||
|
|
if ($effectiveMarkMode === 'icon' && $headerMarkIcon === '') {
|
||
|
|
$effectiveMarkMode = 'text';
|
||
|
|
}
|
||
|
|
if ($effectiveMarkMode === 'text' && trim($headerMarkText) === '') {
|
||
|
|
$effectiveMarkMode = 'icon';
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
<header class="shell">
|
||
|
|
<div class="card">
|
||
|
|
<div class="site-head">
|
||
|
|
<?php if ($headerBrandMode === 'logo_only' && $headerLogoUrl !== ''): ?>
|
||
|
|
<div class="site-brand site-brand-logo-only">
|
||
|
|
<img class="site-brand-logo-only-img" src="<?= htmlspecialchars($headerLogoUrl, ENT_QUOTES, 'UTF-8') ?>" alt="">
|
||
|
|
</div>
|
||
|
|
<?php else: ?>
|
||
|
|
<div class="site-brand">
|
||
|
|
<div class="site-brand-mark" style="background:linear-gradient(135deg, <?= htmlspecialchars($headerMarkBgStart, ENT_QUOTES, 'UTF-8') ?>, <?= htmlspecialchars($headerMarkBgEnd, ENT_QUOTES, 'UTF-8') ?>);">
|
||
|
|
<?php if ($effectiveMarkMode === 'icon'): ?>
|
||
|
|
<i class="<?= htmlspecialchars($headerMarkIcon, ENT_QUOTES, 'UTF-8') ?>" aria-hidden="true"></i>
|
||
|
|
<?php elseif ($effectiveMarkMode === 'logo' && $headerLogoUrl !== ''): ?>
|
||
|
|
<img class="site-brand-mark-logo" src="<?= htmlspecialchars($headerLogoUrl, ENT_QUOTES, 'UTF-8') ?>" alt="">
|
||
|
|
<?php else: ?>
|
||
|
|
<?= htmlspecialchars(trim($headerMarkText) !== '' ? $headerMarkText : 'AC', ENT_QUOTES, 'UTF-8') ?>
|
||
|
|
<?php endif; ?>
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<div class="site-brand-title"><?= htmlspecialchars($headerTitle, ENT_QUOTES, 'UTF-8') ?></div>
|
||
|
|
<div class="site-brand-sub"><?= htmlspecialchars($headerTagline, ENT_QUOTES, 'UTF-8') ?></div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
<div class="badge site-badge"><?= htmlspecialchars($headerBadgeText, ENT_QUOTES, 'UTF-8') ?></div>
|
||
|
|
<button type="button" class="nav-toggle" id="siteNavToggle" aria-expanded="false" aria-controls="siteNavMenu">
|
||
|
|
<i class="fa-solid fa-bars"></i>
|
||
|
|
<span>Menu</span>
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
<div style="margin-top:18px;" class="nav" id="siteNavMenu">
|
||
|
|
<?php foreach ($activeLinks as $link): ?>
|
||
|
|
<?php
|
||
|
|
$label = (string)($link['label'] ?? '');
|
||
|
|
$url = (string)($link['url'] ?? '#');
|
||
|
|
?>
|
||
|
|
<a href="<?= htmlspecialchars($url, ENT_QUOTES, 'UTF-8') ?>">
|
||
|
|
<?= htmlspecialchars($label, ENT_QUOTES, 'UTF-8') ?>
|
||
|
|
</a>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
<?php if ($storeEnabled): ?>
|
||
|
|
<div class="nav-actions">
|
||
|
|
<?php if (!$hasAccountLink): ?>
|
||
|
|
<a class="nav-account" href="/account">
|
||
|
|
<i class="fa-solid fa-user" aria-hidden="true"></i>
|
||
|
|
<span><?= $customerLoggedIn ? 'Account' : 'Login' ?></span>
|
||
|
|
</a>
|
||
|
|
<?php endif; ?>
|
||
|
|
<a class="nav-cart" href="/cart">
|
||
|
|
<i class="fa-solid fa-cart-shopping" aria-hidden="true"></i>
|
||
|
|
<span><?= $cartCount ?></span>
|
||
|
|
<span><?= number_format($cartTotal, 2) ?></span>
|
||
|
|
</a>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</header>
|
||
|
|
<script>
|
||
|
|
(function () {
|
||
|
|
const toggle = document.getElementById('siteNavToggle');
|
||
|
|
const menu = document.getElementById('siteNavMenu');
|
||
|
|
if (!toggle || !menu) return;
|
||
|
|
toggle.addEventListener('click', function () {
|
||
|
|
const isOpen = menu.classList.toggle('is-open');
|
||
|
|
toggle.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
|
||
|
|
});
|
||
|
|
})();
|
||
|
|
</script>
|