Хранилища Subversion ant

Редакция

Содержимое файла | Последнее изменение | Открыть журнал | RSS

Редакция Автор № строки Строка
304 alex-w 1
<?php
2
 
3
/**
4
* Smarty Internal Plugin Resource Registered
5
*
6
* Implements the registered resource for Smarty template
7
*
8
* @package Smarty
9
* @subpackage TemplateResources
10
* @author Uwe Tews
11
*/
12
/**
13
* Smarty Internal Plugin Resource Registered
14
*/
15
 
16
class Smarty_Internal_Resource_Registered {
17
    public function __construct($smarty)
18
    {
19
        $this->smarty = $smarty;
20
    }
21
    // classes used for compiling Smarty templates from file resource
22
    public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler';
23
    public $template_lexer_class = 'Smarty_Internal_Templatelexer';
24
    public $template_parser_class = 'Smarty_Internal_Templateparser';
25
 
26
    /**
27
    * Return flag if template source is existing
28
    *
29
    * @return boolean true
30
    */
31
    public function isExisting($_template)
32
    {
33
        if (is_integer($this->getTemplateTimestamp($_template))) {
34
            return true;
35
        } else {
36
            return false;
37
        }
38
    }
39
    /**
40
    * Get filepath to template source
41
    *
42
    * @param object $_template template object
43
    * @return string return 'string' as template source is not a file
44
    */
45
    public function getTemplateFilepath($_template)
46
    {
47
        // no filepath for strings
48
        // return "string" for compiler error messages
49
           $_filepath = $_template->resource_type .':'.$_template->resource_name;
50
 
51
        return $_filepath;
52
 }
53
 
54
    /**
55
    * Get timestamp to template source
56
    *
57
    * @param object $_template template object
58
    * @return boolean false as string resources have no timestamp
59
    */
60
    public function getTemplateTimestamp($_template)
61
    {
62
        // return timestamp
63
        $time_stamp = false;
64
        call_user_func_array($this->smarty->_plugins['resource'][$_template->resource_type][0][1],
65
            array($_template->resource_name, &$time_stamp, $this->smarty));
66
        return $time_stamp;
67
    }
68
    /**
69
    * Get timestamp to template source by type and name
70
    *
71
    * @param object $_template template object
72
    * @return boolean false as string resources have no timestamp
73
    */
74
    public function getTemplateTimestampTypeName($_resource_type, $_resource_name)
75
    {
76
        // return timestamp
77
        $time_stamp = false;
78
        call_user_func_array($this->smarty->_plugins['resource'][$_resource_type][0][1],
79
            array($_resource_name, &$time_stamp, $this->smarty));
80
        return $time_stamp;
81
    }
82
 
83
    /**
84
    * Retuen template source from resource name
85
    *
86
    * @param object $_template template object
87
    * @return string content of template source
88
    */
89
    public function getTemplateSource($_template)
90
    {
91
        // return template string
92
        return call_user_func_array($this->smarty->_plugins['resource'][$_template->resource_type][0][0],
93
            array($_template->resource_name, &$_template->template_source, $this->smarty));
94
    }
95
 
96
    /**
97
    * Return flag that this resource uses the compiler
98
    *
99
    * @return boolean true
100
    */
101
    public function usesCompiler()
102
    {
103
        // resource string is template, needs compiler
104
        return true;
105
    }
106
 
107
    /**
108
    * Return flag that this resource is evaluated
109
    *
110
    * @return boolean true
111
    */
112
    public function isEvaluated()
113
    {
114
        // compiled template is evaluated instead of saved to disk
115
        return false;
116
    }
117
 
118
    /**
119
    * Get filepath to compiled template
120
    *
121
    * @param object $_template template object
122
    * @return boolean return false as compiled template is not stored
123
    */
124
    public function getCompiledFilepath($_template)
125
    {
126
        // $_filepath = md5($_template->resource_name);
127
        $_filepath = (string)abs(crc32($_template->template_resource));
128
        // if use_sub_dirs, break file into directories
129
        if ($_template->smarty->use_sub_dirs) {
130
            $_filepath = substr($_filepath, 0, 3) . DS
131
             . substr($_filepath, 0, 2) . DS
132
             . substr($_filepath, 0, 1) . DS
133
             . $_filepath;
134
        }
135
        $_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^';
136
        if (isset($_template->compile_id)) {
137
            $_filepath = $_template->compile_id . $_compile_dir_sep . $_filepath;
138
        }
139
        if ($_template->caching) {
140
            $_cache = '.cache';
141
        } else {
142
            $_cache = '';
143
        }
144
        $_compile_dir = $_template->smarty->compile_dir;
145
        if (strpos('/\\', substr($_compile_dir, -1)) === false) {
146
            $_compile_dir .= DS;
147
        }
148
        return $_compile_dir . $_filepath . '.' . $_template->resource_type . '.' . basename($_template->resource_name) . $_cache . $_template->smarty->php_ext;
149
    }
150
}
151
 
152
?>