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