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']) ?: []; // Декодируем extra_fields $extraFields = []; if (!empty($currentPage['extra_fields'])) { $extraFields = json_decode($currentPage['extra_fields'], true) ?: []; } // Контент страницы $pageContent = $currentPage['content'] ?? ''; // Получаем топ контент из extra_fields $topContent = $extraFields['top_content'] ?? ''; // Получаем 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, 'currentDomain' => $currentDomain, 'currentUrl' => $currentUrl, 'isHomepage' => !empty($currentPage['is_homepage']), 'isSearchBot' => $isSearchBot, 'author' => $authorModel->getAll()[0], 'slots' => $slotModel->getAll(), 'userIp' => $ip, ]);