0; } $contentDir = $hasUserContent ? realpath($userContentDir) : realpath($demoContentDir); // Extract request information $requestUri = parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH) ?: '/'; $hasTrailingSlash = str_ends_with($requestUri, '/') && $requestUri !== '/'; $requestPath = trim($requestUri, '/'); // Extract language from URL $currentLang = $defaultLang; $pathParts = explode('/', $requestPath); if (!empty($pathParts[0]) && in_array($pathParts[0], $availableLangs) && $pathParts[0] !== $defaultLang) { $currentLang = $pathParts[0]; array_shift($pathParts); $requestPath = implode('/', $pathParts); } // Use custom templates with fallback to defaults $customBaseTemplate = dirname(__DIR__) . '/custom/templates/base.php'; $defaultBaseTemplate = __DIR__ . '/default/templates/base.php'; $baseTemplate = file_exists($customBaseTemplate) ? $customBaseTemplate : $defaultBaseTemplate; $customPageTemplate = dirname(__DIR__) . '/custom/templates/page.php'; $defaultPageTemplate = __DIR__ . '/default/templates/page.php'; $pageTemplate = file_exists($customPageTemplate) ? $customPageTemplate : $defaultPageTemplate; $customListTemplate = dirname(__DIR__) . '/custom/templates/list.php'; $defaultListTemplate = __DIR__ . '/default/templates/list.php'; $listTemplate = file_exists($customListTemplate) ? $customListTemplate : $defaultListTemplate;