This commit is contained in:
uwetews
2015-12-19 21:55:32 +01:00
parent 9cdf68807f
commit dc9872e0e2
6 changed files with 18 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
 ===== 3.1.29-dev ===== (xx.xx.2015)  ===== 3.1.29-dev ===== (xx.xx.2015)
19.12.2015 19.12.2015
- bugfix using $smarty.capture.foo in expressions could fail https://github.com/smarty-php/smarty/pull/138 - bugfix using $smarty.capture.foo in expressions could fail https://github.com/smarty-php/smarty/pull/138
- bugfix broken PHP 5.2 compatibility - bugfix broken PHP 5.2 compatibility https://github.com/smarty-php/smarty/issues/139
- remove no longer used code - remove no longer used code
- improvement make sure that compiled and cache templates never can contain a trailing '?>? - improvement make sure that compiled and cache templates never can contain a trailing '?>?

View File

@@ -118,7 +118,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.29-dev/12'; const SMARTY_VERSION = '3.1.29-dev/13';
/** /**
* define variable scopes * define variable scopes

View File

@@ -59,7 +59,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
* *
* @var array * @var array
*/ */
public static $nameProperties = array('first', 'last', 'index', 'iteration', 'show', 'total'); public $nameProperties = array('first', 'last', 'index', 'iteration', 'show', 'total');
/** /**
* Valid properties of $item@xxx variable * Valid properties of $item@xxx variable

View File

@@ -50,7 +50,7 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
* *
* @var array * @var array
*/ */
public static $nameProperties = array(); public $nameProperties = array();
/** /**
* {section} tag has no item properties * {section} tag has no item properties
@@ -112,8 +112,7 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
if ($named) { if ($named) {
$this->resultOffsets['named'] = $this->startOffset + 3; $this->resultOffsets['named'] = $this->startOffset + 3;
$this->propertyPreg .= "([\$]smarty[.]{$this->tagName}[.]{$attributes['name']}[.]("; $this->propertyPreg .= "([\$]smarty[.]{$this->tagName}[.]{$attributes['name']}[.](";
$className = get_class($this); $properties = $this->nameProperties;
$properties = $className::$nameProperties;
} else { } else {
$this->resultOffsets['item'] = $this->startOffset + 3; $this->resultOffsets['item'] = $this->startOffset + 3;
$this->propertyPreg .= "([\$]{$attributes['item']}[@]("; $this->propertyPreg .= "([\$]{$attributes['item']}[@](";
@@ -204,17 +203,15 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
* @return string compiled code * @return string compiled code
* @throws \SmartyCompilerException * @throws \SmartyCompilerException
*/ */
public static function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) public function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{ {
$tag = strtolower(trim($parameter[ 0 ], '"\'')); $tag = strtolower(trim($parameter[ 0 ], '"\''));
$name = isset($parameter[ 1 ]) ? $compiler->getId($parameter[ 1 ]) : false; $name = isset($parameter[ 1 ]) ? $compiler->getId($parameter[ 1 ]) : false;
if (!$name) { if (!$name) {
$compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true); $compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true);
} }
/* @var Smarty_Internal_Compile_Foreach|Smarty_Internal_Compile_Section $className */
$className = 'Smarty_Internal_Compile_' . ucfirst($tag);
$property = isset($parameter[ 2 ]) ? strtolower($compiler->getId($parameter[ 2 ])) : false; $property = isset($parameter[ 2 ]) ? strtolower($compiler->getId($parameter[ 2 ])) : false;
if (!$property || !in_array($property, $className::$nameProperties)) { if (!$property || !in_array($property, $this->nameProperties)) {
$compiler->trigger_template_error("missing or illegal \$smarty.{$tag} property attribute", null, true); $compiler->trigger_template_error("missing or illegal \$smarty.{$tag} property attribute", null, true);
} }
$tagVar = "'__smarty_{$tag}_{$name}'"; $tagVar = "'__smarty_{$tag}_{$name}'";

View File

@@ -39,7 +39,11 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
switch ($variable) { switch ($variable) {
case 'foreach': case 'foreach':
case 'section': case 'section':
return Smarty_Internal_Compile_Private_ForeachSection::compileSpecialVariable(array(), $compiler, $_index); if (!isset($compiler->_tag_objects[ $variable ])) {
$class = 'Smarty_Internal_Compile_' . ucfirst($variable);
$compiler->_tag_objects[ $variable ] = new $class;
}
return $compiler->_tag_objects[ $variable ]->compileSpecialVariable(array(), $compiler, $_index);
case 'capture': case 'capture':
if (class_exists('Smarty_Internal_Compile_Capture')) { if (class_exists('Smarty_Internal_Compile_Capture')) {
return Smarty_Internal_Compile_Capture::compileSpecialVariable(array(), $compiler, $_index); return Smarty_Internal_Compile_Capture::compileSpecialVariable(array(), $compiler, $_index);

View File

@@ -59,7 +59,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
* *
* @var array * @var array
*/ */
public static $nameProperties = array('first', 'last', 'index', 'iteration', 'show', 'total', 'rownum', public $nameProperties = array('first', 'last', 'index', 'iteration', 'show', 'total', 'rownum',
'index_prev', 'index_next'); 'index_prev', 'index_next');
/** /**