aboutsummaryrefslogtreecommitdiffstats
path: root/include/smarty/libs/sysplugins/smarty_internal_filter_handler.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2013-06-20 03:38:47 +0000
committerrvelices <rv-github@modusoptimus.com>2013-06-20 03:38:47 +0000
commit6fc07742f8fca9d32db23243d374ea27e8ee4c1e (patch)
treebc7240c53a1c6bdff6c785153deb6306585c4062 /include/smarty/libs/sysplugins/smarty_internal_filter_handler.php
parent9843eb362dd7d1b9d762871777ef76fa84e8202a (diff)
smarty 3 - first pass for tests
git-svn-id: http://piwigo.org/svn/trunk@23384 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/smarty/libs/sysplugins/smarty_internal_filter_handler.php')
-rw-r--r--include/smarty/libs/sysplugins/smarty_internal_filter_handler.php70
1 files changed, 70 insertions, 0 deletions
diff --git a/include/smarty/libs/sysplugins/smarty_internal_filter_handler.php b/include/smarty/libs/sysplugins/smarty_internal_filter_handler.php
new file mode 100644
index 000000000..c9370e1ac
--- /dev/null
+++ b/include/smarty/libs/sysplugins/smarty_internal_filter_handler.php
@@ -0,0 +1,70 @@
+<?php
+/**
+ * Smarty Internal Plugin Filter Handler
+ *
+ * Smarty filter handler class
+ *
+ * @package Smarty
+ * @subpackage PluginsInternal
+ * @author Uwe Tews
+ */
+
+/**
+ * Class for filter processing
+ *
+ * @package Smarty
+ * @subpackage PluginsInternal
+ */
+class Smarty_Internal_Filter_Handler {
+
+ /**
+ * Run filters over content
+ *
+ * The filters will be lazy loaded if required
+ * class name format: Smarty_FilterType_FilterName
+ * plugin filename format: filtertype.filtername.php
+ * Smarty2 filter plugins could be used
+ *
+ * @param string $type the type of filter ('pre','post','output') which shall run
+ * @param string $content the content which shall be processed by the filters
+ * @param Smarty_Internal_Template $template template object
+ * @return string the filtered content
+ */
+ public static function runFilter($type, $content, Smarty_Internal_Template $template)
+ {
+ $output = $content;
+ // loop over autoload filters of specified type
+ if (!empty($template->smarty->autoload_filters[$type])) {
+ foreach ((array)$template->smarty->autoload_filters[$type] as $name) {
+ $plugin_name = "Smarty_{$type}filter_{$name}";
+ if ($template->smarty->loadPlugin($plugin_name)) {
+ if (function_exists($plugin_name)) {
+ // use loaded Smarty2 style plugin
+ $output = $plugin_name($output, $template);
+ } elseif (class_exists($plugin_name, false)) {
+ // loaded class of filter plugin
+ $output = call_user_func(array($plugin_name, 'execute'), $output, $template);
+ }
+ } else {
+ // nothing found, throw exception
+ throw new SmartyException("Unable to load filter {$plugin_name}");
+ }
+ }
+ }
+ // loop over registerd filters of specified type
+ if (!empty($template->smarty->registered_filters[$type])) {
+ foreach ($template->smarty->registered_filters[$type] as $key => $name) {
+ if (is_array($template->smarty->registered_filters[$type][$key])) {
+ $output = call_user_func($template->smarty->registered_filters[$type][$key], $output, $template);
+ } else {
+ $output = $template->smarty->registered_filters[$type][$key]($output, $template);
+ }
+ }
+ }
+ // return filtered output
+ return $output;
+ }
+
+}
+
+?> \ No newline at end of file