fetchOne("SELECT * FROM pages WHERE is_homepage = 1"); } else { // Обычная страница по slug $currentPage = \db()->fetchOne("SELECT * FROM pages WHERE slug = ?", [$slug]); } // Если страница не найдена, возвращаем 404 if (!$currentPage) { http_response_code(404); die('404 - Page not found'); } // Получаем данные из настроек $content = (new Settings('content'))->getAll(); // Получаем SEO данные для страницы $seo = $seoMetaModel->getForRecord('page', $currentPage['id']) ?: []; // Контент страницы $pageContent = $currentPage['content'] ?? ''; // Получаем топ контент если есть $topContent = $currentPage['top_content'] ?? ''; // Подготавливаем содержание для контента $headings = getContainsByText($pageContent); $pageContent = addIdToHInText($pageContent, $headings); // Получаем FAQ для этой страницы $faqItems = $faqModel->getByMorphable('page', $currentPage['id']); // Данные для домена $currentDomain = getCurrentDomain(); $currentUrl = getCurrentUrl(); // Определение типа пользователя $ip = getUserIp(); $isGoogleBot = (strpos(gethostbyaddr($ip), 'google') !== false) ? true : false; $isBingBot = (strpos(gethostbyaddr($ip), 'bing') !== false) ? true : false; $isSearchBot = $isGoogleBot || $isBingBot; // Определяем лейаут страницы $layout = \App\Enums\PageLayout::tryFrom($currentPage['layout'] ?? 'default') ?? \App\Enums\PageLayout::Default; $layoutFile = $layout->viewPath(); return ViewRender($layoutFile, [ 'content' => $content, 'seo' => $seo, 'faqItems' => $faqItems, 'pageContent' => $pageContent, 'pageData' => $currentPage, 'topContent' => $topContent, 'headings' => $headings, 'currentDomain' => $currentDomain, 'currentUrl' => $currentUrl, 'isHomepage' => !empty($currentPage['is_homepage']), 'isSearchBot' => $isSearchBot, 'userIp' => $ip, ]);