<?php
$kernel = & singleton('kernel');
/* ID Информационной системы */
$InformationSystem_id = to_int($GLOBALS['LA']['InformationSystemID']);
/* Количество записей на страницу */
$items_on_page = to_int($GLOBALS['LA']['ItemsOnPage']);
$GLOBALS['LA_InformationSystem'] = & singleton('InformationSystem');
if ($items_on_page !== true)
{
$items_on_page = to_int($items_on_page);
}
$property = to_array($property);
/* Текстовая информация для указания номера страницы, например "страница" */
if (isset($GLOBALS['LA']['page']))
{
$property['page'] = to_str($GLOBALS['LA']['page']);
}
else
{
$property['page'] = 'страница';
}
/* Разделитель в заголовке страницы */
if (isset($GLOBALS['LA']['separator']))
{
$property['separator'] = to_str($GLOBALS['LA']['separator']);
}
else
{
$property['separator'] = ' / ';
}
///////////////////////////////////////////
// Если указание на страницу - не прерываем определение
if (ereg ("^part-([0-9]*)$", end($GLOBALS['URL_ARRAY']), $regs) && to_int($regs[1]) > 0)
{
/* Страница умножается на кол-во элементов, выводимых на страницу */
$break_if_path_not_found = false;
$GLOBALS['part_ii'] = $regs[1];
}
else
{
$break_if_path_not_found = true;
$GLOBALS['part_ii'] = 1;
}
/* получаем для пути ассоциативный массив с id группы и id/url элемента для данной инфосистемы */
$GLOBALS['INFSYS_result'] = $GLOBALS['LA_InformationSystem']->GetInformationFromPath($InformationSystem_id, '', $break_if_path_not_found);
/* Если путь существует */
if ($GLOBALS['INFSYS_result'])
{
/* получаем массив с деревом от текущей группы до корня */
$GLOBALS['LA_InformationSystem']->GetInformationGroupsForXml($GLOBALS['INFSYS_result']['group'], $InformationSystem_id);
$group_path='';
$mas_information_groups_for_xml = $GLOBALS['LA_InformationSystem']->get_mas_information_groups_for_xml();
/* получаем данные о группе */
$group_result = $GLOBALS['LA_InformationSystem']->SelectInformationGroups($GLOBALS['INFSYS_result']['group'], $InformationSystem_id);
$row_group = mysql_fetch_assoc($group_result);
/* получаем данные из seo - полей для групп */
$seo_title = trim($row_group['information_groups_seo_title']);
$seo_description = trim($row_group['information_groups_seo_description']);
$seo_keywords = trim($row_group['information_groups_seo_keywords']);
/* цикл по массиву с деревом для формирования пути по группам */
for($i = count($mas_information_groups_for_xml)-1; $i >= 0; $i--)
{
/* seo_title для группы пустое, то в заголовок подставляем название */
if (trim($mas_information_groups_for_xml[$i]['information_groups_seo_title'])=='')
{
$group_path .= $property['separator'].$mas_information_groups_for_xml[$i]['information_groups_name'];
}
else
{
$group_path .= $property['separator'].$mas_information_groups_for_xml[$i]['information_groups_seo_title'];
}
}
/* определяем название информационной системы */
$row = $GLOBALS['LA_InformationSystem']->GetInformationSystem($InformationSystem_id);
/* имя информационной системы */
$InformationSystem_name = $row['information_systems_name'];
/* Если вывод информационного элемента */
if ($GLOBALS['INFSYS_result']['item'])
{
/* определяем id информационного элемента */
$item_id = $GLOBALS['LA_InformationSystem']->GetIdInformationItem($GLOBALS['INFSYS_result']['item'], $GLOBALS['INFSYS_result']['group'], $InformationSystem_id);
$GLOBALS['InformationResult']['item_id'] = $item_id;
/* получаем данные об элементе */
$row_item = $GLOBALS['LA_InformationSystem']->GetInformationSystemItem($item_id);
/* проверяем если seo_title непустой, то в заголовок страницы подставляем его */
if (trim($row_item['information_items_seo_title']) != '')
{
$item_name = $property['separator'].trim($row_item['information_items_seo_title']);
}
else
{
/* имя элемента */
$item_name = $property['separator'].$row_item['information_items_name'];
}
}
else
{
/* Вывод информационной группы */
/* Определяем номер страницы для показа */
$end_array_item = end($GLOBALS['URL_ARRAY']);
$page = to_str($end_array_item);
if (ereg ("^page-([0-9]*)$", $page, $regs) && to_int($regs[1]) > 0)
{
/* Страница умножается на кол-во элементов, выводимых на страницу */
$items_begin = ($regs[1] - 1) * $items_on_page;
/* Если показываем группу, а не элемент, то указываем страницу (страница N), если она не первая */
$page_number = "{$property['separator']}{$property['page']} {$regs[1]}";
}
else
{
$items_begin = 0;
}
/* Массив, возвращаемый методом */
$GLOBALS['InformationResult']['items_begin'] = $items_begin;
}
if (isset($GLOBALS['INFSYS_result']['tag_name']))
{
$oTag = new Tag();
$tag_row = $oTag->GetTagByPath($GLOBALS['INFSYS_result']['tag_name']);
if ($tag_row)
{
$tag_name = "Метка: {$tag_row['tag_name']} {$property['separator']}";
}
}
/* формируем заголовок страницы */
$new_title = to_str($tag_name) . $InformationSystem_name . $group_path . to_str($item_name) . to_str($page_number);
}
else
{
// Элемент/группа не найдены, возвращаем 404 ошибку.
ShowHeader404();
// Запрещаем отдавать 200-й заголовок
if (!defined('IS_ERROR_404'))
{
define('IS_ERROR_404', true);
}
$site = & singleton('site');
$site_row = $site->GetSite(CURRENT_SITE);
if ($site_row['site_error404'])
{
$structure = & singleton('Structure');
$structure_id = intval($site_row['site_error404']);
$structure_row = $structure->GetStructureItem($structure_id);
// Если тип - страница
if ($structure_row['structure_type'] == 0)
{
$document = & singleton('documents');
$documents_version_row = $document->GetCurrentDocumentVersion($structure_row['documents_id']);
$documents_version_id = $documents_version_row['documents_version_id'];
// Текущая страница
$kernel->set_current_page(PAGE_DIR . 'documents' . $documents_version_id . '.html');
}
elseif ($structure_row['structure_type'] == 1)
{
// Текущая страница - модуль
$kernel->set_current_page(CMS_FOLDER . 'structure/Modules/Module' . $structure_id . '.php');
}
else
{
/* типовая динамическая страница */
$lib_id = intval($structure_row['lib_id']);
/* Получаем параметры типовой динамической страницы */
$lib = new lib();
$GLOBALS['LA'] = $lib->LoadLibPropertiesValue($lib_id, $structure_id);
$kernel->set_current_page(CMS_FOLDER . "lib/lib_$lib_id/lib_$lib_id.php");
}
if(to_int($GLOBALS['INFSYS_result']['group']) == 28)
{
// Шаблон вывода для страницы
$kernel->set_current_page_data_template(13);
}
else
{
// Шаблон вывода для страницы
$kernel->set_current_page_data_template($structure_row['data_templates_id']);
}
}
elseif (to_str($_SERVER['REQUEST_URI']) != '/')
{
header('Location: /');
// Прекращаем выполнение
exit();
}
}
if (!empty($new_title))
{
/* отображаем группу, если не существует данных об элементе и родительская группа не является корнем */
if (!isset($row_item) && $GLOBALS['INFSYS_result']['group'] != 0 || !empty($tag_name) || !empty($page_number))
{
/* Заголовок для группы задан */
if (!empty($seo_title))
{
$kernel->set_title($seo_title);
}
else
{
$kernel->set_title($new_title);
}
/* Описание для группы задано */
if (!empty($seo_description))
{
$kernel->set_description($seo_description);
}
else
{
$kernel->set_description($new_title);
}
/* Ключевые слова для группы заданы */
if (!empty($seo_keywords))
{
$kernel->set_keywords($seo_keywords);
}
else
{
$kernel->set_keywords($new_title);
}
}
elseif (isset($row_item)) /* отображаем элемент */
{
if (!empty($row_item['information_items_seo_title']))
{
$kernel->set_title(trim($row_item['information_items_seo_title']));
}
else
{
$kernel->set_title($new_title);
}
/* Описание для элемента задано */
if (!empty($row_item['information_items_seo_description']))
{
$kernel->set_description(trim($row_item['information_items_seo_description']));
}
else
{
$kernel->set_description($new_title);
}
/* Ключевые слова для элемента заданы */
if (!empty($row_item['information_items_seo_keywords']))
{
$kernel->set_keywords(trim($row_item['information_items_seo_keywords']));
}
else
{
$kernel->set_keywords($new_title);
}
}
}
$GLOBALS['InformationResult']['items_on_page'] = $items_on_page;
?>