- enhancement allow access to properties of registered opjects for Smarty2 BC (forum topic 24344)

This commit is contained in:
Uwe.Tews@googlemail.com
2013-07-27 09:48:42 +00:00
parent 697696fef9
commit e62dcaa6a9
2 changed files with 24 additions and 14 deletions

View File

@@ -1,4 +1,7 @@
===== trunk ===== ===== trunk =====
27.07.2013
- enhancement allow access to properties of registered opjects for Smarty2 BC (forum topic 24344)
26.07.2013 26.07.2013
- bugfix template inheritance nesting problem (forum topic 24387) - bugfix template inheritance nesting problem (forum topic 24387)

View File

@@ -28,9 +28,9 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co
/** /**
* Compiles code for the execution of function plugin * Compiles code for the execution of function plugin
* *
* @param array $args array with attributes from parser * @param array $args array with attributes from parser
* @param object $compiler compiler object * @param object $compiler compiler object
* @param array $parameter array with compilation parameter * @param array $parameter array with compilation parameter
* @param string $tag name of function * @param string $tag name of function
* @param string $method name of method to call * @param string $method name of method to call
* @return string compiled code * @return string compiled code
@@ -48,22 +48,29 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co
$_assign = $_attr['assign']; $_assign = $_attr['assign'];
unset($_attr['assign']); unset($_attr['assign']);
} }
// convert attributes into parameter array string // method or property ?
if ($compiler->smarty->registered_objects[$tag][2]) { if (method_exists($compiler->smarty->registered_objects[$tag][0], $method)) {
$_paramsArray = array(); // convert attributes into parameter array string
foreach ($_attr as $_key => $_value) { if ($compiler->smarty->registered_objects[$tag][2]) {
if (is_int($_key)) { $_paramsArray = array();
$_paramsArray[] = "$_key=>$_value"; foreach ($_attr as $_key => $_value) {
} else { if (is_int($_key)) {
$_paramsArray[] = "'$_key'=>$_value"; $_paramsArray[] = "$_key=>$_value";
} else {
$_paramsArray[] = "'$_key'=>$_value";
}
} }
$_params = 'array(' . implode(",", $_paramsArray) . ')';
$return = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params},\$_smarty_tpl)";
} else {
$_params = implode(",", $_attr);
$return = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params})";
} }
$_params = 'array(' . implode(",", $_paramsArray) . ')';
$return = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params},\$_smarty_tpl)";
} else { } else {
$_params = implode(",", $_attr); // object property
$return = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params})"; $return = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}";
} }
if (empty($_assign)) { if (empty($_assign)) {
// This tag does create output // This tag does create output
$compiler->has_output = true; $compiler->has_output = true;