WebOrbiton
v2.0.0.0

Publisium

174 lines · 9.0 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(!empty($pageNoindex)) ?>
  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. <?php if (!empty($rssFeedUrl)): ?>
  41. <link rel="alternate" type="application/rss+xml" title="<?= htmlspecialchars($resolvedPageTitle, ENT_QUOTES) ?>" href="<?= htmlspecialchars($rssFeedUrl, ENT_QUOTES) ?>">
  42. <?php endif; ?>
  43. <?= Asset::favicon() ?>
  44. <?php if (($settings['pwa_enabled'] ?? '0') === '1'): ?>
  45. <?php $pwaIconUrl = !empty($settings['pwa_icon_url']) ? $settings['pwa_icon_url'] : ($settings['site_logo_url'] ?? ''); ?>
  46. <link rel="manifest" href="<?= htmlspecialchars(rtrim(Config::get('APP_BASE_PATH', ''), '/')) ?>/manifest.json">
  47. <meta name="theme-color" content="<?= htmlspecialchars($settings['pwa_theme_color'] ?: '#ffffff') ?>">
  48. <?php if (!empty($pwaIconUrl)): ?>
  49. <link rel="apple-touch-icon" href="<?= htmlspecialchars($pwaIconUrl) ?>">
  50. <?php endif; ?>
  51. <?php endif; ?>
  52. <?= Asset::css('assets/site.css') ?>
  53. <style>
  54. <?= SiteFront::renderFontFaces() ?><?= SiteFront::fontVariablesCss() ?>
  55. </style>
  56. <?php if (!empty($settings['custom_css'])): ?>
  57. <style>
  58. <?= $settings['custom_css'] ?>
  59. </style>
  60. <?php endif; ?>
  61. <?= SiteFront::renderCustomHeadHtml($pageType ?? null) ?>
  62. <?= SiteFront::renderAnalyticsScripts('head') ?>
  63. </head>
  64. ​
  65. <body class="<?= htmlspecialchars($menuPositionClass) ?>" data-theme="light">
  66. <?= SiteFront::renderAnalyticsScripts('body_start') ?>
  67. <script>
  68. (function() {
  69. try {
  70. var t = localStorage.getItem('publisium_theme');
  71. if (t === 'dark' || t === 'light') {
  72. document.body.setAttribute('data-theme', t);
  73. } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
  74. document.body.setAttribute('data-theme', 'dark');
  75. }
  76. } catch (e) {}
  77. })();
  78. </script>
  79. <?= Icons::sprite() ?>
  80. <div class="site-shell">
  81. ​
  82. <?php
  83. $hasAuthLinks = UserAuth::check() || ($settings['login_enabled'] ?? '1') !== '0';
  84. $centerSearchHtml = $hasAuthLinks ? '' : SiteFront::renderSearchControl('nav');
  85. ?>
  86. <header class="site-header<?= $hasAuthLinks ? '' : ' site-header-no-auth' ?><?= $centerSearchHtml !== '' ? ' site-header-center-search' : '' ?>">
  87. <div class="site-header-row">
  88. <?php
  89. $brandHasLogo = !empty($settings['site_logo_url']);
  90. $brandShowName = !$brandHasLogo || ($settings['site_show_name_with_logo'] ?? '0') === '1';
  91. $brandShortName = trim((string) ($settings['site_short_name'] ?? ''));
  92. $brandUseShort = $brandShowName && ($settings['site_short_name_enabled'] ?? '0') === '1' && $brandShortName !== '';
  93. ?>
  94. <a href="<?= htmlspecialchars(SiteFront::homeUrl(), ENT_QUOTES) ?>" class="site-brand"<?= $brandUseShort ? ' data-short-name="1"' : '' ?>>
  95. <?php if ($brandHasLogo): ?>
  96. <img src="<?= htmlspecialchars($settings['site_logo_url']) ?>" alt="<?= htmlspecialchars($settings['site_name']) ?>" class="site-brand-logo">
  97. <?php endif; ?>
  98. <?php if ($brandShowName): ?>
  99. <span class="site-brand-full"><?= htmlspecialchars($settings['site_name']) ?></span>
  100. <?php if ($brandUseShort): ?>
  101. <span class="site-brand-short"><?= htmlspecialchars($brandShortName) ?></span>
  102. <?php endif; ?>
  103. <?php endif; ?>
  104. </a>
  105. ​
  106. <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">
  107. <?= Icons::icon('menu', 'icon icon-sm site-menu-toggle-icon-open') ?>
  108. <?= Icons::icon('x', 'icon icon-sm site-menu-toggle-icon-close') ?>
  109. </button>
  110. ​
  111. </div>
  112. ​
  113. <?php if ($centerSearchHtml !== ''): ?>
  114. <div class="site-search-center"><?= $centerSearchHtml ?></div>
  115. <?php endif; ?>
  116. ​
  117. <div class="site-nav-backdrop" id="site-nav-backdrop"></div>
  118. ​
  119. <nav class="site-nav" id="site-nav">
  120. <?php foreach ($navItems as $navItem): ?>
  121. <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>
  122. <?php endforeach; ?>
  123. <?= SiteFront::renderSearchControl('nav') ?>
  124. ​
  125. <?php if ($hasAuthLinks): ?>
  126. <div class="site-auth-links site-auth-links-mobile">
  127. <?php if (UserAuth::check()): ?>
  128. <a href="account.php"><?= htmlspecialchars(Language::get('nav_account', 'My account')) ?></a>
  129. <a href="user-login.php?logout=1"><?= htmlspecialchars(Language::get('nav_logout', 'Log out')) ?></a>
  130. <?php else: ?>
  131. <a href="user-login.php?mode=login"><?= htmlspecialchars(Language::get('nav_login', 'Log in')) ?></a>
  132. <?php if (($settings['registration_enabled'] ?? '1') === '1'): ?>
  133. <a href="user-login.php?mode=register" class="site-auth-cta"><?= htmlspecialchars(Language::get('nav_register', 'Sign up')) ?></a>
  134. <?php endif; ?>
  135. <?php endif; ?>
  136. </div>
  137. <?php endif; ?>
  138. </nav>
  139. ​
  140. <?php if ($hasAuthLinks): ?>
  141. <div class="site-auth-links site-auth-links-desktop">
  142. <?php if (UserAuth::check()): ?>
  143. <a href="account.php"><?= htmlspecialchars(Language::get('nav_account', 'My account')) ?></a>
  144. <a href="user-login.php?logout=1"><?= htmlspecialchars(Language::get('nav_logout', 'Log out')) ?></a>
  145. <?php else: ?>
  146. <a href="user-login.php?mode=login"><?= htmlspecialchars(Language::get('nav_login', 'Log in')) ?></a>
  147. <?php if (($settings['registration_enabled'] ?? '1') === '1'): ?>
  148. <a href="user-login.php?mode=register" class="site-auth-cta"><?= htmlspecialchars(Language::get('nav_register', 'Sign up')) ?></a>
  149. <?php endif; ?>
  150. <?php endif; ?>
  151. </div>
  152. <?php endif; ?>
  153. </header>
  154. ​
  155. <?php if (($settings['banner_enabled'] ?? '1') === '1' && !empty($showBanner) && !empty($latestForBanner ?? null)): ?>
  156. <div class="latest-banner">
  157. <h2><?= htmlspecialchars(Language::get('home_latest', 'Latest')) ?></h2>
  158. <div class="latest-banner-row">
  159. <?php foreach ($latestForBanner as $latestItem): ?>
  160. <a href="<?= htmlspecialchars(SiteFront::articleUrl($latestItem['slug'])) ?>" class="latest-banner-item">
  161. <?php if (!empty($latestItem['cover_image_path'])): ?>
  162. <img src="<?= htmlspecialchars($latestItem['cover_image_path']) ?>" alt="">
  163. <?php endif; ?>
  164. <?= htmlspecialchars($latestItem['title']) ?>
  165. </a>
  166. <?php endforeach; ?>
  167. </div>
  168. </div>
  169. <?php endif; ?>
  170. ​
  171. <main class="site-main">
  172. <?php foreach (SiteFront::activeAds('header') as $headerAd): ?>
  173. <?= SiteFront::renderAd($headerAd) ?>
  174. <?php endforeach; ?>