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

From: Date: Mon, 28 Apr 2003 00:22:41 +0000
Subject: cvs: smarty / NEWS /libs Smarty.class.php
Groups: php.smarty.cvs 
Request: Send a blank email to php-smarty-cvs+get-569@lists.php.net to get a copy of this message
messju Sun Apr 27 20:22:41 2003 EDT Modified files: /smarty NEWS /smarty/libs Smarty.class.php Log: enabled array(&$obj. 'source', 'timestamp', 'secure', 'trusted') as callback for register_resource() enabled array(&$obj, 'method') as callback for $default_template_handler_func Index: smarty/NEWS diff -u smarty/NEWS:1.353 smarty/NEWS:1.354 --- smarty/NEWS:1.353 Sun Apr 27 14:04:33 2003 +++ smarty/NEWS Sun Apr 27 20:22:40 2003 @@ -1,3 +1,7 @@ + - enabled array(&$obj. 'source', 'timestamp', 'secure', 'trusted') + as callback for register_resource() (messju); + - enabled array(&$obj, 'method') as callback for + $default_template_handler_func (messju) - made plugin-names case-insensitive. this affects compiler/block/custom- functions and modifers. (messju) - remove unnecessary close/open tags from compiled templates Index: smarty/libs/Smarty.class.php diff -u smarty/libs/Smarty.class.php:1.384 smarty/libs/Smarty.class.php:1.385 --- smarty/libs/Smarty.class.php:1.384 Sun Apr 27 14:10:02 2003 +++ smarty/libs/Smarty.class.php Sun Apr 27 20:22:41 2003 @@ -42,7 +42,7 @@ * @version 2.5.0 */ -/* $Id: Smarty.class.php,v 1.384 2003/04/27 18:10:02 messju Exp $ */ +/* $Id: Smarty.class.php,v 1.385 2003/04/28 00:22:41 messju Exp $ */ /** * set SMARTY_DIR to absolute path to Smarty library files. @@ -798,8 +798,22 @@ */ function register_resource($type, $functions) { - $this->_plugins['resource'][$type] = - array((array)$functions, false); + if (sizeof($functions)==4) { + $this->_plugins['resource'][$type] = + array($functions, false); + + } elseif (sizeof($functions)==5 && is_object($functions[0])) { + $this->_plugins['resource'][$type] = + array(array(array(&$functions[0], $functions[1]) + ,array(&$functions[0], $functions[2]) + ,array(&$functions[0], $functions[3]) + ,array(&$functions[0], $functions[4])) + ,false); + + } else { + $this->trigger_error("malformed function-list for '$type' in register_resource"); + + } } /** @@ -1338,8 +1352,8 @@ } } else { // resource is not on local file system - $resource_func = $this->_plugins['resource'][$resource_type][0][3]; - $_smarty_trusted = $resource_func($resource_name, $this); + $_smarty_trusted = call_user_func_array($this->_plugins['resource'][$resource_type][0][3], + array($resource_name, $this)); } return $_smarty_trusted; @@ -1373,8 +1387,9 @@ } } else { // resource is not on local file system - $resource_func = $this->_plugins['resource'][$resource_type][0][2]; - $_smarty_secure = $resource_func($resource_name, $_smarty_secure, $this); + $_smarty_secure = call_user_func_array( + $this->_plugins['resource'][$resource_type][0][2], + array($resource_name, &$_smarty_secure, &$this)); } return $_smarty_secure; @@ -1593,16 +1608,20 @@ $_return = true; break; - default: + default: // call resource functions to fetch the template source and timestamp if ($get_source) { - $resource_func = $this->_plugins['resource'][$resource_type][0][0]; - $_source_return = $resource_func($resource_name, $template_source, $this); + $_source_return = isset($this->_plugins['resource'][$resource_type]) && + call_user_func_array($this->_plugins['resource'][$resource_type][0][0], + array($resource_name, &$template_source, &$this)); } else { $_source_return = true; } - $resource_func = $this->_plugins['resource'][$resource_type][0][1]; - $_timestamp_return = $resource_func($resource_name, $template_timestamp, $this); + + $_timestamp_return = isset($this->_plugins['resource'][$resource_type]) && + call_user_func_array($this->_plugins['resource'][$resource_type][0][1], + array($resource_name, &$template_timestamp, &$this)); + $_return = $_source_return && $_timestamp_return; break; } @@ -1611,11 +1630,12 @@ if (!$_return) { // see if we can get a template with the default template handler if (!empty($this->default_template_handler_func)) { - if (!function_exists($this->default_template_handler_func)) { + if (!$this->_plugin_implementation_exists($this->default_template_handler_func)) { $this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist."); } else { - $funcname = $this->default_template_handler_func; - $_return = $funcname($resource_type, $resource_name, $template_source, $template_timestamp, $this); + $_return = call_user_func_array( + $this->default_template_handler_func, + array($resource_type, $resource_name, &$template_source, &$template_timestamp, &$this)); } } } @@ -2523,8 +2543,8 @@ if (isset($plugin)) { if (!$plugin[1] && count($plugin[0])) { $plugin[1] = true; - foreach ($plugin[0] as $plugin_func) { - if (!function_exists($plugin_func)) { + foreach ($plugin[0] as $plugin_func) { + if (!$this->_plugin_implementation_exists($plugin_func)) { $plugin[1] = false; break; }

« previous php.smarty.cvs (#569) next »