cvs: smarty / NEWS /libs Smarty.class.php Smarty_Compiler.class.php

"Messju Mohr" <[email protected]>
Newsgroups gmane.comp.php.cvs.smarty
Message-ID <cvsmessju1059659488@cvsserver>
messju		Thu Jul 31 09:51:28 2003 EDT

  Modified files:              
    /smarty	NEWS 
    /smarty/libs	Smarty.class.php Smarty_Compiler.class.php 
  Log:
  enabled registration of class-methods as callbacks for the
  register_*-functions
  
  use: array('classname', 'method_name')) as callback
  
  
  
Index: smarty/NEWS
diff -u smarty/NEWS:1.384 smarty/NEWS:1.385
--- smarty/NEWS:1.384	Sat Jun 21 13:35:15 2003
+++ smarty/NEWS	Thu Jul 31 09:51:28 2003
@@ -1,3 +1,5 @@
+  - enabled registration of class-methods as callbacks for the register_*-
+    functions (use: array('classname', 'method_name')) as callback) (messju)
   - added filepath caching (Monte)
   - added optional assign-attribute to {capture}-tag (messju)
   - added $cacheable-parameter to register_compiler_function() (messju)
Index: smarty/libs/Smarty.class.php
diff -u smarty/libs/Smarty.class.php:1.426 smarty/libs/Smarty.class.php:1.427
--- smarty/libs/Smarty.class.php:1.426	Tue Jul 29 06:29:36 2003
+++ smarty/libs/Smarty.class.php	Thu Jul 31 09:51:28 2003
@@ -42,7 +42,7 @@
  * @version 2.5.0-cvs
  */
 
-/* $Id: Smarty.class.php,v 1.426 2003/07/29 10:29:36 messju Exp $ */
+/* $Id: Smarty.class.php,v 1.427 2003/07/31 13:51:28 messju Exp $ */
 
 /**
  * DIR_SEP isn't used anymore, but third party apps might
@@ -855,11 +855,11 @@
      */    
     function register_resource($type, $functions)
     {
-        if (sizeof($functions)<5) {
+        if (count($functions)==4) {
             $this->_plugins['resource'][$type] =
                 array($functions, false);
 
-        } elseif (sizeof($functions)==5 && is_object($functions[0])) {
+        } elseif (count($functions)==5) {
             $this->_plugins['resource'][$type] =
                 array(array(array(&$functions[0], $functions[1])
                             ,array(&$functions[0], $functions[2])
@@ -1608,10 +1608,9 @@
 
     function _fetch_resource_info(&$params)
     {
-			
         if(!isset($params['get_source'])) { $params['get_source'] = true; }
         if(!isset($params['quiet'])) { $params['quiet'] = false; }
-	
+
         $_return = false;
         $_params = array('resource_name' => $params['resource_name']) ;
         if ($this->_parse_resource_name($_params)) {
@@ -1917,7 +1916,7 @@
     function _plugin_implementation_exists($function)
     {
         return (is_array($function)) ?
-            method_exists($function[0], $function[1]) : function_exists($function);
+            method_exists($function[0], $function[1]) || (in_array(strtolower($function[1]), (array)get_class_methods($function[0]))) : function_exists($function);
     }
 
 
Index: smarty/libs/Smarty_Compiler.class.php
diff -u smarty/libs/Smarty_Compiler.class.php:1.267 smarty/libs/Smarty_Compiler.class.php:1.268
--- smarty/libs/Smarty_Compiler.class.php:1.267	Tue Jul 29 06:29:36 2003
+++ smarty/libs/Smarty_Compiler.class.php	Thu Jul 31 09:51:28 2003
@@ -39,7 +39,7 @@
  * @package Smarty
  */
 
-/* $Id: Smarty_Compiler.class.php,v 1.267 2003/07/29 10:29:36 messju Exp $ */
+/* $Id: Smarty_Compiler.class.php,v 1.268 2003/07/31 13:51:28 messju Exp $ */
 
 /**
  * Template compiling class
@@ -1961,9 +1961,11 @@
         if (isset($this->_plugins[$type][$name])) {
             /* plugin loaded */
             if (is_array($this->_plugins[$type][$name][0])) {
-                /* method callback */
-                return "\$this->_plugins['$type']['$name'][0][0]->".$this->_plugins[$type][$name][0][1];
-                
+                return ((is_object($this->_plugins[$type][$name][0][0])) ? 
+                        "\$this->_plugins['$type']['$name'][0][0]->"    /* method callback */
+                        : (string)($this->_plugins[$type][$name][0][0]).'::'    /* class callback */
+                       ). $this->_plugins[$type][$name][0][1];
+
             } else {
                 /* function callback */
                 return $this->_plugins[$type][$name][0];



-- 
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.