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