mirror of
https://github.com/smarty-php/smarty.git
synced 2026-04-29 18:23:24 +02:00
- bugfix on {insert} to cache parameter
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Insert
|
||||
*
|
||||
* Compiles the {insert} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
* Smarty Internal Plugin Compile Insert
|
||||
*
|
||||
* Compiles the {insert} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Insert Class
|
||||
*/
|
||||
* Smarty Internal Plugin Compile Insert Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {insert} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return string compiled code
|
||||
*/
|
||||
* Compiles code for the {insert} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
@@ -27,7 +27,8 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase {
|
||||
$this->optional_attributes = array('_any');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
// this tag must not be cached
|
||||
// never compile as nocache code
|
||||
$this->compiler->suppressNocacheProcessing = true;
|
||||
$this->compiler->tag_nocache = true;
|
||||
$_smarty_tpl = $compiler->template;
|
||||
|
||||
@@ -49,12 +50,13 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase {
|
||||
$this->compiler->trigger_template_error("{insert} missing script file '{$_script}'");
|
||||
}
|
||||
// code for script file loading
|
||||
$_output .= "require_once {$_script} ;";
|
||||
$_output .= "require_once '{$_script}' ;";
|
||||
require_once $_script;
|
||||
if (!is_callable($_function)) {
|
||||
$this->compiler->trigger_template_error(" {insert} function '{$_name}' is not callable");
|
||||
}
|
||||
} else {
|
||||
$_script = 'null';
|
||||
if (!is_callable($_function)) {
|
||||
if (!$_function = $this->compiler->getPlugin($_name, 'insert')) {
|
||||
$this->compiler->trigger_template_error("{insert} no function or plugin found for '{$_name}'");
|
||||
@@ -71,13 +73,21 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase {
|
||||
$_params = 'array(' . implode(", ", $_paramsArray) . ')';
|
||||
// call insert
|
||||
if (isset($_assign)) {
|
||||
$_output .= "\$_smarty_tpl->assign({$_assign} , {$_function} ({$_params},\$_smarty_tpl->smarty,\$_smarty_tpl), true);?>";
|
||||
if ($_smarty_tpl->caching) {
|
||||
$_output .= "echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_script}',{$_assign});?>";
|
||||
} else {
|
||||
$_output .= "\$_smarty_tpl->assign({$_assign} , {$_function} ({$_params},\$_smarty_tpl->smarty,\$_smarty_tpl), true);?>";
|
||||
}
|
||||
} else {
|
||||
$this->compiler->has_output = true;
|
||||
$_output .= "echo {$_function}({$_params},\$_smarty_tpl->smarty,\$_smarty_tpl);?>";
|
||||
if ($_smarty_tpl->caching) {
|
||||
$_output .= "echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_script}');?>";
|
||||
} else {
|
||||
$_output .= "echo {$_function}({$_params},\$_smarty_tpl->smarty,\$_smarty_tpl);?>";
|
||||
}
|
||||
}
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
Reference in New Issue
Block a user