+++ /dev/null
-<?php\r
-/**\r
- * Smarty plugin\r
- * @package Smarty\r
- * @subpackage plugins\r
- */\r
-\r
-/**\r
- * Load requested plugins\r
- *\r
- * @param array $plugins\r
- */\r
-\r
-// $plugins\r
-\r
-function smarty_core_load_plugins($params, &$smarty)\r
-{\r
-\r
- foreach ($params['plugins'] as $_plugin_info) {\r
- list($_type, $_name, $_tpl_file, $_tpl_line, $_delayed_loading) = $_plugin_info;\r
- $_plugin = &$smarty->_plugins[$_type][$_name];\r
-\r
- /*\r
- * We do not load plugin more than once for each instance of Smarty.\r
- * The following code checks for that. The plugin can also be\r
- * registered dynamically at runtime, in which case template file\r
- * and line number will be unknown, so we fill them in.\r
- *\r
- * The final element of the info array is a flag that indicates\r
- * whether the dynamically registered plugin function has been\r
- * checked for existence yet or not.\r
- */\r
- if (isset($_plugin)) {\r
- if (empty($_plugin[3])) {\r
- if (!is_callable($_plugin[0])) {\r
- $smarty->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __LINE__);\r
- } else {\r
- $_plugin[1] = $_tpl_file;\r
- $_plugin[2] = $_tpl_line;\r
- $_plugin[3] = true;\r
- if (!isset($_plugin[4])) $_plugin[4] = true; /* cacheable */\r
- }\r
- }\r
- continue;\r
- } else if ($_type == 'insert') {\r
- /*\r
- * For backwards compatibility, we check for insert functions in\r
- * the symbol table before trying to load them as a plugin.\r
- */\r
- $_plugin_func = 'insert_' . $_name;\r
- if (function_exists($_plugin_func)) {\r
- $_plugin = array($_plugin_func, $_tpl_file, $_tpl_line, true, false);\r
- continue;\r
- }\r
- }\r
-\r
- $_plugin_file = $smarty->_get_plugin_filepath($_type, $_name);\r
-\r
- if (! $_found = ($_plugin_file != false)) {\r
- $_message = "could not load plugin file '$_type.$_name.php'\n";\r
- }\r
-\r
- /*\r
- * If plugin file is found, it -must- provide the properly named\r
- * plugin function. In case it doesn't, simply output the error and\r
- * do not fall back on any other method.\r
- */\r
- if ($_found) {\r
- include_once $_plugin_file;\r
-\r
- $_plugin_func = 'smarty_' . $_type . '_' . $_name;\r
- if (!function_exists($_plugin_func)) {\r
- $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__);\r
- continue;\r
- }\r
- }\r
- /*\r
- * In case of insert plugins, their code may be loaded later via\r
- * 'script' attribute.\r
- */\r
- else if ($_type == 'insert' && $_delayed_loading) {\r
- $_plugin_func = 'smarty_' . $_type . '_' . $_name;\r
- $_found = true;\r
- }\r
-\r
- /*\r
- * Plugin specific processing and error checking.\r
- */\r
- if (!$_found) {\r
- if ($_type == 'modifier') {\r
- /*\r
- * In case modifier falls back on using PHP functions\r
- * directly, we only allow those specified in the security\r
- * context.\r
- */\r
- if ($smarty->security && !in_array($_name, $smarty->security_settings['MODIFIER_FUNCS'])) {\r
- $_message = "(secure mode) modifier '$_name' is not allowed";\r
- } else {\r
- if (!function_exists($_name)) {\r
- $_message = "modifier '$_name' is not implemented";\r
- } else {\r
- $_plugin_func = $_name;\r
- $_found = true;\r
- }\r
- }\r
- } else if ($_type == 'function') {\r
- /*\r
- * This is a catch-all situation.\r
- */\r
- $_message = "unknown tag - '$_name'";\r
- }\r
- }\r
-\r
- if ($_found) {\r
- $smarty->_plugins[$_type][$_name] = array($_plugin_func, $_tpl_file, $_tpl_line, true, true);\r
- } else {\r
- // output error\r
- $smarty->_trigger_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__);\r
- }\r
- }\r
-}\r
-\r
-/* vim: set expandtab: */\r
-\r
-?>\r