Files
smarty/libs/sysplugins/internal.cacher_inlinecode.php
Uwe.Tews 0e68cdd9d2 - replace internal "eval()" calls by "include" during rendering process
- speed improvment for templates which have included subtemplates
    the compiled code of included templates is merged into the compiled code of the parent template
- added logical operator "xor" for {if} tag
- changed parameter ordering for Smarty2 BC
    fetch($template, $cache_id = null, $compile_id = null, $parent = null)
    display($template, $cache_id = null, $compile_id = null, $parent = null)
    createTemplate($template, $cache_id = null, $compile_id = null, $parent = null)
- property resource_char_set is now replaced by constant SMARTY_RESOURCE_CHAR_SET
- fixed handling of classes in registered blocks
- speed improvement of lexer on text sections
2009-09-19 13:22:32 +00:00

94 lines
2.7 KiB
PHP

<?php
/**
* Smarty Internal Plugin Cacher InlineCode
*
* Process nocached code.
* Version to inject nocache code directly into cache file
* if caching is disabled at render time the code is being evaluated
*
* @package Smarty
* @subpackage Cacher
* @author Uwe Tews
*/
/**
* Smarty Internal Plugin Cacher InlineCode Class
*/
class Smarty_Internal_Cacher_InlineCode {
function __construct($smarty)
{
$this->smarty = $smarty;
}
/**
* Inject inline code for nocache template sections
*
* This method gets the content of each template element from the parser.
* If the content is compiled code and it should be not cached the code is injected
* into the rendered output.
*
* @param string $content content of template element
* @param object $compiler intance of compiler class
* @param boolean $tag_nocache true if the parser detected a nocache situation
* @param boolean $is_code true if content is compiled code
* @return string content
*/
public function processNocacheCode ($content, $compiler, $tag_nocache, $is_code)
{
// If the template is not evaluated and we have a nocache section and or a nocache tag
if ($is_code) {
// generate replacement code
if (!$compiler->template->isEvaluated() && $compiler->template->caching &&
($tag_nocache || $compiler->nocache || $compiler->tag_nocache)) {
$compiler->tag_nocache = false;
$_output = str_replace("'", "\'", $content);
$_output = '<?php echo \'' . $_output . '\';?>';
} else {
$_output = $content;
}
} else {
$_output = $content;
}
// if compiled code shall be grabbed
if ($compiler->template->extract_code == false) {
// return output
return $_output;
} else {
// store code in extract buffer
$compiler->template->extracted_compiled_code .= $_output;
return '';
}
}
/**
* Initialize cacher
*
* Is a noop in current implementation
*
* @param object $compiler intance of compiler class
*/
public function initCacher ($compiler)
{
return;
}
/**
* Close cacher
*
* Hook to perform any post processing on the final compiled template
* Is a noop in current implementation
*
* @param object $compiler intance of compiler class
* @param string $template_code complete compiled template
* @return string compiled template output
*/
public function closeCacher ($compiler, $template_code)
{
return $template_code;
}
}
?>