5 Modification information for LGPL compliance
7 r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync
9 r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
11 r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
13 r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3 tags and updated the build system
15 r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development
17 r50375 - 2009-08-24 18:07:43 -0700 (Mon, 24 Aug 2009) - dwong - branch kobe2 from tokyo r50372
19 r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm
21 r8230 - 2005-10-03 17:47:19 -0700 (Mon, 03 Oct 2005) - majed - Added Sugar_Smarty to the code tree.
34 * Load requested plugins
36 * @param array $plugins
41 function smarty_core_load_plugins($params, &$smarty)
44 foreach ($params['plugins'] as $_plugin_info) {
45 list($_type, $_name, $_tpl_file, $_tpl_line, $_delayed_loading) = $_plugin_info;
46 $_plugin = &$smarty->_plugins[$_type][$_name];
49 * We do not load plugin more than once for each instance of Smarty.
50 * The following code checks for that. The plugin can also be
51 * registered dynamically at runtime, in which case template file
52 * and line number will be unknown, so we fill them in.
54 * The final element of the info array is a flag that indicates
55 * whether the dynamically registered plugin function has been
56 * checked for existence yet or not.
58 if (isset($_plugin)) {
59 if (empty($_plugin[3])) {
60 if (!is_callable($_plugin[0])) {
61 $smarty->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __LINE__);
63 $_plugin[1] = $_tpl_file;
64 $_plugin[2] = $_tpl_line;
66 if (!isset($_plugin[4])) $_plugin[4] = true; /* cacheable */
70 } else if ($_type == 'insert') {
72 * For backwards compatibility, we check for insert functions in
73 * the symbol table before trying to load them as a plugin.
75 $_plugin_func = 'insert_' . $_name;
76 if (function_exists($_plugin_func)) {
77 $_plugin = array($_plugin_func, $_tpl_file, $_tpl_line, true, false);
82 $_plugin_file = $smarty->_get_plugin_filepath($_type, $_name);
84 if (! $_found = ($_plugin_file != false)) {
85 $_message = "could not load plugin file '$_type.$_name.php'\n";
89 * If plugin file is found, it -must- provide the properly named
90 * plugin function. In case it doesn't, simply output the error and
91 * do not fall back on any other method.
94 include_once $_plugin_file;
96 $_plugin_func = 'smarty_' . $_type . '_' . $_name;
97 if (!function_exists($_plugin_func)) {
98 $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__);
103 * In case of insert plugins, their code may be loaded later via
104 * 'script' attribute.
106 else if ($_type == 'insert' && $_delayed_loading) {
107 $_plugin_func = 'smarty_' . $_type . '_' . $_name;
112 * Plugin specific processing and error checking.
115 if ($_type == 'modifier') {
117 * In case modifier falls back on using PHP functions
118 * directly, we only allow those specified in the security
121 if ($smarty->security && !in_array($_name, $smarty->security_settings['MODIFIER_FUNCS'])) {
122 $_message = "(secure mode) modifier '$_name' is not allowed";
124 if (!function_exists($_name)) {
125 $_message = "modifier '$_name' is not implemented";
127 $_plugin_func = $_name;
131 } else if ($_type == 'function') {
133 * This is a catch-all situation.
135 $_message = "unknown tag - '$_name'";
140 $smarty->_plugins[$_type][$_name] = array($_plugin_func, $_tpl_file, $_tpl_line, true, true);
143 $smarty->_trigger_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__);
148 /* vim: set expandtab: */