From fa10e0945ecd45bfe78a2c8fb015a43092b4944b Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 10 Dec 2015 14:02:22 +0100 Subject: bug #385 update to smarty-3.1.28-dev (from Github) --- .../smarty_internal_runtime_filterhandler.php | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 include/smarty/libs/sysplugins/smarty_internal_runtime_filterhandler.php (limited to 'include/smarty/libs/sysplugins/smarty_internal_runtime_filterhandler.php') diff --git a/include/smarty/libs/sysplugins/smarty_internal_runtime_filterhandler.php b/include/smarty/libs/sysplugins/smarty_internal_runtime_filterhandler.php new file mode 100644 index 000000000..9af266758 --- /dev/null +++ b/include/smarty/libs/sysplugins/smarty_internal_runtime_filterhandler.php @@ -0,0 +1,69 @@ +smarty->autoload_filters[$type])) { + foreach ((array) $template->smarty->autoload_filters[$type] as $name) { + $plugin_name = "Smarty_{$type}filter_{$name}"; + if (function_exists($plugin_name)) { + $callback = $plugin_name; + } elseif (class_exists($plugin_name, false) && is_callable(array($plugin_name, 'execute'))) { + $callback = array($plugin_name, 'execute'); + } elseif ($template->smarty->loadPlugin($plugin_name, false)) { + if (function_exists($plugin_name)) { + // use loaded Smarty2 style plugin + $callback = $plugin_name; + } elseif (class_exists($plugin_name, false) && is_callable(array($plugin_name, 'execute'))) { + // loaded class of filter plugin + $callback = array($plugin_name, 'execute'); + } else { + throw new SmartyException("Auto load {$type}-filter plugin method \"{$plugin_name}::execute\" not callable"); + } + } else { + // nothing found, throw exception + throw new SmartyException("Unable to auto load {$type}-filter plugin \"{$plugin_name}\""); + } + $content = call_user_func($callback, $content, $template); + } + } + // loop over registered filters of specified type + if (!empty($template->smarty->registered_filters[$type])) { + foreach ($template->smarty->registered_filters[$type] as $key => $name) { + $content = call_user_func($template->smarty->registered_filters[$type][$key], $content, $template); + } + } + // return filtered output + return $content; + } +} -- cgit v1.2.3 From 8cd9c6602c950955d69592a62320330deb934b93 Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 20 Dec 2015 14:54:07 +0100 Subject: changes on Smarty side breaks all prefilter in Piwigo It would be better to modify the way template.class.php registers prefilters but I didn't find the appropriate data structure. --- .../libs/sysplugins/smarty_internal_runtime_filterhandler.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include/smarty/libs/sysplugins/smarty_internal_runtime_filterhandler.php') diff --git a/include/smarty/libs/sysplugins/smarty_internal_runtime_filterhandler.php b/include/smarty/libs/sysplugins/smarty_internal_runtime_filterhandler.php index 9af266758..4b664c38e 100644 --- a/include/smarty/libs/sysplugins/smarty_internal_runtime_filterhandler.php +++ b/include/smarty/libs/sysplugins/smarty_internal_runtime_filterhandler.php @@ -60,7 +60,11 @@ class Smarty_Internal_Runtime_FilterHandler // loop over registered filters of specified type if (!empty($template->smarty->registered_filters[$type])) { foreach ($template->smarty->registered_filters[$type] as $key => $name) { - $content = call_user_func($template->smarty->registered_filters[$type][$key], $content, $template); + if (is_array($template->smarty->registered_filters[$type][$key])) { + $content = call_user_func($template->smarty->registered_filters[$type][$key], $content, $template); + } else { + $content = $template->smarty->registered_filters[$type][$key]($content, $template); + } } } // return filtered output -- cgit v1.2.3