AVE.CMS v3.28
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.5 KiB

8 years ago
<?php
/**
* AVE.cms
*
* @package AVE.cms
* @version 3.x
* @filesource
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
*
* @license GPL v.2
*/
/**
* Обработка тега системного блока
*
* @param int $id идентификатор системного блока
*/
function parse_sysblock($id)
{
global $AVE_DB, $AVE_Core;
if (is_array($id))
$id = $id[1];
Debug::startTime('SYSBLOCK_' . $id);
$eval_sysblock = false;
if ($id != '')
{
$eval_sysblock = true;
$cache_file = BASE_DIR . '/cache/sql/sysblock/' . $id . '.cache';
7 years ago
// Если включен DEV MODE, то отключаем кеширование запросов
if (defined('DEV_MODE') AND DEV_MODE)
$cache_file = null;
7 years ago
if (! file_exists(dirname($cache_file)))
8 years ago
mkdir(dirname($cache_file), 0766, true);
7 years ago
if (file_exists($cache_file))
8 years ago
{
$return = file_get_contents($cache_file);
}
else
{
$return = $AVE_DB->Query("
SELECT
sysblock_text
FROM
" . PREFIX . "_sysblocks
WHERE
" . (is_numeric($id) ? 'id' : 'sysblock_alias') . " = '" . $id . "'
LIMIT 1
")->GetCell();
7 years ago
if ($cache_file)
file_put_contents($cache_file, $return);
8 years ago
}
//-- парсим теги
$search = array(
'[tag:mediapath]',
'[tag:path]',
'[tag:docid]'
);
$replace = array(
ABS_PATH . 'templates/' . ((defined('THEME_FOLDER') === false) ? DEFAULT_THEME_FOLDER : THEME_FOLDER) . '/',
ABS_PATH,
get_current_document_id()
);
$return = str_replace($search, $replace, $return);
$return = preg_replace_callback('/\[tag:home]/', 'get_home_link', $return);
$return = preg_replace_callback('/\[tag:breadcrumb]/', 'get_breadcrumb', $return);
$return = preg_replace_callback('/\[tag:request:([A-Za-z0-9-_]{1,20}+)\]/', 'request_parse', $return);
if (isset($_REQUEST['id']) && $_REQUEST['id'] != '')
{
//-- парсим теги полей документа в шаблоне рубрики
$return = preg_replace_callback('/\[tag:fld:([a-zA-Z0-9-_]+)\]/', 'document_get_field', $return);
7 years ago
$return = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $return);
8 years ago
}
7 years ago
$return = preg_replace_callback('/\[tag:block:([A-Za-z0-9-_]{1,20}+)\]/', 'parse_block', $return);
8 years ago
if ($eval_sysblock)
$return = eval2var('?'.'>' . $return . '<'.'?');
$gen_time = Debug::endTime('SYSBLOCK_' . $id);
7 years ago
$GLOBALS['block_generate']['SYSBLOCK'][$id] = $gen_time;
8 years ago
return $return;
}
}
?>