mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 03:14:27 +02:00
09.06.2012
- bugfix the compiler did ignore registered compiler plugins for closing tags (Forum Topic 22094)
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
===== trunk =====
|
||||
09.06.2012
|
||||
- bugfix the compiler did ignore registered compiler plugins for closing tags (Forum Topic 22094)
|
||||
|
||||
===== Smarty-3.1.9 =====
|
||||
07.06.2012
|
||||
- bugfix fetch() and display() with relative paths (Issue 104)
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Smarty Template Compiler Base
|
||||
*
|
||||
@@ -23,95 +24,112 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
||||
* @var mixed
|
||||
*/
|
||||
private $nocache_hash = null;
|
||||
|
||||
/**
|
||||
* suppress generation of nocache code
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $suppressNocacheProcessing = false;
|
||||
|
||||
/**
|
||||
* suppress generation of merged template code
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $suppressMergedTemplates = false;
|
||||
|
||||
/**
|
||||
* compile tag objects
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $_tag_objects = array();
|
||||
|
||||
/**
|
||||
* tag stack
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_tag_stack = array();
|
||||
|
||||
/**
|
||||
* current template
|
||||
*
|
||||
* @var Smarty_Internal_Template
|
||||
*/
|
||||
public $template = null;
|
||||
|
||||
/**
|
||||
* merged templates
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $merged_templates = array();
|
||||
|
||||
/**
|
||||
* flag when compiling {block}
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $inheritance = false;
|
||||
|
||||
/**
|
||||
* plugins loaded by default plugin handler
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $default_handler_plugins = array();
|
||||
|
||||
/**
|
||||
* saved preprocessed modifier list
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $default_modifier_list = null;
|
||||
|
||||
/**
|
||||
* force compilation of complete template as nocache
|
||||
* @var boolean
|
||||
*/
|
||||
public $forceNocache = false;
|
||||
|
||||
/**
|
||||
* suppress Smarty header code in compiled template
|
||||
* @var bool
|
||||
*/
|
||||
public $suppressHeader = false;
|
||||
|
||||
/**
|
||||
* suppress template property header code in compiled template
|
||||
* @var bool
|
||||
*/
|
||||
public $suppressTemplatePropertyHeader = false;
|
||||
|
||||
/**
|
||||
* flag if compiled template file shall we written
|
||||
* @var bool
|
||||
*/
|
||||
public $write_compiled_code = true;
|
||||
|
||||
/**
|
||||
* flag if currently a template function is compiled
|
||||
* @var bool
|
||||
*/
|
||||
public $compiles_template_function = false;
|
||||
|
||||
/**
|
||||
* called subfuntions from template function
|
||||
* @var array
|
||||
*/
|
||||
public $called_functions = array();
|
||||
|
||||
/**
|
||||
* flags for used modifier plugins
|
||||
* @var array
|
||||
*/
|
||||
public $modifier_plugins = array();
|
||||
|
||||
/**
|
||||
* type of already compiled modifier
|
||||
* @var array
|
||||
@@ -121,8 +139,7 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
||||
/**
|
||||
* Initialize compiler
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
$this->nocache_hash = str_replace('.', '-', uniqid(rand(), true));
|
||||
}
|
||||
|
||||
@@ -132,8 +149,7 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
||||
* @param Smarty_Internal_Template $template template object to compile
|
||||
* @return bool true if compiling succeeded, false if it failed
|
||||
*/
|
||||
public function compileTemplate(Smarty_Internal_Template $template)
|
||||
{
|
||||
public function compileTemplate(Smarty_Internal_Template $template) {
|
||||
if (empty($template->properties['nocache_hash'])) {
|
||||
$template->properties['nocache_hash'] = $this->nocache_hash;
|
||||
} else {
|
||||
@@ -213,8 +229,7 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compileTag($tag, $args, $parameter = array())
|
||||
{
|
||||
public function compileTag($tag, $args, $parameter = array()) {
|
||||
// $args contains the attributes parsed and compiled by the lexer/parser
|
||||
// assume that tag does compile into code, but creates no HTML output
|
||||
$this->has_code = true;
|
||||
@@ -302,7 +317,6 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
||||
if ($plugin_type == Smarty::PLUGIN_FUNCTION || $plugin_type == Smarty::PLUGIN_BLOCK) {
|
||||
return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter, $tag);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// check plugins from plugins folder
|
||||
@@ -394,6 +408,22 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
||||
if ($function = $this->getPlugin($base_tag, Smarty::PLUGIN_BLOCK)) {
|
||||
return $this->callTagCompiler('private_block_plugin', $args, $parameter, $tag, $function);
|
||||
}
|
||||
// registered compiler plugin ?
|
||||
if (isset($this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag])) {
|
||||
// if compiler function plugin call it now
|
||||
$args = array();
|
||||
if (!$this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag][1]) {
|
||||
$this->tag_nocache = true;
|
||||
}
|
||||
$function = $this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag][0];
|
||||
if (!is_array($function)) {
|
||||
return $function($args, $this);
|
||||
} else if (is_object($function[0])) {
|
||||
return $this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag][0][0]->$function[1]($args, $this);
|
||||
} else {
|
||||
return call_user_func_array($function, array($args, $this));
|
||||
}
|
||||
}
|
||||
if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
|
||||
$plugin = 'smarty_compiler_' . $tag;
|
||||
if (is_callable($plugin)) {
|
||||
@@ -426,8 +456,7 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
||||
* @param mixed $param3 optional parameter
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null)
|
||||
{
|
||||
public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null) {
|
||||
// re-use object if already exists
|
||||
if (isset(self::$_tag_objects[$tag])) {
|
||||
// compile this tag
|
||||
@@ -455,8 +484,7 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
||||
* @param string $plugin_type type of plugin
|
||||
* @return string call name of function
|
||||
*/
|
||||
public function getPlugin($plugin_name, $plugin_type)
|
||||
{
|
||||
public function getPlugin($plugin_name, $plugin_type) {
|
||||
$function = null;
|
||||
if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
|
||||
if (isset($this->template->required_plugins['nocache'][$plugin_name][$plugin_type])) {
|
||||
@@ -510,14 +538,12 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
||||
* @param string $plugin_type type of plugin
|
||||
* @return boolean true if found
|
||||
*/
|
||||
public function getPluginFromDefaultHandler($tag, $plugin_type)
|
||||
{
|
||||
public function getPluginFromDefaultHandler($tag, $plugin_type) {
|
||||
$callback = null;
|
||||
$script = null;
|
||||
$cacheable = true;
|
||||
$result = call_user_func_array(
|
||||
$this->smarty->default_plugin_handler_func,
|
||||
array($tag, $plugin_type, $this->template, &$callback, &$script, &$cacheable)
|
||||
$this->smarty->default_plugin_handler_func, array($tag, $plugin_type, $this->template, &$callback, &$script, &$cacheable)
|
||||
);
|
||||
if ($result) {
|
||||
$this->tag_nocache = $this->tag_nocache || !$cacheable;
|
||||
@@ -559,8 +585,7 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
||||
* @param boolean $is_code true if content is compiled code
|
||||
* @return string content
|
||||
*/
|
||||
public function processNocacheCode($content, $is_code)
|
||||
{
|
||||
public function processNocacheCode($content, $is_code) {
|
||||
// If the template is not evaluated and we have a nocache section and or a nocache tag
|
||||
if ($is_code && !empty($content)) {
|
||||
// generate replacement code
|
||||
@@ -601,8 +626,7 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
||||
* @param string $line line-number
|
||||
* @throws SmartyCompilerException when an unexpected token is found
|
||||
*/
|
||||
public function trigger_template_error($args = null, $line = null)
|
||||
{
|
||||
public function trigger_template_error($args = null, $line = null) {
|
||||
// get template source line which has error
|
||||
if (!isset($line)) {
|
||||
$line = $this->lex->line;
|
||||
|
Reference in New Issue
Block a user