From 413606d0d4efd06b011f437a3353765b1911dc8e Mon Sep 17 00:00:00 2001 From: Repellent Date: Sun, 1 Mar 2026 23:48:54 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BB=D1=8F=20=D0=BC=D1=83=D0=BB=D1=8C?= =?UTF-8?q?=D1=82=D0=B8=D1=8F=D0=B7=D1=8B=D1=87=D0=BD=D1=8B=D1=85=20=D1=81?= =?UTF-8?q?=D0=B0=D0=B9=D1=82=D0=BE=D0=B2=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BF=D1=80=D0=B8=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B5=20=D1=81=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8F=D0=BC?= =?UTF-8?q?=D0=B8=20=D0=B8=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=BE=D0=BC=20?= =?UTF-8?q?=D1=85=D0=BB=D0=B5=D0=B1=D0=BD=D1=8B=D1=85=20=D0=BA=D1=80=D0=BE?= =?UTF-8?q?=D1=88=D0=B5=D0=BA.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/class.core.php | 100 ++++++++++++++++++++++++--------- functions/func.breadcrumbs.php | 38 ++++++++++--- 2 files changed, 103 insertions(+), 35 deletions(-) diff --git a/class/class.core.php b/class/class.core.php index 2a5e570..c246c69 100644 --- a/class/class.core.php +++ b/class/class.core.php @@ -518,7 +518,7 @@ return (isset($this->curentdoc->Id) && $this->curentdoc->Id == $page_not_found_id); } - /** +/** * Метод, предназначенный для получения МЕТА-тегов для различных модулей. * ToDo * @return boolean @@ -526,8 +526,8 @@ function _coreModuleMetatagsFetch() { global $AVE_DB; - - // Если в запросе не пришел параметр module, заврешаем работу + + // Если в запросе не пришел параметр module, завершаем работу if (! isset($_REQUEST['module'])) return false; @@ -535,6 +535,7 @@ SELECT 1 AS Id, 0 AS document_published, + document_lang, document_meta_robots, document_meta_keywords, document_meta_description, @@ -545,6 +546,10 @@ Id = 1 ")->FetchRow(); + if (isset($this->curentdoc) && !isset($this->curentdoc->document_lang)) { + $this->curentdoc->document_lang = $_SESSION['user_language'] ?? 'ru'; + } + return (isset($this->curentdoc->Id) && $this->curentdoc->Id == 1); } @@ -759,8 +764,6 @@ $main_content ); - // ИСПРАВЛЕНИЕ DEPRECATED: strftime() заменена на date() - $main_content = str_replace('[tag:docdate]', ave_date_format(DATE_FORMAT, $this->curentdoc->document_published), $main_content); $main_content = str_replace('[tag:doctime]', ave_date_format(TIME_FORMAT, $this->curentdoc->document_published), $main_content); @@ -793,7 +796,7 @@ function _get_cache_hash () { $hash = 'g-' . UGROUP; // Группа пользователей - $hash .= 'r-' . RUB_ID; // ID Рубрики + $hash .= 'r-' . (defined('RUB_ID') ? RUB_ID : 0);// ID Рубрики $hash .= 't-' . (isset($this->curentdoc->rubric_tmpl_id) ? $this->curentdoc->rubric_tmpl_id : '0'); // Шаблон рубрики //$hash .= 'u-' . get_redirect_link(); // ToDo @@ -1187,24 +1190,41 @@ ? $rub_id : $this->curentdoc->rubric_id);*/ - // Определяем рубрику +/* // Определяем рубрику define('RUB_ID', ! empty ($rub_id) ? $rub_id // ИСПРАВЛЕНИЕ: Проверяем, что $this->curentdoc является объектом : (is_object($this->curentdoc) ? $this->curentdoc->rubric_id : 0) - ); + );*/ + + if (isset($_REQUEST['module']) && !empty($_REQUEST['module'])) { + } else { + if (!defined('RUB_ID')) { + + define( + 'RUB_ID', + !empty($rub_id) + ? $rub_id + : (isset($this->curentdoc) && is_object($this->curentdoc) + ? $this->curentdoc->rubric_id + : 0 + ) + ); + } + } $main_content = ''; - // ИСПРАВЛЕНИЕ: Инициализируем $out пустой строкой, чтобы избежать "Undefined variable $out" + // Инициализируем $out пустой строкой, чтобы избежать "Undefined variable $out" // если условие кэша не выполняется (например, при AJAX запросе). $out = ''; if ((defined('CACHE_DOC_FULL') && CACHE_DOC_FULL) && isAjax() == false) { - if ($out = $this->getCompileContent()) + + if ($out = $this->getCompileContent()) { - foreach ($AVE_Module->moduleListGet() as $row) + foreach ($AVE_Module->moduleListGet() as $row) { // Проверяем, существует ли для данного модуля файл module.php в его персональной директории $mod_file = BASE_DIR . '/modules/' . $row['ModuleSysName'] . '/module.php'; @@ -1214,7 +1234,7 @@ } $this->_coreRubricPermissionFetch(RUB_ID); - + // Выполняем Код рубрики До загрузки документа ob_start(); eval(' ?>' . $this->curentdoc->rubric_start_code . '_coreModuleMetatagsFetch(); + // връща в out шаблона $out = $this->_coreDocumentTemplateGet('', '', $this->_coreModuleTemplateGet()); + } // Если происходит вызов системного блока elseif (isset($_REQUEST['sysblock']) && ! empty($_REQUEST['sysblock'])) @@ -1465,7 +1488,7 @@ unset ($this->curentdoc->rubric_template, $this->curentdoc->template); } //-- Конец вывода документа - + //Работа с условиями /* $out = preg_replace('/\[tag:if_exp:?(.*)\]/u', 'curentdoc) && + is_object($this->curentdoc) + ) { + $rubHeader = $this->curentdoc->rubric_header_template ?? ''; + $rubFooter = $this->curentdoc->rubric_footer_template ?? ''; + } + + $out = str_replace( + ['[tag:rubheader]', '[tag:rubfooter]'], + [$rubHeader, $rubFooter], + $out + ); + // Парсим поля запроса $out = preg_replace_callback('/\[tag:rfld:([a-zA-Z0-9-_]+)]\[(more|esc|img|[0-9-]+)]/', function ($m) use ($id) @@ -1632,12 +1675,13 @@ (isset($this->curentdoc->Id) ? $this->curentdoc->Id : ''), (isset($this->curentdoc->document_parent) ? $this->curentdoc->document_parent : '') ); + } // Если пришел контент из модуля if (defined('MODULE_CONTENT')) - { - // парсинг тегов при выводе из модуля + { + // парсинг тегов при выводе из модуля $search[] = '[tag:maincontent]'; $replace[] = MODULE_CONTENT; $search[] = '[tag:title]'; @@ -1697,7 +1741,7 @@ }, $out ); - + // Если пришел вызов на активацию языковых файлов $out = preg_replace_callback( '/\[tag:langfile:([a-zA-Z0-9-_]+)\]/u', @@ -1725,7 +1769,7 @@ // Парсим тег версии системы $search[] = '[tag:version]'; $replace[] = APP_NAME . ' v' . APP_VERSION ; - + // Парсим тег кол-ва просмотра данного документа $search[] = '[tag:docviews]'; $replace[] = isset ($this->curentdoc->document_count_view) ? $this->curentdoc->document_count_view : ''; @@ -1748,15 +1792,17 @@ }, $out ); + - // Парсим теги языковых условий + // Парсим теги языковых условий (Фикс для PHP 8.4) if (defined('RUB_ID')) { - $out = preg_replace('/\[tag:lang:([a-zA-Z0-9-_]+)\]/', 'curentdoc->document_lang == "$1") { ?>', $out); + // Используем ?? чтобы если свойства нет, PHP не ругался, а брал данные из сессии или пустую строку + $out = preg_replace('/\[tag:lang:([a-zA-Z0-9-_]+)\]/', 'curentdoc->document_lang ?? $_SESSION["user_language"] ?? "") == "$1") { ?>', $out); } else { - $out = preg_replace('/\[tag:lang:([a-zA-Z0-9-_]+)\]/', '', $out); + $out = preg_replace('/\[tag:lang:([a-zA-Z0-9-_]+)\]/', '', $out); } $out = str_replace('[tag:/lang]', '', $out); @@ -1766,7 +1812,7 @@ { $out = preg_replace_callback('/\[tag:breadcrumb\]/', 'get_breadcrumb', $out); } - + // Парсим остальные теги основного шаблона $out = str_replace($search, $replace, $out); @@ -1782,7 +1828,8 @@ if ($cacheCompile == false) { - $this->setCompileContent($out); + + $this->setCompileContent($out); } } @@ -2131,14 +2178,11 @@ $GLOBALS['block_generate']['DOCUMENT']['URL_PARSE'] = Debug::endTime('URL_PARSE'); - // ИСПРАВЛЕНИЕ: Используем оператор Nullsafe (?->) if ($redirect_alias?->document_alias) { $redirect_alias = ABS_PATH . $redirect_alias->document_alias . URL_SUFF; $redirect_alias = str_replace('//', '/', $redirect_alias); - // ДОПОЛНИТЕЛЬНОЕ ИСПРАВЛЕНИЕ: Безопасный доступ к document_alias_header - // Это может быть причиной другой ошибки, если $redirect_alias->document_alias_header не существует $header_code = $redirect_alias->document_alias_header ?? 301; header('Location:' . $redirect_alias, true, $header_code); exit; diff --git a/functions/func.breadcrumbs.php b/functions/func.breadcrumbs.php index f020fd0..6f0be6e 100644 --- a/functions/func.breadcrumbs.php +++ b/functions/func.breadcrumbs.php @@ -47,14 +47,38 @@ $noprint = null; - if ($bread_show_main) + if ($bread_show_main) { - $home_id = ($_SESSION['user_language'] == DEFAULT_LANGUAGE) - ? 1 - : $curent_document; + // Главная страница — это всегда ID 1 для любого языка + $home_id = 1; + $lang = $_SESSION['user_language'] ?? null; + if ( + $lang && + isset($_SESSION['accept_langs'][$lang]) && + $lang !== DEFAULT_LANGUAGE + ) { + $alias = $_SESSION['accept_langs'][$lang]; + $sql = " + SELECT * + FROM " . PREFIX . "_documents + WHERE document_alias = '" . $alias . "/' + AND document_lang = '" . $lang . "' + "; + + $data = $AVE_DB->Query($sql)->FetchRow(); + if (is_object($data)) { + $home_id = $data->Id; + } + } $lang_home_alias = getDocument($home_id); + // Если спец-заголовок для крошек пуст, берем основной заголовок документа + // Это гарантирует, что не будет пустым + $home_title = (empty($lang_home_alias->document_breadcrum_title)) + ? stripslashes(htmlspecialchars_decode($lang_home_alias->document_title)) + : stripslashes(htmlspecialchars_decode($lang_home_alias->document_breadcrum_title)); + $number = 1; $search = [ @@ -64,8 +88,8 @@ ]; $replace = [ - $lang_home_alias->document_breadcrum_title, - $bread_show_host ? HOST . '/' . ltrim($lang_home_alias->document_alias, '/') : $lang_home_alias->document_alias, + $home_title, + $bread_show_host ? HOST . '/' . ltrim($lang_home_alias->document_alias, '/') : '/' .$lang_home_alias->document_alias, 1 ]; @@ -78,7 +102,7 @@ if ($bread_sepparator_use) $bread_crumb .= $bread_sepparator; - unset ($search, $replace, $link, $sql, $lang_home_alias); + unset ($search, $replace, $link, $sql, $lang_home_alias, $home_title); } if ($curent_document == 1 || $curent_document == PAGE_NOT_FOUND_ID)