mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- bugfix broken PHP 5.2 compatibility https://github.com/smarty-php/smarty/issues/139
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
===== 3.1.29-dev ===== (xx.xx.2015)
|
||||
19.12.2015
|
||||
- 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
|
||||
- improvement make sure that compiled and cache templates never can contain a trailing '?>?
|
||||
|
||||
|
@@ -118,7 +118,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '3.1.29-dev/12';
|
||||
const SMARTY_VERSION = '3.1.29-dev/13';
|
||||
|
||||
/**
|
||||
* define variable scopes
|
||||
|
@@ -59,7 +59,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
||||
*
|
||||
* @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
|
||||
|
@@ -50,7 +50,7 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $nameProperties = array();
|
||||
public $nameProperties = array();
|
||||
|
||||
/**
|
||||
* {section} tag has no item properties
|
||||
@@ -112,8 +112,7 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
||||
if ($named) {
|
||||
$this->resultOffsets['named'] = $this->startOffset + 3;
|
||||
$this->propertyPreg .= "([\$]smarty[.]{$this->tagName}[.]{$attributes['name']}[.](";
|
||||
$className = get_class($this);
|
||||
$properties = $className::$nameProperties;
|
||||
$properties = $this->nameProperties;
|
||||
} else {
|
||||
$this->resultOffsets['item'] = $this->startOffset + 3;
|
||||
$this->propertyPreg .= "([\$]{$attributes['item']}[@](";
|
||||
@@ -204,17 +203,15 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
||||
* @return string compiled code
|
||||
* @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 ], '"\''));
|
||||
$name = isset($parameter[ 1 ]) ? $compiler->getId($parameter[ 1 ]) : false;
|
||||
if (!$name) {
|
||||
$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;
|
||||
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);
|
||||
}
|
||||
$tagVar = "'__smarty_{$tag}_{$name}'";
|
||||
|
@@ -39,7 +39,11 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
||||
switch ($variable) {
|
||||
case 'foreach':
|
||||
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':
|
||||
if (class_exists('Smarty_Internal_Compile_Capture')) {
|
||||
return Smarty_Internal_Compile_Capture::compileSpecialVariable(array(), $compiler, $_index);
|
||||
|
@@ -59,7 +59,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
||||
*
|
||||
* @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');
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user