/** * Writes the rendered template output to cache file * * @param object $template current template * @return boolean status */ public function writeCachedContent($template, $content) { if (!$template->isEvaluated()) { return Smarty_Internal_Write_File::writeFile($template->getCachedFilepath(), $content, $this->smarty); } else { return false; } }
$_lock_dir = $_cache_dir; } $cached->lock_id = $_lock_dir . sha1($_cache_id . $_compile_id . $_template->source->uid) . '.lock'; } $cached->filepath = $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_source_file_path) . '.php'; $cached->timestamp = @filemtime($cached->filepath); $cached->exists = !!$cached->timestamp; } /** * populate Cached Object with timestamp and exists from Resource
public function compileConfigSource() { if (!is_object($this->compiler_object)) { $this->compiler_object = new Smarty_Internal_Config_File_Compiler($this->smarty); } if ($this->smarty->compile_locking) { if ($saved_timestamp = $this->getCompiledTimestamp()) { touch($this->getCompiledFilepath()); } } try { $this->compiler_object->compileSource($this); } catch (Exception $e) { if ($this->smarty->compile_locking && $saved_timestamp) { touch($this->getCompiledFilepath(), $saved_timestamp); } throw $e; } Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->getCompiledConfig(), $this->smarty); }
public function compileTemplateSource() { if (!$this->source->recompiled) { $this->properties['file_dependency'] = array(); if ($this->source->components) { $source = end($this->source->components); $this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $source->type); } else { $this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $this->source->type); } } if ($this->smarty->debugging) { Smarty_Internal_Debug::start_compile($this); } if ($this->smarty->compile_locking && !$this->source->recompiled) { if ($saved_timestamp = $this->compiled->timestamp) { touch($this->compiled->filepath); } } try { $code = $this->compiler->compileTemplate($this); } catch (Exception $e) { if ($this->smarty->compile_locking && !$this->source->recompiled && $saved_timestamp) { touch($this->compiled->filepath, $saved_timestamp); } throw $e; } if (!$this->source->recompiled && $this->compiler->write_compiled_code) { $_filepath = $this->compiled->filepath; if ($_filepath === false) { throw new SmartyException('getCompiledFilepath() did not return a destination to save the compiled template to'); } Smarty_Internal_Write_File::writeFile($_filepath, $code, $this->smarty); $this->compiled->exists = true; $this->compiled->isCompiled = true; } if ($this->smarty->debugging) { Smarty_Internal_Debug::end_compile($this); } unset($this->compiler); }
/** * Compiles the template * * If the template is not evaluated the compiled template is saved on disk */ public function compileTemplateSource() { if (!$this->source->recompiled) { $this->properties['file_dependency'] = array(); if ($this->source->components) { // uses real resource for file dependency $source = end($this->source->components); $this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $source->type); } else { $this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $this->source->type); } } if ($this->smarty->debugging) { Smarty_Internal_Debug::start_compile($this); } // compile locking if ($this->smarty->compile_locking && !$this->source->recompiled) { if ($saved_timestamp = $this->compiled->timestamp) { touch($this->compiled->filepath); } } // call compiler try { $code = $this->compiler->compileTemplate($this); } catch (Exception $e) { // restore old timestamp in case of error if ($this->smarty->compile_locking && !$this->source->recompiled && $saved_timestamp) { touch($this->compiled->filepath, $saved_timestamp); } throw $e; } // compiling succeded if (!$this->source->recompiled && $this->compiler->write_compiled_code) { // write compiled template $_filepath = $this->compiled->filepath; if ($_filepath === false) { throw new SmartyException('getCompiledFilepath() did not return a destination to save the compiled template to'); } Smarty_Internal_Write_File::writeFile($_filepath, $code, $this->smarty); $this->compiled->exists = true; $this->compiled->isCompiled = true; } if ($this->smarty->debugging) { Smarty_Internal_Debug::end_compile($this); } // release compiler object to free memory unset($this->compiler); }
/** * Writes the rendered template output to cache file * * @param object $_template current template * @return boolean status */ public function writeCachedContent($_template, $content) { if (!$_template->resource_object->isEvaluated) { if (Smarty_Internal_Write_File::writeFile($_template->getCachedFilepath(), $content, $this->smarty) === true) { $_template->cached_timestamp = filemtime($_template->getCachedFilepath()); return true; } } return false; }
/** * Compiles the template * * If the template is not evaluated the compiled template is saved on disk */ public function compileTemplateSource() { if (!$this->resource_object->isEvaluated) { $this->properties['file_dependency'] = array(); $this->properties['file_dependency'][$this->templateUid] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp(), $this->resource_type); } if ($this->smarty->debugging) { Smarty_Internal_Debug::start_compile($this); } // compile template if (!is_object($this->compiler_object)) { // load compiler $this->smarty->loadPlugin($this->resource_object->compiler_class); $this->compiler_object = new $this->resource_object->compiler_class($this->resource_object->template_lexer_class, $this->resource_object->template_parser_class, $this->smarty); } // compile locking if ($this->smarty->compile_locking && !$this->resource_object->isEvaluated) { if ($saved_timestamp = $this->getCompiledTimestamp()) { touch($this->getCompiledFilepath()); } } // call compiler try { $this->compiler_object->compileTemplate($this); } catch (Exception $e) { // restore old timestamp in case of error if ($this->smarty->compile_locking && !$this->resource_object->isEvaluated && $saved_timestamp) { touch($this->getCompiledFilepath(), $saved_timestamp); } throw $e; } // compiling succeded if (!$this->resource_object->isEvaluated && $this->write_compiled_code) { // write compiled template Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->compiled_template, $this->smarty); } if ($this->smarty->debugging) { Smarty_Internal_Debug::end_compile($this); } // release objects to free memory Smarty_Internal_TemplateCompilerBase::$_tag_objects = array(); unset($this->compiler_object->parser->root_buffer, $this->compiler_object->parser->current_buffer, $this->compiler_object->parser, $this->compiler_object->lex, $this->compiler_object->template, $this->compiler_object); }
/** * Compiles the config files * * @throws Exception */ public function compileConfigSource() { // compile template if (!is_object($this->compiler_object)) { // load compiler $this->compiler_object = new Smarty_Internal_Config_File_Compiler($this->smarty); } // compile locking if ($this->smarty->compile_locking) { if ($saved_timestamp = $this->getCompiledTimestamp()) { touch($this->getCompiledFilepath()); } } // call compiler try { $this->compiler_object->compileSource($this); } catch (Exception $e) { // restore old timestamp in case of error if ($this->smarty->compile_locking && $saved_timestamp) { touch($this->getCompiledFilepath(), $saved_timestamp); } throw $e; } // compiling succeeded // write compiled template Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->getCompiledConfig(), $this->smarty); }
/** * Write the rendered template output to cache * * @param Smarty_Internal_Template $_template template object * @param string $content content to cache * * @return boolean success */ public function writeCachedContent(Smarty_Internal_Template $_template, $content) { $obj = new Smarty_Internal_Write_File(); if ($obj->writeFile($_template->cached->filepath, $content, $_template->smarty) === true) { if (function_exists('opcache_invalidate')) { opcache_invalidate($_template->cached->filepath); } $cached = $_template->cached; $cached->timestamp = $cached->exists = is_file($cached->filepath); if ($cached->exists) { $cached->timestamp = filemtime($cached->filepath); return true; } } return false; }
/** * Write compiled code by handler * @param Smarty_Internal_Template $_template template object * @param string $code compiled code * @return boolean success */ public function write(Smarty_Internal_Template $_template, $code) { if (!$_template->source->recompiled) { $obj = new Smarty_Internal_Write_File(); if ($obj->writeFile($this->filepath, $code, $_template->smarty) === TRUE) { $this->timestamp = $this->exists = is_file($this->filepath); if ($this->exists) { $this->timestamp = @filemtime($this->filepath); return TRUE; } } return FALSE; } else { $this->code = $code; } $this->timestamp = time(); $this->exists = TRUE; return TRUE; }
/** * Write compiled code by handler * * @param Smarty_Internal_Template $_template template object * @param string $code compiled code * * @return boolean success */ public function write(Smarty_Internal_Template $_template, $code) { if (!$_template->source->recompiled) { if (Smarty_Internal_Write_File::writeFile($this->filepath, $code, $_template->smarty) === true) { $this->timestamp = @filemtime($this->filepath); $this->exists = !!$this->timestamp; if ($this->exists) { return true; } } return false; } else { $this->code = $code; } $this->timestamp = time(); $this->exists = true; return true; }
/** * Compiles the template * * If the template is not evaluated the compiled template is saved on disk */ public function compileTemplateSource() { if (!$this->resource_object->isEvaluated) { $this->properties['file_dependency'] = array(); $this->properties['file_dependency'][$this->templateUid] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp()); } if ($this->smarty->debugging) { Smarty_Internal_Debug::start_compile($this); } // compile template if (!is_object($this->compiler_object)) { // load compiler $this->smarty->loadPlugin($this->resource_object->compiler_class); $this->compiler_object = new $this->resource_object->compiler_class($this->resource_object->template_lexer_class, $this->resource_object->template_parser_class, $this->smarty); } // call compiler if ($this->compiler_object->compileTemplate($this)) { // compiling succeded if (!$this->resource_object->isEvaluated) { // write compiled template Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->compiled_template, $this->smarty); } } else { // error compiling template throw new Exception("Error compiling template {$this->getTemplateFilepath()}"); return false; } if ($this->smarty->debugging) { Smarty_Internal_Debug::end_compile($this); } }
/** * Write compiled code by handler * * @param Smarty_Internal_Template $_template template object * @param string $code compiled code * * @return boolean success */ public function write(Smarty_Internal_Template $_template, $code) { if (!$_template->source->handler->recompiled) { $obj = new Smarty_Internal_Write_File(); if ($obj->writeFile($this->filepath, $code, $_template->smarty) === true) { $this->timestamp = $this->exists = is_file($this->filepath); if ($this->exists) { $this->timestamp = filemtime($this->filepath); return true; } } return false; } else { $this->content = $code; } $this->timestamp = time(); $this->exists = true; return true; }
/** * Write the rendered template output to cache * @param Smarty_Internal_Template $_template template object * @param string $content content to cache * @return boolean success */ public function writeCachedContent(Smarty_Internal_Template $_template, $content) { $obj = new Smarty_Internal_Write_File(); if ($obj->writeFile($_template->cached->filepath, $content, $_template->smarty) === TRUE) { $cached = $_template->cached; $cached->timestamp = $cached->exists = is_file($cached->filepath); if ($cached->exists) { $cached->timestamp = filemtime($cached->filepath); return TRUE; } } return FALSE; }
/** * Compiles the config files */ public function compileConfigSource() { // compile template if (!is_object($this->compiler_object)) { // load compiler $this->compiler_object = new Smarty_Internal_Config_File_Compiler($this->smarty); } // call compiler if ($this->compiler_object->compileSource($this)) { // compiling succeded // write compiled template Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->getCompiledConfig(), $this->smarty); // make template and compiled file timestamp match touch($this->getCompiledFilepath(), $this->getTimestamp()); } else { // error compiling template throw new Exception("Error compiling template {$this->getConfigFilepath()}"); return false; } }
/** * Compiles the template * * If the template is not evaluated the compiled template is saved on disk */ public function compileTemplateSource() { if (!$this->isEvaluated) { $this->properties['file_dependency']['F' . abs(crc32($this->getTemplateFilepath()))] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp()); } if ($this->smarty->debugging) { Smarty_Internal_Debug::start_compile($this); } // compile template if (!is_object($this->compiler_object)) { // load compiler $this->smarty->loadPlugin($this->resource_object->compiler_class); $this->compiler_object = new $this->resource_object->compiler_class($this->resource_object->template_lexer_class, $this->resource_object->template_parser_class, $this->smarty); // load cacher if ($this->caching) { $this->smarty->loadPlugin($this->cacher_class); $this->cacher_object = new $this->cacher_class($this->smarty); } } // call compiler if ($this->compiler_object->compileTemplate($this)) { // compiling succeded if (!$this->isEvaluated()) { // write compiled template Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->compiled_template, $this->smarty); // make template and compiled file timestamp match /** $this->compiled_timestamp = null; touch($this->getCompiledFilepath(), $this->getTemplateTimestamp()); // daylight saving time problem on windows if ($this->template_timestamp != $this->getCompiledTimestamp()) { touch($this->getCompiledFilepath(), 2 * $this->template_timestamp - $this->compiled_timestamp); } **/ } } else { // error compiling template throw new Exception("Error compiling template {$this->getTemplateFilepath()}"); return false; } if ($this->smarty->debugging) { Smarty_Internal_Debug::end_compile($this); } }