mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-07 03:44:26 +02:00
- bugfix on assigning multidimensional arrays within templates
- corrected bugfix for truncate modifier
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
08/07/2010
|
||||||
|
- bugfix on assigning multidimensional arrays within templates
|
||||||
|
- corrected bugfix for truncate modifier
|
||||||
|
|
||||||
07/07/2010
|
07/07/2010
|
||||||
- bugfix the truncate modifier needs to check if the string is utf-8 encoded or not
|
- bugfix the truncate modifier needs to check if the string is utf-8 encoded or not
|
||||||
- bugfix support of script files relative to trusted_dir
|
- bugfix support of script files relative to trusted_dir
|
||||||
|
@@ -31,7 +31,7 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
|||||||
return '';
|
return '';
|
||||||
|
|
||||||
if (is_callable('mb_strlen')) {
|
if (is_callable('mb_strlen')) {
|
||||||
if (mb_detect_encoding($text, 'UTF-8, ISO-8859-1') === 'UTF-8') {
|
if (mb_detect_encoding($string, 'UTF-8, ISO-8859-1') === 'UTF-8') {
|
||||||
// $string has utf-8 encoding
|
// $string has utf-8 encoding
|
||||||
if (mb_strlen($string) > $length) {
|
if (mb_strlen($string) > $length) {
|
||||||
$length -= min($length, mb_strlen($etc));
|
$length -= min($length, mb_strlen($etc));
|
||||||
|
@@ -1,25 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Assign
|
* Smarty Internal Plugin Compile Assign
|
||||||
*
|
*
|
||||||
* Compiles the {assign} tag
|
* Compiles the {assign} tag
|
||||||
*
|
*
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage Compiler
|
* @subpackage Compiler
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Assign Class
|
* Smarty Internal Plugin Compile Assign Class
|
||||||
*/
|
*/
|
||||||
class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase {
|
class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase {
|
||||||
/**
|
/**
|
||||||
* Compiles code for the {assign} tag
|
* Compiles code for the {assign} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param object $compiler compiler object
|
* @param object $compiler compiler object
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
public function compile($args, $compiler)
|
public function compile($args, $compiler)
|
||||||
{
|
{
|
||||||
$this->compiler = $compiler;
|
$this->compiler = $compiler;
|
||||||
@@ -45,21 +45,17 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase {
|
|||||||
$_scope = SMARTY_PARENT_SCOPE;
|
$_scope = SMARTY_PARENT_SCOPE;
|
||||||
} elseif ($_attr['scope'] == '\'root\'') {
|
} elseif ($_attr['scope'] == '\'root\'') {
|
||||||
$_scope = SMARTY_ROOT_SCOPE;
|
$_scope = SMARTY_ROOT_SCOPE;
|
||||||
} elseif ($_attr['scope'] == '\'global\'') {
|
} elseif ($_attr['scope'] == '\'global\'') {
|
||||||
$_scope = SMARTY_GLOBAL_SCOPE;
|
$_scope = SMARTY_GLOBAL_SCOPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// compiled output
|
// compiled output
|
||||||
if (isset($_attr['smarty_internal_index'])) {
|
if (isset($_attr['smarty_internal_index'])) {
|
||||||
if ($_attr['smarty_internal_index'] == '') {
|
return "<?php if (!isset(\$_smarty_tpl->tpl_vars[$_attr[var]]) || !is_array(\$_smarty_tpl->tpl_vars[$_attr[var]]->value)) \$_smarty_tpl->createLocalArrayVariable($_attr[var], $_nocache, $_scope);\n\$_smarty_tpl->tpl_vars[$_attr[var]]->value$_attr[smarty_internal_index] = $_attr[value];?>";
|
||||||
return "<?php \$_smarty_tpl->append($_attr[var],$_attr[value],false,$_nocache,$_scope);?>";
|
|
||||||
} else {
|
|
||||||
return "<?php \$_tmp$_attr[smarty_internal_index] = $_attr[value]; \$_smarty_tpl->append($_attr[var],\$_tmp,true,$_nocache,$_scope); unset (\$_tmp);?>";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return "<?php \$_smarty_tpl->assign($_attr[var],$_attr[value],$_nocache,$_scope);?>";
|
return "<?php \$_smarty_tpl->tpl_vars[$_attr[var]] = new Smarty_variable($_attr[value], $_nocache, $_scope);?>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@@ -806,6 +806,26 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a loacal Smarty variable for array assihgments
|
||||||
|
*/
|
||||||
|
public function createLocalArrayVariable($tpl_var, $nocache = false, $scope = SMARTY_LOCAL_SCOPE)
|
||||||
|
{
|
||||||
|
if (!isset($this->tpl_vars[$tpl_var])) {
|
||||||
|
$tpl_var_inst = $this->getVariable($tpl_var, null, true, false);
|
||||||
|
if ($tpl_var_inst instanceof Undefined_Smarty_Variable) {
|
||||||
|
$this->tpl_vars[$tpl_var] = new Smarty_variable(array(), $nocache, $scope);
|
||||||
|
} else {
|
||||||
|
$this->tpl_vars[$tpl_var] = clone $tpl_var_inst;
|
||||||
|
if ($scope != SMARTY_LOCAL_SCOPE) {
|
||||||
|
$this->tpl_vars[$tpl_var]->scope = $scope;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!(is_array($this->tpl_vars[$tpl_var]->value) || $this->tpl_vars[$tpl_var]->value instanceof ArrayAccess)) {
|
||||||
|
settype($this->tpl_vars[$tpl_var]->value, 'array');
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* wrapper for display
|
* wrapper for display
|
||||||
*/
|
*/
|
||||||
|
@@ -1997,7 +1997,6 @@ static public $yy_action = array(
|
|||||||
121 => 121,
|
121 => 121,
|
||||||
122 => 122,
|
122 => 122,
|
||||||
124 => 124,
|
124 => 124,
|
||||||
185 => 124,
|
|
||||||
126 => 126,
|
126 => 126,
|
||||||
127 => 127,
|
127 => 127,
|
||||||
128 => 128,
|
128 => 128,
|
||||||
@@ -2049,6 +2048,7 @@ static public $yy_action = array(
|
|||||||
181 => 181,
|
181 => 181,
|
||||||
182 => 182,
|
182 => 182,
|
||||||
183 => 183,
|
183 => 183,
|
||||||
|
185 => 185,
|
||||||
);
|
);
|
||||||
#line 92 "smarty_internal_templateparser.y"
|
#line 92 "smarty_internal_templateparser.y"
|
||||||
function yy_r0(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
|
function yy_r0(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
|
||||||
@@ -2456,7 +2456,7 @@ static public $yy_action = array(
|
|||||||
function yy_r122(){ $this->_retvalue = '['.$this->compiler->compileTag('private_special_variable','[\'section\'][\''.$this->yystack[$this->yyidx + -3]->minor.'\'][\''.$this->yystack[$this->yyidx + -1]->minor.'\']').']'; }
|
function yy_r122(){ $this->_retvalue = '['.$this->compiler->compileTag('private_special_variable','[\'section\'][\''.$this->yystack[$this->yyidx + -3]->minor.'\'][\''.$this->yystack[$this->yyidx + -1]->minor.'\']').']'; }
|
||||||
#line 2453 "smarty_internal_templateparser.php"
|
#line 2453 "smarty_internal_templateparser.php"
|
||||||
#line 484 "smarty_internal_templateparser.y"
|
#line 484 "smarty_internal_templateparser.y"
|
||||||
function yy_r124(){$this->_retvalue = ''; }
|
function yy_r124(){$this->_retvalue = '[]'; }
|
||||||
#line 2456 "smarty_internal_templateparser.php"
|
#line 2456 "smarty_internal_templateparser.php"
|
||||||
#line 492 "smarty_internal_templateparser.y"
|
#line 492 "smarty_internal_templateparser.y"
|
||||||
function yy_r126(){$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.'.'.$this->yystack[$this->yyidx + 0]->minor; }
|
function yy_r126(){$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.'.'.$this->yystack[$this->yyidx + 0]->minor; }
|
||||||
@@ -2614,6 +2614,9 @@ static public $yy_action = array(
|
|||||||
#line 624 "smarty_internal_templateparser.y"
|
#line 624 "smarty_internal_templateparser.y"
|
||||||
function yy_r183(){ $this->_retvalue = new _smarty_dq_content($this, $this->yystack[$this->yyidx + 0]->minor); }
|
function yy_r183(){ $this->_retvalue = new _smarty_dq_content($this, $this->yystack[$this->yyidx + 0]->minor); }
|
||||||
#line 2612 "smarty_internal_templateparser.php"
|
#line 2612 "smarty_internal_templateparser.php"
|
||||||
|
#line 631 "smarty_internal_templateparser.y"
|
||||||
|
function yy_r185(){$this->_retvalue = ''; }
|
||||||
|
#line 2615 "smarty_internal_templateparser.php"
|
||||||
|
|
||||||
private $_retvalue;
|
private $_retvalue;
|
||||||
|
|
||||||
@@ -2675,7 +2678,7 @@ static public $yy_action = array(
|
|||||||
$this->internalError = true;
|
$this->internalError = true;
|
||||||
$this->yymajor = $yymajor;
|
$this->yymajor = $yymajor;
|
||||||
$this->compiler->trigger_template_error();
|
$this->compiler->trigger_template_error();
|
||||||
#line 2675 "smarty_internal_templateparser.php"
|
#line 2678 "smarty_internal_templateparser.php"
|
||||||
}
|
}
|
||||||
|
|
||||||
function yy_accept()
|
function yy_accept()
|
||||||
@@ -2692,7 +2695,7 @@ static public $yy_action = array(
|
|||||||
$this->internalError = false;
|
$this->internalError = false;
|
||||||
$this->retvalue = $this->_retvalue;
|
$this->retvalue = $this->_retvalue;
|
||||||
//echo $this->retvalue."\n\n";
|
//echo $this->retvalue."\n\n";
|
||||||
#line 2693 "smarty_internal_templateparser.php"
|
#line 2696 "smarty_internal_templateparser.php"
|
||||||
}
|
}
|
||||||
|
|
||||||
function doParse($yymajor, $yytokenvalue)
|
function doParse($yymajor, $yytokenvalue)
|
||||||
|
Reference in New Issue
Block a user