00001 <?php
00014
00015
00016 function smarty_core_load_plugins($params, &$smarty)
00017 {
00018
00019 foreach ($params['plugins'] as $_plugin_info) {
00020 list($_type, $_name, $_tpl_file, $_tpl_line, $_delayed_loading) = $_plugin_info;
00021 $_plugin = &$smarty->_plugins[$_type][$_name];
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 if (isset($_plugin)) {
00034 if (empty($_plugin[3])) {
00035 if (!is_callable($_plugin[0])) {
00036 $smarty->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __LINE__);
00037 } else {
00038 $_plugin[1] = $_tpl_file;
00039 $_plugin[2] = $_tpl_line;
00040 $_plugin[3] = true;
00041 if (!isset($_plugin[4])) $_plugin[4] = true;
00042 }
00043 }
00044 continue;
00045 } else if ($_type == 'insert') {
00046
00047
00048
00049
00050 $_plugin_func = 'insert_' . $_name;
00051 if (function_exists($_plugin_func)) {
00052 $_plugin = array($_plugin_func, $_tpl_file, $_tpl_line, true, false);
00053 continue;
00054 }
00055 }
00056
00057 $_plugin_file = $smarty->_get_plugin_filepath($_type, $_name);
00058
00059 if (! $_found = ($_plugin_file != false)) {
00060 $_message = "could not load plugin file '$_type.$_name.php'\n";
00061 }
00062
00063
00064
00065
00066
00067
00068 if ($_found) {
00069 include_once $_plugin_file;
00070
00071 $_plugin_func = 'smarty_' . $_type . '_' . $_name;
00072 if (!function_exists($_plugin_func)) {
00073 $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__);
00074 continue;
00075 }
00076 }
00077
00078
00079
00080
00081 else if ($_type == 'insert' && $_delayed_loading) {
00082 $_plugin_func = 'smarty_' . $_type . '_' . $_name;
00083 $_found = true;
00084 }
00085
00086
00087
00088
00089 if (!$_found) {
00090 if ($_type == 'modifier') {
00091
00092
00093
00094
00095
00096 if ($smarty->security && !in_array($_name, $smarty->security_settings['MODIFIER_FUNCS'])) {
00097 $_message = "(secure mode) modifier '$_name' is not allowed";
00098 } else {
00099 if (!function_exists($_name)) {
00100 $_message = "modifier '$_name' is not implemented";
00101 } else {
00102 $_plugin_func = $_name;
00103 $_found = true;
00104 }
00105 }
00106 } else if ($_type == 'function') {
00107
00108
00109
00110 $_message = "unknown tag - '$_name'";
00111 }
00112 }
00113
00114 if ($_found) {
00115 $smarty->_plugins[$_type][$_name] = array($_plugin_func, $_tpl_file, $_tpl_line, true, true);
00116 } else {
00117
00118 $smarty->_trigger_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__);
00119 }
00120 }
00121 }
00122
00123
00124
00125 ?>