Разные шаблоны для групы ИС и всех ее подчиненых
Puma писал(а):
Ну я же об этом не знаю.
Ниже рабочий код, проверенный локально:
это я вспешке вставляла щас этот кусок
Ну я же об этом не знаю.
Ниже рабочий код, проверенный локально:
<?php
$kernel = & singleton('kernel');
/* ID Информационной системы */
$InformationSystem_id = to_int($GLOBALS['LA']['InformationSystemID']);
/* Количество записей на страницу */
$items_on_page = to_int($GLOBALS['LA']['ItemsOnPage']);
$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'] = $InformationSystem->GetInformationFromPath($InformationSystem_id, '', $break_if_path_not_found);
/* Если путь существует */
if ($GLOBALS['INFSYS_result'])
{
$template_id = 0;
$template_property_id = 111;
$group_id = $GLOBALS['INFSYS_result']['group'];
while (!$template_id) {
$row = $InformationSystem->GetPropertysGroup($group_id, $InformationSystem_id);
if (sizeof($row))
foreach ($row as $key => $property_row)
if ($property_row['information_propertys_groups_id'] == $template_property_id) {
$template_id = $property_row['information_propertys_groups_value_value'];
break;
}
if ($template_id)
break;
else {
$row2 = $InformationSystem->GetInformationGroup($group_id);
if ($row2)
$group_id = $row2['information_groups_parent_id'];
else
break;
}
}
if ($template_id)
{
$kernel->SetTemplate($template_id);
}
/* получаем массив с деревом от текущей группы до корня */
$InformationSystem->GetInformationGroupsForXml($GLOBALS['INFSYS_result']['group'], $InformationSystem_id);
$group_path='';
$mas_information_groups_for_xml = $InformationSystem->get_mas_information_groups_for_xml();
/* получаем данные о группе */
$group_result = $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 = $InformationSystem->GetInformationSystem($InformationSystem_id);
/* имя информационной системы */
$InformationSystem_name = $row['information_systems_name'];
/* Если вывод информационного элемента */
if ($GLOBALS['INFSYS_result']['item'])
{
/* определяем id информационного элемента */
$item_id = $InformationSystem->GetIdInformationItem($GLOBALS['INFSYS_result']['item'], $GLOBALS['INFSYS_result']['group'], $InformationSystem_id);
$GLOBALS['InformationResult']['item_id'] = $item_id;
/* получаем данные об элементе */
$row_item = $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)
{
$documents = & singleton('documents');
$documents_version_row = $documents->GetCurrentDocumentVersion($structure_row['documents_id']);
$documents_version_id = $documents_version_row['documents_version_id'];
// Текущая страница
$kernel->set_current_page($documents->GetDocumentVersionPath($documents_version_id));
}
elseif ($structure_row['structure_type'] == 1)
{
// Текущая страница - модуль
$kernel->set_current_page($structure->GetStructureFilesPath() . "/Structure{$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($lib->GetLibPath($lib_id) . "/lib_{$lib_id}.php");
}
// Шаблон вывода для страницы
$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;
?>
$kernel = & singleton('kernel');
/* ID Информационной системы */
$InformationSystem_id = to_int($GLOBALS['LA']['InformationSystemID']);
/* Количество записей на страницу */
$items_on_page = to_int($GLOBALS['LA']['ItemsOnPage']);
$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'] = $InformationSystem->GetInformationFromPath($InformationSystem_id, '', $break_if_path_not_found);
/* Если путь существует */
if ($GLOBALS['INFSYS_result'])
{
$template_id = 0;
$template_property_id = 111;
$group_id = $GLOBALS['INFSYS_result']['group'];
while (!$template_id) {
$row = $InformationSystem->GetPropertysGroup($group_id, $InformationSystem_id);
if (sizeof($row))
foreach ($row as $key => $property_row)
if ($property_row['information_propertys_groups_id'] == $template_property_id) {
$template_id = $property_row['information_propertys_groups_value_value'];
break;
}
if ($template_id)
break;
else {
$row2 = $InformationSystem->GetInformationGroup($group_id);
if ($row2)
$group_id = $row2['information_groups_parent_id'];
else
break;
}
}
if ($template_id)
{
$kernel->SetTemplate($template_id);
}
/* получаем массив с деревом от текущей группы до корня */
$InformationSystem->GetInformationGroupsForXml($GLOBALS['INFSYS_result']['group'], $InformationSystem_id);
$group_path='';
$mas_information_groups_for_xml = $InformationSystem->get_mas_information_groups_for_xml();
/* получаем данные о группе */
$group_result = $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 = $InformationSystem->GetInformationSystem($InformationSystem_id);
/* имя информационной системы */
$InformationSystem_name = $row['information_systems_name'];
/* Если вывод информационного элемента */
if ($GLOBALS['INFSYS_result']['item'])
{
/* определяем id информационного элемента */
$item_id = $InformationSystem->GetIdInformationItem($GLOBALS['INFSYS_result']['item'], $GLOBALS['INFSYS_result']['group'], $InformationSystem_id);
$GLOBALS['InformationResult']['item_id'] = $item_id;
/* получаем данные об элементе */
$row_item = $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)
{
$documents = & singleton('documents');
$documents_version_row = $documents->GetCurrentDocumentVersion($structure_row['documents_id']);
$documents_version_id = $documents_version_row['documents_version_id'];
// Текущая страница
$kernel->set_current_page($documents->GetDocumentVersionPath($documents_version_id));
}
elseif ($structure_row['structure_type'] == 1)
{
// Текущая страница - модуль
$kernel->set_current_page($structure->GetStructureFilesPath() . "/Structure{$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($lib->GetLibPath($lib_id) . "/lib_{$lib_id}.php");
}
// Шаблон вывода для страницы
$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;
?>
Вы только что начали читать предложение, чтение которого вы уже заканчиваете.
с этим у меня вот такая шибка теперь : Fatal error: Call to a member function ShowInformationSystem() on a non-object in /home/k/kisoldaru/public_html/hostcmsfiles/lib/lib_1/lib_1.php on line 135
Email: golden-puma@yandex.ru; Telegram: @GoldenPuma; Сайт: https://goldenpuma.ru
Напишите в поддержку запрос с адресом сайта и данными доступа. У меня локально никаких ошибок нет.
Вы только что начали читать предложение, чтение которого вы уже заканчиваете.
Авторизация