mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
- bugfix on {call} with variable function name
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
17/11/2010
|
||||
- bugfix on {call} with variable function name
|
||||
|
||||
16/11/2010
|
||||
- bugfix whitespace in front of "<?php" in smarty_internal_compile_private_block_plugin.php
|
||||
- bugfix {$smarty.now} did compile incorrectly
|
||||
|
@@ -75,20 +75,29 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
//varibale name?
|
||||
if (!(strpos($_name,'$')===false)) {
|
||||
$call_cache = $_name;
|
||||
$call_function = "\$tmp = \"smarty_template_function_{{$_name}}\"; \$tmp";
|
||||
} else {
|
||||
$call_cache = "'{$_name}'";
|
||||
$call_function = 'smarty_template_function_'.$_name;
|
||||
}
|
||||
|
||||
$_params = 'array(' . implode(",", $_paramsArray) . ')';
|
||||
$_hash = str_replace('-','_',$compiler->template->properties['nocache_hash']);
|
||||
// was there an assign attribute
|
||||
if (isset($_assign)) {
|
||||
if ($compiler->template->caching) {
|
||||
$_output = "<?php ob_start(); Smarty_Internal_Function_Call_Handler::call ('{$_name}',\$_smarty_tpl,{$_params},'{$_hash}',{$_nocache}); \$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
|
||||
$_output = "<?php ob_start(); Smarty_Internal_Function_Call_Handler::call ({$call_cache},\$_smarty_tpl,{$_params},'{$_hash}',{$_nocache}); \$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
|
||||
} else {
|
||||
$_output = "<?php ob_start(); smarty_template_function_{$_name}(\$_smarty_tpl,{$_params}); \$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
|
||||
$_output = "<?php ob_start(); {$call_function}(\$_smarty_tpl,{$_params}); \$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
|
||||
}
|
||||
} else {
|
||||
if ($compiler->template->caching) {
|
||||
$_output = "<?php Smarty_Internal_Function_Call_Handler::call ('{$_name}',\$_smarty_tpl,{$_params},'{$_hash}',{$_nocache});?>\n";
|
||||
$_output = "<?php Smarty_Internal_Function_Call_Handler::call ({$call_cache},\$_smarty_tpl,{$_params},'{$_hash}',{$_nocache});?>\n";
|
||||
} else {
|
||||
$_output = "<?php smarty_template_function_{$_name}(\$_smarty_tpl,{$_params});?>\n";
|
||||
$_output = "<?php {$call_function}(\$_smarty_tpl,{$_params});?>\n";
|
||||
}
|
||||
}
|
||||
return $_output;
|
||||
|
@@ -52,7 +52,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase {
|
||||
$output = "<?php if (!function_exists('smarty_template_function_{$_name}')) {
|
||||
function smarty_template_function_{$_name}(\$_smarty_tpl,\$params) {
|
||||
\$saved_tpl_vars = \$_smarty_tpl->tpl_vars;
|
||||
foreach (\$_smarty_tpl->smarty->template_functions['{$_name}']['parameter'] as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(trim(\$value,'\''));};
|
||||
foreach (\$_smarty_tpl->template_functions['{$_name}']['parameter'] as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(trim(\$value,'\''));};
|
||||
foreach (\$params as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);}?>";
|
||||
}
|
||||
// Init temporay context
|
||||
|
@@ -22,6 +22,7 @@ class Smarty_Internal_Function_Call_Handler extends Smarty_Internal_Template {
|
||||
if (!is_callable($_function)) {
|
||||
$_code = "function {$_function}(\$_smarty_tpl,\$params) {
|
||||
\$saved_tpl_vars = \$_smarty_tpl->tpl_vars;
|
||||
foreach (\$_smarty_tpl->template_functions['{$_name}']['parameter'] as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(trim(\$value,'\''));};
|
||||
foreach (\$params as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);}?>";
|
||||
if ($_nocache) {
|
||||
$_code .= preg_replace(array("!<\?php echo \\'/\*%%SmartyNocache:{$_template->smarty->template_functions[$_name]['nocache_hash']}%%\*/|/\*/%%SmartyNocache:{$_template->smarty->template_functions[$_name]['nocache_hash']}%%\*/\\';\?>!",
|
||||
|
Reference in New Issue
Block a user