110 $this->compile_id = $_template->compile_id;
111 $this->cache_id = $_template->cache_id;
112 if (!isset($_template->source)) {
115 $this->source = $_template->source;
116 if (!class_exists(
'Smarty_CacheResource',
false)) {
117 require SMARTY_SYSPLUGINS_DIR .
'smarty_cacheresource.php';
130 $cached->handler->populate($cached, $_template);
133 $cached->valid =
false;
147 if ($this->valid !== null) {
152 if ($this->exists ===
false || $_template->smarty->force_compile || $_template->smarty->force_cache) {
153 $this->valid =
false;
157 if ($this->valid && $_template->caching ==
Smarty::CACHING_LIFETIME_CURRENT && $_template->cache_lifetime >= 0 && time() > ($this->timestamp + $_template->cache_lifetime)) {
159 $this->valid =
false;
161 if ($this->valid && $_template->source->timestamp > $this->timestamp) {
162 $this->valid =
false;
164 if ($this->valid || !$_template->smarty->cache_locking) {
167 if (!$this->handler->locked($_template->smarty, $this)) {
168 $this->handler->acquireLock($_template->smarty, $this);
171 $this->handler->populate($this, $_template);
174 if (!$_template->smarty->cache_locking || $this->handler->locked($_template->smarty, $this) === null) {
176 if ($_template->smarty->debugging) {
179 if ($this->handler->process($_template, $this) ===
false) {
180 $this->valid =
false;
182 $this->processed =
true;
184 if ($_template->smarty->debugging) {
188 $this->is_locked =
true;
194 if ($this->valid && $_template->caching ===
Smarty::CACHING_LIFETIME_SAVED && $_template->properties[
'cache_lifetime'] >= 0 && (time() > ($_template->cached->timestamp + $_template->properties[
'cache_lifetime']))) {
195 $this->valid =
false;
197 if ($_template->smarty->cache_locking) {
199 $this->handler->acquireLock($_template->smarty, $this);
200 } elseif ($this->is_locked) {
201 $this->handler->releaseLock($_template->smarty, $this);
216 if ($this->handler->process($_template, $this) ===
false) {
217 $this->valid =
false;
220 $this->processed =
true;
222 $this->processed =
false;
236 if (!$this->processed) {
252 if (!$_template->source->recompiled) {
253 if ($this->handler->writeCachedContent($_template,
$content)) {
254 $this->content = null;
255 $this->timestamp = time();
256 $this->exists =
true;
258 $this->processed =
false;
259 if ($_template->smarty->cache_locking) {
260 $this->handler->releaseLock($_template->smarty, $this);
265 $this->content = null;
266 $this->timestamp =
false;
267 $this->exists =
false;
268 $this->valid =
false;
269 $this->processed =
false;
284 if (!$_template->source->recompiled) {
285 return $this->handler->readCachedContent($_template);
301 $_template->properties[
'has_nocache_code'] =
false;
303 $cache_split = preg_split(
"!/\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!s",
$content);
305 preg_match_all(
"!/\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!s",
$content, $cache_parts);
308 foreach ($cache_split as $curr_idx => $curr_split) {
310 $output .= preg_replace(
'/(<%|%>|<\?php|<\?|\?>|<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>)/',
"<?php echo '\$1'; ?>\n", $curr_split);
311 if (isset($cache_parts[0][$curr_idx])) {
312 $_template->properties[
'has_nocache_code'] =
true;
313 $output .= $cache_parts[1][$curr_idx];
316 if (!$no_output_filter && !$_template->has_nocache_code && (isset($_template->smarty->autoload_filters[
'output']) || isset($_template->smarty->registered_filters[
'output']))) {
337 $_template->properties[
'cache_lifetime'] = $_template->cache_lifetime;
338 $_template->properties[
'unifunc'] =
'content_' . str_replace(array(
'.',
','),
'_', uniqid(
'',
true));
340 if (!empty($_template->properties[
'tpl_function'])) {
341 foreach ($_template->properties[
'tpl_function'] as $funcParam) {
342 if (is_file($funcParam[
'compiled_filepath'])) {
344 $code = file_get_contents($funcParam[
'compiled_filepath']);
346 if (preg_match(
"/\/\* {$funcParam['call_name']} \*\/([\S\s]*?)\/\*\/ {$funcParam['call_name']} \*\//", $code, $match)) {
348 $content .=
"<?php " . $match[0] .
"?>\n";
364 $_isCached = $_template->
isCached() && !$_template->has_nocache_code;
365 $_last_modified_date = @substr($_SERVER[
'HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER[
'HTTP_IF_MODIFIED_SINCE'],
'GMT') + 3);
366 if ($_isCached && $this->timestamp <= strtotime($_last_modified_date)) {
371 header(
'Status: 304 Not Modified');
376 !empty($_SERVER[
'SMARTY_PHPUNIT_DISABLE_HEADERS'])
378 $_SERVER[
'SMARTY_PHPUNIT_HEADERS'][] =
'304 Not Modified';
383 header($_SERVER[
'SERVER_PROTOCOL'] .
' 304 Not Modified');
390 !empty($_SERVER[
'SMARTY_PHPUNIT_DISABLE_HEADERS'])
392 $_SERVER[
'SMARTY_PHPUNIT_HEADERS'][] =
'Last-Modified: ' . gmdate(
'D, d M Y H:i:s', $this->timestamp) .
' GMT';
397 header(
'Last-Modified: ' . gmdate(
'D, d M Y H:i:s', $this->timestamp) .
' GMT');