mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
enabled registration of class-methods as callbacks for the
register_*-functions use: array('classname', 'method_name')) as callback
This commit is contained in:
2
NEWS
2
NEWS
@@ -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 filepath caching (Monte)
|
||||||
- added optional assign-attribute to {capture}-tag (messju)
|
- added optional assign-attribute to {capture}-tag (messju)
|
||||||
- added $cacheable-parameter to register_compiler_function() (messju)
|
- added $cacheable-parameter to register_compiler_function() (messju)
|
||||||
|
@@ -855,11 +855,11 @@ class Smarty
|
|||||||
*/
|
*/
|
||||||
function register_resource($type, $functions)
|
function register_resource($type, $functions)
|
||||||
{
|
{
|
||||||
if (sizeof($functions)<5) {
|
if (count($functions)==4) {
|
||||||
$this->_plugins['resource'][$type] =
|
$this->_plugins['resource'][$type] =
|
||||||
array($functions, false);
|
array($functions, false);
|
||||||
|
|
||||||
} elseif (sizeof($functions)==5 && is_object($functions[0])) {
|
} elseif (count($functions)==5) {
|
||||||
$this->_plugins['resource'][$type] =
|
$this->_plugins['resource'][$type] =
|
||||||
array(array(array(&$functions[0], $functions[1])
|
array(array(array(&$functions[0], $functions[1])
|
||||||
,array(&$functions[0], $functions[2])
|
,array(&$functions[0], $functions[2])
|
||||||
@@ -1608,10 +1608,9 @@ class Smarty
|
|||||||
|
|
||||||
function _fetch_resource_info(&$params)
|
function _fetch_resource_info(&$params)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!isset($params['get_source'])) { $params['get_source'] = true; }
|
if(!isset($params['get_source'])) { $params['get_source'] = true; }
|
||||||
if(!isset($params['quiet'])) { $params['quiet'] = false; }
|
if(!isset($params['quiet'])) { $params['quiet'] = false; }
|
||||||
|
|
||||||
$_return = false;
|
$_return = false;
|
||||||
$_params = array('resource_name' => $params['resource_name']) ;
|
$_params = array('resource_name' => $params['resource_name']) ;
|
||||||
if ($this->_parse_resource_name($_params)) {
|
if ($this->_parse_resource_name($_params)) {
|
||||||
@@ -1917,7 +1916,7 @@ class Smarty
|
|||||||
function _plugin_implementation_exists($function)
|
function _plugin_implementation_exists($function)
|
||||||
{
|
{
|
||||||
return (is_array($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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1961,9 +1961,11 @@ class Smarty_Compiler extends Smarty {
|
|||||||
if (isset($this->_plugins[$type][$name])) {
|
if (isset($this->_plugins[$type][$name])) {
|
||||||
/* plugin loaded */
|
/* plugin loaded */
|
||||||
if (is_array($this->_plugins[$type][$name][0])) {
|
if (is_array($this->_plugins[$type][$name][0])) {
|
||||||
/* method callback */
|
return ((is_object($this->_plugins[$type][$name][0][0])) ?
|
||||||
return "\$this->_plugins['$type']['$name'][0][0]->".$this->_plugins[$type][$name][0][1];
|
"\$this->_plugins['$type']['$name'][0][0]->" /* method callback */
|
||||||
|
: (string)($this->_plugins[$type][$name][0][0]).'::' /* class callback */
|
||||||
|
). $this->_plugins[$type][$name][0][1];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* function callback */
|
/* function callback */
|
||||||
return $this->_plugins[$type][$name][0];
|
return $this->_plugins[$type][$name][0];
|
||||||
|
Reference in New Issue
Block a user