62 static function load($_template)
64 if (!isset($_template->source)) {
65 $_template->loadSource();
68 if (!$_template->source->recompiled && $_template->smarty->resource_caching) {
69 $_cache_key = $_template->source->unique_resource .
'#';
70 if ($_template->caching) {
71 $_cache_key .=
'caching#';
73 $_cache_key .= $_template->compile_id;
74 if (isset($_template->source->compileds[$_cache_key])) {
75 return $_template->source->compileds[$_cache_key];
79 if (method_exists($_template->source->handler,
'populateCompiledFilepath')) {
80 $_template->source->handler->populateCompiledFilepath($compiled, $_template);
82 $compiled->populateCompiledFilepath($_template);
85 if (!$_template->source->recompiled && $_template->smarty->resource_caching) {
86 $_template->source->compileds[$_cache_key] = $compiled;
98 $_compile_id = isset($_template->compile_id) ? preg_replace(
'![^\w\|]+!',
'_', $_template->compile_id) : null;
99 if ($_template->source->isConfig) {
100 $_flag =
'_' . ((int) $_template->smarty->config_read_hidden + (
int) $_template->smarty->config_booleanize * 2
101 + (int) $_template->smarty->config_overwrite * 4);
103 $_flag =
'_' . ((int) $_template->smarty->merge_compiled_includes + (
int) $_template->smarty->escape_html * 2);
105 $_filepath = $_template->source->uid . $_flag;
107 if ($_template->smarty->use_sub_dirs) {
108 $_filepath = substr($_filepath, 0, 2) . DS
109 . substr($_filepath, 2, 2) . DS
110 . substr($_filepath, 4, 2) . DS
113 $_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS :
'^';
114 if (isset($_compile_id)) {
115 $_filepath = $_compile_id . $_compile_dir_sep . $_filepath;
118 if ($_template->caching) {
123 $_compile_dir = $_template->smarty->getCompileDir();
125 $_basename = $_template->source->handler->getBasename($_template->source);
126 if ($_basename === null) {
127 $_basename = basename(preg_replace(
'![^\w\/]+!',
'_', $_template->source->name));
131 $_basename =
'.' . $_basename;
134 $this->filepath = $_compile_dir . $_filepath .
'.' . $_template->source->type . $_basename . $_cache .
'.php';
135 $this->timestamp = $this->exists = is_file($this->filepath);
137 $this->timestamp = @filemtime($this->filepath);
150 $_smarty_tpl = $_template;
151 if ($_template->source->recompiled || !$_template->compiled->exists || $_template->smarty->force_compile) {
153 $compileCheck = $_template->smarty->compile_check;
154 $_template->smarty->compile_check =
false;
155 if ($_template->source->recompiled) {
156 $level = ob_get_level();
159 eval(
"?>" . $this->code);
161 catch (Exception $e) {
162 while (ob_get_level() > $level) {
170 include($_template->compiled->filepath);
172 $_template->smarty->compile_check = $compileCheck;
174 include($_template->compiled->filepath);
177 $compileCheck = $_template->smarty->compile_check;
178 $_template->smarty->compile_check =
false;
179 include($_template->compiled->filepath);
180 $_template->smarty->compile_check = $compileCheck;
183 $this->unifunc = $_template->properties[
'unifunc'];
184 $this->processed =
true;
198 if (!$this->processed) {
201 $_template->properties[
'unifunc'] = $this->unifunc;
215 if (!$_template->source->recompiled) {
216 $_template->properties[
'file_dependency'] = array();
219 if (!$_template->source->recompiled) {
220 if ($saved_timestamp = $_template->compiled->timestamp) {
221 touch($_template->compiled->filepath);
226 $code = $_template->compiler->compileTemplate($_template);
228 catch (Exception $e) {
230 if (!$_template->source->recompiled && $saved_timestamp) {
231 touch($_template->compiled->filepath, $saved_timestamp);
236 if ($_template->compiler->write_compiled_code) {
242 unset($_template->compiler);
256 if (!$_template->source->recompiled) {
258 if ($obj->writeFile($this->filepath,
$code, $_template->smarty) ===
true) {
259 $this->timestamp = $this->exists = is_file($this->filepath);
261 $this->timestamp = @filemtime($this->filepath);
269 $this->timestamp = time();
270 $this->exists =
true;
283 if (!$_template->source->recompiled) {
284 return file_get_contents($this->filepath);
286 return isset($this->content) ? $this->content :
false;