diff --git a/change_log.txt b/change_log.txt index f7fcb0ae..338889a5 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +05/05/2010 +- bugfix on {insert} to cache parameter + 01/05/2010 - bugfix on handling of variable method names at object chaning diff --git a/libs/sysplugins/smarty_internal_compile_insert.php b/libs/sysplugins/smarty_internal_compile_insert.php index 189fe6d3..d90a9f29 100644 --- a/libs/sysplugins/smarty_internal_compile_insert.php +++ b/libs/sysplugins/smarty_internal_compile_insert.php @@ -1,25 +1,25 @@ 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; } } -?> +?> \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_nocache_insert.php b/libs/sysplugins/smarty_internal_nocache_insert.php new file mode 100644 index 00000000..79aa8857 --- /dev/null +++ b/libs/sysplugins/smarty_internal_nocache_insert.php @@ -0,0 +1,43 @@ +assign('{$_assign}' , {$_function} (" . var_export($_attr, true) . ",\$_smarty_tpl->smarty,\$_smarty_tpl), true);?>"; + } else { + $_output .= "echo {$_function}(" . var_export($_attr, true) . ",\$_smarty_tpl->smarty,\$_smarty_tpl);?>"; + } + return "/*%%SmartyNocache:{$_template->properties['nocache_hash']}%%*/" . $_output . "/*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%*/"; + } +} +?> \ No newline at end of file