Редакция 2 | Только различия | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 2 | Редакция 235 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | /**
|
2 | /**
|
3 | * Smarty plugin
|
3 | * Smarty plugin
|
4 | * @package Smarty
|
4 | * @package Smarty
|
5 | * @subpackage plugins
|
5 | * @subpackage plugins
|
6 | */
|
6 | */
|
7 | 7 | ||
8 | /**
|
8 | /**
|
9 | * Handle insert tags
|
9 | * Handle insert tags
|
10 | *
|
10 | *
|
11 | * @param array $args
|
11 | * @param array $args
|
12 | * @return string
|
12 | * @return string
|
13 | */
|
13 | */
|
14 | function smarty_core_run_insert_handler($params, &$smarty) |
14 | function smarty_core_run_insert_handler($params, &$smarty) |
15 | {
|
15 | {
|
16 | 16 | ||
17 | require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); |
17 | require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); |
18 | if ($smarty->debugging) { |
18 | if ($smarty->debugging) { |
19 | $_params = array(); |
19 | $_params = array(); |
20 | $_debug_start_time = smarty_core_get_microtime($_params, $smarty); |
20 | $_debug_start_time = smarty_core_get_microtime($_params, $smarty); |
21 | }
|
21 | }
|
22 | 22 | ||
23 | if ($smarty->caching) { |
23 | if ($smarty->caching) { |
24 | $_arg_string = serialize($params['args']); |
24 | $_arg_string = serialize($params['args']); |
25 | $_name = $params['args']['name']; |
25 | $_name = $params['args']['name']; |
26 | if (!isset($smarty->_cache_info['insert_tags'][$_name])) { |
26 | if (!isset($smarty->_cache_info['insert_tags'][$_name])) { |
27 | $smarty->_cache_info['insert_tags'][$_name] = array('insert', |
27 | $smarty->_cache_info['insert_tags'][$_name] = array('insert', |
28 | $_name, |
28 | $_name, |
29 | $smarty->_plugins['insert'][$_name][1], |
29 | $smarty->_plugins['insert'][$_name][1], |
30 | $smarty->_plugins['insert'][$_name][2], |
30 | $smarty->_plugins['insert'][$_name][2], |
31 | !empty($params['args']['script']) ? true : false); |
31 | !empty($params['args']['script']) ? true : false); |
32 | }
|
32 | }
|
33 | return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5; |
33 | return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5; |
34 | } else { |
34 | } else { |
35 | if (isset($params['args']['script'])) { |
35 | if (isset($params['args']['script'])) { |
36 | $_params = array('resource_name' => $smarty->_dequote($params['args']['script'])); |
36 | $_params = array('resource_name' => $smarty->_dequote($params['args']['script'])); |
37 | require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); |
37 | require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); |
38 | if(!smarty_core_get_php_resource($_params, $smarty)) { |
38 | if(!smarty_core_get_php_resource($_params, $smarty)) { |
39 | return false; |
39 | return false; |
40 | }
|
40 | }
|
41 | 41 | ||
42 | if ($_params['resource_type'] == 'file') { |
42 | if ($_params['resource_type'] == 'file') { |
43 | $smarty->_include($_params['php_resource'], true); |
43 | $smarty->_include($_params['php_resource'], true); |
44 | } else { |
44 | } else { |
45 | $smarty->_eval($_params['php_resource']); |
45 | $smarty->_eval($_params['php_resource']); |
46 | }
|
46 | }
|
47 | unset($params['args']['script']); |
47 | unset($params['args']['script']); |
48 | }
|
48 | }
|
49 | 49 | ||
50 | $_funcname = $smarty->_plugins['insert'][$params['args']['name']][0]; |
50 | $_funcname = $smarty->_plugins['insert'][$params['args']['name']][0]; |
51 | $_content = $_funcname($params['args'], $smarty); |
51 | $_content = $_funcname($params['args'], $smarty); |
52 | if ($smarty->debugging) { |
52 | if ($smarty->debugging) { |
53 | $_params = array(); |
53 | $_params = array(); |
54 | require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); |
54 | require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); |
55 | $smarty->_smarty_debug_info[] = array('type' => 'insert', |
55 | $smarty->_smarty_debug_info[] = array('type' => 'insert', |
56 | 'filename' => 'insert_'.$params['args']['name'], |
56 | 'filename' => 'insert_'.$params['args']['name'], |
57 | 'depth' => $smarty->_inclusion_depth, |
57 | 'depth' => $smarty->_inclusion_depth, |
58 | 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time); |
58 | 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time); |
59 | }
|
59 | }
|
60 | 60 | ||
61 | if (!empty($params['args']["assign"])) { |
61 | if (!empty($params['args']["assign"])) { |
62 | $smarty->assign($params['args']["assign"], $_content); |
62 | $smarty->assign($params['args']["assign"], $_content); |
63 | } else { |
63 | } else { |
64 | return $_content; |
64 | return $_content; |
65 | }
|
65 | }
|
66 | }
|
66 | }
|
67 | }
|
67 | }
|
68 | 68 | ||
69 | /* vim: set expandtab: */
|
69 | /* vim: set expandtab: */
|
70 | 70 | ||
71 | ?>
|
71 | ?>
|
72 | 72 |