1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12: class Smarty_Internal_Resource_PHP extends Smarty_Resource_Uncompiled
13: {
14: 15: 16: 17: 18:
19: protected $short_open_tag;
20:
21: 22: 23: 24:
25: public function __construct()
26: {
27: $this->short_open_tag = ini_get('short_open_tag');
28: }
29:
30: 31: 32: 33: 34: 35: 36: 37:
38: public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
39: {
40: $source->filepath = $this->buildFilepath($source, $_template);
41:
42: if ($source->filepath !== false) {
43: if (is_object($source->smarty->security_policy)) {
44: $source->smarty->security_policy->isTrustedResourceDir($source->filepath);
45: }
46:
47: $source->uid = sha1($source->filepath);
48: if ($source->smarty->compile_check) {
49: $source->timestamp = @filemtime($source->filepath);
50: $source->exists = !!$source->timestamp;
51: }
52: }
53: }
54:
55: 56: 57: 58: 59: 60: 61:
62: public function populateTimestamp(Smarty_Template_Source $source)
63: {
64: $source->timestamp = @filemtime($source->filepath);
65: $source->exists = !!$source->timestamp;
66: }
67:
68: 69: 70: 71: 72: 73: 74: 75:
76: public function getContent(Smarty_Template_Source $source)
77: {
78: if ($source->timestamp) {
79: return '';
80: }
81: throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
82: }
83:
84: 85: 86: 87: 88: 89: 90: 91: 92:
93: public function renderUncompiled(Smarty_Template_Source $source, Smarty_Internal_Template $_template)
94: {
95: if (!$source->smarty->allow_php_templates) {
96: throw new SmartyException("PHP templates are disabled");
97: }
98: if (!$source->exists) {
99: if ($_template->parent instanceof Smarty_Internal_Template) {
100: $parent_resource = " in '{$_template->parent->template_resource}'";
101: } else {
102: $parent_resource = '';
103: }
104: throw new SmartyException("Unable to load template {$source->type} '{$source->name}'{$parent_resource}");
105: }
106:
107:
108: extract($_template->getTemplateVars());
109:
110:
111: ini_set('short_open_tag', '1');
112: 113: 114:
115: $_smarty_template = $_template;
116: include($source->filepath);
117: ini_set('short_open_tag', $this->short_open_tag);
118: }
119: }
120: