core.process_cached_inserts.php
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:2k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. <?php
  2. /**
  3.  * Smarty plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  */
  7. /**
  8.  * Replace cached inserts with the actual results
  9.  *
  10.  * @param string $results
  11.  * @return string
  12.  */
  13. function smarty_core_process_cached_inserts($params, &$smarty)
  14. {
  15.     preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis',
  16.                    $params['results'], $match);
  17.     list($cached_inserts, $insert_args) = $match;
  18.     for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
  19.         if ($smarty->debugging) {
  20.             $_params = array();
  21.             require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
  22.             $debug_start_time = smarty_core_get_microtime($_params, $smarty);
  23.         }
  24.         $args = unserialize($insert_args[$i]);
  25.         $name = $args['name'];
  26.         if (isset($args['script'])) {
  27.             $_params = array('resource_name' => $smarty->_dequote($args['script']));
  28.             require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
  29.             if(!smarty_core_get_php_resource($_params, $smarty)) {
  30.                 return false;
  31.             }
  32.             $resource_type = $_params['resource_type'];
  33.             $php_resource = $_params['php_resource'];
  34.             if ($resource_type == 'file') {
  35.                 $smarty->_include($php_resource, true);
  36.             } else {
  37.                 $smarty->_eval($php_resource);
  38.             }
  39.         }
  40.         $function_name = $smarty->_plugins['insert'][$name][0];
  41.         if (empty($args['assign'])) {
  42.             $replace = $function_name($args, $smarty);
  43.         } else {
  44.             $smarty->assign($args['assign'], $function_name($args, $smarty));
  45.             $replace = '';
  46.         }
  47.         $params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']);
  48.         if ($smarty->debugging) {
  49.             $_params = array();
  50.             require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
  51.             $smarty->_smarty_debug_info[] = array('type'      => 'insert',
  52.                                                 'filename'  => 'insert_'.$name,
  53.                                                 'depth'     => $smarty->_inclusion_depth,
  54.                                                 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time);
  55.         }
  56.     }
  57.     return $params['results'];
  58. }
  59. /* vim: set expandtab: */
  60. ?>