- code optimization

This commit is contained in:
Uwe.Tews
2010-02-27 23:28:14 +00:00
parent 3898f593f4
commit ed2458e9ae

View File

@@ -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;