mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-07 11:54:26 +02:00
- code optimization
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Smarty Template Compiler Base
|
||||
*
|
||||
* This file contains the basic classes and methodes for compiling Smarty templates with lexer/parser
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
* Smarty Internal Plugin Smarty Template Compiler Base
|
||||
*
|
||||
* This file contains the basic classes and methodes for compiling Smarty templates with lexer/parser
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Main compiler class
|
||||
*/
|
||||
* Main compiler class
|
||||
*/
|
||||
class Smarty_Internal_TemplateCompilerBase {
|
||||
// hash for nocache sections
|
||||
private $nocache_hash = null;
|
||||
@@ -176,16 +176,15 @@ class Smarty_Internal_TemplateCompilerBase {
|
||||
if ($plugin_type == 'compiler' && $this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
|
||||
$plugin = 'smarty_compiler_' . $tag;
|
||||
if (is_callable($plugin)) {
|
||||
return call_user_func_array($plugin, array($args, $this->smarty));
|
||||
return $plugin($args, $this->smarty);
|
||||
}
|
||||
if (class_exists($plugin, false)) {
|
||||
$plugin = array(new $plugin, 'compile');
|
||||
$plugin_object = new $plugin;
|
||||
if (method_exists($plugin_object, 'compile')) {
|
||||
return $plugin_object->compile($args, $this);
|
||||
}
|
||||
}
|
||||
if (is_callable($plugin)) {
|
||||
return call_user_func_array($plugin, array($args, $this));
|
||||
} else {
|
||||
throw new Exception("Plugin \"{$tag}\" not callable");
|
||||
}
|
||||
} else {
|
||||
if ($function = $this->getPlugin($tag, $plugin_type)) {
|
||||
return $this->callTagCompiler('private_' . $plugin_type . '_plugin', $args, $tag, $function);
|
||||
@@ -216,18 +215,17 @@ class Smarty_Internal_TemplateCompilerBase {
|
||||
if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
|
||||
$plugin = 'smarty_compiler_' . $tag;
|
||||
if (is_callable($plugin)) {
|
||||
return call_user_func_array($plugin, array($args, $this->smarty));
|
||||
return $plugin($args, $this->smarty);
|
||||
}
|
||||
if (class_exists($plugin, false)) {
|
||||
$plugin = array(new $plugin, 'compile');
|
||||
$plugin_object = new $plugin;
|
||||
if (method_exists($plugin_object, 'compile')) {
|
||||
return $plugin_object->compile($args, $this);
|
||||
}
|
||||
}
|
||||
if (is_callable($plugin)) {
|
||||
return call_user_func_array($plugin, array($args, $this));
|
||||
} else {
|
||||
throw new Exception("Plugin \"{$tag}\" not callable");
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->trigger_template_error ("unknown tag \"" . $tag . "\"", $this->lex->taglineno);
|
||||
}
|
||||
}
|
||||
@@ -251,7 +249,7 @@ class Smarty_Internal_TemplateCompilerBase {
|
||||
// re-use object if already exists
|
||||
if (isset(self::$_tag_objects[$tag])) {
|
||||
// compile this tag
|
||||
return call_user_func(array(self::$_tag_objects[$tag], 'compile'), $args, $this, $param1, $param2, $param3);
|
||||
return self::$_tag_objects[$tag]->compile($args, $this, $param1, $param2, $param3);
|
||||
}
|
||||
// lazy load internal compiler plugin
|
||||
$class_name = 'Smarty_Internal_Compile_' . $tag;
|
||||
@@ -259,7 +257,7 @@ class Smarty_Internal_TemplateCompilerBase {
|
||||
// use plugin if found
|
||||
self::$_tag_objects[$tag] = new $class_name;
|
||||
// compile this tag
|
||||
return call_user_func(array(self::$_tag_objects[$tag], 'compile'), $args, $this, $param1, $param2, $param3);
|
||||
return self::$_tag_objects[$tag]->compile($args, $this, $param1, $param2, $param3);
|
||||
}
|
||||
// no internal compile plugin for this tag
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user