native name * $NAV_ITEMS - (optional) Array of lang => [nav items] * $PAGE_MAPPING - (optional) Array of page => [lang => path] */ require_once __DIR__ . '/access-guard.php'; require_once __DIR__ . '/page-path.php'; if (isset($_GET['rj_agent_preview']) && is_file(__DIR__ . '/ai/agent/preview.php')) { require_once __DIR__ . '/ai/agent/preview.php'; // owner-only preview of an AI change set raijuAgentPreviewBoot(); } raijuAccessEnforceMaintenance(); if (!empty($contentPage)) { raijuAccessEnforceCurrentTemplatePage((string)$contentPage); } // Auto-load site config if not already loaded $_configPath = __DIR__ . '/../admin/config.php'; if (!defined('SITE_LANG_DEFAULT') && file_exists($_configPath)) { require_once $_configPath; } $basePath = $basePath ?? ''; $currentLang = $currentLang ?? (defined('SITE_LANG_DEFAULT') ? SITE_LANG_DEFAULT : 'en'); $isHomepage = ($currentPage ?? '') === 'home'; $defaultLang = defined('SITE_LANG_DEFAULT') ? SITE_LANG_DEFAULT : 'en'; // ============================================================ // PAGE MAPPING & NAVIGATION // ============================================================ // Load shared nav config (also sets $SITE_LANGUAGES fallback). // Customize includes/nav-config.php for your site's pages. if (!isset($PAGE_MAPPING) || !isset($NAV_ITEMS)) { $_navConfigPath = __DIR__ . '/nav-config.php'; if (!file_exists($_navConfigPath)) { $_navConfigPath = __DIR__ . '/nav-config.default.php'; } if (file_exists($_navConfigPath)) { include_once $_navConfigPath; } } // Final fallback if $SITE_LANGUAGES still not set if (!isset($SITE_LANGUAGES)) { $SITE_LANGUAGES = [$defaultLang => $defaultLang]; } // Fallback if still not set if (!isset($PAGE_MAPPING)) { $PAGE_MAPPING = ['home' => []]; foreach ($SITE_LANGUAGES as $code => $name) { $PAGE_MAPPING['home'][$code] = ($code === $defaultLang) ? '.' : $code . '/'; } } // Determine links for language switching $currentPageKey = $currentPage ?? 'home'; $langLinks = []; $_contentPath = __DIR__ . '/../content/pages/'; foreach ($SITE_LANGUAGES as $code => $name) { if (isset($PAGE_MAPPING[$currentPageKey][$code])) { $langLinks[$code] = $basePath . $PAGE_MAPPING[$currentPageKey][$code]; } elseif ($currentPageKey !== 'home' && is_file($_contentPath . raijuPageContentKey($code, $currentPageKey) . '.json')) { // Dynamic fallback: same slug exists in target language $langLinks[$code] = $basePath . ltrim(raijuPageUrlPath($code, $currentPageKey, $defaultLang), '/'); } else { // Final fallback: home page of that language $langLinks[$code] = $basePath . (($code === $defaultLang) ? '.' : $code . '/'); } } // Fallback for $NAV_ITEMS if (!isset($NAV_ITEMS)) { $NAV_ITEMS = []; foreach ($SITE_LANGUAGES as $code => $name) { $NAV_ITEMS[$code] = [ ['href' => ($code === $defaultLang) ? '.' : $code . '/', 'label' => 'Home', 'page' => 'home'], ]; } } require_once __DIR__ . '/menu-helpers.php'; require_once __DIR__ . '/asset-helpers.php'; require_once __DIR__ . '/version.php'; require_once __DIR__ . '/seo-helper.php'; require_once __DIR__ . '/analytics-helper.php'; $_raijuDevLogin = session_status() === PHP_SESSION_ACTIVE && !empty($_SESSION['raiju_dev_login']); $_allNavItems = $NAV_ITEMS[$currentLang] ?? $NAV_ITEMS[$defaultLang] ?? []; $navItems = getMenuItems('header', $currentLang, $basePath ?? '', $_allNavItems); $_headerMenuType = getMenuType('header'); $_homeHref = ($currentLang === $defaultLang) ? '.' : $currentLang . '/'; $_buildNavHref = function (array $item) use ($basePath, $isHomepage, $_headerMenuType, $_homeHref) { $href = (string)($item['href'] ?? '#'); if ($_headerMenuType === 'one-page' && str_starts_with($href, '#') && $href !== '#') { return ($isHomepage ? '' : $basePath . $_homeHref) . $href; } return $basePath . $href; }; $_navLinkAttrs = function (array $item, bool $isActive) use ($_headerMenuType) { $href = (string)($item['href'] ?? ''); $classes = []; if ($isActive) $classes[] = 'active'; $attrs = ''; if ($_headerMenuType === 'one-page' && str_starts_with($href, '#') && $href !== '#') { $attrs .= ' data-nav-hash="' . htmlspecialchars(substr($href, 1), ENT_QUOTES, 'UTF-8') . '"'; } if ($classes) { $attrs .= ' class="' . htmlspecialchars(implode(' ', $classes), ENT_QUOTES, 'UTF-8') . '"'; } return $attrs; }; // Load site settings (used for favicon, theme colors, editor button style) $_settingsPath = __DIR__ . '/../content/settings.json'; $_settings = []; $_favicon = ltrim(defined('RAIJU_DEFAULT_FAVICON') ? RAIJU_DEFAULT_FAVICON : '/assets/images/favicon.svg', '/'); $_faviconPng = ''; if (file_exists($_settingsPath)) { $_settings = json_decode(file_get_contents($_settingsPath), true) ?: []; if (!empty($_settings['favicon'])) $_favicon = ltrim($_settings['favicon'], '/'); if (!empty($_settings['favicon_png'])) $_faviconPng = ltrim($_settings['favicon_png'], '/'); } $_rememberPublicTheme = !isset($_settings['privacy']['rememberPublicTheme']) || !empty($_settings['privacy']['rememberPublicTheme']); $_publicThemeDefault = $_settings['theme']['publicDefault'] ?? 'system'; if (!in_array($_publicThemeDefault, ['light', 'dark', 'system'], true)) { $_publicThemeDefault = 'system'; } $_editorFlat = isset($_settings['theme']['buttonGlow']) && !$_settings['theme']['buttonGlow']; $_seoContext = raijuSeoContext([ 'contentPage' => $contentPage ?? null, 'currentLang' => $currentLang, 'currentPage' => $currentPage ?? '', 'pageTitle' => $pageTitle ?? '', 'pageDescription' => $pageDescription ?? '', 'data' => isset($data) && is_array($data) ? $data : null, ]); $_seoHealth = raijuSeoHealth($_seoContext); // Site-wide search engine block: also as a header, so files and proxies agree with the meta tag. if (raijuSeoSiteBlocked() && !headers_sent()) header('X-Robots-Tag: ' . $_seoContext['robots']); $_seoJsonLd = raijuSeoJsonLd($_seoContext, $langLinks); raijuAnalyticsTrack($contentPage ?? null, $currentLang, $currentPage ?? null); require_once __DIR__ . '/email-obfuscator.php'; raijuStartEmailObfuscation(); ?> >
$_altName): ?>