- new feature {parent} = {$smarty.block.parent} {child} = {$smarty.block.child}

This commit is contained in:
Uwe Tews
2018-03-26 22:35:31 +02:00
parent c81948d602
commit 0dbace8321
14 changed files with 2012 additions and 1707 deletions

View File

@@ -1,4 +1,11 @@
3.1.31-dev
3.1.3"
New tags for inheritance parent and chilD
{parent} == {$smarty.block.parent}
{child} == {$smarty.block.child}
Both tags support the assign attribute like
{child assign=foo}
3.1.31
New tags for inheritance parent and child
{block_parent} == {$smarty.block.parent}
{block_child} == {$smarty.block.child}

View File

@@ -2,7 +2,12 @@
This file contains a brief description of new features which have been added to Smarty 3.1
Smarty 3.1.32
Smarty 3.1.32 New tags for inheritance parent and child
=========================================
{parent} == {$smarty.block.parent}
{child} == {$smarty.block.child}
Both tags support the assign attribute like
{child assign=foo}
Deprecate functions Smarty::muteExpectedErrors() and Smarty::unmuteExpectedErrors()
===================================================================================
@@ -44,7 +49,7 @@ Smarty 3.1.32
....
{/foreach}
Smarty 3.1.31
Smarty 3.1.31
New tags for inheritance parent and child
=========================================
{block_parent} == {$smarty.block.parent}

View File

@@ -1,4 +1,7 @@
===== 3.1.32 - dev ===
26.03.2018
- new feature {parent} = {$smarty.block.parent} {child} = {$smarty.block.child}
23.03.2018
- bugfix preg_replace could fail on large content resulting in a blank page https://github.com/smarty-php/smarty/issues/417

View File

@@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.32-dev-43';
const SMARTY_VERSION = '3.1.32-dev-44';
/**
* define variable scopes
*/

View File

