1: | <?php
|
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: |
|
10: |
|
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: |
|
19: | class Smarty_Internal_Resource_Registered extends Smarty_Resource
|
20: | {
|
21: | |
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: |
|
29: | public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
|
30: | {
|
31: | $source->filepath = $source->type . ':' . $source->name;
|
32: | $source->uid = sha1($source->filepath . $source->smarty->_joined_template_dir);
|
33: | $source->timestamp = $this->getTemplateTimestamp($source);
|
34: | $source->exists = !!$source->timestamp;
|
35: | }
|
36: |
|
37: | |
38: | |
39: | |
40: | |
41: | |
42: | |
43: |
|
44: | public function populateTimestamp(Smarty_Template_Source $source)
|
45: | {
|
46: | $source->timestamp = $this->getTemplateTimestamp($source);
|
47: | $source->exists = !!$source->timestamp;
|
48: | }
|
49: |
|
50: | |
51: | |
52: | |
53: | |
54: | |
55: | |
56: |
|
57: | public function getTemplateTimestamp(Smarty_Template_Source $source)
|
58: | {
|
59: |
|
60: | $time_stamp = false;
|
61: | call_user_func_array(
|
62: | $source->smarty->registered_resources[ $source->type ][ 0 ][ 1 ],
|
63: | array($source->name, &$time_stamp, $source->smarty)
|
64: | );
|
65: | return is_numeric($time_stamp) ? (int)$time_stamp : $time_stamp;
|
66: | }
|
67: |
|
68: | |
69: | |
70: | |
71: | |
72: | |
73: | |
74: | |
75: |
|
76: | public function getContent(Smarty_Template_Source $source)
|
77: | {
|
78: |
|
79: | $content = null;
|
80: | $t = call_user_func_array(
|
81: | $source->smarty->registered_resources[ $source->type ][ 0 ][ 0 ],
|
82: | array($source->name, &$content, $source->smarty)
|
83: | );
|
84: | if (is_bool($t) && !$t) {
|
85: | throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
|
86: | }
|
87: | return $content;
|
88: | }
|
89: |
|
90: | |
91: | |
92: | |
93: | |
94: | |
95: | |
96: |
|
97: | public function getBasename(Smarty_Template_Source $source)
|
98: | {
|
99: | return basename($source->name);
|
100: | }
|
101: | }
|
102: | |