mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-02 17:34:26 +02:00
WIP making compile classes PSR-4
This commit is contained in:
@@ -29,7 +29,7 @@ class Append extends Assign
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// the following must be assigned at runtime because it will be overwritten in parent class
|
||||
$this->required_attributes = array('var', 'value');
|
||||
|
@@ -26,7 +26,7 @@ class Assign extends CompileBase
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $option_flags = array('nocache', 'noscope');
|
||||
|
||||
@@ -51,7 +51,7 @@ class Assign extends CompileBase
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// the following must be assigned at runtime because it will be overwritten in Append
|
||||
$this->required_attributes = array('var', 'value');
|
||||
|
212
src/Compile/Base.php
Normal file
212
src/Compile/Base.php
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin CompileBase
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
namespace Smarty\Compile;
|
||||
/**
|
||||
* This class does extend all internal compile plugins
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
abstract class Base {
|
||||
|
||||
/**
|
||||
* Array of names of required attribute required by tag
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $required_attributes = [];
|
||||
|
||||
/**
|
||||
* Array of names of optional attribute required by tag
|
||||
* use array('_any') if there is no restriction of attributes names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $optional_attributes = [];
|
||||
|
||||
/**
|
||||
* Shorttag attribute order defined by its names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $shorttag_order = [];
|
||||
|
||||
/**
|
||||
* Array of names of valid option flags
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $option_flags = ['nocache'];
|
||||
|
||||
/**
|
||||
* Mapping array for boolean option value
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $optionMap = [1 => true, 0 => false, 'true' => true, 'false' => false];
|
||||
|
||||
/**
|
||||
* Mapping array with attributes as key
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $mapCache = [];
|
||||
|
||||
/**
|
||||
* This function checks if the attributes passed are valid
|
||||
* The attributes passed for the tag to compile are checked against the list of required and
|
||||
* optional attributes. Required attributes must be present. Optional attributes are check against
|
||||
* the corresponding list. The keyword '_any' specifies that any attribute will be accepted
|
||||
* as valid
|
||||
*
|
||||
* @param object $compiler compiler object
|
||||
* @param array $attributes attributes applied to the tag
|
||||
*
|
||||
* @return array of mapped attributes for further processing
|
||||
*/
|
||||
protected function getAttributes($compiler, $attributes) {
|
||||
$_indexed_attr = [];
|
||||
if (!isset($this->mapCache['option'])) {
|
||||
$this->mapCache['option'] = array_fill_keys($this->option_flags, true);
|
||||
}
|
||||
foreach ($attributes as $key => $mixed) {
|
||||
// shorthand ?
|
||||
if (!is_array($mixed)) {
|
||||
// option flag ?
|
||||
if (isset($this->mapCache['option'][trim($mixed, '\'"')])) {
|
||||
$_indexed_attr[trim($mixed, '\'"')] = true;
|
||||
// shorthand attribute ?
|
||||
} elseif (isset($this->shorttag_order[$key])) {
|
||||
$_indexed_attr[$this->shorttag_order[$key]] = $mixed;
|
||||
} else {
|
||||
// too many shorthands
|
||||
$compiler->trigger_template_error('too many shorthand attributes', null, true);
|
||||
}
|
||||
// named attribute
|
||||
} else {
|
||||
foreach ($mixed as $k => $v) {
|
||||
// option flag?
|
||||
if (isset($this->mapCache['option'][$k])) {
|
||||
if (is_bool($v)) {
|
||||
$_indexed_attr[$k] = $v;
|
||||
} else {
|
||||
if (is_string($v)) {
|
||||
$v = trim($v, '\'" ');
|
||||
}
|
||||
if (isset($this->optionMap[$v])) {
|
||||
$_indexed_attr[$k] = $this->optionMap[$v];
|
||||
} else {
|
||||
$compiler->trigger_template_error(
|
||||
"illegal value '" . var_export($v, true) .
|
||||
"' for option flag '{$k}'",
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
// must be named attribute
|
||||
} else {
|
||||
$_indexed_attr[$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if all required attributes present
|
||||
foreach ($this->required_attributes as $attr) {
|
||||
if (!isset($_indexed_attr[$attr])) {
|
||||
$compiler->trigger_template_error("missing '{$attr}' attribute", null, true);
|
||||
}
|
||||
}
|
||||
// check for not allowed attributes
|
||||
if ($this->optional_attributes !== ['_any']) {
|
||||
if (!isset($this->mapCache['all'])) {
|
||||
$this->mapCache['all'] =
|
||||
array_fill_keys(
|
||||
array_merge(
|
||||
$this->required_attributes,
|
||||
$this->optional_attributes,
|
||||
$this->option_flags
|
||||
),
|
||||
true
|
||||
);
|
||||
}
|
||||
foreach ($_indexed_attr as $key => $dummy) {
|
||||
if (!isset($this->mapCache['all'][$key]) && $key !== 0) {
|
||||
$compiler->trigger_template_error("unexpected '{$key}' attribute", null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
// default 'false' for all option flags not set
|
||||
foreach ($this->option_flags as $flag) {
|
||||
if (!isset($_indexed_attr[$flag])) {
|
||||
$_indexed_attr[$flag] = false;
|
||||
}
|
||||
}
|
||||
if (isset($_indexed_attr['nocache']) && $_indexed_attr['nocache']) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
return $_indexed_attr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push opening tag name on stack
|
||||
* Optionally additional data can be saved on stack
|
||||
*
|
||||
* @param object $compiler compiler object
|
||||
* @param string $openTag the opening tag's name
|
||||
* @param mixed $data optional data saved
|
||||
*/
|
||||
protected function openTag($compiler, $openTag, $data = null) {
|
||||
array_push($compiler->_tag_stack, [$openTag, $data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop closing tag
|
||||
* Raise an error if this stack-top doesn't match with expected opening tags
|
||||
*
|
||||
* @param object $compiler compiler object
|
||||
* @param array|string $expectedTag the expected opening tag names
|
||||
*
|
||||
* @return mixed any type the opening tag's name or saved data
|
||||
*/
|
||||
protected function closeTag($compiler, $expectedTag) {
|
||||
if (count($compiler->_tag_stack) > 0) {
|
||||
// get stacked info
|
||||
[$_openTag, $_data] = array_pop($compiler->_tag_stack);
|
||||
// open tag must match with the expected ones
|
||||
if (in_array($_openTag, (array)$expectedTag)) {
|
||||
if (is_null($_data)) {
|
||||
// return opening tag
|
||||
return $_openTag;
|
||||
} else {
|
||||
// return restored data
|
||||
return $_data;
|
||||
}
|
||||
}
|
||||
// wrong nesting of tags
|
||||
$compiler->trigger_template_error("unclosed '{$compiler->smarty->left_delimiter}{$_openTag}{$compiler->smarty->right_delimiter}' tag");
|
||||
return;
|
||||
}
|
||||
// wrong nesting of tags
|
||||
$compiler->trigger_template_error('unexpected closing tag', null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles code for the tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
abstract public function compile($args, \Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null);
|
||||
}
|
96
src/Compile/Block.php
Normal file
96
src/Compile/Block.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of Smarty.
|
||||
*
|
||||
* (c) 2015 Uwe Tews
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\ParseTree\Template;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Class
|
||||
*
|
||||
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||
*/
|
||||
class Block extends Inheritance {
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
public $required_attributes = ['name'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
public $shorttag_order = ['name'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
public $option_flags = ['hide', 'nocache'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
public $optional_attributes = ['assign'];
|
||||
|
||||
/**
|
||||
* Compiles code for the {block} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
if (!isset($compiler->_cache['blockNesting'])) {
|
||||
$compiler->_cache['blockNesting'] = 0;
|
||||
}
|
||||
if ($compiler->_cache['blockNesting'] === 0) {
|
||||
// make sure that inheritance gets initialized in template code
|
||||
$this->registerInit($compiler);
|
||||
$this->option_flags = ['hide', 'nocache', 'append', 'prepend'];
|
||||
} else {
|
||||
$this->option_flags = ['hide', 'nocache'];
|
||||
}
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
++$compiler->_cache['blockNesting'];
|
||||
$_className = 'Block_' . preg_replace('![^\w]+!', '_', uniqid(mt_rand(), true));
|
||||
$compiler->_cache['blockName'][$compiler->_cache['blockNesting']] = $_attr['name'];
|
||||
$compiler->_cache['blockClass'][$compiler->_cache['blockNesting']] = $_className;
|
||||
$compiler->_cache['blockParams'][$compiler->_cache['blockNesting']] = [];
|
||||
$compiler->_cache['blockParams'][1]['subBlocks'][trim($_attr['name'], '"\'')][] = $_className;
|
||||
$this->openTag(
|
||||
$compiler,
|
||||
'block',
|
||||
[
|
||||
$_attr, $compiler->nocache, $compiler->parser->current_buffer,
|
||||
$compiler->template->compiled->has_nocache_code,
|
||||
$compiler->template->caching,
|
||||
]
|
||||
);
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
$compiler->parser->current_buffer = new Template();
|
||||
$compiler->template->compiled->has_nocache_code = false;
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
}
|
||||
}
|
101
src/Compile/Blockclose.php
Normal file
101
src/Compile/Blockclose.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\ParseTree\Template;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile BlockClose Class
|
||||
*/
|
||||
class Blockclose extends Inheritance {
|
||||
|
||||
/**
|
||||
* Compiles code for the {/block} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return bool true
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
[$_attr, $_nocache, $_buffer, $_has_nocache_code, $_caching] = $this->closeTag($compiler, ['block']);
|
||||
// init block parameter
|
||||
$_block = $compiler->_cache['blockParams'][$compiler->_cache['blockNesting']];
|
||||
unset($compiler->_cache['blockParams'][$compiler->_cache['blockNesting']]);
|
||||
$_name = $_attr['name'];
|
||||
$_assign = isset($_attr['assign']) ? $_attr['assign'] : null;
|
||||
unset($_attr['assign'], $_attr['name']);
|
||||
foreach ($_attr as $name => $stat) {
|
||||
if ((is_bool($stat) && $stat !== false) || (!is_bool($stat) && $stat !== 'false')) {
|
||||
$_block[$name] = 'true';
|
||||
}
|
||||
}
|
||||
$_className = $compiler->_cache['blockClass'][$compiler->_cache['blockNesting']];
|
||||
// get compiled block code
|
||||
$_functionCode = $compiler->parser->current_buffer;
|
||||
// setup buffer for template function code
|
||||
$compiler->parser->current_buffer = new Template();
|
||||
$output = "<?php\n";
|
||||
$output .= $compiler->cStyleComment(" {block {$_name}} ") . "\n";
|
||||
$output .= "class {$_className} extends \\Smarty\\Block\n";
|
||||
$output .= "{\n";
|
||||
foreach ($_block as $property => $value) {
|
||||
$output .= "public \${$property} = " . var_export($value, true) . ";\n";
|
||||
}
|
||||
$output .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n";
|
||||
if ($compiler->template->compiled->has_nocache_code) {
|
||||
$output .= "\$_smarty_tpl->cached->hashes['{$compiler->template->compiled->nocache_hash}'] = true;\n";
|
||||
}
|
||||
if (isset($_assign)) {
|
||||
$output .= "ob_start();\n";
|
||||
}
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
new \Smarty\ParseTree\Tag(
|
||||
$compiler->parser,
|
||||
$output
|
||||
)
|
||||
);
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
||||
$output = "<?php\n";
|
||||
if (isset($_assign)) {
|
||||
$output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
||||
}
|
||||
$output .= "}\n";
|
||||
$output .= "}\n";
|
||||
$output .= $compiler->cStyleComment(" {/block {$_name}} ") . "\n\n";
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
new \Smarty\ParseTree\Tag(
|
||||
$compiler->parser,
|
||||
$output
|
||||
)
|
||||
);
|
||||
$compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
|
||||
$compiler->parser->current_buffer = new Template();
|
||||
// restore old status
|
||||
$compiler->template->compiled->has_nocache_code = $_has_nocache_code;
|
||||
$compiler->tag_nocache = $compiler->nocache;
|
||||
$compiler->nocache = $_nocache;
|
||||
$compiler->parser->current_buffer = $_buffer;
|
||||
$output = "<?php \n";
|
||||
if ($compiler->_cache['blockNesting'] === 1) {
|
||||
$output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name);\n";
|
||||
} else {
|
||||
$output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name, \$this->tplIndex);\n";
|
||||
}
|
||||
$output .= "?>\n";
|
||||
--$compiler->_cache['blockNesting'];
|
||||
if ($compiler->_cache['blockNesting'] === 0) {
|
||||
unset($compiler->_cache['blockNesting']);
|
||||
}
|
||||
$compiler->has_code = true;
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
return $output;
|
||||
}
|
||||
}
|
121
src/Compile/BreakTag.php
Normal file
121
src/Compile/BreakTag.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Break
|
||||
* Compiles the {break} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_Compile_Foreach;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Break Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class BreakTag extends Base {
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
protected $optional_attributes = ['levels'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
protected $shorttag_order = ['levels'];
|
||||
|
||||
/**
|
||||
* Tag name may be overloaded by Smarty_Internal_Compile_Continue
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $tag = 'break';
|
||||
|
||||
/**
|
||||
* Compiles code for the {break} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
[$levels, $foreachLevels] = $this->checkLevels($args, $compiler);
|
||||
$output = "<?php ";
|
||||
if ($foreachLevels > 0 && $this->tag === 'continue') {
|
||||
$foreachLevels--;
|
||||
}
|
||||
if ($foreachLevels > 0) {
|
||||
/* @var Smarty_Internal_Compile_Foreach $foreachCompiler */
|
||||
$foreachCompiler = $compiler->getTagCompiler('foreach');
|
||||
$output .= $foreachCompiler->compileRestore($foreachLevels);
|
||||
}
|
||||
$output .= "{$this->tag} {$levels};?>";
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* check attributes and return array of break and foreach levels
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return array
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function checkLevels($args, Smarty_Internal_TemplateCompilerBase $compiler) {
|
||||
static $_is_loopy = ['for' => true, 'foreach' => true, 'while' => true, 'section' => true];
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
if (isset($_attr['levels'])) {
|
||||
if (!is_numeric($_attr['levels'])) {
|
||||
$compiler->trigger_template_error('level attribute must be a numeric constant', null, true);
|
||||
}
|
||||
$levels = $_attr['levels'];
|
||||
} else {
|
||||
$levels = 1;
|
||||
}
|
||||
$level_count = $levels;
|
||||
$stack_count = count($compiler->_tag_stack) - 1;
|
||||
$foreachLevels = 0;
|
||||
$lastTag = '';
|
||||
while ($level_count > 0 && $stack_count >= 0) {
|
||||
if (isset($_is_loopy[$compiler->_tag_stack[$stack_count][0]])) {
|
||||
$lastTag = $compiler->_tag_stack[$stack_count][0];
|
||||
if ($level_count === 0) {
|
||||
break;
|
||||
}
|
||||
$level_count--;
|
||||
if ($compiler->_tag_stack[$stack_count][0] === 'foreach') {
|
||||
$foreachLevels++;
|
||||
}
|
||||
}
|
||||
$stack_count--;
|
||||
}
|
||||
if ($level_count !== 0) {
|
||||
$compiler->trigger_template_error("cannot {$this->tag} {$levels} level(s)", null, true);
|
||||
}
|
||||
if ($lastTag === 'foreach' && $this->tag === 'break' && $foreachLevels > 0) {
|
||||
$foreachLevels--;
|
||||
}
|
||||
return [$levels, $foreachLevels];
|
||||
}
|
||||
}
|
@@ -8,19 +8,21 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Function_Call Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
|
||||
class Call extends Base
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $required_attributes = array('name');
|
||||
|
||||
@@ -28,7 +30,7 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $shorttag_order = array('name');
|
||||
|
||||
@@ -36,7 +38,7 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $optional_attributes = array('_any');
|
||||
|
||||
@@ -48,7 +50,7 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
82
src/Compile/Child.php
Normal file
82
src/Compile/Child.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of Smarty.
|
||||
*
|
||||
* (c) 2015 Uwe Tews
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Child Class
|
||||
*
|
||||
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||
*/
|
||||
class Child extends Base {
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
protected $optional_attributes = ['assign'];
|
||||
|
||||
/**
|
||||
* Tag name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $tag = 'child';
|
||||
|
||||
/**
|
||||
* Block type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $blockType = 'Child';
|
||||
|
||||
/**
|
||||
* Compiles code for the {child} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$tag = isset($parameter[0]) ? "'{$parameter[0]}'" : "'{{$this->tag}}'";
|
||||
if (!isset($compiler->_cache['blockNesting'])) {
|
||||
$compiler->trigger_template_error(
|
||||
"{$tag} used outside {block} tags ",
|
||||
$compiler->parser->lex->taglineno
|
||||
);
|
||||
}
|
||||
$compiler->has_code = true;
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
if ($this->blockType === 'Child') {
|
||||
$compiler->_cache['blockParams'][$compiler->_cache['blockNesting']]['callsChild'] = 'true';
|
||||
}
|
||||
$_assign = $_attr['assign'] ?? null;
|
||||
$output = "<?php \n";
|
||||
if (isset($_assign)) {
|
||||
$output .= "ob_start();\n";
|
||||
}
|
||||
$output .= '$_smarty_tpl->inheritance->call' . $this->blockType . '($_smarty_tpl, $this' .
|
||||
($this->blockType === 'Child' ? '' : ", {$tag}") . ");\n";
|
||||
if (isset($_assign)) {
|
||||
$output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
||||
}
|
||||
$output .= "?>\n";
|
||||
return $output;
|
||||
}
|
||||
}
|
94
src/Compile/ConfigLoad.php
Normal file
94
src/Compile/ConfigLoad.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Config Load
|
||||
* Compiles the {config load} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Smarty;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Config Load Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class ConfigLoad extends Base {
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
protected $required_attributes = ['file'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
protected $shorttag_order = ['file', 'section'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
protected $optional_attributes = ['section', 'scope'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
protected $option_flags = ['nocache', 'noscope'];
|
||||
|
||||
/**
|
||||
* Valid scope names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $valid_scopes = [
|
||||
'local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
|
||||
'root' => Smarty::SCOPE_ROOT, 'tpl_root' => Smarty::SCOPE_TPL_ROOT,
|
||||
'smarty' => Smarty::SCOPE_SMARTY, 'global' => Smarty::SCOPE_SMARTY,
|
||||
];
|
||||
|
||||
/**
|
||||
* Compiles code for the {config_load} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
// save possible attributes
|
||||
$conf_file = $_attr['file'];
|
||||
$section = $_attr['section'] ?? 'null';
|
||||
// scope setup
|
||||
if ($_attr['noscope']) {
|
||||
$_scope = -1;
|
||||
} else {
|
||||
$_scope = $compiler->convertScope($_attr, $this->valid_scopes);
|
||||
}
|
||||
// create config object
|
||||
return "<?php\n\$_smarty_tpl->smarty->ext->configLoad->_loadConfigFile(\$_smarty_tpl, {$conf_file}, {$section}, {$_scope});\n?>\n";
|
||||
}
|
||||
}
|
44
src/Compile/Debug.php
Normal file
44
src/Compile/Debug.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Debug
|
||||
* Compiles the {debug} tag.
|
||||
* It opens a window the the Smarty Debugging Console.
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Debug Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Debug extends Base {
|
||||
|
||||
/**
|
||||
* Compiles code for the {debug} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes, may trigger errors
|
||||
$this->getAttributes($compiler, $args);
|
||||
|
||||
// compile always as nocache
|
||||
$compiler->tag_nocache = true;
|
||||
// display debug template
|
||||
$_output =
|
||||
"<?php \$_smarty_debug = new \\Smarty\\Debug;\n \$_smarty_debug->display_debug(\$_smarty_tpl);\n";
|
||||
$_output .= "unset(\$_smarty_debug);\n?>";
|
||||
return $_output;
|
||||
}
|
||||
}
|
74
src/Compile/EvalTag.php
Normal file
74
src/Compile/EvalTag.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Eval
|
||||
* Compiles the {eval} tag.
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Eval Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class EvalTag extends Base {
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
public $required_attributes = ['var'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
public $optional_attributes = ['assign'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
public $shorttag_order = ['var', 'assign'];
|
||||
|
||||
/**
|
||||
* Compiles code for the {eval} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if (isset($_attr['assign'])) {
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
$_assign = $_attr['assign'];
|
||||
}
|
||||
// create template object
|
||||
$_output =
|
||||
"\$_template = new {$compiler->smarty->template_class}('eval:'.{$_attr[ 'var' ]}, \$_smarty_tpl->smarty, \$_smarty_tpl);";
|
||||
//was there an assign attribute?
|
||||
if (isset($_assign)) {
|
||||
$_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch());";
|
||||
} else {
|
||||
$_output .= 'echo $_template->fetch();';
|
||||
}
|
||||
return "<?php $_output ?>";
|
||||
}
|
||||
}
|
355
src/Compile/Include.php
Normal file
355
src/Compile/Include.php
Normal file
@@ -0,0 +1,355 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Include
|
||||
* Compiles the {include} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Smarty;
|
||||
use Smarty_Internal_SmartyTemplateCompiler;
|
||||
use Smarty_Internal_Template;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty_Resource;
|
||||
use Smarty_Template_Compiled;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Include Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class IncludeTag extends Base {
|
||||
|
||||
/**
|
||||
* caching mode to create nocache code but no cache file
|
||||
*/
|
||||
private const CACHING_NOCACHE_CODE = 9999;
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
protected $required_attributes = ['file'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
protected $shorttag_order = ['file'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
protected $option_flags = ['nocache', 'inline', 'caching'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
protected $optional_attributes = ['_any'];
|
||||
|
||||
/**
|
||||
* Valid scope names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $valid_scopes = [
|
||||
'parent' => Smarty::SCOPE_PARENT, 'root' => Smarty::SCOPE_ROOT,
|
||||
'global' => Smarty::SCOPE_GLOBAL, 'tpl_root' => Smarty::SCOPE_TPL_ROOT,
|
||||
'smarty' => Smarty::SCOPE_SMARTY,
|
||||
];
|
||||
|
||||
/**
|
||||
* Compiles code for the {include} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param Smarty_Internal_SmartyTemplateCompiler $compiler compiler object
|
||||
*
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$uid = $t_hash = null;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$fullResourceName = $source_resource = $_attr['file'];
|
||||
$variable_template = false;
|
||||
$cache_tpl = false;
|
||||
// parse resource_name
|
||||
if (preg_match('/^([\'"])(([A-Za-z0-9_\-]{2,})[:])?(([^$()]+)|(.+))\1$/', $source_resource, $match)) {
|
||||
$type = !empty($match[3]) ? $match[3] : $compiler->template->smarty->default_resource_type;
|
||||
$name = !empty($match[5]) ? $match[5] : $match[6];
|
||||
$handler = Smarty_Resource::load($compiler->smarty, $type);
|
||||
if ($handler->recompiled || $handler->uncompiled) {
|
||||
$variable_template = true;
|
||||
}
|
||||
if (!$variable_template) {
|
||||
if ($type !== 'string') {
|
||||
$fullResourceName = "{$type}:{$name}";
|
||||
$compiled = $compiler->parent_compiler->template->compiled;
|
||||
if (isset($compiled->includes[$fullResourceName])) {
|
||||
$compiled->includes[$fullResourceName]++;
|
||||
$cache_tpl = true;
|
||||
} else {
|
||||
if ("{$compiler->template->source->type}:{$compiler->template->source->name}" ==
|
||||
$fullResourceName
|
||||
) {
|
||||
// recursive call of current template
|
||||
$compiled->includes[$fullResourceName] = 2;
|
||||
$cache_tpl = true;
|
||||
} else {
|
||||
$compiled->includes[$fullResourceName] = 1;
|
||||
}
|
||||
}
|
||||
$fullResourceName = $match[1] . $fullResourceName . $match[1];
|
||||
}
|
||||
}
|
||||
if (empty($match[5])) {
|
||||
$variable_template = true;
|
||||
}
|
||||
} else {
|
||||
$variable_template = true;
|
||||
}
|
||||
// scope setup
|
||||
$_scope = $compiler->convertScope($_attr, $this->valid_scopes);
|
||||
// set flag to cache subtemplate object when called within loop or template name is variable.
|
||||
if ($cache_tpl || $variable_template || $compiler->loopNesting > 0) {
|
||||
$_cache_tpl = 'true';
|
||||
} else {
|
||||
$_cache_tpl = 'false';
|
||||
}
|
||||
// assume caching is off
|
||||
$_caching = Smarty::CACHING_OFF;
|
||||
$call_nocache = $compiler->tag_nocache || $compiler->nocache;
|
||||
// caching was on and {include} is not in nocache mode
|
||||
if ($compiler->template->caching && !$compiler->nocache && !$compiler->tag_nocache) {
|
||||
$_caching = self::CACHING_NOCACHE_CODE;
|
||||
}
|
||||
// flag if included template code should be merged into caller
|
||||
$merge_compiled_includes = ($compiler->smarty->merge_compiled_includes || $_attr['inline'] === true) &&
|
||||
!$compiler->template->source->handler->recompiled;
|
||||
if ($merge_compiled_includes) {
|
||||
// variable template name ?
|
||||
if ($variable_template) {
|
||||
$merge_compiled_includes = false;
|
||||
}
|
||||
// variable compile_id?
|
||||
if (isset($_attr['compile_id']) && $compiler->isVariable($_attr['compile_id'])) {
|
||||
$merge_compiled_includes = false;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if the {include} tag provides individual parameter for caching or compile_id
|
||||
* the subtemplate must not be included into the common cache file and is treated like
|
||||
* a call in nocache mode.
|
||||
*
|
||||
*/
|
||||
if ($_attr['nocache'] !== true && $_attr['caching']) {
|
||||
$_caching = $_new_caching = (int)$_attr['caching'];
|
||||
$call_nocache = true;
|
||||
} else {
|
||||
$_new_caching = Smarty::CACHING_LIFETIME_CURRENT;
|
||||
}
|
||||
if (isset($_attr['cache_lifetime'])) {
|
||||
$_cache_lifetime = $_attr['cache_lifetime'];
|
||||
$call_nocache = true;
|
||||
$_caching = $_new_caching;
|
||||
} else {
|
||||
$_cache_lifetime = '$_smarty_tpl->cache_lifetime';
|
||||
}
|
||||
if (isset($_attr['cache_id'])) {
|
||||
$_cache_id = $_attr['cache_id'];
|
||||
$call_nocache = true;
|
||||
$_caching = $_new_caching;
|
||||
} else {
|
||||
$_cache_id = '$_smarty_tpl->cache_id';
|
||||
}
|
||||
if (isset($_attr['compile_id'])) {
|
||||
$_compile_id = $_attr['compile_id'];
|
||||
} else {
|
||||
$_compile_id = '$_smarty_tpl->compile_id';
|
||||
}
|
||||
// if subtemplate will be called in nocache mode do not merge
|
||||
if ($compiler->template->caching && $call_nocache) {
|
||||
$merge_compiled_includes = false;
|
||||
}
|
||||
// assign attribute
|
||||
if (isset($_attr['assign'])) {
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
if ($_assign = $compiler->getId($_attr['assign'])) {
|
||||
$_assign = "'{$_assign}'";
|
||||
if ($compiler->tag_nocache || $compiler->nocache || $call_nocache) {
|
||||
// create nocache var to make it know for further compiling
|
||||
$compiler->setNocacheInVariable($_attr['assign']);
|
||||
}
|
||||
} else {
|
||||
$_assign = $_attr['assign'];
|
||||
}
|
||||
}
|
||||
$has_compiled_template = false;
|
||||
if ($merge_compiled_includes) {
|
||||
$c_id = isset($_attr['compile_id']) ? $_attr['compile_id'] : $compiler->template->compile_id;
|
||||
// we must observe different compile_id and caching
|
||||
$t_hash = sha1($c_id . ($_caching ? '--caching' : '--nocaching'));
|
||||
$compiler->smarty->allow_ambiguous_resources = true;
|
||||
/* @var Smarty_Internal_Template $tpl */
|
||||
$tpl = new $compiler->smarty->template_class(
|
||||
trim($fullResourceName, '"\''),
|
||||
$compiler->smarty,
|
||||
$compiler->template,
|
||||
$compiler->template->cache_id,
|
||||
$c_id,
|
||||
$_caching
|
||||
);
|
||||
$uid = $tpl->source->type . $tpl->source->uid;
|
||||
if (!isset($compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash])) {
|
||||
$has_compiled_template = $this->compileInlineTemplate($compiler, $tpl, $t_hash);
|
||||
} else {
|
||||
$has_compiled_template = true;
|
||||
}
|
||||
unset($tpl);
|
||||
}
|
||||
// delete {include} standard attributes
|
||||
unset($_attr['file'], $_attr['assign'], $_attr['cache_id'], $_attr['compile_id'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope'], $_attr['inline']);
|
||||
// remaining attributes must be assigned as smarty variable
|
||||
$_vars = 'array()';
|
||||
if (!empty($_attr)) {
|
||||
$_pairs = [];
|
||||
// create variables
|
||||
foreach ($_attr as $key => $value) {
|
||||
$_pairs[] = "'$key'=>$value";
|
||||
}
|
||||
$_vars = 'array(' . join(',', $_pairs) . ')';
|
||||
}
|
||||
$update_compile_id = $compiler->template->caching && !$compiler->tag_nocache && !$compiler->nocache &&
|
||||
$_compile_id !== '$_smarty_tpl->compile_id';
|
||||
if ($has_compiled_template && !$call_nocache) {
|
||||
$_output = "<?php\n";
|
||||
if ($update_compile_id) {
|
||||
$_output .= $compiler->makeNocacheCode("\$_compile_id_save[] = \$_smarty_tpl->compile_id;\n\$_smarty_tpl->compile_id = {$_compile_id};\n");
|
||||
}
|
||||
if (!empty($_attr) && $_caching === 9999 && $compiler->template->caching) {
|
||||
$_vars_nc = "foreach ($_vars as \$ik => \$iv) {\n";
|
||||
$_vars_nc .= "\$_smarty_tpl->tpl_vars[\$ik] = new \\Smarty\\Variable(\$iv);\n";
|
||||
$_vars_nc .= "}\n";
|
||||
$_output .= substr($compiler->processNocacheCode('<?php ' . $_vars_nc . "?>\n", true), 6, -3);
|
||||
}
|
||||
if (isset($_assign)) {
|
||||
$_output .= "ob_start();\n";
|
||||
}
|
||||
$_output .= "\$_smarty_tpl->_subTemplateRender({$fullResourceName}, {$_cache_id}, {$_compile_id}, {$_caching}, {$_cache_lifetime}, {$_vars}, {$_scope}, {$_cache_tpl}, '{$compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['uid']}', '{$compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['func']}');\n";
|
||||
if (isset($_assign)) {
|
||||
$_output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
||||
}
|
||||
if ($update_compile_id) {
|
||||
$_output .= $compiler->makeNocacheCode("\$_smarty_tpl->compile_id = array_pop(\$_compile_id_save);\n");
|
||||
}
|
||||
$_output .= "?>";
|
||||
return $_output;
|
||||
}
|
||||
if ($call_nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
$_output = "<?php ";
|
||||
if ($update_compile_id) {
|
||||
$_output .= "\$_compile_id_save[] = \$_smarty_tpl->compile_id;\n\$_smarty_tpl->compile_id = {$_compile_id};\n";
|
||||
}
|
||||
// was there an assign attribute
|
||||
if (isset($_assign)) {
|
||||
$_output .= "ob_start();\n";
|
||||
}
|
||||
$_output .= "\$_smarty_tpl->_subTemplateRender({$fullResourceName}, $_cache_id, $_compile_id, $_caching, $_cache_lifetime, $_vars, $_scope, {$_cache_tpl});\n";
|
||||
if (isset($_assign)) {
|
||||
$_output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
||||
}
|
||||
if ($update_compile_id) {
|
||||
$_output .= "\$_smarty_tpl->compile_id = array_pop(\$_compile_id_save);\n";
|
||||
}
|
||||
$_output .= "?>";
|
||||
return $_output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile inline sub template
|
||||
*
|
||||
* @param \Smarty_Internal_SmartyTemplateCompiler $compiler
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param string $t_hash
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
private function compileInlineTemplate(
|
||||
Smarty_Internal_SmartyTemplateCompiler $compiler,
|
||||
Smarty_Internal_Template $tpl,
|
||||
$t_hash
|
||||
) {
|
||||
$uid = $tpl->source->type . $tpl->source->uid;
|
||||
if (!($tpl->source->handler->uncompiled) && $tpl->source->exists) {
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['uid'] = $tpl->source->uid;
|
||||
if (isset($compiler->template->inheritance)) {
|
||||
$tpl->inheritance = clone $compiler->template->inheritance;
|
||||
}
|
||||
$tpl->compiled = new Smarty_Template_Compiled();
|
||||
$tpl->compiled->nocache_hash = $compiler->parent_compiler->template->compiled->nocache_hash;
|
||||
$tpl->loadCompiler();
|
||||
// save unique function name
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['func'] =
|
||||
$tpl->compiled->unifunc = 'content_' . str_replace(['.', ','], '_', uniqid('', true));
|
||||
// make sure whole chain gets compiled
|
||||
$tpl->mustCompile = true;
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['nocache_hash'] =
|
||||
$tpl->compiled->nocache_hash;
|
||||
if ($tpl->source->type === 'file') {
|
||||
$sourceInfo = $tpl->source->filepath;
|
||||
} else {
|
||||
$basename = $tpl->source->handler->getBasename($tpl->source);
|
||||
$sourceInfo = $tpl->source->type . ':' .
|
||||
($basename ? $basename : $tpl->source->name);
|
||||
}
|
||||
// get compiled code
|
||||
$compiled_code = "<?php\n\n";
|
||||
$compiled_code .= $compiler->cStyleComment(" Start inline template \"{$sourceInfo}\" =============================") . "\n";
|
||||
$compiled_code .= "function {$tpl->compiled->unifunc} (Smarty_Internal_Template \$_smarty_tpl) {\n";
|
||||
$compiled_code .= "?>\n" . $tpl->compiler->compileTemplateSource($tpl, null, $compiler->parent_compiler);
|
||||
$compiled_code .= "<?php\n";
|
||||
$compiled_code .= "}\n?>\n";
|
||||
$compiled_code .= $tpl->compiler->postFilter($tpl->compiler->blockOrFunctionCode);
|
||||
$compiled_code .= "<?php\n\n";
|
||||
$compiled_code .= $compiler->cStyleComment(" End inline template \"{$sourceInfo}\" =============================") . "\n";
|
||||
$compiled_code .= '?>';
|
||||
unset($tpl->compiler);
|
||||
if ($tpl->compiled->has_nocache_code) {
|
||||
// replace nocache_hash
|
||||
$compiled_code =
|
||||
str_replace(
|
||||
"{$tpl->compiled->nocache_hash}",
|
||||
$compiler->template->compiled->nocache_hash,
|
||||
$compiled_code
|
||||
);
|
||||
$compiler->template->compiled->has_nocache_code = true;
|
||||
}
|
||||
$compiler->parent_compiler->mergedSubTemplatesCode[$tpl->compiled->unifunc] = $compiled_code;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -17,7 +17,7 @@ namespace Smarty\Compile;
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
abstract class Inheritance extends \Smarty_Internal_CompileBase
|
||||
abstract class Inheritance extends \Smarty\Compile\Base
|
||||
{
|
||||
/**
|
||||
* Compile inheritance initialization code as prefix
|
||||
|
161
src/Compile/Insert.php
Normal file
161
src/Compile/Insert.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Insert
|
||||
* Compiles the {insert} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Variable;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Insert Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Insert extends Base {
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
protected $required_attributes = ['name'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
protected $shorttag_order = ['name'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
protected $optional_attributes = ['_any'];
|
||||
|
||||
/**
|
||||
* Compiles code for the {insert} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$nocacheParam = $compiler->template->caching && ($compiler->tag_nocache || $compiler->nocache);
|
||||
if (!$nocacheParam) {
|
||||
// do not compile as nocache code
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
}
|
||||
$compiler->tag_nocache = true;
|
||||
$_smarty_tpl = $compiler->template;
|
||||
$_name = null;
|
||||
$_script = null;
|
||||
$_output = '<?php ';
|
||||
// save possible attributes
|
||||
eval('$_name = @' . $_attr['name'] . ';');
|
||||
if (isset($_attr['assign'])) {
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
$_assign = $_attr['assign'];
|
||||
// create variable to make sure that the compiler knows about its nocache status
|
||||
$var = trim($_attr['assign'], '\'');
|
||||
if (isset($compiler->template->tpl_vars[$var])) {
|
||||
$compiler->template->tpl_vars[$var]->nocache = true;
|
||||
} else {
|
||||
$compiler->template->tpl_vars[$var] = new Variable(null, true);
|
||||
}
|
||||
}
|
||||
if (isset($_attr['script'])) {
|
||||
// script which must be included
|
||||
$_function = "smarty_insert_{$_name}";
|
||||
$_smarty_tpl = $compiler->template;
|
||||
$_filepath = false;
|
||||
eval('$_script = @' . $_attr['script'] . ';');
|
||||
if (!isset($compiler->smarty->security_policy) && file_exists($_script)) {
|
||||
$_filepath = $_script;
|
||||
} else {
|
||||
if (isset($compiler->smarty->security_policy)) {
|
||||
$_dir = $compiler->smarty->security_policy->trusted_dir;
|
||||
} else {
|
||||
$_dir = null;
|
||||
}
|
||||
if (!empty($_dir)) {
|
||||
foreach ((array)$_dir as $_script_dir) {
|
||||
$_script_dir = rtrim($_script_dir ?? '', '/\\') . DIRECTORY_SEPARATOR;
|
||||
if (file_exists($_script_dir . $_script)) {
|
||||
$_filepath = $_script_dir . $_script;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($_filepath === false) {
|
||||
$compiler->trigger_template_error("{insert} missing script file '{$_script}'", null, true);
|
||||
}
|
||||
// code for script file loading
|
||||
$_output .= "require_once '{$_filepath}' ;";
|
||||
include_once $_filepath;
|
||||
if (!is_callable($_function)) {
|
||||
$compiler->trigger_template_error(
|
||||
" {insert} function '{$_function}' is not callable in script file '{$_script}'",
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$_filepath = 'null';
|
||||
$_function = "insert_{$_name}";
|
||||
// function in PHP script ?
|
||||
if (!is_callable($_function)) {
|
||||
// try plugin
|
||||
if (!$_function = $compiler->getPlugin($_name, 'insert')) {
|
||||
$compiler->trigger_template_error(
|
||||
"{insert} no function or plugin found for '{$_name}'",
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// delete {insert} standard attributes
|
||||
unset($_attr['name'], $_attr['assign'], $_attr['script'], $_attr['nocache']);
|
||||
// convert attributes into parameter array string
|
||||
$_paramsArray = [];
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
$_paramsArray[] = "'$_key' => $_value";
|
||||
}
|
||||
$_params = 'array(' . implode(", ", $_paramsArray) . ')';
|
||||
// call insert
|
||||
if (isset($_assign)) {
|
||||
if ($_smarty_tpl->caching && !$nocacheParam) {
|
||||
$_output .= "echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}',{$_assign});?>";
|
||||
} else {
|
||||
$_output .= "\$_smarty_tpl->assign({$_assign} , {$_function} ({$_params},\$_smarty_tpl), true);?>";
|
||||
}
|
||||
} else {
|
||||
if ($_smarty_tpl->caching && !$nocacheParam) {
|
||||
$_output .= "echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}');?>";
|
||||
} else {
|
||||
$_output .= "echo {$_function}({$_params},\$_smarty_tpl);?>";
|
||||
}
|
||||
}
|
||||
$compiler->template->compiled->has_nocache_code = true;
|
||||
return $_output;
|
||||
}
|
||||
}
|
40
src/Compile/Ldelim.php
Normal file
40
src/Compile/Ldelim.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Ldelim
|
||||
* Compiles the {ldelim} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Ldelim Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Ldelim extends Base {
|
||||
|
||||
/**
|
||||
* Compiles code for the {ldelim} tag
|
||||
* This tag does output the left delimiter
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
return $compiler->smarty->left_delimiter;
|
||||
}
|
||||
}
|
153
src/Compile/PrivateModifier.php
Normal file
153
src/Compile/PrivateModifier.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Modifier
|
||||
* Compiles code for modifier execution
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Modifier Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class PrivateModifier extends Base {
|
||||
|
||||
/**
|
||||
* Compiles code for modifier execution
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$output = $parameter['value'];
|
||||
// loop over list of modifiers
|
||||
foreach ($parameter['modifierlist'] as $single_modifier) {
|
||||
/* @var string $modifier */
|
||||
$modifier = $single_modifier[0];
|
||||
$single_modifier[0] = $output;
|
||||
$params = implode(',', $single_modifier);
|
||||
// check if we know already the type of modifier
|
||||
if (isset($compiler->known_modifier_type[$modifier])) {
|
||||
$modifier_types = [$compiler->known_modifier_type[$modifier]];
|
||||
} else {
|
||||
$modifier_types = [1, 2, 3, 4, 5, 6];
|
||||
}
|
||||
foreach ($modifier_types as $type) {
|
||||
switch ($type) {
|
||||
case 1:
|
||||
// registered modifier
|
||||
if (isset($compiler->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_MODIFIER][$modifier])) {
|
||||
if (is_callable($compiler->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_MODIFIER][$modifier][0])) {
|
||||
$output =
|
||||
sprintf(
|
||||
'call_user_func_array($_smarty_tpl->registered_plugins[ \'%s\' ][ %s ][ 0 ], array( %s ))',
|
||||
\Smarty\Smarty::PLUGIN_MODIFIER,
|
||||
var_export($modifier, true),
|
||||
$params
|
||||
);
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// registered modifier compiler
|
||||
if (isset($compiler->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0])) {
|
||||
$output =
|
||||
call_user_func(
|
||||
$compiler->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0],
|
||||
$single_modifier,
|
||||
$compiler->smarty
|
||||
);
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// modifiercompiler plugin
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy)
|
||||
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
||||
) {
|
||||
$plugin = 'smarty_modifiercompiler_' . $modifier;
|
||||
$output = $plugin($single_modifier, $compiler);
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
case 4:
|
||||
// modifier plugin
|
||||
if ($function = $compiler->getPlugin($modifier, \Smarty\Smarty::PLUGIN_MODIFIER)) {
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy)
|
||||
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
||||
) {
|
||||
$output = "{$function}({$params})";
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
// PHP function
|
||||
if (is_callable($modifier)) {
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy)
|
||||
|| $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)
|
||||
) {
|
||||
trigger_error('Using php-function "' . $modifier . '" as a modifier is deprecated and will be ' .
|
||||
'removed in a future release. Use Smarty::registerPlugin to explicitly register ' .
|
||||
'a custom modifier.', E_USER_DEPRECATED);
|
||||
$output = "{$modifier}({$params})";
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
// default plugin handler
|
||||
if (isset($compiler->default_handler_plugins[\Smarty\Smarty::PLUGIN_MODIFIER][$modifier])
|
||||
|| (is_callable($compiler->smarty->default_plugin_handler_func)
|
||||
&& $compiler->getPluginFromDefaultHandler($modifier, \Smarty\Smarty::PLUGIN_MODIFIER))
|
||||
) {
|
||||
$function = $compiler->default_handler_plugins[\Smarty\Smarty::PLUGIN_MODIFIER][$modifier][0];
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy)
|
||||
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
||||
) {
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$params})";
|
||||
} else {
|
||||
if (is_object($function[0])) {
|
||||
$output = $function[0] . '->' . $function[1] . '(' . $params . ')';
|
||||
} else {
|
||||
$output = $function[0] . '::' . $function[1] . '(' . $params . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
$compiler->known_modifier_type[$modifier] = $type;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($compiler->known_modifier_type[$modifier])) {
|
||||
$compiler->trigger_template_error("unknown modifier '{$modifier}'", null, true);
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
67
src/Compile/WhileTag.php
Normal file
67
src/Compile/WhileTag.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile While Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class WhileTag extends Base {
|
||||
|
||||
/**
|
||||
* Compiles code for the {while} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting++;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$this->openTag($compiler, 'while', $compiler->nocache);
|
||||
if (!array_key_exists('if condition', $parameter)) {
|
||||
$compiler->trigger_template_error('missing while condition', null, true);
|
||||
}
|
||||
// maybe nocache because of nocache variables
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
if (is_array($parameter['if condition'])) {
|
||||
if ($compiler->nocache) {
|
||||
// create nocache var to make it know for further compiling
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
$var = $parameter['if condition']['var']['var'];
|
||||
} else {
|
||||
$var = $parameter['if condition']['var'];
|
||||
}
|
||||
$compiler->setNocacheInVariable($var);
|
||||
}
|
||||
$prefixVar = $compiler->getNewPrefixVariable();
|
||||
$assignCompiler = new Assign();
|
||||
$assignAttr = [];
|
||||
$assignAttr[]['value'] = $prefixVar;
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
$assignAttr[]['var'] = $parameter['if condition']['var']['var'];
|
||||
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
|
||||
$_output .= $assignCompiler->compile(
|
||||
$assignAttr,
|
||||
$compiler,
|
||||
['smarty_internal_index' => $parameter['if condition']['var']['smarty_internal_index']]
|
||||
);
|
||||
} else {
|
||||
$assignAttr[]['var'] = $parameter['if condition']['var'];
|
||||
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
|
||||
$_output .= $assignCompiler->compile($assignAttr, $compiler, []);
|
||||
}
|
||||
return $_output;
|
||||
} else {
|
||||
return "<?php\n while ({$parameter['if condition']}) {?>";
|
||||
}
|
||||
}
|
||||
}
|
40
src/Compile/Whileclose.php
Normal file
40
src/Compile/Whileclose.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile While
|
||||
* Compiles the {while} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Whileclose Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Whileclose extends Base {
|
||||
|
||||
/**
|
||||
* Compiles code for the {/while} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting--;
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
$compiler->nocache = $this->closeTag($compiler, ['while']);
|
||||
return "<?php }?>\n";
|
||||
}
|
||||
}
|
@@ -8,19 +8,21 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Make_Nocache Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Make_Nocache extends Smarty_Internal_CompileBase
|
||||
class _Make_Nocache extends Base
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $option_flags = array();
|
||||
|
||||
@@ -46,7 +48,7 @@ class Smarty_Internal_Compile_Make_Nocache extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
@@ -8,19 +8,21 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Plugin Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_CompileBase
|
||||
class _Private_Block_Plugin extends Base
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $optional_attributes = array('_any');
|
||||
|
||||
@@ -44,7 +46,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $function = null)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
if (!isset($tag[ 5 ]) || substr($tag, -5) !== 'close') {
|
||||
// opening tag of block plugin
|
||||
@@ -52,7 +54,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$this->nesting++;
|
||||
unset($_attr[ 'nocache' ]);
|
||||
list($callback, $_paramsArray, $callable) = $this->setup($compiler, $_attr, $tag, $function);
|
||||
[$callback, $_paramsArray, $callable] = $this->setup($compiler, $_attr, $tag, $function);
|
||||
$_params = 'array(' . implode(',', $_paramsArray) . ')';
|
||||
// compile code
|
||||
$output = "<?php ";
|
||||
@@ -73,7 +75,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
// closing tag of block plugin, restore nocache
|
||||
list($_params, $compiler->nocache, $callback) = $this->closeTag($compiler, substr($tag, 0, -5));
|
||||
[$_params, $compiler->nocache, $callback] = $this->closeTag($compiler, substr($tag, 0, -5));
|
||||
// compile code
|
||||
if (!isset($parameter[ 'modifier_list' ])) {
|
||||
$mod_pre = $mod_post = $mod_content = '';
|
@@ -8,13 +8,15 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile ForeachSection Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_CompileBase
|
||||
class _Private_ForeachSection extends Base
|
||||
{
|
||||
/**
|
||||
* Name of this tag
|
@@ -8,19 +8,21 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Function Plugin Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_CompileBase
|
||||
class _Private_Function_Plugin extends Base
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $required_attributes = array();
|
||||
|
||||
@@ -28,7 +30,7 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $optional_attributes = array('_any');
|
||||
|
||||
@@ -45,7 +47,7 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $function)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
@@ -8,19 +8,21 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Object Function Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_CompileBase
|
||||
class _Private_Object_Function extends Base
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $optional_attributes = array('_any');
|
||||
|
||||
@@ -31,13 +33,13 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @param string $tag name of function
|
||||
* @param string $method name of method to call
|
||||
* @param string $function name of method to call
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $method)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
@@ -48,7 +50,7 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co
|
||||
unset($_attr[ 'assign' ]);
|
||||
}
|
||||
// method or property ?
|
||||
if (is_callable(array($compiler->smarty->registered_objects[ $tag ][ 0 ], $method))) {
|
||||
if (is_callable(array($compiler->smarty->registered_objects[ $tag ][ 0 ], $function))) {
|
||||
// convert attributes into parameter array string
|
||||
if ($compiler->smarty->registered_objects[ $tag ][ 2 ]) {
|
||||
$_paramsArray = array();
|
||||
@@ -60,14 +62,14 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co
|
||||
}
|
||||
}
|
||||
$_params = 'array(' . implode(',', $_paramsArray) . ')';
|
||||
$output = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params},\$_smarty_tpl)";
|
||||
$output = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$function}({$_params},\$_smarty_tpl)";
|
||||
} else {
|
||||
$_params = implode(',', $_attr);
|
||||
$output = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params})";
|
||||
$output = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$function}({$_params})";
|
||||
}
|
||||
} else {
|
||||
// object property
|
||||
$output = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}";
|
||||
$output = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$function}";
|
||||
}
|
||||
if (!empty($parameter[ 'modifierlist' ])) {
|
||||
$output = $compiler->compileTag(
|
@@ -8,19 +8,21 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Print Expression Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_CompileBase
|
||||
class _Private_Print_Expression extends Base
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $optional_attributes = array('assign');
|
||||
|
||||
@@ -28,7 +30,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $option_flags = array('nocache', 'nofilter');
|
||||
|
||||
@@ -42,7 +44,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
||||
* @return string
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
@@ -8,19 +8,21 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Registered Function Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Internal_CompileBase
|
||||
class _Private_Registered_Function extends Base
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $optional_attributes = array('_any');
|
||||
|
||||
@@ -36,7 +38,7 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
@@ -8,13 +8,15 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile special Smarty Variable Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_CompileBase
|
||||
class _Private_Special_Variable extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the special $smarty variables
|
||||
@@ -26,7 +28,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
$_index = preg_split("/\]\[/", substr($parameter, 1, strlen($parameter) - 2));
|
||||
$variable = smarty_strtolower_ascii($compiler->getId($_index[ 0 ]));
|
||||
@@ -49,8 +51,8 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
||||
$_index
|
||||
);
|
||||
case 'capture':
|
||||
if (class_exists('Smarty_Internal_Compile_Capture')) {
|
||||
return Smarty_Internal_Compile_Capture::compileSpecialVariable(array(), $compiler, $_index);
|
||||
if (class_exists('_Capture')) {
|
||||
return _Capture::compileSpecialVariable(array(), $compiler, $_index);
|
||||
}
|
||||
return '';
|
||||
case 'now':
|
@@ -1,188 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of Smarty.
|
||||
*
|
||||
* (c) 2015 Uwe Tews
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Inheritance;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Class
|
||||
*
|
||||
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||
*/
|
||||
class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inheritance
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $option_flags = array('hide', 'nocache');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('assign');
|
||||
|
||||
/**
|
||||
* Compiles code for the {block} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
if (!isset($compiler->_cache[ 'blockNesting' ])) {
|
||||
$compiler->_cache[ 'blockNesting' ] = 0;
|
||||
}
|
||||
if ($compiler->_cache[ 'blockNesting' ] === 0) {
|
||||
// make sure that inheritance gets initialized in template code
|
||||
$this->registerInit($compiler);
|
||||
$this->option_flags = array('hide', 'nocache', 'append', 'prepend');
|
||||
} else {
|
||||
$this->option_flags = array('hide', 'nocache');
|
||||
}
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
++$compiler->_cache[ 'blockNesting' ];
|
||||
$_className = 'Block_' . preg_replace('![^\w]+!', '_', uniqid(mt_rand(), true));
|
||||
$compiler->_cache[ 'blockName' ][ $compiler->_cache[ 'blockNesting' ] ] = $_attr[ 'name' ];
|
||||
$compiler->_cache[ 'blockClass' ][ $compiler->_cache[ 'blockNesting' ] ] = $_className;
|
||||
$compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ] = array();
|
||||
$compiler->_cache[ 'blockParams' ][ 1 ][ 'subBlocks' ][ trim($_attr[ 'name' ], '"\'') ][] = $_className;
|
||||
$this->openTag(
|
||||
$compiler,
|
||||
'block',
|
||||
array(
|
||||
$_attr, $compiler->nocache, $compiler->parser->current_buffer,
|
||||
$compiler->template->compiled->has_nocache_code,
|
||||
$compiler->template->caching
|
||||
)
|
||||
);
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
$compiler->parser->current_buffer = new \Smarty\ParseTree\Template();
|
||||
$compiler->template->compiled->has_nocache_code = false;
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile BlockClose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Blockclose extends Inheritance
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/block} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return bool true
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
[$_attr, $_nocache, $_buffer, $_has_nocache_code, $_caching] = $this->closeTag($compiler, array('block'));
|
||||
// init block parameter
|
||||
$_block = $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ];
|
||||
unset($compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ]);
|
||||
$_name = $_attr[ 'name' ];
|
||||
$_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null;
|
||||
unset($_attr[ 'assign' ], $_attr[ 'name' ]);
|
||||
foreach ($_attr as $name => $stat) {
|
||||
if ((is_bool($stat) && $stat !== false) || (!is_bool($stat) && $stat !== 'false')) {
|
||||
$_block[ $name ] = 'true';
|
||||
}
|
||||
}
|
||||
$_className = $compiler->_cache[ 'blockClass' ][ $compiler->_cache[ 'blockNesting' ] ];
|
||||
// get compiled block code
|
||||
$_functionCode = $compiler->parser->current_buffer;
|
||||
// setup buffer for template function code
|
||||
$compiler->parser->current_buffer = new \Smarty\ParseTree\Template();
|
||||
$output = "<?php\n";
|
||||
$output .= $compiler->cStyleComment(" {block {$_name}} ") . "\n";
|
||||
$output .= "class {$_className} extends \\Smarty\\Block\n";
|
||||
$output .= "{\n";
|
||||
foreach ($_block as $property => $value) {
|
||||
$output .= "public \${$property} = " . var_export($value, true) . ";\n";
|
||||
}
|
||||
$output .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n";
|
||||
if ($compiler->template->compiled->has_nocache_code) {
|
||||
$output .= "\$_smarty_tpl->cached->hashes['{$compiler->template->compiled->nocache_hash}'] = true;\n";
|
||||
}
|
||||
if (isset($_assign)) {
|
||||
$output .= "ob_start();\n";
|
||||
}
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
new \Smarty\ParseTree\Tag(
|
||||
$compiler->parser,
|
||||
$output
|
||||
)
|
||||
);
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
||||
$output = "<?php\n";
|
||||
if (isset($_assign)) {
|
||||
$output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
||||
}
|
||||
$output .= "}\n";
|
||||
$output .= "}\n";
|
||||
$output .= $compiler->cStyleComment(" {/block {$_name}} ") . "\n\n";
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
new \Smarty\ParseTree\Tag(
|
||||
$compiler->parser,
|
||||
$output
|
||||
)
|
||||
);
|
||||
$compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
|
||||
$compiler->parser->current_buffer = new \Smarty\ParseTree\Template();
|
||||
// restore old status
|
||||
$compiler->template->compiled->has_nocache_code = $_has_nocache_code;
|
||||
$compiler->tag_nocache = $compiler->nocache;
|
||||
$compiler->nocache = $_nocache;
|
||||
$compiler->parser->current_buffer = $_buffer;
|
||||
$output = "<?php \n";
|
||||
if ($compiler->_cache[ 'blockNesting' ] === 1) {
|
||||
$output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name);\n";
|
||||
} else {
|
||||
$output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name, \$this->tplIndex);\n";
|
||||
}
|
||||
$output .= "?>\n";
|
||||
--$compiler->_cache[ 'blockNesting' ];
|
||||
if ($compiler->_cache[ 'blockNesting' ] === 0) {
|
||||
unset($compiler->_cache[ 'blockNesting' ]);
|
||||
}
|
||||
$compiler->has_code = true;
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
return $output;
|
||||
}
|
||||
}
|
@@ -8,12 +8,14 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Child;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Child Class
|
||||
*
|
||||
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||
*/
|
||||
class Smarty_Internal_Compile_Block_Child extends Smarty_Internal_Compile_Child
|
||||
class Smarty_Internal_Compile_Block_Child extends Child
|
||||
{
|
||||
/**
|
||||
* Tag name
|
||||
|
@@ -8,12 +8,14 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Child;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Parent Class
|
||||
*
|
||||
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||
*/
|
||||
class Smarty_Internal_Compile_Block_Parent extends Smarty_Internal_Compile_Child
|
||||
class Smarty_Internal_Compile_Block_Parent extends Child
|
||||
{
|
||||
/**
|
||||
* Tag name
|
||||
|
@@ -1,117 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Break
|
||||
* Compiles the {break} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Break Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('levels');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('levels');
|
||||
|
||||
/**
|
||||
* Tag name may be overloaded by Smarty_Internal_Compile_Continue
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tag = 'break';
|
||||
|
||||
/**
|
||||
* Compiles code for the {break} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
list($levels, $foreachLevels) = $this->checkLevels($args, $compiler);
|
||||
$output = "<?php ";
|
||||
if ($foreachLevels > 0 && $this->tag === 'continue') {
|
||||
$foreachLevels--;
|
||||
}
|
||||
if ($foreachLevels > 0) {
|
||||
/* @var Smarty_Internal_Compile_Foreach $foreachCompiler */
|
||||
$foreachCompiler = $compiler->getTagCompiler('foreach');
|
||||
$output .= $foreachCompiler->compileRestore($foreachLevels);
|
||||
}
|
||||
$output .= "{$this->tag} {$levels};?>";
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* check attributes and return array of break and foreach levels
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return array
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function checkLevels($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
static $_is_loopy = array('for' => true, 'foreach' => true, 'while' => true, 'section' => true);
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
if (isset($_attr[ 'levels' ])) {
|
||||
if (!is_numeric($_attr[ 'levels' ])) {
|
||||
$compiler->trigger_template_error('level attribute must be a numeric constant', null, true);
|
||||
}
|
||||
$levels = $_attr[ 'levels' ];
|
||||
} else {
|
||||
$levels = 1;
|
||||
}
|
||||
$level_count = $levels;
|
||||
$stack_count = count($compiler->_tag_stack) - 1;
|
||||
$foreachLevels = 0;
|
||||
$lastTag = '';
|
||||
while ($level_count > 0 && $stack_count >= 0) {
|
||||
if (isset($_is_loopy[ $compiler->_tag_stack[ $stack_count ][ 0 ] ])) {
|
||||
$lastTag = $compiler->_tag_stack[ $stack_count ][ 0 ];
|
||||
if ($level_count === 0) {
|
||||
break;
|
||||
}
|
||||
$level_count--;
|
||||
if ($compiler->_tag_stack[ $stack_count ][ 0 ] === 'foreach') {
|
||||
$foreachLevels++;
|
||||
}
|
||||
}
|
||||
$stack_count--;
|
||||
}
|
||||
if ($level_count !== 0) {
|
||||
$compiler->trigger_template_error("cannot {$this->tag} {$levels} level(s)", null, true);
|
||||
}
|
||||
if ($lastTag === 'foreach' && $this->tag === 'break' && $foreachLevels > 0) {
|
||||
$foreachLevels--;
|
||||
}
|
||||
return array($levels, $foreachLevels);
|
||||
}
|
||||
}
|
@@ -8,19 +8,21 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Capture Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
||||
class _Capture extends Base
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $shorttag_order = array('name');
|
||||
|
||||
@@ -28,7 +30,7 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $optional_attributes = array('name', 'assign', 'append');
|
||||
|
||||
@@ -59,7 +61,7 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = null)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args, $parameter, 'capture');
|
||||
@@ -80,7 +82,7 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase
|
||||
class _CaptureClose extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/capture} tag
|
||||
@@ -91,7 +93,7 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args, $parameter, '/capture');
|
||||
@@ -99,7 +101,7 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase
|
||||
if ($compiler->nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
list($compiler->nocache) = array_pop($compiler->_cache[ 'capture_stack' ]);
|
||||
[$compiler->nocache] = array_pop($compiler->_cache[ 'capture_stack' ]);
|
||||
return "<?php \$_smarty_tpl->smarty->ext->_capture->close(\$_smarty_tpl);?>";
|
||||
}
|
||||
}
|
||||
|
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of Smarty.
|
||||
*
|
||||
* (c) 2015 Uwe Tews
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Child Class
|
||||
*
|
||||
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||
*/
|
||||
class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('assign');
|
||||
|
||||
/**
|
||||
* Tag name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tag = 'child';
|
||||
|
||||
/**
|
||||
* Block type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $blockType = 'Child';
|
||||
|
||||
/**
|
||||
* Compiles code for the {child} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$tag = isset($parameter[ 0 ]) ? "'{$parameter[0]}'" : "'{{$this->tag}}'";
|
||||
if (!isset($compiler->_cache[ 'blockNesting' ])) {
|
||||
$compiler->trigger_template_error(
|
||||
"{$tag} used outside {block} tags ",
|
||||
$compiler->parser->lex->taglineno
|
||||
);
|
||||
}
|
||||
$compiler->has_code = true;
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
if ($this->blockType === 'Child') {
|
||||
$compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ][ 'callsChild' ] = 'true';
|
||||
}
|
||||
$_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null;
|
||||
$output = "<?php \n";
|
||||
if (isset($_assign)) {
|
||||
$output .= "ob_start();\n";
|
||||
}
|
||||
$output .= '$_smarty_tpl->inheritance->call' . $this->blockType . '($_smarty_tpl, $this' .
|
||||
($this->blockType === 'Child' ? '' : ", {$tag}") . ");\n";
|
||||
if (isset($_assign)) {
|
||||
$output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
||||
}
|
||||
$output .= "?>\n";
|
||||
return $output;
|
||||
}
|
||||
}
|
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Config Load
|
||||
* Compiles the {config load} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Config Load Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('file');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('file', 'section');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('section', 'scope');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $option_flags = array('nocache', 'noscope');
|
||||
|
||||
/**
|
||||
* Valid scope names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $valid_scopes = array(
|
||||
'local' => \Smarty\Smarty::SCOPE_LOCAL, 'parent' => \Smarty\Smarty::SCOPE_PARENT,
|
||||
'root' => \Smarty\Smarty::SCOPE_ROOT, 'tpl_root' => \Smarty\Smarty::SCOPE_TPL_ROOT,
|
||||
'smarty' => \Smarty\Smarty::SCOPE_SMARTY, 'global' => \Smarty\Smarty::SCOPE_SMARTY
|
||||
);
|
||||
|
||||
/**
|
||||
* Compiles code for the {config_load} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
// save possible attributes
|
||||
$conf_file = $_attr[ 'file' ];
|
||||
if (isset($_attr[ 'section' ])) {
|
||||
$section = $_attr[ 'section' ];
|
||||
} else {
|
||||
$section = 'null';
|
||||
}
|
||||
// scope setup
|
||||
if ($_attr[ 'noscope' ]) {
|
||||
$_scope = -1;
|
||||
} else {
|
||||
$_scope = $compiler->convertScope($_attr, $this->valid_scopes);
|
||||
}
|
||||
// create config object
|
||||
$_output =
|
||||
"<?php\n\$_smarty_tpl->smarty->ext->configLoad->_loadConfigFile(\$_smarty_tpl, {$conf_file}, {$section}, {$_scope});\n?>\n";
|
||||
return $_output;
|
||||
}
|
||||
}
|
@@ -8,13 +8,15 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\BreakTag;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Continue Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Continue extends Smarty_Internal_Compile_Break
|
||||
class Smarty_Internal_Compile_Continue extends BreakTag
|
||||
{
|
||||
/**
|
||||
* Tag name
|
||||
|
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Debug
|
||||
* Compiles the {debug} tag.
|
||||
* It opens a window the the Smarty Debugging Console.
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Debug Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {debug} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
// check and get attributes, may trigger errors
|
||||
$this->getAttributes($compiler, $args);
|
||||
|
||||
// compile always as nocache
|
||||
$compiler->tag_nocache = true;
|
||||
// display debug template
|
||||
$_output =
|
||||
"<?php \$_smarty_debug = new \\Smarty\\Debug;\n \$_smarty_debug->display_debug(\$_smarty_tpl);\n";
|
||||
$_output .= "unset(\$_smarty_debug);\n?>";
|
||||
return $_output;
|
||||
}
|
||||
}
|
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Eval
|
||||
* Compiles the {eval} tag.
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Eval Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Eval extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('var');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('assign');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('var', 'assign');
|
||||
|
||||
/**
|
||||
* Compiles code for the {eval} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if (isset($_attr[ 'assign' ])) {
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
$_assign = $_attr[ 'assign' ];
|
||||
}
|
||||
// create template object
|
||||
$_output =
|
||||
"\$_template = new {$compiler->smarty->template_class}('eval:'.{$_attr[ 'var' ]}, \$_smarty_tpl->smarty, \$_smarty_tpl);";
|
||||
//was there an assign attribute?
|
||||
if (isset($_assign)) {
|
||||
$_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch());";
|
||||
} else {
|
||||
$_output .= 'echo $_template->fetch();';
|
||||
}
|
||||
return "<?php $_output ?>";
|
||||
}
|
||||
}
|
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Inheritance;
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile extend Class
|
||||
@@ -22,7 +23,7 @@ class Smarty_Internal_Compile_Extends extends Inheritance
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $required_attributes = array('file');
|
||||
|
||||
@@ -38,7 +39,7 @@ class Smarty_Internal_Compile_Extends extends Inheritance
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $shorttag_order = array('file');
|
||||
|
||||
@@ -52,7 +53,7 @@ class Smarty_Internal_Compile_Extends extends Inheritance
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
@@ -8,13 +8,15 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile For Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
|
||||
class _For extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {for} tag
|
||||
@@ -32,7 +34,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
$compiler->loopNesting++;
|
||||
if ($parameter === 0) {
|
||||
@@ -106,7 +108,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase
|
||||
class _Forelse extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {forelse} tag
|
||||
@@ -117,11 +119,11 @@ class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
list($openTag, $nocache) = $this->closeTag($compiler, array('for'));
|
||||
[$openTag, $nocache] = $this->closeTag($compiler, array('for'));
|
||||
$this->openTag($compiler, 'forelse', array('forelse', $nocache));
|
||||
return "<?php }} else { ?>";
|
||||
}
|
||||
@@ -133,7 +135,7 @@ class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase
|
||||
class _Forclose extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/for} tag
|
||||
@@ -144,7 +146,7 @@ class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
$compiler->loopNesting--;
|
||||
// check and get attributes
|
||||
@@ -153,7 +155,7 @@ class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase
|
||||
if ($compiler->nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
list($openTag, $compiler->nocache) = $this->closeTag($compiler, array('for', 'forelse'));
|
||||
[$openTag, $compiler->nocache] = $this->closeTag($compiler, array('for', 'forelse'));
|
||||
$output = "<?php }\n";
|
||||
if ($openTag !== 'forelse') {
|
||||
$output .= "}\n";
|
||||
|
@@ -8,19 +8,21 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreach Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_ForeachSection
|
||||
class Smarty_Internal_Compile_Foreach extends _Private_ForeachSection
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $required_attributes = array('from', 'item');
|
||||
|
||||
@@ -28,7 +30,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $optional_attributes = array('name', 'key', 'properties');
|
||||
|
||||
@@ -36,7 +38,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $shorttag_order = array('from', 'item', 'key', 'name');
|
||||
|
||||
@@ -85,7 +87,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
$compiler->loopNesting++;
|
||||
// init
|
||||
@@ -277,7 +279,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase
|
||||
class _Foreachelse extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {foreachelse} tag
|
||||
@@ -287,11 +289,11 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
list($openTag, $nocache, $local, $itemVar, $restore) = $this->closeTag($compiler, array('foreach'));
|
||||
[$openTag, $nocache, $local, $itemVar, $restore] = $this->closeTag($compiler, array('foreach'));
|
||||
$this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $local, $itemVar, 0));
|
||||
$output = "<?php\n";
|
||||
if ($restore === 2) {
|
||||
@@ -308,7 +310,7 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
|
||||
class _Foreachclose extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/foreach} tag
|
||||
@@ -319,16 +321,16 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
$compiler->loopNesting--;
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
list(
|
||||
[
|
||||
$openTag, $compiler->nocache, $local, $itemVar, $restore
|
||||
) = $this->closeTag($compiler, array('foreach', 'foreachelse'));
|
||||
] = $this->closeTag($compiler, array('foreach', 'foreachelse'));
|
||||
$output = "<?php\n";
|
||||
if ($restore === 2) {
|
||||
$output .= "{$itemVar} = {$local}saved;\n";
|
||||
|
@@ -8,19 +8,21 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Function Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||
class _Function extends Base
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $required_attributes = array('name');
|
||||
|
||||
@@ -28,7 +30,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $shorttag_order = array('name');
|
||||
|
||||
@@ -36,7 +38,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $optional_attributes = array('_any');
|
||||
|
||||
@@ -49,7 +51,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||
* @return bool true
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
@@ -82,7 +84,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
class _Functionclose extends Base
|
||||
{
|
||||
/**
|
||||
* Compiler object
|
||||
@@ -99,7 +101,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return bool true
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
$saved_data = $this->closeTag($compiler, array('function'));
|
||||
|
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Assign;
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile If Class
|
||||
@@ -16,7 +17,7 @@ use Smarty\Compile\Assign;
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
|
||||
class _If extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {if} tag
|
||||
@@ -28,7 +29,7 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
@@ -78,7 +79,7 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase
|
||||
class _Else extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {else} tag
|
||||
@@ -88,7 +89,7 @@ class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
[$nesting, $compiler->tag_nocache] = $this->closeTag($compiler, array('if', 'elseif'));
|
||||
$this->openTag($compiler, 'else', array($nesting, $compiler->tag_nocache));
|
||||
@@ -102,7 +103,7 @@ class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
||||
class _Elseif extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {elseif} tag
|
||||
@@ -114,7 +115,7 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
@@ -183,7 +184,7 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase
|
||||
class _Ifclose extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/if} tag
|
||||
@@ -193,7 +194,7 @@ class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
|
@@ -1,347 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Include
|
||||
* Compiles the {include} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Include Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* caching mode to create nocache code but no cache file
|
||||
*/
|
||||
const CACHING_NOCACHE_CODE = 9999;
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('file');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('file');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $option_flags = array('nocache', 'inline', 'caching');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('_any');
|
||||
|
||||
/**
|
||||
* Valid scope names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $valid_scopes = array(
|
||||
'parent' => \Smarty\Smarty::SCOPE_PARENT, 'root' => \Smarty\Smarty::SCOPE_ROOT,
|
||||
'global' => \Smarty\Smarty::SCOPE_GLOBAL, 'tpl_root' => \Smarty\Smarty::SCOPE_TPL_ROOT,
|
||||
'smarty' => \Smarty\Smarty::SCOPE_SMARTY
|
||||
);
|
||||
|
||||
/**
|
||||
* Compiles code for the {include} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param Smarty_Internal_SmartyTemplateCompiler $compiler compiler object
|
||||
*
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_SmartyTemplateCompiler $compiler)
|
||||
{
|
||||
$uid = $t_hash = null;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$fullResourceName = $source_resource = $_attr[ 'file' ];
|
||||
$variable_template = false;
|
||||
$cache_tpl = false;
|
||||
// parse resource_name
|
||||
if (preg_match('/^([\'"])(([A-Za-z0-9_\-]{2,})[:])?(([^$()]+)|(.+))\1$/', $source_resource, $match)) {
|
||||
$type = !empty($match[ 3 ]) ? $match[ 3 ] : $compiler->template->smarty->default_resource_type;
|
||||
$name = !empty($match[ 5 ]) ? $match[ 5 ] : $match[ 6 ];
|
||||
$handler = Smarty_Resource::load($compiler->smarty, $type);
|
||||
if ($handler->recompiled || $handler->uncompiled) {
|
||||
$variable_template = true;
|
||||
}
|
||||
if (!$variable_template) {
|
||||
if ($type !== 'string') {
|
||||
$fullResourceName = "{$type}:{$name}";
|
||||
$compiled = $compiler->parent_compiler->template->compiled;
|
||||
if (isset($compiled->includes[ $fullResourceName ])) {
|
||||
$compiled->includes[ $fullResourceName ]++;
|
||||
$cache_tpl = true;
|
||||
} else {
|
||||
if ("{$compiler->template->source->type}:{$compiler->template->source->name}" ==
|
||||
$fullResourceName
|
||||
) {
|
||||
// recursive call of current template
|
||||
$compiled->includes[ $fullResourceName ] = 2;
|
||||
$cache_tpl = true;
|
||||
} else {
|
||||
$compiled->includes[ $fullResourceName ] = 1;
|
||||
}
|
||||
}
|
||||
$fullResourceName = $match[ 1 ] . $fullResourceName . $match[ 1 ];
|
||||
}
|
||||
}
|
||||
if (empty($match[ 5 ])) {
|
||||
$variable_template = true;
|
||||
}
|
||||
} else {
|
||||
$variable_template = true;
|
||||
}
|
||||
// scope setup
|
||||
$_scope = $compiler->convertScope($_attr, $this->valid_scopes);
|
||||
// set flag to cache subtemplate object when called within loop or template name is variable.
|
||||
if ($cache_tpl || $variable_template || $compiler->loopNesting > 0) {
|
||||
$_cache_tpl = 'true';
|
||||
} else {
|
||||
$_cache_tpl = 'false';
|
||||
}
|
||||
// assume caching is off
|
||||
$_caching = \Smarty\Smarty::CACHING_OFF;
|
||||
$call_nocache = $compiler->tag_nocache || $compiler->nocache;
|
||||
// caching was on and {include} is not in nocache mode
|
||||
if ($compiler->template->caching && !$compiler->nocache && !$compiler->tag_nocache) {
|
||||
$_caching = self::CACHING_NOCACHE_CODE;
|
||||
}
|
||||
// flag if included template code should be merged into caller
|
||||
$merge_compiled_includes = ($compiler->smarty->merge_compiled_includes || $_attr[ 'inline' ] === true) &&
|
||||
!$compiler->template->source->handler->recompiled;
|
||||
if ($merge_compiled_includes) {
|
||||
// variable template name ?
|
||||
if ($variable_template) {
|
||||
$merge_compiled_includes = false;
|
||||
}
|
||||
// variable compile_id?
|
||||
if (isset($_attr[ 'compile_id' ]) && $compiler->isVariable($_attr[ 'compile_id' ])) {
|
||||
$merge_compiled_includes = false;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if the {include} tag provides individual parameter for caching or compile_id
|
||||
* the subtemplate must not be included into the common cache file and is treated like
|
||||
* a call in nocache mode.
|
||||
*
|
||||
*/
|
||||
if ($_attr[ 'nocache' ] !== true && $_attr[ 'caching' ]) {
|
||||
$_caching = $_new_caching = (int)$_attr[ 'caching' ];
|
||||
$call_nocache = true;
|
||||
} else {
|
||||
$_new_caching = \Smarty\Smarty::CACHING_LIFETIME_CURRENT;
|
||||
}
|
||||
if (isset($_attr[ 'cache_lifetime' ])) {
|
||||
$_cache_lifetime = $_attr[ 'cache_lifetime' ];
|
||||
$call_nocache = true;
|
||||
$_caching = $_new_caching;
|
||||
} else {
|
||||
$_cache_lifetime = '$_smarty_tpl->cache_lifetime';
|
||||
}
|
||||
if (isset($_attr[ 'cache_id' ])) {
|
||||
$_cache_id = $_attr[ 'cache_id' ];
|
||||
$call_nocache = true;
|
||||
$_caching = $_new_caching;
|
||||
} else {
|
||||
$_cache_id = '$_smarty_tpl->cache_id';
|
||||
}
|
||||
if (isset($_attr[ 'compile_id' ])) {
|
||||
$_compile_id = $_attr[ 'compile_id' ];
|
||||
} else {
|
||||
$_compile_id = '$_smarty_tpl->compile_id';
|
||||
}
|
||||
// if subtemplate will be called in nocache mode do not merge
|
||||
if ($compiler->template->caching && $call_nocache) {
|
||||
$merge_compiled_includes = false;
|
||||
}
|
||||
// assign attribute
|
||||
if (isset($_attr[ 'assign' ])) {
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
if ($_assign = $compiler->getId($_attr[ 'assign' ])) {
|
||||
$_assign = "'{$_assign}'";
|
||||
if ($compiler->tag_nocache || $compiler->nocache || $call_nocache) {
|
||||
// create nocache var to make it know for further compiling
|
||||
$compiler->setNocacheInVariable($_attr[ 'assign' ]);
|
||||
}
|
||||
} else {
|
||||
$_assign = $_attr[ 'assign' ];
|
||||
}
|
||||
}
|
||||
$has_compiled_template = false;
|
||||
if ($merge_compiled_includes) {
|
||||
$c_id = isset($_attr[ 'compile_id' ]) ? $_attr[ 'compile_id' ] : $compiler->template->compile_id;
|
||||
// we must observe different compile_id and caching
|
||||
$t_hash = sha1($c_id . ($_caching ? '--caching' : '--nocaching'));
|
||||
$compiler->smarty->allow_ambiguous_resources = true;
|
||||
/* @var Smarty_Internal_Template $tpl */
|
||||
$tpl = new $compiler->smarty->template_class(
|
||||
trim($fullResourceName, '"\''),
|
||||
$compiler->smarty,
|
||||
$compiler->template,
|
||||
$compiler->template->cache_id,
|
||||
$c_id,
|
||||
$_caching
|
||||
);
|
||||
$uid = $tpl->source->type . $tpl->source->uid;
|
||||
if (!isset($compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ])) {
|
||||
$has_compiled_template = $this->compileInlineTemplate($compiler, $tpl, $t_hash);
|
||||
} else {
|
||||
$has_compiled_template = true;
|
||||
}
|
||||
unset($tpl);
|
||||
}
|
||||
// delete {include} standard attributes
|
||||
unset($_attr[ 'file' ], $_attr[ 'assign' ], $_attr[ 'cache_id' ], $_attr[ 'compile_id' ], $_attr[ 'cache_lifetime' ], $_attr[ 'nocache' ], $_attr[ 'caching' ], $_attr[ 'scope' ], $_attr[ 'inline' ]);
|
||||
// remaining attributes must be assigned as smarty variable
|
||||
$_vars = 'array()';
|
||||
if (!empty($_attr)) {
|
||||
$_pairs = array();
|
||||
// create variables
|
||||
foreach ($_attr as $key => $value) {
|
||||
$_pairs[] = "'$key'=>$value";
|
||||
}
|
||||
$_vars = 'array(' . join(',', $_pairs) . ')';
|
||||
}
|
||||
$update_compile_id = $compiler->template->caching && !$compiler->tag_nocache && !$compiler->nocache &&
|
||||
$_compile_id !== '$_smarty_tpl->compile_id';
|
||||
if ($has_compiled_template && !$call_nocache) {
|
||||
$_output = "<?php\n";
|
||||
if ($update_compile_id) {
|
||||
$_output .= $compiler->makeNocacheCode("\$_compile_id_save[] = \$_smarty_tpl->compile_id;\n\$_smarty_tpl->compile_id = {$_compile_id};\n");
|
||||
}
|
||||
if (!empty($_attr) && $_caching === 9999 && $compiler->template->caching) {
|
||||
$_vars_nc = "foreach ($_vars as \$ik => \$iv) {\n";
|
||||
$_vars_nc .= "\$_smarty_tpl->tpl_vars[\$ik] = new \\Smarty\\Variable(\$iv);\n";
|
||||
$_vars_nc .= "}\n";
|
||||
$_output .= substr($compiler->processNocacheCode('<?php ' . $_vars_nc . "?>\n", true), 6, -3);
|
||||
}
|
||||
if (isset($_assign)) {
|
||||
$_output .= "ob_start();\n";
|
||||
}
|
||||
$_output .= "\$_smarty_tpl->_subTemplateRender({$fullResourceName}, {$_cache_id}, {$_compile_id}, {$_caching}, {$_cache_lifetime}, {$_vars}, {$_scope}, {$_cache_tpl}, '{$compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['uid']}', '{$compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['func']}');\n";
|
||||
if (isset($_assign)) {
|
||||
$_output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
||||
}
|
||||
if ($update_compile_id) {
|
||||
$_output .= $compiler->makeNocacheCode("\$_smarty_tpl->compile_id = array_pop(\$_compile_id_save);\n");
|
||||
}
|
||||
$_output .= "?>";
|
||||
return $_output;
|
||||
}
|
||||
if ($call_nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
$_output = "<?php ";
|
||||
if ($update_compile_id) {
|
||||
$_output .= "\$_compile_id_save[] = \$_smarty_tpl->compile_id;\n\$_smarty_tpl->compile_id = {$_compile_id};\n";
|
||||
}
|
||||
// was there an assign attribute
|
||||
if (isset($_assign)) {
|
||||
$_output .= "ob_start();\n";
|
||||
}
|
||||
$_output .= "\$_smarty_tpl->_subTemplateRender({$fullResourceName}, $_cache_id, $_compile_id, $_caching, $_cache_lifetime, $_vars, $_scope, {$_cache_tpl});\n";
|
||||
if (isset($_assign)) {
|
||||
$_output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
||||
}
|
||||
if ($update_compile_id) {
|
||||
$_output .= "\$_smarty_tpl->compile_id = array_pop(\$_compile_id_save);\n";
|
||||
}
|
||||
$_output .= "?>";
|
||||
return $_output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile inline sub template
|
||||
*
|
||||
* @param \Smarty_Internal_SmartyTemplateCompiler $compiler
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param string $t_hash
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compileInlineTemplate(
|
||||
Smarty_Internal_SmartyTemplateCompiler $compiler,
|
||||
Smarty_Internal_Template $tpl,
|
||||
$t_hash
|
||||
) {
|
||||
$uid = $tpl->source->type . $tpl->source->uid;
|
||||
if (!($tpl->source->handler->uncompiled) && $tpl->source->exists) {
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'uid' ] = $tpl->source->uid;
|
||||
if (isset($compiler->template->inheritance)) {
|
||||
$tpl->inheritance = clone $compiler->template->inheritance;
|
||||
}
|
||||
$tpl->compiled = new Smarty_Template_Compiled();
|
||||
$tpl->compiled->nocache_hash = $compiler->parent_compiler->template->compiled->nocache_hash;
|
||||
$tpl->loadCompiler();
|
||||
// save unique function name
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'func' ] =
|
||||
$tpl->compiled->unifunc = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
|
||||
// make sure whole chain gets compiled
|
||||
$tpl->mustCompile = true;
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'nocache_hash' ] =
|
||||
$tpl->compiled->nocache_hash;
|
||||
if ($tpl->source->type === 'file') {
|
||||
$sourceInfo = $tpl->source->filepath;
|
||||
} else {
|
||||
$basename = $tpl->source->handler->getBasename($tpl->source);
|
||||
$sourceInfo = $tpl->source->type . ':' .
|
||||
($basename ? $basename : $tpl->source->name);
|
||||
}
|
||||
// get compiled code
|
||||
$compiled_code = "<?php\n\n";
|
||||
$compiled_code .= $compiler->cStyleComment(" Start inline template \"{$sourceInfo}\" =============================") . "\n";
|
||||
$compiled_code .= "function {$tpl->compiled->unifunc} (Smarty_Internal_Template \$_smarty_tpl) {\n";
|
||||
$compiled_code .= "?>\n" . $tpl->compiler->compileTemplateSource($tpl, null, $compiler->parent_compiler);
|
||||
$compiled_code .= "<?php\n";
|
||||
$compiled_code .= "}\n?>\n";
|
||||
$compiled_code .= $tpl->compiler->postFilter($tpl->compiler->blockOrFunctionCode);
|
||||
$compiled_code .= "<?php\n\n";
|
||||
$compiled_code .= $compiler->cStyleComment(" End inline template \"{$sourceInfo}\" =============================") . "\n";
|
||||
$compiled_code .= '?>';
|
||||
unset($tpl->compiler);
|
||||
if ($tpl->compiled->has_nocache_code) {
|
||||
// replace nocache_hash
|
||||
$compiled_code =
|
||||
str_replace(
|
||||
"{$tpl->compiled->nocache_hash}",
|
||||
$compiler->template->compiled->nocache_hash,
|
||||
$compiled_code
|
||||
);
|
||||
$compiler->template->compiled->has_nocache_code = true;
|
||||
}
|
||||
$compiler->parent_compiler->mergedSubTemplatesCode[ $tpl->compiled->unifunc ] = $compiled_code;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,157 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Insert
|
||||
* Compiles the {insert} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Insert Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('_any');
|
||||
|
||||
/**
|
||||
* Compiles code for the {insert} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$nocacheParam = $compiler->template->caching && ($compiler->tag_nocache || $compiler->nocache);
|
||||
if (!$nocacheParam) {
|
||||
// do not compile as nocache code
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
}
|
||||
$compiler->tag_nocache = true;
|
||||
$_smarty_tpl = $compiler->template;
|
||||
$_name = null;
|
||||
$_script = null;
|
||||
$_output = '<?php ';
|
||||
// save possible attributes
|
||||
eval('$_name = @' . $_attr[ 'name' ] . ';');
|
||||
if (isset($_attr[ 'assign' ])) {
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
$_assign = $_attr[ 'assign' ];
|
||||
// create variable to make sure that the compiler knows about its nocache status
|
||||
$var = trim($_attr[ 'assign' ], '\'');
|
||||
if (isset($compiler->template->tpl_vars[ $var ])) {
|
||||
$compiler->template->tpl_vars[ $var ]->nocache = true;
|
||||
} else {
|
||||
$compiler->template->tpl_vars[ $var ] = new \Smarty\Variable(null, true);
|
||||
}
|
||||
}
|
||||
if (isset($_attr[ 'script' ])) {
|
||||
// script which must be included
|
||||
$_function = "smarty_insert_{$_name}";
|
||||
$_smarty_tpl = $compiler->template;
|
||||
$_filepath = false;
|
||||
eval('$_script = @' . $_attr[ 'script' ] . ';');
|
||||
if (!isset($compiler->smarty->security_policy) && file_exists($_script)) {
|
||||
$_filepath = $_script;
|
||||
} else {
|
||||
if (isset($compiler->smarty->security_policy)) {
|
||||
$_dir = $compiler->smarty->security_policy->trusted_dir;
|
||||
} else {
|
||||
$_dir = null;
|
||||
}
|
||||
if (!empty($_dir)) {
|
||||
foreach ((array)$_dir as $_script_dir) {
|
||||
$_script_dir = rtrim($_script_dir ?? '', '/\\') . DIRECTORY_SEPARATOR;
|
||||
if (file_exists($_script_dir . $_script)) {
|
||||
$_filepath = $_script_dir . $_script;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($_filepath === false) {
|
||||
$compiler->trigger_template_error("{insert} missing script file '{$_script}'", null, true);
|
||||
}
|
||||
// code for script file loading
|
||||
$_output .= "require_once '{$_filepath}' ;";
|
||||
include_once $_filepath;
|
||||
if (!is_callable($_function)) {
|
||||
$compiler->trigger_template_error(
|
||||
" {insert} function '{$_function}' is not callable in script file '{$_script}'",
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$_filepath = 'null';
|
||||
$_function = "insert_{$_name}";
|
||||
// function in PHP script ?
|
||||
if (!is_callable($_function)) {
|
||||
// try plugin
|
||||
if (!$_function = $compiler->getPlugin($_name, 'insert')) {
|
||||
$compiler->trigger_template_error(
|
||||
"{insert} no function or plugin found for '{$_name}'",
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// delete {insert} standard attributes
|
||||
unset($_attr[ 'name' ], $_attr[ 'assign' ], $_attr[ 'script' ], $_attr[ 'nocache' ]);
|
||||
// convert attributes into parameter array string
|
||||
$_paramsArray = array();
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
$_paramsArray[] = "'$_key' => $_value";
|
||||
}
|
||||
$_params = 'array(' . implode(", ", $_paramsArray) . ')';
|
||||
// call insert
|
||||
if (isset($_assign)) {
|
||||
if ($_smarty_tpl->caching && !$nocacheParam) {
|
||||
$_output .= "echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}',{$_assign});?>";
|
||||
} else {
|
||||
$_output .= "\$_smarty_tpl->assign({$_assign} , {$_function} ({$_params},\$_smarty_tpl), true);?>";
|
||||
}
|
||||
} else {
|
||||
if ($_smarty_tpl->caching && !$nocacheParam) {
|
||||
$_output .= "echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}');?>";
|
||||
} else {
|
||||
$_output .= "echo {$_function}({$_params},\$_smarty_tpl);?>";
|
||||
}
|
||||
}
|
||||
$compiler->template->compiled->has_nocache_code = true;
|
||||
return $_output;
|
||||
}
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Ldelim
|
||||
* Compiles the {ldelim} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Ldelim Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Ldelim extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {ldelim} tag
|
||||
* This tag does output the left delimiter
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
return $compiler->smarty->left_delimiter;
|
||||
}
|
||||
}
|
@@ -8,13 +8,15 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Nocache Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase
|
||||
class _Nocache extends Base
|
||||
{
|
||||
/**
|
||||
* Array of names of valid option flags
|
||||
@@ -32,7 +34,7 @@ class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$this->openTag($compiler, 'nocache', array($compiler->nocache));
|
||||
@@ -50,7 +52,7 @@ class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase
|
||||
class _Nocacheclose extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/nocache} tag
|
||||
@@ -61,11 +63,11 @@ class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// leave nocache mode
|
||||
list($compiler->nocache) = $this->closeTag($compiler, array('nocache'));
|
||||
[$compiler->nocache] = $this->closeTag($compiler, array('nocache'));
|
||||
// this tag does not return compiled code
|
||||
$compiler->has_code = false;
|
||||
return true;
|
||||
|
@@ -8,12 +8,14 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Child;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Parent Class
|
||||
*
|
||||
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||
*/
|
||||
class Smarty_Internal_Compile_Parent extends Smarty_Internal_Compile_Child
|
||||
class Smarty_Internal_Compile_Parent extends Child
|
||||
{
|
||||
/**
|
||||
* Tag name
|
||||
|
@@ -1,150 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Modifier
|
||||
* Compiles code for modifier execution
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Modifier Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for modifier execution
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$output = $parameter[ 'value' ];
|
||||
// loop over list of modifiers
|
||||
foreach ($parameter[ 'modifierlist' ] as $single_modifier) {
|
||||
/* @var string $modifier */
|
||||
$modifier = $single_modifier[ 0 ];
|
||||
$single_modifier[ 0 ] = $output;
|
||||
$params = implode(',', $single_modifier);
|
||||
// check if we know already the type of modifier
|
||||
if (isset($compiler->known_modifier_type[ $modifier ])) {
|
||||
$modifier_types = array($compiler->known_modifier_type[ $modifier ]);
|
||||
} else {
|
||||
$modifier_types = array(1, 2, 3, 4, 5, 6);
|
||||
}
|
||||
foreach ($modifier_types as $type) {
|
||||
switch ($type) {
|
||||
case 1:
|
||||
// registered modifier
|
||||
if (isset($compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_MODIFIER ][ $modifier ])) {
|
||||
if (is_callable($compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ])) {
|
||||
$output =
|
||||
sprintf(
|
||||
'call_user_func_array($_smarty_tpl->registered_plugins[ \'%s\' ][ %s ][ 0 ], array( %s ))',
|
||||
\Smarty\Smarty::PLUGIN_MODIFIER,
|
||||
var_export($modifier, true),
|
||||
$params
|
||||
);
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// registered modifier compiler
|
||||
if (isset($compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ])) {
|
||||
$output =
|
||||
call_user_func(
|
||||
$compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ],
|
||||
$single_modifier,
|
||||
$compiler->smarty
|
||||
);
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// modifiercompiler plugin
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy)
|
||||
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
||||
) {
|
||||
$plugin = 'smarty_modifiercompiler_' . $modifier;
|
||||
$output = $plugin($single_modifier, $compiler);
|
||||
}
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
break 2;
|
||||
case 4:
|
||||
// modifier plugin
|
||||
if ($function = $compiler->getPlugin($modifier, \Smarty\Smarty::PLUGIN_MODIFIER)) {
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy)
|
||||
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
||||
) {
|
||||
$output = "{$function}({$params})";
|
||||
}
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
// PHP function
|
||||
if (is_callable($modifier)) {
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy)
|
||||
|| $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)
|
||||
) {
|
||||
trigger_error('Using php-function "' . $modifier . '" as a modifier is deprecated and will be ' .
|
||||
'removed in a future release. Use Smarty::registerPlugin to explicitly register ' .
|
||||
'a custom modifier.', E_USER_DEPRECATED);
|
||||
$output = "{$modifier}({$params})";
|
||||
}
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
// default plugin handler
|
||||
if (isset($compiler->default_handler_plugins[ \Smarty\Smarty::PLUGIN_MODIFIER ][ $modifier ])
|
||||
|| (is_callable($compiler->smarty->default_plugin_handler_func)
|
||||
&& $compiler->getPluginFromDefaultHandler($modifier, \Smarty\Smarty::PLUGIN_MODIFIER))
|
||||
) {
|
||||
$function = $compiler->default_handler_plugins[ \Smarty\Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ];
|
||||
// check if modifier allowed
|
||||
if (!is_object($compiler->smarty->security_policy)
|
||||
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
||||
) {
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$params})";
|
||||
} else {
|
||||
if (is_object($function[ 0 ])) {
|
||||
$output = $function[ 0 ] . '->' . $function[ 1 ] . '(' . $params . ')';
|
||||
} else {
|
||||
$output = $function[ 0 ] . '::' . $function[ 1 ] . '(' . $params . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($compiler->known_modifier_type[ $modifier ])) {
|
||||
$compiler->trigger_template_error("unknown modifier '{$modifier}'", null, true);
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
@@ -14,7 +14,7 @@
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Internal_Compile_Private_Block_Plugin
|
||||
class Smarty_Internal_Compile_Private_Object_Block_Function extends _Private_Block_Plugin
|
||||
{
|
||||
/**
|
||||
* Setup callback and parameter array
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_Compile_Private_Block_Plugin
|
||||
class Smarty_Internal_Compile_Private_Registered_Block extends _Private_Block_Plugin
|
||||
{
|
||||
/**
|
||||
* Setup callback, parameter array and nocache mode
|
||||
|
@@ -8,13 +8,15 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Ldelim;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Rdelim Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_Compile_Ldelim
|
||||
class Smarty_Internal_Compile_Rdelim extends Ldelim
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {rdelim} tag
|
||||
@@ -26,7 +28,7 @@ class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_Compile_Ldelim
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
parent::compile($args, $compiler);
|
||||
return $compiler->smarty->right_delimiter;
|
||||
|
@@ -8,19 +8,21 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Section Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_ForeachSection
|
||||
class Smarty_Internal_Compile_Section extends _Private_ForeachSection
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $required_attributes = array('name', 'loop');
|
||||
|
||||
@@ -28,7 +30,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $shorttag_order = array('name', 'loop');
|
||||
|
||||
@@ -36,7 +38,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
* @see Base
|
||||
*/
|
||||
public $optional_attributes = array('start', 'step', 'max', 'show', 'properties');
|
||||
|
||||
@@ -88,7 +90,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
$compiler->loopNesting++;
|
||||
// check and get attributes
|
||||
@@ -405,7 +407,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Sectionelse extends Smarty_Internal_CompileBase
|
||||
class _Sectionelse extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {sectionelse} tag
|
||||
@@ -415,11 +417,11 @@ class Smarty_Internal_Compile_Sectionelse extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
list($openTag, $nocache, $local, $sectionVar) = $this->closeTag($compiler, array('section'));
|
||||
[$openTag, $nocache, $local, $sectionVar] = $this->closeTag($compiler, array('section'));
|
||||
$this->openTag($compiler, 'sectionelse', array('sectionelse', $nocache, $local, $sectionVar));
|
||||
return "<?php }} else {\n ?>";
|
||||
}
|
||||
@@ -431,7 +433,7 @@ class Smarty_Internal_Compile_Sectionelse extends Smarty_Internal_CompileBase
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase
|
||||
class _Sectionclose extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/section} tag
|
||||
@@ -441,14 +443,14 @@ class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
$compiler->loopNesting--;
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
list($openTag, $compiler->nocache, $local, $sectionVar) =
|
||||
[$openTag, $compiler->nocache, $local, $sectionVar] =
|
||||
$this->closeTag($compiler, array('section', 'sectionelse'));
|
||||
$output = "<?php\n";
|
||||
if ($openTag === 'sectionelse') {
|
||||
|
@@ -8,13 +8,15 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Setfilter Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase
|
||||
class _Setfilter extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for setfilter tag
|
||||
@@ -25,7 +27,7 @@ class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
$compiler->variable_filter_stack[] = $compiler->variable_filters;
|
||||
$compiler->variable_filters = $parameter[ 'modifier_list' ];
|
||||
@@ -41,7 +43,7 @@ class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase
|
||||
class _Setfilterclose extends Base
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/setfilter} tag
|
||||
@@ -52,7 +54,7 @@ class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// reset variable filter to previous state
|
||||
|
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile While
|
||||
* Compiles the {while} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
use Smarty\Compile\Assign;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile While Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {while} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
$compiler->loopNesting++;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$this->openTag($compiler, 'while', $compiler->nocache);
|
||||
if (!array_key_exists('if condition', $parameter)) {
|
||||
$compiler->trigger_template_error('missing while condition', null, true);
|
||||
}
|
||||
// maybe nocache because of nocache variables
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
if (is_array($parameter[ 'if condition' ])) {
|
||||
if ($compiler->nocache) {
|
||||
// create nocache var to make it know for further compiling
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$var = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||
} else {
|
||||
$var = $parameter[ 'if condition' ][ 'var' ];
|
||||
}
|
||||
$compiler->setNocacheInVariable($var);
|
||||
}
|
||||
$prefixVar = $compiler->getNewPrefixVariable();
|
||||
$assignCompiler = new Assign();
|
||||
$assignAttr = array();
|
||||
$assignAttr[][ 'value' ] = $prefixVar;
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
|
||||
$_output .= $assignCompiler->compile(
|
||||
$assignAttr,
|
||||
$compiler,
|
||||
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])
|
||||
);
|
||||
} else {
|
||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
|
||||
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
|
||||
$_output .= $assignCompiler->compile($assignAttr, $compiler, array());
|
||||
}
|
||||
return $_output;
|
||||
} else {
|
||||
return "<?php\n while ({$parameter['if condition']}) {?>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Whileclose Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/while} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$compiler->loopNesting--;
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
$compiler->nocache = $this->closeTag($compiler, array('while'));
|
||||
return "<?php }?>\n";
|
||||
}
|
||||
}
|
@@ -1,203 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin CompileBase
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class does extend all internal compile plugins
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
abstract class Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Array of names of required attribute required by tag
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $required_attributes = array();
|
||||
|
||||
/**
|
||||
* Array of names of optional attribute required by tag
|
||||
* use array('_any') if there is no restriction of attributes names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $optional_attributes = array();
|
||||
|
||||
/**
|
||||
* Shorttag attribute order defined by its names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $shorttag_order = array();
|
||||
|
||||
/**
|
||||
* Array of names of valid option flags
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $option_flags = array('nocache');
|
||||
|
||||
/**
|
||||
* Mapping array for boolean option value
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $optionMap = array(1 => true, 0 => false, 'true' => true, 'false' => false);
|
||||
|
||||
/**
|
||||
* Mapping array with attributes as key
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $mapCache = array();
|
||||
|
||||
/**
|
||||
* This function checks if the attributes passed are valid
|
||||
* The attributes passed for the tag to compile are checked against the list of required and
|
||||
* optional attributes. Required attributes must be present. Optional attributes are check against
|
||||
* the corresponding list. The keyword '_any' specifies that any attribute will be accepted
|
||||
* as valid
|
||||
*
|
||||
* @param object $compiler compiler object
|
||||
* @param array $attributes attributes applied to the tag
|
||||
*
|
||||
* @return array of mapped attributes for further processing
|
||||
*/
|
||||
public function getAttributes($compiler, $attributes)
|
||||
{
|
||||
$_indexed_attr = array();
|
||||
if (!isset($this->mapCache[ 'option' ])) {
|
||||
$this->mapCache[ 'option' ] = array_fill_keys($this->option_flags, true);
|
||||
}
|
||||
foreach ($attributes as $key => $mixed) {
|
||||
// shorthand ?
|
||||
if (!is_array($mixed)) {
|
||||
// option flag ?
|
||||
if (isset($this->mapCache[ 'option' ][ trim($mixed, '\'"') ])) {
|
||||
$_indexed_attr[ trim($mixed, '\'"') ] = true;
|
||||
// shorthand attribute ?
|
||||
} elseif (isset($this->shorttag_order[ $key ])) {
|
||||
$_indexed_attr[ $this->shorttag_order[ $key ] ] = $mixed;
|
||||
} else {
|
||||
// too many shorthands
|
||||
$compiler->trigger_template_error('too many shorthand attributes', null, true);
|
||||
}
|
||||
// named attribute
|
||||
} else {
|
||||
foreach ($mixed as $k => $v) {
|
||||
// option flag?
|
||||
if (isset($this->mapCache[ 'option' ][ $k ])) {
|
||||
if (is_bool($v)) {
|
||||
$_indexed_attr[ $k ] = $v;
|
||||
} else {
|
||||
if (is_string($v)) {
|
||||
$v = trim($v, '\'" ');
|
||||
}
|
||||
if (isset($this->optionMap[ $v ])) {
|
||||
$_indexed_attr[ $k ] = $this->optionMap[ $v ];
|
||||
} else {
|
||||
$compiler->trigger_template_error(
|
||||
"illegal value '" . var_export($v, true) .
|
||||
"' for option flag '{$k}'",
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
// must be named attribute
|
||||
} else {
|
||||
$_indexed_attr[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if all required attributes present
|
||||
foreach ($this->required_attributes as $attr) {
|
||||
if (!isset($_indexed_attr[ $attr ])) {
|
||||
$compiler->trigger_template_error("missing '{$attr}' attribute", null, true);
|
||||
}
|
||||
}
|
||||
// check for not allowed attributes
|
||||
if ($this->optional_attributes !== array('_any')) {
|
||||
if (!isset($this->mapCache[ 'all' ])) {
|
||||
$this->mapCache[ 'all' ] =
|
||||
array_fill_keys(
|
||||
array_merge(
|
||||
$this->required_attributes,
|
||||
$this->optional_attributes,
|
||||
$this->option_flags
|
||||
),
|
||||
true
|
||||
);
|
||||
}
|
||||
foreach ($_indexed_attr as $key => $dummy) {
|
||||
if (!isset($this->mapCache[ 'all' ][ $key ]) && $key !== 0) {
|
||||
$compiler->trigger_template_error("unexpected '{$key}' attribute", null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
// default 'false' for all option flags not set
|
||||
foreach ($this->option_flags as $flag) {
|
||||
if (!isset($_indexed_attr[ $flag ])) {
|
||||
$_indexed_attr[ $flag ] = false;
|
||||
}
|
||||
}
|
||||
if (isset($_indexed_attr[ 'nocache' ]) && $_indexed_attr[ 'nocache' ]) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
return $_indexed_attr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push opening tag name on stack
|
||||
* Optionally additional data can be saved on stack
|
||||
*
|
||||
* @param object $compiler compiler object
|
||||
* @param string $openTag the opening tag's name
|
||||
* @param mixed $data optional data saved
|
||||
*/
|
||||
public function openTag($compiler, $openTag, $data = null)
|
||||
{
|
||||
array_push($compiler->_tag_stack, array($openTag, $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop closing tag
|
||||
* Raise an error if this stack-top doesn't match with expected opening tags
|
||||
*
|
||||
* @param object $compiler compiler object
|
||||
* @param array|string $expectedTag the expected opening tag names
|
||||
*
|
||||
* @return mixed any type the opening tag's name or saved data
|
||||
*/
|
||||
public function closeTag($compiler, $expectedTag)
|
||||
{
|
||||
if (count($compiler->_tag_stack) > 0) {
|
||||
// get stacked info
|
||||
list($_openTag, $_data) = array_pop($compiler->_tag_stack);
|
||||
// open tag must match with the expected ones
|
||||
if (in_array($_openTag, (array)$expectedTag)) {
|
||||
if (is_null($_data)) {
|
||||
// return opening tag
|
||||
return $_openTag;
|
||||
} else {
|
||||
// return restored data
|
||||
return $_data;
|
||||
}
|
||||
}
|
||||
// wrong nesting of tags
|
||||
$compiler->trigger_template_error("unclosed '{$compiler->smarty->left_delimiter}{$_openTag}{$compiler->smarty->right_delimiter}' tag");
|
||||
return;
|
||||
}
|
||||
// wrong nesting of tags
|
||||
$compiler->trigger_template_error('unexpected closing tag', null, true);
|
||||
return;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user