cvs: smarty / NEWS /libs Smarty.class.php
[email protected] ("Danilo Buerger") Mon, 18 Jun 2007 14:29:00 -0000
| Newsgroups | php.smarty.cvs |
|---|---|
| Message-ID | <cvsdanilo1182176940@cvsserver> |
danilo Mon Jun 18 14:29:00 2007 UTC
Modified files:
/smarty/libs Smarty.class.php
/smarty NEWS
Log:
Added the ability to (un)register multiple filters of the same type with the same method name but different class name. Before it was not possible due to the fact that only the method name was used to distinguish between different filters of the same type. This does however not allow (same as before) to register multiple filters of the same type with the same method and class name (i.e. different instances of the same class).
http://cvs.php.net/viewvc.cgi/smarty/libs/Smarty.class.php?r1=1.529&r2=1.530&diff_format=u
Index: smarty/libs/Smarty.class.php
diff -u smarty/libs/Smarty.class.php:1.529 smarty/libs/Smarty.class.php:1.530
--- smarty/libs/Smarty.class.php:1.529 Thu Mar 8 19:11:22 2007
+++ smarty/libs/Smarty.class.php Mon Jun 18 14:29:00 2007
@@ -30,7 +30,7 @@
* @version 2.6.19-dev
*/
-/* $Id: Smarty.class.php,v 1.529 2007/03/08 19:11:22 mohrt Exp $ */
+/* $Id: Smarty.class.php,v 1.530 2007/06/18 14:29:00 danilo Exp $ */
/**
* DIR_SEP isn't used anymore, but third party apps might
@@ -838,69 +838,66 @@
* Registers a prefilter function to apply
* to a template before compiling
*
- * @param string $function name of PHP function to register
+ * @param callback $function
*/
function register_prefilter($function)
{
- $_name = (is_array($function)) ? $function[1] : $function;
- $this->_plugins['prefilter'][$_name]
+ $this->_plugins['prefilter'][$this->_get_filter_name($function)]
= array($function, null, null, false);
}
/**
* Unregisters a prefilter function
*
- * @param string $function name of PHP function
+ * @param callback $function
*/
function unregister_prefilter($function)
{
- unset($this->_plugins['prefilter'][$function]);
+ unset($this->_plugins['prefilter'][$this->_get_filter_name($function)]);
}
/**
* Registers a postfilter function to apply
* to a compiled template after compilation
*
- * @param string $function name of PHP function to register
+ * @param callback $function
*/
function register_postfilter($function)
{
- $_name = (is_array($function)) ? $function[1] : $function;
- $this->_plugins['postfilter'][$_name]
+ $this->_plugins['postfilter'][$this->_get_filter_name($function)]
= array($function, null, null, false);
}
/**
* Unregisters a postfilter function
*
- * @param string $function name of PHP function
+ * @param callback $function
*/
function unregister_postfilter($function)
{
- unset($this->_plugins['postfilter'][$function]);
+ unset($this->_plugins['postfilter'][$this->_get_filter_name($function)]);
}
/**
* Registers an output filter function to apply
* to a template output
*
- * @param string $function name of PHP function
+ * @param callback $function
*/
function register_outputfilter($function)
{
- $_name = (is_array($function)) ? $function[1] : $function;
- $this->_plugins['outputfilter'][$_name]
+ $this->_plugins['outputfilter'][$this->_get_filter_name($function)]
= array($function, null, null, false);
}
/**
* Unregisters an outputfilter function
*
- * @param string $function name of PHP function
+ * @param callback $function
*/
function unregister_outputfilter($function)
{
- unset($this->_plugins['outputfilter'][$function]);
+ unset($this->_plugins['outputfilter'][$this->_get_filter_name($function)]);
}
/**
@@ -1935,6 +1932,25 @@
{
return eval($code);
}
+
+ /**
+ * Extracts the filter name from the given callback
+ *
+ * @param callback $function
+ * @return string
+ */
+ function _get_filter_name($function)
+ {
+ if (is_array($function)) {
+ $_class_name = (is_object($function[0]) ?
+ get_class($function[0]) : $function[0]);
+ return $_class_name . '_' . $function[1];
+ }
+ else {
+ return $function;
+ }
+ }
+
/**#@-*/
}
http://cvs.php.net/viewvc.cgi/smarty/NEWS?r1=1.556&r2=1.557&diff_format=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.556 smarty/NEWS:1.557
--- smarty/NEWS:1.556 Fri May 11 13:45:36 2007
+++ smarty/NEWS Mon Jun 18 14:29:00 2007
@@ -1,5 +1,11 @@
+- fix when (un)registering filters with the same method name but different class
+ name (danilo)
- fix calling registered objects' methods with an empty argument list
(marcello, messju)
+
+Version 2.6.18 (Mar 7th, 2007)
+------------------------------
+
- fix html_select_date separator when parts are missing (hayk,
monte)
- fix broken detection of non-cached blocks introduced in 2.6.17