cvs: smarty /libs Smarty.class.php Smarty_Compiler.class.php
"Messju Mohr" <[email protected]>
| Newsgroups | gmane.comp.php.cvs.smarty |
|---|---|
| Message-ID | <cvsmessju1059474577@cvsserver> |
messju Tue Jul 29 06:29:37 2003 EDT
Modified files:
/smarty/libs Smarty.class.php Smarty_Compiler.class.php
Log:
modifiers are resolved at compile-time now. _run_mod_handler() is
still used for modifiers with map_array=true (== no preceeding '@')
Index: smarty/libs/Smarty.class.php
diff -u smarty/libs/Smarty.class.php:1.425 smarty/libs/Smarty.class.php:1.426
--- smarty/libs/Smarty.class.php:1.425 Tue Jul 29 04:26:22 2003
+++ smarty/libs/Smarty.class.php Tue Jul 29 06:29:36 2003
@@ -42,7 +42,7 @@
* @version 2.5.0-cvs
*/
-/* $Id: Smarty.class.php,v 1.425 2003/07/29 08:26:22 messju Exp $ */
+/* $Id: Smarty.class.php,v 1.426 2003/07/29 10:29:36 messju Exp $ */
/**
* DIR_SEP isn't used anymore, but third party apps might
@@ -1752,17 +1752,12 @@
list($_modifier_name, $_map_array) = array_splice($_args, 0, 2);
list($_func_name, $_tpl_file, $_tpl_line) =
$this->_plugins['modifier'][$_modifier_name];
- $_var = $_args[0];
- if ($_map_array && is_array($_var)) {
- foreach ($_var as $_key => $_val) {
- $_args[0] = $_val;
- $_var[$_key] = call_user_func_array($_func_name, $_args);
- }
- return $_var;
- } else {
- return call_user_func_array($_func_name, $_args);
+ foreach ($_var as $_key => $_val) {
+ $_args[0] = $_val;
+ $_var[$_key] = call_user_func_array($_func_name, $_args);
}
+ return $_var;
}
/**
Index: smarty/libs/Smarty_Compiler.class.php
diff -u smarty/libs/Smarty_Compiler.class.php:1.266 smarty/libs/Smarty_Compiler.class.php:1.267
--- smarty/libs/Smarty_Compiler.class.php:1.266 Tue Jul 29 04:26:22 2003
+++ smarty/libs/Smarty_Compiler.class.php Tue Jul 29 06:29:36 2003
@@ -39,7 +39,7 @@
* @package Smarty
*/
-/* $Id: Smarty_Compiler.class.php,v 1.266 2003/07/29 08:26:22 messju Exp $ */
+/* $Id: Smarty_Compiler.class.php,v 1.267 2003/07/29 10:29:36 messju Exp $ */
/**
* Template compiling class
@@ -1767,13 +1767,30 @@
$_modifier_args = $_match[1];
if ($_modifier_name{0} == '@') {
- $_map_array = 'false';
+ $_map_array = false;
$_modifier_name = substr($_modifier_name, 1);
} else {
- $_map_array = 'true';
+ $_map_array = true;
}
-
- $this->_add_plugin('modifier', $_modifier_name);
+
+ if (isset($this->_plugins['modifier'][$_modifier_name])
+ || (isset($this->_plugin_info['modifier']) && isset($this->_plugin_info['modifier'][$_modifier_name]))) {
+ /* modifier is already known */
+ } elseif ($this->_get_plugin_filepath('modifier', $_modifier_name)) {
+ $this->_add_plugin('modifier', $_modifier_name);
+ } elseif (function_exists($_modifier_name)) {
+ if ($this->security && !in_array($_modifier_name, $this->security_settings['MODIFIER_FUNCS'])) {
+ $this->_trigger_fatal_error("[plugin] (secure mode) modifier '$_modifier_name' is not allowed" , $_tpl_file, $_tpl_line, __FILE__, __LINE__);
+ } else {
+ $this->_plugins['modifier'][$_modifier_name] = array($_modifier_name, null, null, false);
+ }
+ } else {
+ /* modifier not found */
+ $this->_syntax_error("[plugin] modifier '$_modifier_name' not found", E_USER_ERROR, __FILE__, __LINE__);
+ return;
+ }
+
+
$this->_parse_vars_props($_modifier_args);
if($_modifier_name == 'default') {
@@ -1790,7 +1807,14 @@
else
$_modifier_args = '';
- $output = "\$this->_run_mod_handler('$_modifier_name', $_map_array, $output$_modifier_args)";
+ if ($_map_array) {
+ $output = "((is_array(\$_tmp=$output)) ? \$this->_run_mod_handler('$_modifier_name', true, \$_tmp$_modifier_args) : " . $this->_compile_plugin_call('modifier', $_modifier_name) . "(\$_tmp$_modifier_args))";
+
+ } else {
+
+ $output = $this->_compile_plugin_call('modifier', $_modifier_name)."($output$_modifier_args)";
+
+ }
}
}
--
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php