mirror of
				https://github.com/avecms/AVE.cms.git
				synced 2025-10-30 05:16:40 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			105 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			105 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?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 идентификатор системного блока
 | |
| 	 *
 | |
| 	 * @return bool|mixed|null|string|string[]
 | |
| 	 */
 | |
| 	function parse_block($id)
 | |
| 	{
 | |
| 		global $AVE_DB;
 | |
| 
 | |
| 		if (is_array($id))
 | |
| 			$id = $id[1];
 | |
| 
 | |
| 		Debug::startTime('BLOCK_' . $id);
 | |
| 
 | |
| 		if ($id != '')
 | |
| 		{
 | |
| 			$cache = md5('block' . $id);
 | |
| 
 | |
| 			$cache_file = BASE_DIR . '/tmp/cache/sql/block/' . $cache . '.cache';
 | |
| 
 | |
| 			// Если включен DEV MODE, то отключаем кеширование запросов
 | |
| 			if (defined('DEV_MODE') AND DEV_MODE)
 | |
| 				$cache_file = null;
 | |
| 
 | |
| 			if (! file_exists(dirname($cache_file)))
 | |
| 				mkdir(dirname($cache_file), 0766, true);
 | |
| 
 | |
| 			if (file_exists($cache_file))
 | |
| 			{
 | |
| 				$return = file_get_contents($cache_file);
 | |
| 			}
 | |
| 			else
 | |
| 				{
 | |
| 					$return = $AVE_DB->Query("
 | |
| 						SELECT
 | |
| 							block_text
 | |
| 						FROM
 | |
| 							" . PREFIX . "_blocks
 | |
| 						WHERE
 | |
| 							" . (is_numeric($id) ? 'id' : 'block_alias') . " = '" . $id . "'
 | |
| 						LIMIT 1
 | |
| 					")->GetCell();
 | |
| 
 | |
| 					if ($cache_file)
 | |
| 						file_put_contents($cache_file, $return);
 | |
| 				}
 | |
| 
 | |
| 			//-- парсим теги
 | |
| 			$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-_]+)\]\[([0-9]+)]\[([0-9]+)]/', 'get_field_element', $return);
 | |
| 				$return = preg_replace_callback('/\[tag:fld:([a-zA-Z0-9-_]+)(|[:(\d)])+?\]/', 'document_get_field', $return);
 | |
| 				$return = preg_replace_callback('/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/', 'watermarks', $return);
 | |
| 				$return = preg_replace_callback('/\[tag:([r|c|f|t|s]\d+x\d+r*):(.+?)]/', 'callback_make_thumbnail', $return);
 | |
| 			}
 | |
| 
 | |
| 			// Парсим блоки
 | |
| 			$return = preg_replace_callback('/\[tag:block:([A-Za-z0-9-_]{1,20}+)\]/', 'parse_block', $return);
 | |
| 			// Парсим ситемные блоки
 | |
| 			$return = preg_replace_callback('/\[tag:sysblock:([A-Za-z0-9-_]{1,20}+)\]/', 'parse_sysblock', $return);
 | |
| 
 | |
| 			$gen_time = Debug::endTime('BLOCK_' . $id);
 | |
| 
 | |
| 			$GLOBALS['block_generate']['BLOCKS'][$id] = $gen_time;
 | |
| 
 | |
| 			return $return;
 | |
| 		}
 | |
| 
 | |
| 		return false;
 | |
| 	}
 | |
| ?>
 |