@@ -22,7 +22,6 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array('name');
/**
* Attribute definition: Overwrites base class.
*
@@ -30,7 +29,6 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
* @see Smarty_Internal_CompileBase
*/
public $shorttag_order = array('name');
/**
* Attribute definition: Overwrites base class.
*
@@ -38,7 +36,6 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
* @see Smarty_Internal_CompileBase
*/
public $option_flags = array('hide', 'nocache');
/**
* Attribute definition: Overwrites base class.
*
@@ -47,27 +44,20 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
*/
public $optional_attributes = array('assign');
/**
* Saved compiler object
*
* @var Smarty_Internal_TemplateCompilerBase
*/
public $compiler = null;
/**
* Compiles code for the {block} tag
*
* @param array $args array with attributes from parser
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
* @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
*/
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
if (!isset($compiler->_cache['blockNesting'])) {
$compiler->_cache['blockNesting'] = 0;
if (!isset($compiler->_cache[ 'blockNesting' ])) {
$compiler->_cache[ 'blockNesting' ] = 0;
}
if ($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');
@@ -76,70 +66,23 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
}
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
$compiler->_cache['blockNesting']++;
++$compiler->_cache[ 'blockNesting' ];
$_className = 'Block_' . preg_replace('![^\w]+!', '_', uniqid(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;
$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));
// must whole block be nocache ?
if ($compiler->tag_nocache) {
$i = 0;
}
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
// $compiler->suppressNocacheProcessing = true;
if ($_attr['nocache'] === true) {
//$compiler->trigger_template_error('nocache option not allowed', $compiler->parser->lex->taglineno);
}
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
$compiler->template->compiled->has_nocache_code = false;
$compiler->suppressNocacheProcessing = true;
}
/**
* Compiles code for the {$smarty.block.parent} or {$smarty.block.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 compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
$name = isset($parameter[1]) ? $compiler->getId($parameter[1]) : false;
if (!$name) {
$compiler->trigger_template_error("invalid '\$smarty.block' expected '\$smarty.block.child' or '\$smarty.block.parent'",
null,
true);
}
if (!isset($compiler->_cache['blockNesting'])) {
$compiler->trigger_template_error(" '\$smarty.block.{$name}' used outside {block} tags ",
$compiler->parser->lex->taglineno);
}
$compiler->suppressNocacheProcessing = true;
switch ($name) {
case 'child':
$compiler->_cache['blockParams'][ $compiler->_cache['blockNesting'] ]['callsChild'] = 'true';
return '$_smarty_tpl->inheritance->callChild($_smarty_tpl, $this, true)';
break;
case 'parent':
return '$_smarty_tpl->inheritance->callParent($_smarty_tpl, $this, null, true)';
break;
default:
$compiler->trigger_template_error("invalid '\$smarty.block.{$name}' expected '\$smarty.block.child' or '\$smarty.block.parent'",
null,
true);
}
}
}
/**
* Smarty Internal Plugin Compile BlockClose Class
*
@@ -149,27 +92,27 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
/**
* Compiles code for the {/block} tag
*
* @param array $args array with attributes from parser
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
* @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
* @internal param array $parameter array with compilation parameter
* @return bool true
*/
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
list($_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']);
$_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'] ];
$_className = $compiler->_cache[ 'blockClass' ][ $compiler->_cache[ 'blockNesting' ] ];
// get compiled block code
$_functionCode = $compiler->parser->current_buffer;
// setup buffer for template function code
@@ -180,7 +123,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
$output .= "class {$_className} extends Smarty_Internal_Block\n";
$output .= "{\n";
foreach ($_block as $property => $value) {
$output .= "public \${$property} = " . var_export($value, true) . ";\n";
$output .= "public \${$property} = " . var_export($value,true) .";\n";
}
$output .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n";
//$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\n";
@@ -206,13 +149,13 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
$compiler->parser->current_buffer->append_subtree($compiler->parser,
new Smarty_Internal_ParseTree_Tag($compiler->parser,
$output));
$compiler->blockOrFunctionCode .= $f = $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
$compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
// nocache plugins must be copied
if (!empty($compiler->template->compiled->required_plugins['nocache'])) {
foreach ($compiler->template->compiled->required_plugins['nocache'] as $plugin => $tmp) {
if (!empty($compiler->template->compiled->required_plugins[ 'nocache' ])) {
foreach ($compiler->template->compiled->required_plugins[ 'nocache' ] as $plugin => $tmp) {
foreach ($tmp as $type => $data) {
$compiler->parent_compiler->template->compiled->required_plugins['compiled'][ $plugin ][ $type ] =
$compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin ][ $type ] =
$data;
}
}
@@ -224,16 +167,17 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
$compiler->nocache = $_nocache;
$compiler->parser->current_buffer = $_buffer;
$output = "<?php \n";
if ($compiler->_cache['blockNesting'] === 1) {
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->_cache[ 'blockNesting' ];
if ($compiler->_cache[ 'blockNesting' ] === 0) {
unset($compiler->_cache[ 'blockNesting' ]);
}
$compiler->has_code = true;
$compiler->suppressNocacheProcessing = true;
return $output;
}

View File

@@ -0,0 +1,24 @@
<?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 Block Child Class
*
* @author Uwe Tews <uwe.tews@googlemail.com>
*/
class Smarty_Internal_Compile_Block_Child extends Smarty_Internal_Compile_Child
{
/**
* Tag name
*
* @var string
*/
public $tag = 'block_child';
}

View File

@@ -0,0 +1,31 @@
<?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 Block Parent Class
*
* @author Uwe Tews <uwe.tews@googlemail.com>
*/
class Smarty_Internal_Compile_Block_Parent extends Smarty_Internal_Compile_Child
{
/**
* Tag name
*
* @var string
*/
public $tag = 'block_parent';
/**
* Block type
*
* @var string
*/
public $blockType = 'Parent';
}

View File

@@ -0,0 +1,77 @@
<?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;
}
}

View File

@@ -0,0 +1,32 @@
<?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 Parent Class
*
* @author Uwe Tews <uwe.tews@googlemail.com>
*/
class Smarty_Internal_Compile_Parent extends Smarty_Internal_Compile_Child
{
/**
* Tag name
*
* @var string
*/
public $tag = 'parent';
/**
* Block type
*
* @var string
*/
public $blockType = 'Parent';
}

View File

@@ -51,9 +51,6 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
return '';
case 'now':
return 'time()';
case 'block':
$tag = $compiler->getTagCompiler('block');
return $tag->compileSpecialVariable(array(), $compiler, $_index);
case 'cookies':
if (isset($compiler->smarty->security_policy) &&
!$compiler->smarty->security_policy->allow_super_globals
@@ -114,7 +111,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
case 'rdelim':
return "\$_smarty_tpl->smarty->right_delimiter";
default:
$compiler->trigger_template_error('$smarty.' . trim($_index[ 0 ], '\'') . ' is not defined');
$compiler->trigger_template_error('$smarty.' . trim($_index[ 0 ], "'") . ' is not defined');
break;
}
if (isset($_index[ 1 ])) {

View File

@@ -42,11 +42,10 @@ class Smarty_Internal_Runtime_Inheritance
*
* @var int
*/
public $tplIndex = -1;
public $tplIndex = - 1;
/**
* Array of template source objects
* - key template index
*
* @var Smarty_Template_Source[]
*/
@@ -75,7 +74,7 @@ class Smarty_Internal_Runtime_Inheritance
$tpl->inheritance->init($tpl, $initChild, $blockNames);
return;
}
$this->tplIndex++;
++$this->tplIndex;
$this->sources[ $this->tplIndex ] = $tpl->source;
// start of child sub template(s)
@@ -85,7 +84,7 @@ class Smarty_Internal_Runtime_Inheritance
//grab any output of child templates
ob_start();
}
$this->inheritanceLevel++;
++$this->inheritanceLevel;
// $tpl->startRenderCallbacks[ 'inheritance' ] = array($this, 'subTemplateStart');
// $tpl->endRenderCallbacks[ 'inheritance' ] = array($this, 'subTemplateEnd');
}
@@ -109,7 +108,7 @@ class Smarty_Internal_Runtime_Inheritance
*/
public function endChild(Smarty_Internal_Template $tpl, $template = null, $uid = null, $func = null)
{
$this->inheritanceLevel--;
--$this->inheritanceLevel;
if (!$this->inheritanceLevel) {
ob_end_clean();
$this->state = 2;
@@ -167,8 +166,7 @@ class Smarty_Internal_Runtime_Inheritance
*
* @throws \SmartyException
*/
public function process(Smarty_Internal_Template $tpl,
Smarty_Internal_Block $block,
public function process(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block,
Smarty_Internal_Block $parent = null)
{
if ($block->hide && !isset($block->child)) {
@@ -179,7 +177,7 @@ class Smarty_Internal_Runtime_Inheritance
}
$block->parent = $parent;
if ($block->append && !$block->prepend && isset($parent)) {
$this->callParent($tpl, $block);
$this->callParent($tpl, $block, '\'{block append}\'');
}
if ($block->callsChild || !isset($block->child) || ($block->child->hide && !isset($block->child->child))) {
$this->callBlock($block, $tpl);
@@ -187,7 +185,7 @@ class Smarty_Internal_Runtime_Inheritance
$this->process($tpl, $block->child, $block);
}
if ($block->prepend && isset($parent)) {
$this->callParent($tpl, $block);
$this->callParent($tpl, $block, '{block prepend}');
if ($block->append) {
if ($block->callsChild || !isset($block->child) ||
($block->child->hide && !isset($block->child->child))
@@ -202,70 +200,42 @@ class Smarty_Internal_Runtime_Inheritance
}
/**
* Render child on $smarty.block.child
* Render child on \$smarty.block.child
*
* @param \Smarty_Internal_Template $tpl
* @param \Smarty_Internal_Block $block
* @param boolean $returnContent flag if content shall be returned
*
* @return null|string null or block content dependent on $returnContent
* @return null|string block content
* @throws \SmartyException
*/
public function callChild(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block, $returnContent = false)
public function callChild(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block)
{
if ($returnContent) {
ob_start();
}
if (isset($block->child)) {
$this->process($tpl, $block->child, $block);
}
if ($returnContent) {
return ob_get_clean();
}
return;
}
/**
* Render parent block on $smarty.block.parent or {block append/prepend}
* Render parent block on \$smarty.block.parent or {block append/prepend}
*
* @param \Smarty_Internal_Template $tpl
* @param \Smarty_Internal_Block $block
* @param null|string $name
* @param boolean $returnContent flag if content shall be returned
* @param string $tag
*
* @return null|string null or block content dependent on $returnContent
* @return null|string block content
* @throws \SmartyException
*/
public function callParent(Smarty_Internal_Template $tpl,
Smarty_Internal_Block $block,
$name = null,
$returnContent = false)
public function callParent(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block, $tag)
{
if ($returnContent) {
ob_start();
}
if (isset($name)) {
$block = $block->parent;
while (isset($block)) {
if (isset($block->subBlocks[ $name ])) {
} else {
$block = $block->parent;
}
}
return;
} else if (isset($block->parent)) {
if (isset($block->parent)) {
$this->callBlock($block->parent, $tpl);
} else {
throw new SmartyException("inheritance: illegal '\$smarty.block.parent' or {block append/prepend} used in parent template '{$tpl->inheritance->sources[$block->tplIndex]->filepath}' block '{$block->name}'");
throw new SmartyException("inheritance: illegal '{$tag}' used in child template '{$tpl->inheritance->sources[$block->tplIndex]->filepath}' block '{$block->name}'");
}
if ($returnContent) {
return ob_get_clean();
}
return;
}
/**
* redender block
* render block
*
* @param \Smarty_Internal_Block $block
* @param \Smarty_Internal_Template $tpl

View File

@@ -18,10 +18,10 @@
*/
class Smarty_Internal_Templatelexer
{
const TEXT = 1;
const TAG = 2;
const TAGBODY = 3;
const LITERAL = 4;
const TEXT = 1;
const TAG = 2;
const TAGBODY = 3;
const LITERAL = 4;
const DOUBLEQUOTEDSTRING = 5;
/**
* Source
@@ -192,8 +192,8 @@ class Smarty_Internal_Templatelexer
* @var null
*/
private $yy_global_pattern5 = null;
private $_yy_state = 1;
private $_yy_stack = array();
private $_yy_state = 1;
private $_yy_stack = array();
/**
* constructor
@@ -239,7 +239,7 @@ class Smarty_Internal_Templatelexer
return $this->compiler->replaceDelimiter($preg);
}
/**
/**
* check if current value is an autoliteral left delimiter
*
* @return bool
@@ -306,7 +306,7 @@ class Smarty_Internal_Templatelexer
}
}
public function yylex1()
public function yylex1()
{
if (!isset($this->yy_global_pattern1)) {
$this->yy_global_pattern1 =
@@ -398,7 +398,7 @@ class Smarty_Internal_Templatelexer
$this->yypushstate(self::LITERAL);
}
function yy_r1_12()
function yy_r1_12()
{
$this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
$this->yypushstate(self::LITERAL);
@@ -420,11 +420,11 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
public function yylex2()
public function yylex2()
{
if (!isset($this->yy_global_pattern2)) {
$this->yy_global_pattern2 =
$this->replace("/\G((SMARTYldel)SMARTYal(if|elseif|else if|while)\\s+)|\G((SMARTYldel)SMARTYalfor\\s+)|\G((SMARTYldel)SMARTYalforeach(?![^\s]))|\G((SMARTYldel)SMARTYalsetfilter\\s+)|\G((SMARTYldel)SMARTYalmake_nocache\\s+)|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal)/isS");
$this->replace("/\G((SMARTYldel)SMARTYal(if|elseif|else if|while)\\s+)|\G((SMARTYldel)SMARTYalfor\\s+)|\G((SMARTYldel)SMARTYalforeach(?![^\s]))|\G((SMARTYldel)SMARTYalsetfilter\\s+)|\G((SMARTYldel)SMARTYalmake_nocache\\s+)|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$]smarty\\.block\\.(child|parent)\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/][0-9]*[a-zA-Z_]\\w*\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal)/isS");
}
if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data);
@@ -518,13 +518,20 @@ class Smarty_Internal_Templatelexer
}
function yy_r2_15()
{
$this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT;
$this->taglineno = $this->line;
}
function yy_r2_18()
{
$this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_CLOSETAG;
$this->taglineno = $this->line;
}
function yy_r2_17()
function yy_r2_20()
{
if ($this->_yy_stack[ count($this->_yy_stack) - 1 ] === self::TEXT) {
$this->yypopstate();
@@ -538,21 +545,21 @@ class Smarty_Internal_Templatelexer
}
} // end function
function yy_r2_20()
function yy_r2_23()
{
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
function yy_r2_22()
function yy_r2_25()
{
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
public function yylex3()
public function yylex3()
{
if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 =
@@ -830,7 +837,7 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_HEX;
}
function yy_r3_58()
function yy_r3_58()
{
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
} // end function
@@ -840,7 +847,7 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
public function yylex4()
public function yylex4()
{
if (!isset($this->yy_global_pattern4)) {
$this->yy_global_pattern4 =
@@ -912,12 +919,12 @@ class Smarty_Internal_Templatelexer
}
}
function yy_r4_5()
function yy_r4_5()
{
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
} // end function
public function yylex5()
public function yylex5()
{
if (!isset($this->yy_global_pattern5)) {
$this->yy_global_pattern5 =

File diff suppressed because it is too large Load Diff

View File

@@ -200,7 +200,7 @@ class Smarty_Internal_TestInstall
} else {
$errors[ 'plugins_dir' ] = $message;
}
} else if ($_core_plugins_dir && $_core_plugins_dir === realpath($plugin_dir)) {
} else if ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) {
$_core_plugins_available = true;
if ($errors === null) {
echo "$plugin_dir is OK.\n";
@@ -332,157 +332,159 @@ class Smarty_Internal_TestInstall
// test if sysplugins are available
$source = SMARTY_SYSPLUGINS_DIR;
if (is_dir($source)) {
$expectedSysplugins = array(
'smartycompilerexception.php' => true,
'smartyexception.php' => true,
'smarty_cacheresource.php' => true,
'smarty_cacheresource_custom.php' => true,
'smarty_cacheresource_keyvaluestore.php' => true,
'smarty_data.php' => true,
'smarty_internal_block.php' => true,
'smarty_internal_cacheresource_file.php' => true,
'smarty_internal_compilebase.php' => true,
'smarty_internal_compile_append.php' => true,
'smarty_internal_compile_assign.php' => true,
'smarty_internal_compile_block.php' => true,
'smarty_internal_compile_break.php' => true,
'smarty_internal_compile_call.php' => true,
'smarty_internal_compile_capture.php' => true,
'smarty_internal_compile_config_load.php' => true,
'smarty_internal_compile_continue.php' => true,
'smarty_internal_compile_debug.php' => true,
'smarty_internal_compile_eval.php' => true,
'smarty_internal_compile_extends.php' => true,
'smarty_internal_compile_for.php' => true,
'smarty_internal_compile_foreach.php' => true,
'smarty_internal_compile_function.php' => true,
'smarty_internal_compile_if.php' => true,
'smarty_internal_compile_include.php' => true,
'smarty_internal_compile_include_php.php' => true,
'smarty_internal_compile_insert.php' => true,
'smarty_internal_compile_ldelim.php' => true,
'smarty_internal_compile_make_nocache.php' => true,
'smarty_internal_compile_nocache.php' => true,
'smarty_internal_compile_private_block_plugin.php' => true,
'smarty_internal_compile_private_foreachsection.php' => true,
'smarty_internal_compile_private_function_plugin.php' => true,
'smarty_internal_compile_private_modifier.php' => true,
'smarty_internal_compile_private_object_block_function.php' => true,
'smarty_internal_compile_private_object_function.php' => true,
'smarty_internal_compile_private_php.php' => true,
'smarty_internal_compile_private_print_expression.php' => true,
'smarty_internal_compile_private_registered_block.php' => true,
'smarty_internal_compile_private_registered_function.php' => true,
'smarty_internal_compile_private_special_variable.php' => true,
'smarty_internal_compile_rdelim.php' => true,
'smarty_internal_compile_section.php' => true,
'smarty_internal_compile_setfilter.php' => true,
'smarty_internal_compile_shared_inheritance.php' => true,
'smarty_internal_compile_while.php' => true,
'smarty_internal_configfilelexer.php' => true,
'smarty_internal_configfileparser.php' => true,
'smarty_internal_config_file_compiler.php' => true,
'smarty_internal_data.php' => true,
'smarty_internal_debug.php' => true,
'smarty_internal_errorhandler.php' => true,
'smarty_internal_extension_handler.php' => true,
'smarty_internal_method_addautoloadfilters.php' => true,
'smarty_internal_method_adddefaultmodifiers.php' => true,
'smarty_internal_method_append.php' => true,
'smarty_internal_method_appendbyref.php' => true,
'smarty_internal_method_assignbyref.php' => true,
'smarty_internal_method_assignglobal.php' => true,
'smarty_internal_method_clearallassign.php' => true,
'smarty_internal_method_clearallcache.php' => true,
'smarty_internal_method_clearassign.php' => true,
'smarty_internal_method_clearcache.php' => true,
'smarty_internal_method_clearcompiledtemplate.php' => true,
'smarty_internal_method_clearconfig.php' => true,
'smarty_internal_method_compileallconfig.php' => true,
'smarty_internal_method_compilealltemplates.php' => true,
'smarty_internal_method_configload.php' => true,
'smarty_internal_method_createdata.php' => true,
'smarty_internal_method_getautoloadfilters.php' => true,
'smarty_internal_method_getconfigvariable.php' => true,
'smarty_internal_method_getconfigvars.php' => true,
'smarty_internal_method_getdebugtemplate.php' => true,
'smarty_internal_method_getdefaultmodifiers.php' => true,
'smarty_internal_method_getglobal.php' => true,
'smarty_internal_method_getregisteredobject.php' => true,
'smarty_internal_method_getstreamvariable.php' => true,
'smarty_internal_method_gettags.php' => true,
'smarty_internal_method_gettemplatevars.php' => true,
'smarty_internal_method_literals.php' => true,
'smarty_internal_method_loadfilter.php' => true,
'smarty_internal_method_loadplugin.php' => true,
'smarty_internal_method_mustcompile.php' => true,
'smarty_internal_method_registercacheresource.php' => true,
'smarty_internal_method_registerclass.php' => true,
'smarty_internal_method_registerdefaultconfighandler.php' => true,
'smarty_internal_method_registerdefaultpluginhandler.php' => true,
'smarty_internal_method_registerdefaulttemplatehandler.php' => true,
'smarty_internal_method_registerfilter.php' => true,
'smarty_internal_method_registerobject.php' => true,
'smarty_internal_method_registerplugin.php' => true,
'smarty_internal_method_registerresource.php' => true,
'smarty_internal_method_setautoloadfilters.php' => true,
'smarty_internal_method_setdebugtemplate.php' => true,
'smarty_internal_method_setdefaultmodifiers.php' => true,
'smarty_internal_method_unloadfilter.php' => true,
'smarty_internal_method_unregistercacheresource.php' => true,
'smarty_internal_method_unregisterfilter.php' => true,
'smarty_internal_method_unregisterobject.php' => true,
'smarty_internal_method_unregisterplugin.php' => true,
'smarty_internal_method_unregisterresource.php' => true,
'smarty_internal_nocache_insert.php' => true,
'smarty_internal_parsetree.php' => true,
'smarty_internal_parsetree_code.php' => true,
'smarty_internal_parsetree_dq.php' => true,
'smarty_internal_parsetree_dqcontent.php' => true,
'smarty_internal_parsetree_tag.php' => true,
'smarty_internal_parsetree_template.php' => true,
'smarty_internal_parsetree_text.php' => true,
'smarty_internal_resource_eval.php' => true,
'smarty_internal_resource_extends.php' => true,
'smarty_internal_resource_file.php' => true,
'smarty_internal_resource_php.php' => true,
'smarty_internal_resource_registered.php' => true,
'smarty_internal_resource_stream.php' => true,
'smarty_internal_resource_string.php' => true,
'smarty_internal_runtime_cachemodify.php' => true,
'smarty_internal_runtime_cacheresourcefile.php' => true,
'smarty_internal_runtime_capture.php' => true,
'smarty_internal_runtime_codeframe.php' => true,
'smarty_internal_runtime_filterhandler.php' => true,
'smarty_internal_runtime_foreach.php' => true,
'smarty_internal_runtime_getincludepath.php' => true,
'smarty_internal_runtime_inheritance.php' => true,
'smarty_internal_runtime_make_nocache.php' => true,
'smarty_internal_runtime_tplfunction.php' => true,
'smarty_internal_runtime_updatecache.php' => true,
'smarty_internal_runtime_updatescope.php' => true,
'smarty_internal_runtime_writefile.php' => true,
'smarty_internal_smartytemplatecompiler.php' => true,
'smarty_internal_template.php' => true,
'smarty_internal_templatebase.php' => true,
'smarty_internal_templatecompilerbase.php' => true,
'smarty_internal_templatelexer.php' => true,
'smarty_internal_templateparser.php' => true,
'smarty_internal_testinstall.php' => true,
'smarty_internal_undefined.php' => true,
'smarty_resource.php' => true,
'smarty_resource_custom.php' => true,
'smarty_resource_recompiled.php' => true,
'smarty_resource_uncompiled.php' => true,
'smarty_security.php' => true,
'smarty_template_cached.php' => true,
'smarty_template_compiled.php' => true,
'smarty_template_config.php' => true,
'smarty_template_resource_base.php' => true,
'smarty_template_source.php' => true,
'smarty_undefined_variable.php' => true,
'smarty_variable.php' => true,
);
$expectedSysplugins = array('smartycompilerexception.php' => true,
'smartyexception.php' => true,
'smarty_cacheresource.php' => true,
'smarty_cacheresource_custom.php' => true,
'smarty_cacheresource_keyvaluestore.php' => true,
'smarty_data.php' => true,
'smarty_internal_block.php' => true,
'smarty_internal_cacheresource_file.php' => true,
'smarty_internal_compilebase.php' => true,
'smarty_internal_compile_append.php' => true,
'smarty_internal_compile_assign.php' => true,
'smarty_internal_compile_block.php' => true,
'smarty_internal_compile_block_child.php' => true,
'smarty_internal_compile_block_parent.php' => true,
'smarty_internal_compile_child.php' => true,
'smarty_internal_compile_parent.php' => true,
'smarty_internal_compile_break.php' => true,
'smarty_internal_compile_call.php' => true,
'smarty_internal_compile_capture.php' => true,
'smarty_internal_compile_config_load.php' => true,
'smarty_internal_compile_continue.php' => true,
'smarty_internal_compile_debug.php' => true,
'smarty_internal_compile_eval.php' => true,
'smarty_internal_compile_extends.php' => true,
'smarty_internal_compile_for.php' => true,
'smarty_internal_compile_foreach.php' => true,
'smarty_internal_compile_function.php' => true,
'smarty_internal_compile_if.php' => true,
'smarty_internal_compile_include.php' => true,
'smarty_internal_compile_include_php.php' => true,
'smarty_internal_compile_insert.php' => true,
'smarty_internal_compile_ldelim.php' => true,
'smarty_internal_compile_make_nocache.php' => true,
'smarty_internal_compile_nocache.php' => true,
'smarty_internal_compile_private_block_plugin.php' => true,
'smarty_internal_compile_private_foreachsection.php' => true,
'smarty_internal_compile_private_function_plugin.php' => true,
'smarty_internal_compile_private_modifier.php' => true,
'smarty_internal_compile_private_object_block_function.php' => true,
'smarty_internal_compile_private_object_function.php' => true,
'smarty_internal_compile_private_php.php' => true,
'smarty_internal_compile_private_print_expression.php' => true,
'smarty_internal_compile_private_registered_block.php' => true,
'smarty_internal_compile_private_registered_function.php' => true,
'smarty_internal_compile_private_special_variable.php' => true,
'smarty_internal_compile_rdelim.php' => true,
'smarty_internal_compile_section.php' => true,
'smarty_internal_compile_setfilter.php' => true,
'smarty_internal_compile_shared_inheritance.php' => true,
'smarty_internal_compile_while.php' => true,
'smarty_internal_configfilelexer.php' => true,
'smarty_internal_configfileparser.php' => true,
'smarty_internal_config_file_compiler.php' => true,
'smarty_internal_data.php' => true,
'smarty_internal_debug.php' => true,
'smarty_internal_errorhandler.php' => true,
'smarty_internal_extension_handler.php' => true,
'smarty_internal_method_addautoloadfilters.php' => true,
'smarty_internal_method_adddefaultmodifiers.php' => true,
'smarty_internal_method_append.php' => true,
'smarty_internal_method_appendbyref.php' => true,
'smarty_internal_method_assignbyref.php' => true,
'smarty_internal_method_assignglobal.php' => true,
'smarty_internal_method_clearallassign.php' => true,
'smarty_internal_method_clearallcache.php' => true,
'smarty_internal_method_clearassign.php' => true,
'smarty_internal_method_clearcache.php' => true,
'smarty_internal_method_clearcompiledtemplate.php' => true,
'smarty_internal_method_clearconfig.php' => true,
'smarty_internal_method_compileallconfig.php' => true,
'smarty_internal_method_compilealltemplates.php' => true,
'smarty_internal_method_configload.php' => true,
'smarty_internal_method_createdata.php' => true,
'smarty_internal_method_getautoloadfilters.php' => true,
'smarty_internal_method_getconfigvariable.php' => true,
'smarty_internal_method_getconfigvars.php' => true,
'smarty_internal_method_getdebugtemplate.php' => true,
'smarty_internal_method_getdefaultmodifiers.php' => true,
'smarty_internal_method_getglobal.php' => true,
'smarty_internal_method_getregisteredobject.php' => true,
'smarty_internal_method_getstreamvariable.php' => true,
'smarty_internal_method_gettags.php' => true,
'smarty_internal_method_gettemplatevars.php' => true,
'smarty_internal_method_literals.php' => true,
'smarty_internal_method_loadfilter.php' => true,
'smarty_internal_method_loadplugin.php' => true,
'smarty_internal_method_mustcompile.php' => true,
'smarty_internal_method_registercacheresource.php' => true,
'smarty_internal_method_registerclass.php' => true,
'smarty_internal_method_registerdefaultconfighandler.php' => true,
'smarty_internal_method_registerdefaultpluginhandler.php' => true,
'smarty_internal_method_registerdefaulttemplatehandler.php' => true,
'smarty_internal_method_registerfilter.php' => true,
'smarty_internal_method_registerobject.php' => true,
'smarty_internal_method_registerplugin.php' => true,
'smarty_internal_method_registerresource.php' => true,
'smarty_internal_method_setautoloadfilters.php' => true,
'smarty_internal_method_setdebugtemplate.php' => true,
'smarty_internal_method_setdefaultmodifiers.php' => true,
'smarty_internal_method_unloadfilter.php' => true,
'smarty_internal_method_unregistercacheresource.php' => true,
'smarty_internal_method_unregisterfilter.php' => true,
'smarty_internal_method_unregisterobject.php' => true,
'smarty_internal_method_unregisterplugin.php' => true,
'smarty_internal_method_unregisterresource.php' => true,
'smarty_internal_nocache_insert.php' => true,
'smarty_internal_parsetree.php' => true,
'smarty_internal_parsetree_code.php' => true,
'smarty_internal_parsetree_dq.php' => true,
'smarty_internal_parsetree_dqcontent.php' => true,
'smarty_internal_parsetree_tag.php' => true,
'smarty_internal_parsetree_template.php' => true,
'smarty_internal_parsetree_text.php' => true,
'smarty_internal_resource_eval.php' => true,
'smarty_internal_resource_extends.php' => true,
'smarty_internal_resource_file.php' => true,
'smarty_internal_resource_php.php' => true,
'smarty_internal_resource_registered.php' => true,
'smarty_internal_resource_stream.php' => true,
'smarty_internal_resource_string.php' => true,
'smarty_internal_runtime_cachemodify.php' => true,
'smarty_internal_runtime_cacheresourcefile.php' => true,
'smarty_internal_runtime_capture.php' => true,
'smarty_internal_runtime_codeframe.php' => true,
'smarty_internal_runtime_filterhandler.php' => true,
'smarty_internal_runtime_foreach.php' => true,
'smarty_internal_runtime_getincludepath.php' => true,
'smarty_internal_runtime_inheritance.php' => true,
'smarty_internal_runtime_make_nocache.php' => true,
'smarty_internal_runtime_tplfunction.php' => true,
'smarty_internal_runtime_updatecache.php' => true,
'smarty_internal_runtime_updatescope.php' => true,
'smarty_internal_runtime_writefile.php' => true,
'smarty_internal_smartytemplatecompiler.php' => true,
'smarty_internal_template.php' => true,
'smarty_internal_templatebase.php' => true,
'smarty_internal_templatecompilerbase.php' => true,
'smarty_internal_templatelexer.php' => true,
'smarty_internal_templateparser.php' => true,
'smarty_internal_testinstall.php' => true,
'smarty_internal_undefined.php' => true,
'smarty_resource.php' => true,
'smarty_resource_custom.php' => true,
'smarty_resource_recompiled.php' => true,
'smarty_resource_uncompiled.php' => true,
'smarty_security.php' => true,
'smarty_template_cached.php' => true,
'smarty_template_compiled.php' => true,
'smarty_template_config.php' => true,
'smarty_template_resource_base.php' => true,
'smarty_template_source.php' => true,
'smarty_undefined_variable.php' => true,
'smarty_variable.php' => true,);
$iterator = new DirectoryIterator($source);
foreach ($iterator as $file) {
if (!$file->isDot()) {