WebOrbiton
v1.0.0.6

Publisium

171 lines · 8.8 KB
  1. <?php
  2. ​
  3. declare(strict_types=1);
  4. ​
  5. require_once __DIR__ . '/icons.php';
  6. require_once __DIR__ . '/asset.php';
  7. ​
  8. if (Languages::current() !== '') {
  9. ob_start([Languages::class, 'absolutizeUrls']);
  10. }
  11. ​
  12. $navItems = SiteFront::navItems();
  13. ​
  14. $menuPositionClass = 'site-menu-' . ($settings['menu_position'] ?? 'top');
  15. ​
  16. $resolvedPageTitle = $pageTitle ?? $settings['site_name'];
  17. $resolvedPageDescription = $pageDescription ?? '';
  18. $isHomepage = ($_SERVER['REQUEST_URI'] ?? '') === '/' || basename((string) ($_SERVER['SCRIPT_NAME'] ?? '')) === 'index.php';
  19. ​
  20. ?>
  21. <!DOCTYPE html>
  22. <html lang="<?= htmlspecialchars(Languages::htmlLang(), ENT_QUOTES) ?>">
  23. ​
  24. <head>
  25. <meta charset="utf-8">
  26. <meta name="viewport" content="width=device-width, initial-scale=1">
  27. <title><?= htmlspecialchars($resolvedPageTitle) ?></title>
  28. <?php if (!empty($resolvedPageDescription)): ?>
  29. <meta name="description" content="<?= htmlspecialchars($resolvedPageDescription) ?>">
  30. <?php endif; ?>
  31. <?= SiteFront::renderSeoMeta() ?>
  32. <?= Languages::renderAlternates() ?>
  33. <?= SiteFront::renderOpenGraph($resolvedPageTitle, $resolvedPageDescription, $ogType ?? 'website', $ogImagePath ?? null, $ogArticleMeta ?? null) ?>
  34. <?php if ($isHomepage): ?>
  35. <?= SiteFront::renderOrganizationSchema() ?>
  36. <?php endif; ?>
  37. <?php if (!empty($pageSchema)): ?>
  38. <?= $pageSchema ?>
  39. <?php endif; ?>
  40. <?= Asset::favicon() ?>
  41. <?php if (($settings['pwa_enabled'] ?? '0') === '1'): ?>
  42. <?php $pwaIconUrl = !empty($settings['pwa_icon_url']) ? $settings['pwa_icon_url'] : ($settings['site_logo_url'] ?? ''); ?>
  43. <link rel="manifest" href="<?= htmlspecialchars(rtrim(Config::get('APP_BASE_PATH', ''), '/')) ?>/manifest.json">
  44. <meta name="theme-color" content="<?= htmlspecialchars($settings['pwa_theme_color'] ?: '#ffffff') ?>">
  45. <?php if (!empty($pwaIconUrl)): ?>
  46. <link rel="apple-touch-icon" href="<?= htmlspecialchars($pwaIconUrl) ?>">
  47. <?php endif; ?>
  48. <?php endif; ?>
  49. <?= Asset::css('assets/site.css') ?>
  50. <style>
  51. <?= SiteFront::renderFontFaces() ?><?= SiteFront::fontVariablesCss() ?>
  52. </style>
  53. <?php if (!empty($settings['custom_css'])): ?>
  54. <style>
  55. <?= $settings['custom_css'] ?>
  56. </style>
  57. <?php endif; ?>
  58. <?= SiteFront::renderCustomHeadHtml($pageType ?? null) ?>
  59. <?= SiteFront::renderAnalyticsScripts('head') ?>
  60. </head>
  61. ​
  62. <body class="<?= htmlspecialchars($menuPositionClass) ?>" data-theme="light">
  63. <?= SiteFront::renderAnalyticsScripts('body_start') ?>
  64. <script>
  65. (function() {
  66. try {
  67. var t = localStorage.getItem('publisium_theme');
  68. if (t === 'dark' || t === 'light') {
  69. document.body.setAttribute('data-theme', t);
  70. } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
  71. document.body.setAttribute('data-theme', 'dark');
  72. }
  73. } catch (e) {}
  74. })();
  75. </script>
  76. <?= Icons::sprite() ?>
  77. <div class="site-shell">
  78. ​
  79. <?php
  80. $hasAuthLinks = UserAuth::check() || ($settings['login_enabled'] ?? '1') !== '0';
  81. $centerSearchHtml = $hasAuthLinks ? '' : SiteFront::renderSearchControl('nav');
  82. ?>
  83. <header class="site-header<?= $hasAuthLinks ? '' : ' site-header-no-auth' ?><?= $centerSearchHtml !== '' ? ' site-header-center-search' : '' ?>">
  84. <div class="site-header-row">
  85. <?php
  86. $brandHasLogo = !empty($settings['site_logo_url']);
  87. $brandShowName = !$brandHasLogo || ($settings['site_show_name_with_logo'] ?? '0') === '1';
  88. $brandShortName = trim((string) ($settings['site_short_name'] ?? ''));
  89. $brandUseShort = $brandShowName && ($settings['site_short_name_enabled'] ?? '0') === '1' && $brandShortName !== '';
  90. ?>
  91. <a href="<?= htmlspecialchars(SiteFront::homeUrl(), ENT_QUOTES) ?>" class="site-brand"<?= $brandUseShort ? ' data-short-name="1"' : '' ?>>
  92. <?php if ($brandHasLogo): ?>
  93. <img src="<?= htmlspecialchars($settings['site_logo_url']) ?>" alt="<?= htmlspecialchars($settings['site_name']) ?>" class="site-brand-logo">
  94. <?php endif; ?>
  95. <?php if ($brandShowName): ?>
  96. <span class="site-brand-full"><?= htmlspecialchars($settings['site_name']) ?></span>
  97. <?php if ($brandUseShort): ?>
  98. <span class="site-brand-short"><?= htmlspecialchars($brandShortName) ?></span>
  99. <?php endif; ?>
  100. <?php endif; ?>
  101. </a>
  102. ​
  103. <button type="button" class="site-menu-toggle" id="site-menu-toggle" aria-label="<?= htmlspecialchars(Language::get('nav_menu_toggle', 'Open menu'), ENT_QUOTES) ?>" aria-expanded="false">
  104. <?= Icons::icon('menu', 'icon icon-sm site-menu-toggle-icon-open') ?>
  105. <?= Icons::icon('x', 'icon icon-sm site-menu-toggle-icon-close') ?>
  106. </button>
  107. ​
  108. </div>
  109. ​
  110. <?php if ($centerSearchHtml !== ''): ?>
  111. <div class="site-search-center"><?= $centerSearchHtml ?></div>
  112. <?php endif; ?>
  113. ​
  114. <div class="site-nav-backdrop" id="site-nav-backdrop"></div>
  115. ​
  116. <nav class="site-nav" id="site-nav">
  117. <?php foreach ($navItems as $navItem): ?>
  118. <a href="<?= htmlspecialchars($navItem['url'], ENT_QUOTES) ?>" target="<?= htmlspecialchars($navItem['target'], ENT_QUOTES) ?>" <?= $navItem['target'] === '_blank' ? ' rel="noopener noreferrer"' : '' ?>><?= $navItem['icon_html'] ?? '' ?><?= htmlspecialchars($navItem['label']) ?></a>
  119. <?php endforeach; ?>
  120. <?= SiteFront::renderSearchControl('nav') ?>
  121. ​
  122. <?php if ($hasAuthLinks): ?>
  123. <div class="site-auth-links site-auth-links-mobile">
  124. <?php if (UserAuth::check()): ?>
  125. <a href="account.php"><?= htmlspecialchars(Language::get('nav_account', 'My account')) ?></a>
  126. <a href="user-login.php?logout=1"><?= htmlspecialchars(Language::get('nav_logout', 'Log out')) ?></a>
  127. <?php else: ?>
  128. <a href="user-login.php?mode=login"><?= htmlspecialchars(Language::get('nav_login', 'Log in')) ?></a>
  129. <?php if (($settings['registration_enabled'] ?? '1') === '1'): ?>
  130. <a href="user-login.php?mode=register" class="site-auth-cta"><?= htmlspecialchars(Language::get('nav_register', 'Sign up')) ?></a>
  131. <?php endif; ?>
  132. <?php endif; ?>
  133. </div>
  134. <?php endif; ?>
  135. </nav>
  136. ​
  137. <?php if ($hasAuthLinks): ?>
  138. <div class="site-auth-links site-auth-links-desktop">
  139. <?php if (UserAuth::check()): ?>
  140. <a href="account.php"><?= htmlspecialchars(Language::get('nav_account', 'My account')) ?></a>
  141. <a href="user-login.php?logout=1"><?= htmlspecialchars(Language::get('nav_logout', 'Log out')) ?></a>
  142. <?php else: ?>
  143. <a href="user-login.php?mode=login"><?= htmlspecialchars(Language::get('nav_login', 'Log in')) ?></a>
  144. <?php if (($settings['registration_enabled'] ?? '1') === '1'): ?>
  145. <a href="user-login.php?mode=register" class="site-auth-cta"><?= htmlspecialchars(Language::get('nav_register', 'Sign up')) ?></a>
  146. <?php endif; ?>
  147. <?php endif; ?>
  148. </div>
  149. <?php endif; ?>
  150. </header>
  151. ​
  152. <?php if (($settings['banner_enabled'] ?? '1') === '1' && !empty($showBanner) && !empty($latestForBanner ?? null)): ?>
  153. <div class="latest-banner">
  154. <h2><?= htmlspecialchars(Language::get('home_latest', 'Latest')) ?></h2>
  155. <div class="latest-banner-row">
  156. <?php foreach ($latestForBanner as $latestItem): ?>
  157. <a href="<?= htmlspecialchars(SiteFront::articleUrl($latestItem['slug'])) ?>" class="latest-banner-item">
  158. <?php if (!empty($latestItem['cover_image_path'])): ?>
  159. <img src="<?= htmlspecialchars($latestItem['cover_image_path']) ?>" alt="">
  160. <?php endif; ?>
  161. <?= htmlspecialchars($latestItem['title']) ?>
  162. </a>
  163. <?php endforeach; ?>
  164. </div>
  165. </div>
  166. <?php endif; ?>
  167. ​
  168. <main class="site-main">
  169. <?php foreach (SiteFront::activeAds('header') as $headerAd): ?>
  170. <?= SiteFront::renderAd($headerAd) ?>
  171. <?php endforeach; ?>