1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: 12: 13: 14: 15: 16: 17:
18: class Smarty_Internal_Resource_Extends extends Smarty_Resource
19: {
20: 21: 22: 23: 24:
25: public $mbstring_overload = 0;
26:
27: 28: 29: 30: 31: 32: 33: 34:
35: public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
36: {
37: $uid = '';
38: $sources = array();
39: $components = explode('|', $source->name);
40: $exists = true;
41: foreach ($components as $component) {
42: $s = Smarty_Resource::source(null, $source->smarty, $component);
43: if ($s->type == 'php') {
44: throw new SmartyException("Resource type {$s->type} cannot be used with the extends resource type");
45: }
46: $sources[$s->uid] = $s;
47: $uid .= realpath($s->filepath);
48: if ($_template && $_template->smarty->compile_check) {
49: $exists = $exists && $s->exists;
50: }
51: }
52: $source->components = $sources;
53: $source->filepath = $s->filepath;
54: $source->uid = sha1($uid);
55: if ($_template && $_template->smarty->compile_check) {
56: $source->timestamp = $s->timestamp;
57: $source->exists = $exists;
58: }
59:
60: $source->template = $_template;
61: }
62:
63: 64: 65: 66: 67:
68: public function populateTimestamp(Smarty_Template_Source $source)
69: {
70: $source->exists = true;
71: foreach ($source->components as $s) {
72: $source->exists = $source->exists && $s->exists;
73: }
74: $source->timestamp = $s->timestamp;
75: }
76:
77: 78: 79: 80: 81: 82: 83: 84:
85: public function getContent(Smarty_Template_Source $source)
86: {
87: if (!$source->exists) {
88: throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
89: }
90:
91: $_components = array_reverse($source->components);
92:
93: $_content = '';
94: foreach ($_components as $_component) {
95:
96: $_content .= $_component->content;
97: }
98: return $_content;
99: }
100:
101: 102: 103: 104: 105: 106: 107:
108: public function getBasename(Smarty_Template_Source $source)
109: {
110: return str_replace(':', '.', basename($source->filepath));
111: }
112: }
113: