Хранилища Subversion ant

Редакция

Редакция 2 | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS

Редакция 2 Редакция 296
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
 * Replace cached inserts with the actual results
9
 * Replace cached inserts with the actual results
10
 *
10
 *
11
 * @param string $results
11
 * @param string $results
12
 * @return string
12
 * @return string
13
 */
13
 */
14
function smarty_core_process_cached_inserts($params, &$smarty)
14
function smarty_core_process_cached_inserts($params, &$smarty)
15
{
15
{
16
    preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis',
16
    preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis',
17
                   $params['results'], $match);
17
                   $params['results'], $match);
18
    list($cached_inserts, $insert_args) = $match;
18
    list($cached_inserts, $insert_args) = $match;
19
19
20
    for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
20
    for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
21
        if ($smarty->debugging) {
21
        if ($smarty->debugging) {
22
            $_params = array();
22
            $_params = array();
23
            require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
23
            require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
24
            $debug_start_time = smarty_core_get_microtime($_params, $smarty);
24
            $debug_start_time = smarty_core_get_microtime($_params, $smarty);
25
        }
25
        }
26
26
27
        $args = unserialize($insert_args[$i]);
27
        $args = unserialize($insert_args[$i]);
28
        $name = $args['name'];
28
        $name = $args['name'];
29
29
30
        if (isset($args['script'])) {
30
        if (isset($args['script'])) {
31
            $_params = array('resource_name' => $smarty->_dequote($args['script']));
31
            $_params = array('resource_name' => $smarty->_dequote($args['script']));
32
            require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
32
            require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
33
            if(!smarty_core_get_php_resource($_params, $smarty)) {
33
            if(!smarty_core_get_php_resource($_params, $smarty)) {
34
                return false;
34
                return false;
35
            }
35
            }
36
            $resource_type = $_params['resource_type'];
36
            $resource_type = $_params['resource_type'];
37
            $php_resource = $_params['php_resource'];
37
            $php_resource = $_params['php_resource'];
38
38
39
39
40
            if ($resource_type == 'file') {
40
            if ($resource_type == 'file') {
41
                $smarty->_include($php_resource, true);
41
                $smarty->_include($php_resource, true);
42
            } else {
42
            } else {
43
                $smarty->_eval($php_resource);
43
                $smarty->_eval($php_resource);
44
            }
44
            }
45
        }
45
        }
46
46
47
        $function_name = $smarty->_plugins['insert'][$name][0];
47
        $function_name = $smarty->_plugins['insert'][$name][0];
48
        if (empty($args['assign'])) {
48
        if (empty($args['assign'])) {
49
            $replace = $function_name($args, $smarty);
49
            $replace = $function_name($args, $smarty);
50
        } else {
50
        } else {
51
            $smarty->assign($args['assign'], $function_name($args, $smarty));
51
            $smarty->assign($args['assign'], $function_name($args, $smarty));
52
            $replace = '';
52
            $replace = '';
53
        }
53
        }
54
54
55
        $params['results'] = substr_replace($params['results'], $replace, strpos($params['results'], $cached_inserts[$i]), strlen($cached_inserts[$i]));
55
        $params['results'] = substr_replace($params['results'], $replace, strpos($params['results'], $cached_inserts[$i]), strlen($cached_inserts[$i]));
56
        if ($smarty->debugging) {
56
        if ($smarty->debugging) {
57
            $_params = array();
57
            $_params = array();
58
            require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
58
            require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
59
            $smarty->_smarty_debug_info[] = array('type'      => 'insert',
59
            $smarty->_smarty_debug_info[] = array('type'      => 'insert',
60
                                                'filename'  => 'insert_'.$name,
60
                                                'filename'  => 'insert_'.$name,
61
                                                'depth'     => $smarty->_inclusion_depth,
61
                                                'depth'     => $smarty->_inclusion_depth,
62
                                                'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time);
62
                                                'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time);
63
        }
63
        }
64
    }
64
    }
65
65
66
    return $params['results'];
66
    return $params['results'];
67
}
67
}
68
68
69
/* vim: set expandtab: */
69
/* vim: set expandtab: */
70
70
71
?>
71
?>
72
 
72