summaryrefslogtreecommitdiff
path: root/libs/sysplugins/smarty_internal_runtime_tplfunction.php
diff options
context:
space:
mode:
Diffstat (limited to 'libs/sysplugins/smarty_internal_runtime_tplfunction.php')
-rw-r--r--libs/sysplugins/smarty_internal_runtime_tplfunction.php37
1 files changed, 22 insertions, 15 deletions
diff --git a/libs/sysplugins/smarty_internal_runtime_tplfunction.php b/libs/sysplugins/smarty_internal_runtime_tplfunction.php
index a8deaf28..f6b36f2a 100644
--- a/libs/sysplugins/smarty_internal_runtime_tplfunction.php
+++ b/libs/sysplugins/smarty_internal_runtime_tplfunction.php
@@ -22,14 +22,16 @@ class Smarty_Internal_Runtime_TplFunction
*/
public function callTemplateFunction(Smarty_Internal_Template $tpl, $name, $params, $nocache)
{
- if (isset($tpl->tplFunctions[ $name ])) {
+ $funcParam = isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] :
+ (isset($tpl->smarty->tplFunctions[ $name ]) ? $tpl->smarty->tplFunctions[ $name ] : null);
+ if (isset($funcParam)) {
if (!$tpl->caching || ($tpl->caching && $nocache)) {
- $function = $tpl->tplFunctions[ $name ][ 'call_name' ];
+ $function = $funcParam[ 'call_name' ];
} else {
- if (isset($tpl->tplFunctions[ $name ][ 'call_name_caching' ])) {
- $function = $tpl->tplFunctions[ $name ][ 'call_name_caching' ];
+ if (isset($funcParam[ 'call_name_caching' ])) {
+ $function = $funcParam[ 'call_name_caching' ];
} else {
- $function = $tpl->tplFunctions[ $name ][ 'call_name' ];
+ $function = $funcParam[ 'call_name' ];
}
}
if (function_exists($function)) {
@@ -52,23 +54,27 @@ class Smarty_Internal_Runtime_TplFunction
/**
* Register template functions defined by template
*
- * @param \Smarty_Internal_Template $tpl
- * @param array $tplFunctions source information array of template functions defined in template
- * @param bool $override if true replace existing functions with same name
+ * @param \Smarty|\Smarty_Internal_Template|\Smarty_Internal_TemplateBase $obj
+ * @param array $tplFunctions source information array of template functions defined in template
+ * @param bool $override if true replace existing functions with same name
*/
- public function registerTplFunctions(Smarty_Internal_Template $tpl, $tplFunctions, $override = true)
+ public function registerTplFunctions(Smarty_Internal_TemplateBase $obj, $tplFunctions, $override = true)
{
- $tpl->tplFunctions = $override ? array_merge($tpl->tplFunctions, $tplFunctions) : array_merge($tplFunctions, $tpl->tplFunctions);
+ $obj->tplFunctions =
+ $override ? array_merge($obj->tplFunctions, $tplFunctions) : array_merge($tplFunctions, $obj->tplFunctions);
// make sure that the template functions are known in parent templates
- if ($tpl->_isSubTpl()) {
- $tpl->smarty->ext->_tplFunction->registerTplFunctions($tpl->parent,$tplFunctions, false);
+ if ($obj->_isSubTpl()) {
+ $obj->smarty->ext->_tplFunction->registerTplFunctions($obj->parent, $tplFunctions, false);
+ } else {
+ $obj->smarty->tplFunctions = $override ? array_merge($obj->smarty->tplFunctions, $tplFunctions) :
+ array_merge($tplFunctions, $obj->smarty->tplFunctions);
}
}
/**
* Return source parameter array for single or all template functions
*
- * @param \Smarty_Internal_Template $tpl template object
+ * @param \Smarty_Internal_Template $tpl template object
* @param null|string $name template function name
*
* @return array|bool|mixed
@@ -76,9 +82,10 @@ class Smarty_Internal_Runtime_TplFunction
public function getTplFunction(Smarty_Internal_Template $tpl, $name = null)
{
if (isset($name)) {
- return isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] : false;
+ return isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] :
+ (isset($tpl->smarty->tplFunctions[ $name ]) ? $tpl->smarty->tplFunctions[ $name ] : false);
} else {
- return $tpl->tplFunctions;
+ return empty($tpl->tplFunctions) ? $tpl->smarty->tplFunctions : $tpl->tplFunctions;
}
}