00001 <?php
00014 function smarty_core_process_cached_inserts($params, &$smarty)
00015 {
00016 preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis',
00017 $params['results'], $match);
00018 list($cached_inserts, $insert_args) = $match;
00019
00020 for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
00021 if ($smarty->debugging) {
00022 $_params = array();
00023 require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
00024 $debug_start_time = smarty_core_get_microtime($_params, $smarty);
00025 }
00026
00027 $args = unserialize($insert_args[$i]);
00028 $name = $args['name'];
00029
00030 if (isset($args['script'])) {
00031 $_params = array('resource_name' => $smarty->_dequote($args['script']));
00032 require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
00033 if(!smarty_core_get_php_resource($_params, $smarty)) {
00034 return false;
00035 }
00036 $resource_type = $_params['resource_type'];
00037 $php_resource = $_params['php_resource'];
00038
00039
00040 if ($resource_type == 'file') {
00041 $smarty->_include($php_resource, true);
00042 } else {
00043 $smarty->_eval($php_resource);
00044 }
00045 }
00046
00047 $function_name = $smarty->_plugins['insert'][$name][0];
00048 if (empty($args['assign'])) {
00049 $replace = $function_name($args, $smarty);
00050 } else {
00051 $smarty->assign($args['assign'], $function_name($args, $smarty));
00052 $replace = '';
00053 }
00054
00055 $params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']);
00056 if ($smarty->debugging) {
00057 $_params = array();
00058 require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
00059 $smarty->_smarty_debug_info[] = array('type' => 'insert',
00060 'filename' => 'insert_'.$name,
00061 'depth' => $smarty->_inclusion_depth,
00062 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time);
00063 }
00064 }
00065
00066 return $params['results'];
00067 }
00068
00069
00070
00071 ?>