- change on handling of unassigned template variable -- default will drop E_NOTICE

- bugfix on Smarty2 wrapper load_filter() did not work
This commit is contained in:
uwe.tews@googlemail.com
2010-11-18 18:58:53 +00:00
parent 6b9921baae
commit eddb301947
5 changed files with 175 additions and 180 deletions

View File

@@ -1,3 +1,7 @@
18/11/2010
- change on handling of unassigned template variable -- default will drop E_NOTICE
- bugfix on Smarty2 wrapper load_filter() did not work
17/11/2010 17/11/2010
- bugfix on {call} with variable function name - bugfix on {call} with variable function name
- bugfix on {block} if name did contain '-' - bugfix on {block} if name did contain '-'

View File

@@ -33,8 +33,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
case 'capture': case 'capture':
return "Smarty::\$_smarty_vars$parameter"; return "Smarty::\$_smarty_vars$parameter";
case 'now': case 'now':
// the '#' below is not a bug, its a flag for the parser not to us isset() on the return return 'time()';
return '#time()';
case 'cookies': case 'cookies':
if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) { if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
$compiler->trigger_template_error("(secure mode) super globals not permitted"); $compiler->trigger_template_error("(secure mode) super globals not permitted");

View File

@@ -259,14 +259,14 @@ class Smarty_Internal_Data {
* @param boolean $search_parents search also in parent data * @param boolean $search_parents search also in parent data
* @return object the object of the variable * @return object the object of the variable
*/ */
public function getVariable($variable, $_ptr = null, $search_parents = true, $error_enable = true) public function getVariable($_variable, $_ptr = null, $search_parents = true, $error_enable = true)
{ {
if ($_ptr === null) { if ($_ptr === null) {
$_ptr = $this; $_ptr = $this;
} while ($_ptr !== null) { } while ($_ptr !== null) {
if (isset($_ptr->tpl_vars[$variable])) { if (isset($_ptr->tpl_vars[$_variable])) {
// found it, return it // found it, return it
return $_ptr->tpl_vars[$variable]; return $_ptr->tpl_vars[$_variable];
} }
// not found, try at parent // not found, try at parent
if ($search_parents) { if ($search_parents) {
@@ -275,13 +275,17 @@ class Smarty_Internal_Data {
$_ptr = null; $_ptr = null;
} }
} }
if (isset(Smarty::$global_tpl_vars[$variable])) { if (isset(Smarty::$global_tpl_vars[$_variable])) {
// found it, return it // found it, return it
return Smarty::$global_tpl_vars[$variable]; return Smarty::$global_tpl_vars[$_variable];
} }
if ($this->smarty->error_unassigned && $error_enable) { if ($this->smarty->error_unassigned && $error_enable) {
throw new SmartyException('Undefined Smarty variable "' . $variable . '"'); throw new SmartyException('Undefined Smarty variable "' . $_variable . '"');
} else { } else {
if ($error_enable) {
// force a notice
$x = $$_variable;
}
return new Undefined_Smarty_Variable; return new Undefined_Smarty_Variable;
} }
} }
@@ -291,23 +295,26 @@ class Smarty_Internal_Data {
* @param string $variable the name of the config variable * @param string $variable the name of the config variable
* @return mixed the value of the config variable * @return mixed the value of the config variable
*/ */
public function getConfigVariable($variable) public function getConfigVariable($_variable)
{ {
$_ptr = $this; $_ptr = $this;
while ($_ptr !== null) { while ($_ptr !== null) {
if (isset($_ptr->config_vars[$variable])) { if (isset($_ptr->config_vars[$_variable])) {
// found it, return it // found it, return it
return $_ptr->config_vars[$variable]; return $_ptr->config_vars[$_variable];
} }
// not found, try at parent // not found, try at parent
$_ptr = $_ptr->parent; $_ptr = $_ptr->parent;
} }
if ($this->smarty->error_unassigned) { if ($this->smarty->error_unassigned) {
throw new SmartyException('Undefined config variable "' . $variable . '"'); throw new SmartyException('Undefined config variable "' . $_variable . '"');
} else { } else {
// force a notice
$x = $$_variable;
return null; return null;
} }
} }
/** /**
* gets a stream variable * gets a stream variable
* *

View File

@@ -2476,128 +2476,118 @@ static public $yy_action = array(
#line 445 "smarty_internal_templateparser.y" #line 445 "smarty_internal_templateparser.y"
function yy_r116(){if ($this->yystack[$this->yyidx + 0]->minor['var'] == '\'smarty\'') { function yy_r116(){if ($this->yystack[$this->yyidx + 0]->minor['var'] == '\'smarty\'') {
$smarty_var = $this->compiler->compileTag('private_special_variable',array(),$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index']); $smarty_var = $this->compiler->compileTag('private_special_variable',array(),$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index']);
if (substr($smarty_var,0,1) == "'" || substr($smarty_var,0,1) == '@' || substr($smarty_var,0,1) == '#') { $this->_retvalue = $smarty_var;
if (substr($smarty_var,0,1) == '#') {
$this->_retvalue = substr($smarty_var,1);
} else {
$this->_retvalue = $smarty_var;
}
} else {
$this->_retvalue = '(isset('.$smarty_var.')?'.$smarty_var.':null)';
}
} else { } else {
// used for array reset,next,prev,end,current // used for array reset,next,prev,end,current
$this->last_variable = $this->yystack[$this->yyidx + 0]->minor['var']; $this->last_variable = $this->yystack[$this->yyidx + 0]->minor['var'];
$this->last_index = $this->yystack[$this->yyidx + 0]->minor['smarty_internal_index']; $this->last_index = $this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'];
if (isset($this->compiler->local_var[$this->yystack[$this->yyidx + 0]->minor['var']])) { if (isset($this->compiler->local_var[$this->yystack[$this->yyidx + 0]->minor['var']])) {
$this->_retvalue = '(isset($_smarty_tpl->tpl_vars['. $this->yystack[$this->yyidx + 0]->minor['var'] .']->value'.$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'].') ? $_smarty_tpl->tpl_vars['. $this->yystack[$this->yyidx + 0]->minor['var'] .']->value'.$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'].' : null)'; $this->_retvalue = '$_smarty_tpl->tpl_vars['. $this->yystack[$this->yyidx + 0]->minor['var'] .']->value'.$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'];
} else { } else {
if (isset($this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'])) { $this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + 0]->minor['var'] .')->value'.$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'];
$this->_retvalue = '(isset($_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + 0]->minor['var'] .')->value'.$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'].') ? $_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + 0]->minor['var'] .')->value'.$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'].' : null)'; }
} else { $this->compiler->tag_nocache=$this->compiler->tag_nocache|$this->template->getVariable(trim($this->yystack[$this->yyidx + 0]->minor['var'],"'"), null, true, false)->nocache;
$this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + 0]->minor['var'] .')->value'; }
} }
} #line 2488 "smarty_internal_templateparser.php"
$this->compiler->tag_nocache=$this->compiler->tag_nocache|$this->template->getVariable(trim($this->yystack[$this->yyidx + 0]->minor['var'],"'"), null, true, false)->nocache;} } #line 461 "smarty_internal_templateparser.y"
#line 2498 "smarty_internal_templateparser.php"
#line 471 "smarty_internal_templateparser.y"
function yy_r117(){if (isset($this->compiler->local_var[$this->yystack[$this->yyidx + -2]->minor])) { function yy_r117(){if (isset($this->compiler->local_var[$this->yystack[$this->yyidx + -2]->minor])) {
$this->_retvalue = '$_smarty_tpl->tpl_vars['. $this->yystack[$this->yyidx + -2]->minor .']->'.$this->yystack[$this->yyidx + 0]->minor; $this->_retvalue = '$_smarty_tpl->tpl_vars['. $this->yystack[$this->yyidx + -2]->minor .']->'.$this->yystack[$this->yyidx + 0]->minor;
} else { } else {
$this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -2]->minor .')->'.$this->yystack[$this->yyidx + 0]->minor; $this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -2]->minor .')->'.$this->yystack[$this->yyidx + 0]->minor;
} }
$this->compiler->tag_nocache=$this->compiler->tag_nocache|$this->template->getVariable(trim($this->yystack[$this->yyidx + -2]->minor,"'"), null, true, false)->nocache; } $this->compiler->tag_nocache=$this->compiler->tag_nocache|$this->template->getVariable(trim($this->yystack[$this->yyidx + -2]->minor,"'"), null, true, false)->nocache; }
#line 2506 "smarty_internal_templateparser.php" #line 2496 "smarty_internal_templateparser.php"
#line 480 "smarty_internal_templateparser.y" #line 470 "smarty_internal_templateparser.y"
function yy_r119(){$this->_retvalue = '$_smarty_tpl->getConfigVariable(\''. $this->yystack[$this->yyidx + -1]->minor .'\')'; } function yy_r119(){$this->_retvalue = '$_smarty_tpl->getConfigVariable(\''. $this->yystack[$this->yyidx + -1]->minor .'\')'; }
#line 2509 "smarty_internal_templateparser.php" #line 2499 "smarty_internal_templateparser.php"
#line 481 "smarty_internal_templateparser.y" #line 471 "smarty_internal_templateparser.y"
function yy_r120(){$this->_retvalue = '$_smarty_tpl->getConfigVariable('. $this->yystack[$this->yyidx + -1]->minor .')'; } function yy_r120(){$this->_retvalue = '$_smarty_tpl->getConfigVariable('. $this->yystack[$this->yyidx + -1]->minor .')'; }
#line 2512 "smarty_internal_templateparser.php" #line 2502 "smarty_internal_templateparser.php"
#line 484 "smarty_internal_templateparser.y" #line 474 "smarty_internal_templateparser.y"
function yy_r121(){$this->_retvalue = array('var'=>$this->yystack[$this->yyidx + -1]->minor, 'smarty_internal_index'=>$this->yystack[$this->yyidx + 0]->minor); } function yy_r121(){$this->_retvalue = array('var'=>$this->yystack[$this->yyidx + -1]->minor, 'smarty_internal_index'=>$this->yystack[$this->yyidx + 0]->minor); }
#line 2515 "smarty_internal_templateparser.php" #line 2505 "smarty_internal_templateparser.php"
#line 490 "smarty_internal_templateparser.y" #line 480 "smarty_internal_templateparser.y"
function yy_r122(){$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } function yy_r122(){$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; }
#line 2518 "smarty_internal_templateparser.php" #line 2508 "smarty_internal_templateparser.php"
#line 492 "smarty_internal_templateparser.y" #line 482 "smarty_internal_templateparser.y"
function yy_r123(){return; } function yy_r123(){return; }
#line 2521 "smarty_internal_templateparser.php" #line 2511 "smarty_internal_templateparser.php"
#line 496 "smarty_internal_templateparser.y" #line 486 "smarty_internal_templateparser.y"
function yy_r124(){ $this->_retvalue = '[$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + 0]->minor .')->value]'; $this->compiler->tag_nocache=$this->compiler->tag_nocache|$this->template->getVariable('$this->yystack[$this->yyidx + 0]->minor', null, true, false)->nocache; } function yy_r124(){ $this->_retvalue = '[$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + 0]->minor .')->value]'; $this->compiler->tag_nocache=$this->compiler->tag_nocache|$this->template->getVariable('$this->yystack[$this->yyidx + 0]->minor', null, true, false)->nocache; }
#line 2524 "smarty_internal_templateparser.php" #line 2514 "smarty_internal_templateparser.php"
#line 497 "smarty_internal_templateparser.y" #line 487 "smarty_internal_templateparser.y"
function yy_r125(){ $this->_retvalue = '[$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -2]->minor .')->'.$this->yystack[$this->yyidx + 0]->minor.']'; $this->compiler->tag_nocache=$this->compiler->tag_nocache|$this->template->getVariable(trim($this->yystack[$this->yyidx + -2]->minor,"'"), null, true, false)->nocache; } function yy_r125(){ $this->_retvalue = '[$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -2]->minor .')->'.$this->yystack[$this->yyidx + 0]->minor.']'; $this->compiler->tag_nocache=$this->compiler->tag_nocache|$this->template->getVariable(trim($this->yystack[$this->yyidx + -2]->minor,"'"), null, true, false)->nocache; }
#line 2527 "smarty_internal_templateparser.php" #line 2517 "smarty_internal_templateparser.php"
#line 498 "smarty_internal_templateparser.y" #line 488 "smarty_internal_templateparser.y"
function yy_r126(){ $this->_retvalue = "['". $this->yystack[$this->yyidx + 0]->minor ."']"; } function yy_r126(){ $this->_retvalue = "['". $this->yystack[$this->yyidx + 0]->minor ."']"; }
#line 2530 "smarty_internal_templateparser.php" #line 2520 "smarty_internal_templateparser.php"
#line 499 "smarty_internal_templateparser.y" #line 489 "smarty_internal_templateparser.y"
function yy_r127(){ $this->_retvalue = "[". $this->yystack[$this->yyidx + 0]->minor ."]"; } function yy_r127(){ $this->_retvalue = "[". $this->yystack[$this->yyidx + 0]->minor ."]"; }
#line 2533 "smarty_internal_templateparser.php" #line 2523 "smarty_internal_templateparser.php"
#line 500 "smarty_internal_templateparser.y" #line 490 "smarty_internal_templateparser.y"
function yy_r128(){ $this->_retvalue = "[". $this->yystack[$this->yyidx + -1]->minor ."]"; } function yy_r128(){ $this->_retvalue = "[". $this->yystack[$this->yyidx + -1]->minor ."]"; }
#line 2536 "smarty_internal_templateparser.php" #line 2526 "smarty_internal_templateparser.php"
#line 502 "smarty_internal_templateparser.y" #line 492 "smarty_internal_templateparser.y"
function yy_r129(){ $this->_retvalue = '['.$this->compiler->compileTag('private_special_variable',array(),'[\'section\'][\''.$this->yystack[$this->yyidx + -1]->minor.'\'][\'index\']').']'; } function yy_r129(){ $this->_retvalue = '['.$this->compiler->compileTag('private_special_variable',array(),'[\'section\'][\''.$this->yystack[$this->yyidx + -1]->minor.'\'][\'index\']').']'; }
#line 2539 "smarty_internal_templateparser.php" #line 2529 "smarty_internal_templateparser.php"
#line 503 "smarty_internal_templateparser.y" #line 493 "smarty_internal_templateparser.y"
function yy_r130(){ $this->_retvalue = '['.$this->compiler->compileTag('private_special_variable',array(),'[\'section\'][\''.$this->yystack[$this->yyidx + -3]->minor.'\'][\''.$this->yystack[$this->yyidx + -1]->minor.'\']').']'; } function yy_r130(){ $this->_retvalue = '['.$this->compiler->compileTag('private_special_variable',array(),'[\'section\'][\''.$this->yystack[$this->yyidx + -3]->minor.'\'][\''.$this->yystack[$this->yyidx + -1]->minor.'\']').']'; }
#line 2542 "smarty_internal_templateparser.php" #line 2532 "smarty_internal_templateparser.php"
#line 507 "smarty_internal_templateparser.y" #line 497 "smarty_internal_templateparser.y"
function yy_r132(){$this->_retvalue = '[]'; } function yy_r132(){$this->_retvalue = '[]'; }
#line 2545 "smarty_internal_templateparser.php" #line 2535 "smarty_internal_templateparser.php"
#line 515 "smarty_internal_templateparser.y" #line 505 "smarty_internal_templateparser.y"
function yy_r134(){$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.'.'.$this->yystack[$this->yyidx + 0]->minor; } function yy_r134(){$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.'.'.$this->yystack[$this->yyidx + 0]->minor; }
#line 2548 "smarty_internal_templateparser.php" #line 2538 "smarty_internal_templateparser.php"
#line 517 "smarty_internal_templateparser.y" #line 507 "smarty_internal_templateparser.y"
function yy_r135(){$this->_retvalue = '\''.$this->yystack[$this->yyidx + 0]->minor.'\''; } function yy_r135(){$this->_retvalue = '\''.$this->yystack[$this->yyidx + 0]->minor.'\''; }
#line 2551 "smarty_internal_templateparser.php" #line 2541 "smarty_internal_templateparser.php"
#line 519 "smarty_internal_templateparser.y" #line 509 "smarty_internal_templateparser.y"
function yy_r136(){$this->_retvalue = '('.$this->yystack[$this->yyidx + -1]->minor.')'; } function yy_r136(){$this->_retvalue = '('.$this->yystack[$this->yyidx + -1]->minor.')'; }
#line 2554 "smarty_internal_templateparser.php" #line 2544 "smarty_internal_templateparser.php"
#line 524 "smarty_internal_templateparser.y" #line 514 "smarty_internal_templateparser.y"
function yy_r137(){ if ($this->yystack[$this->yyidx + -1]->minor['var'] == '\'smarty\'') { $this->_retvalue = $this->compiler->compileTag('private_special_variable',array(),$this->yystack[$this->yyidx + -1]->minor['smarty_internal_index']).$this->yystack[$this->yyidx + 0]->minor;} else { function yy_r137(){ if ($this->yystack[$this->yyidx + -1]->minor['var'] == '\'smarty\'') { $this->_retvalue = $this->compiler->compileTag('private_special_variable',array(),$this->yystack[$this->yyidx + -1]->minor['smarty_internal_index']).$this->yystack[$this->yyidx + 0]->minor;} else {
$this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -1]->minor['var'] .')->value'.$this->yystack[$this->yyidx + -1]->minor['smarty_internal_index'].$this->yystack[$this->yyidx + 0]->minor; $this->compiler->tag_nocache=$this->compiler->tag_nocache|$this->template->getVariable(trim($this->yystack[$this->yyidx + -1]->minor['var'],"'"), null, true, false)->nocache;} } $this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -1]->minor['var'] .')->value'.$this->yystack[$this->yyidx + -1]->minor['smarty_internal_index'].$this->yystack[$this->yyidx + 0]->minor; $this->compiler->tag_nocache=$this->compiler->tag_nocache|$this->template->getVariable(trim($this->yystack[$this->yyidx + -1]->minor['var'],"'"), null, true, false)->nocache;} }
#line 2558 "smarty_internal_templateparser.php" #line 2548 "smarty_internal_templateparser.php"
#line 527 "smarty_internal_templateparser.y" #line 517 "smarty_internal_templateparser.y"
function yy_r138(){$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; } function yy_r138(){$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
#line 2561 "smarty_internal_templateparser.php" #line 2551 "smarty_internal_templateparser.php"
#line 529 "smarty_internal_templateparser.y" #line 519 "smarty_internal_templateparser.y"
function yy_r139(){$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } function yy_r139(){$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; }
#line 2564 "smarty_internal_templateparser.php" #line 2554 "smarty_internal_templateparser.php"
#line 531 "smarty_internal_templateparser.y" #line 521 "smarty_internal_templateparser.y"
function yy_r140(){if ($this->security && substr($this->yystack[$this->yyidx + -1]->minor,0,1) == '_') { function yy_r140(){if ($this->security && substr($this->yystack[$this->yyidx + -1]->minor,0,1) == '_') {
$this->compiler->trigger_template_error (self::Err1); $this->compiler->trigger_template_error (self::Err1);
} }
$this->_retvalue = '->'.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; $this->_retvalue = '->'.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor;
} }
#line 2571 "smarty_internal_templateparser.php" #line 2561 "smarty_internal_templateparser.php"
#line 536 "smarty_internal_templateparser.y" #line 526 "smarty_internal_templateparser.y"
function yy_r141(){if ($this->security) { function yy_r141(){if ($this->security) {
$this->compiler->trigger_template_error (self::Err2); $this->compiler->trigger_template_error (self::Err2);
} }
$this->_retvalue = '->{$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -1]->minor .')->value'.$this->yystack[$this->yyidx + 0]->minor.'}'; $this->compiler->tag_nocache=$this->compiler->tag_nocache|$this->template->getVariable(trim($this->yystack[$this->yyidx + -1]->minor,"'"), null, true, false)->nocache; $this->_retvalue = '->{$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -1]->minor .')->value'.$this->yystack[$this->yyidx + 0]->minor.'}'; $this->compiler->tag_nocache=$this->compiler->tag_nocache|$this->template->getVariable(trim($this->yystack[$this->yyidx + -1]->minor,"'"), null, true, false)->nocache;
} }
#line 2578 "smarty_internal_templateparser.php" #line 2568 "smarty_internal_templateparser.php"
#line 541 "smarty_internal_templateparser.y" #line 531 "smarty_internal_templateparser.y"
function yy_r142(){if ($this->security) { function yy_r142(){if ($this->security) {
$this->compiler->trigger_template_error (self::Err2); $this->compiler->trigger_template_error (self::Err2);
} }
$this->_retvalue = '->{'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + 0]->minor.'}'; $this->_retvalue = '->{'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + 0]->minor.'}';
} }
#line 2585 "smarty_internal_templateparser.php" #line 2575 "smarty_internal_templateparser.php"
#line 546 "smarty_internal_templateparser.y" #line 536 "smarty_internal_templateparser.y"
function yy_r143(){if ($this->security) { function yy_r143(){if ($this->security) {
$this->compiler->trigger_template_error (self::Err2); $this->compiler->trigger_template_error (self::Err2);
} }
$this->_retvalue = '->{\''.$this->yystack[$this->yyidx + -4]->minor.'\'.'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + 0]->minor.'}'; $this->_retvalue = '->{\''.$this->yystack[$this->yyidx + -4]->minor.'\'.'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + 0]->minor.'}';
} }
#line 2592 "smarty_internal_templateparser.php" #line 2582 "smarty_internal_templateparser.php"
#line 552 "smarty_internal_templateparser.y" #line 542 "smarty_internal_templateparser.y"
function yy_r144(){ $this->_retvalue = '->'.$this->yystack[$this->yyidx + 0]->minor; } function yy_r144(){ $this->_retvalue = '->'.$this->yystack[$this->yyidx + 0]->minor; }
#line 2595 "smarty_internal_templateparser.php" #line 2585 "smarty_internal_templateparser.php"
#line 558 "smarty_internal_templateparser.y" #line 548 "smarty_internal_templateparser.y"
function yy_r145(){if (!$this->security || $this->smarty->security_policy->isTrustedPhpFunction($this->yystack[$this->yyidx + -3]->minor, $this->compiler)) { function yy_r145(){if (!$this->security || $this->smarty->security_policy->isTrustedPhpFunction($this->yystack[$this->yyidx + -3]->minor, $this->compiler)) {
if (strcasecmp($this->yystack[$this->yyidx + -3]->minor,'isset') === 0 || strcasecmp($this->yystack[$this->yyidx + -3]->minor,'empty') === 0 || strcasecmp($this->yystack[$this->yyidx + -3]->minor,'array') === 0 || is_callable($this->yystack[$this->yyidx + -3]->minor)) { if (strcasecmp($this->yystack[$this->yyidx + -3]->minor,'isset') === 0 || strcasecmp($this->yystack[$this->yyidx + -3]->minor,'empty') === 0 || strcasecmp($this->yystack[$this->yyidx + -3]->minor,'array') === 0 || is_callable($this->yystack[$this->yyidx + -3]->minor)) {
$func_name = strtolower($this->yystack[$this->yyidx + -3]->minor); $func_name = strtolower($this->yystack[$this->yyidx + -3]->minor);
@@ -2605,23 +2595,13 @@ static public $yy_action = array(
if (count($this->yystack[$this->yyidx + -1]->minor) == 0) { if (count($this->yystack[$this->yyidx + -1]->minor) == 0) {
$this->compiler->trigger_template_error ('Illegal number of paramer in "isset()"'); $this->compiler->trigger_template_error ('Illegal number of paramer in "isset()"');
} }
$exp = array(); $isset_par=str_replace("')->value","',null,true,false)->value",implode(',',$this->yystack[$this->yyidx + -1]->minor));
foreach ($this->yystack[$this->yyidx + -1]->minor as $par) { $this->_retvalue = $this->yystack[$this->yyidx + -3]->minor . "(". $isset_par .")";
$exp[] = '('. $par .' !== null)'; } elseif (in_array($func_name,array('empty','reset','current','end','prev','next'))){
}
$this->_retvalue = '('. implode('&&',$exp) .')';
} elseif ($func_name == 'empty'){
if (count($this->yystack[$this->yyidx + -1]->minor) != 1) { if (count($this->yystack[$this->yyidx + -1]->minor) != 1) {
$this->compiler->trigger_template_error ('Illegal number of paramer in "empty()"'); $this->compiler->trigger_template_error ('Illegal number of paramer in "empty()"');
} }
$this->prefix_number++; $this->compiler->prefix_code[] = '<?php $_tmp'.$this->prefix_number.'='.$this->yystack[$this->yyidx + -1]->minor[0].';?>'; $this->_retvalue = $func_name.'('.$this->yystack[$this->yyidx + -1]->minor[0].')';
$this->_retvalue = 'empty($_tmp'.$this->prefix_number.')';
} elseif (in_array($func_name,array('reset','current','end','prev','next'))){
if (count($this->yystack[$this->yyidx + -1]->minor) != 1) {
$this->compiler->trigger_template_error ("Illegal number of paramer in '{$func_name}()'");
}
$this->prefix_number++; $this->compiler->prefix_code[] = '<?php $_tmp'.$this->prefix_number.'= '.$this->yystack[$this->yyidx + -1]->minor[0].'? $_smarty_tpl->getVariable('.$this->last_variable .'):null;?>';
$this->_retvalue = '(isset($_tmp'.$this->prefix_number.')?'.$func_name.'($_tmp'.$this->prefix_number.'->value'.$this->last_index.'):null)';
} else { } else {
$this->_retvalue = $this->yystack[$this->yyidx + -3]->minor . "(". implode(',',$this->yystack[$this->yyidx + -1]->minor) .")"; $this->_retvalue = $this->yystack[$this->yyidx + -3]->minor . "(". implode(',',$this->yystack[$this->yyidx + -1]->minor) .")";
} }
@@ -2630,115 +2610,115 @@ static public $yy_action = array(
} }
} }
} }
#line 2629 "smarty_internal_templateparser.php" #line 2609 "smarty_internal_templateparser.php"
#line 594 "smarty_internal_templateparser.y" #line 574 "smarty_internal_templateparser.y"
function yy_r146(){if ($this->security && substr($this->yystack[$this->yyidx + -3]->minor,0,1) == '_') { function yy_r146(){if ($this->security && substr($this->yystack[$this->yyidx + -3]->minor,0,1) == '_') {
$this->compiler->trigger_template_error (self::Err1); $this->compiler->trigger_template_error (self::Err1);
} }
$this->_retvalue = $this->yystack[$this->yyidx + -3]->minor . "(". implode(',',$this->yystack[$this->yyidx + -1]->minor) .")"; $this->_retvalue = $this->yystack[$this->yyidx + -3]->minor . "(". implode(',',$this->yystack[$this->yyidx + -1]->minor) .")";
} }
#line 2636 "smarty_internal_templateparser.php" #line 2616 "smarty_internal_templateparser.php"
#line 599 "smarty_internal_templateparser.y" #line 579 "smarty_internal_templateparser.y"
function yy_r147(){if ($this->security) { function yy_r147(){if ($this->security) {
$this->compiler->trigger_template_error (self::Err2); $this->compiler->trigger_template_error (self::Err2);
} }
$this->prefix_number++; $this->compiler->prefix_code[] = '<?php $_tmp'.$this->prefix_number.'=$_smarty_tpl->getVariable(\''. $this->yystack[$this->yyidx + -3]->minor .'\')->value;?>'; $this->_retvalue = '$_tmp'.$this->prefix_number.'('. implode(',',$this->yystack[$this->yyidx + -1]->minor) .')'; $this->prefix_number++; $this->compiler->prefix_code[] = '<?php $_tmp'.$this->prefix_number.'=$_smarty_tpl->getVariable(\''. $this->yystack[$this->yyidx + -3]->minor .'\')->value;?>'; $this->_retvalue = '$_tmp'.$this->prefix_number.'('. implode(',',$this->yystack[$this->yyidx + -1]->minor) .')';
} }
#line 2643 "smarty_internal_templateparser.php" #line 2623 "smarty_internal_templateparser.php"
#line 607 "smarty_internal_templateparser.y" #line 587 "smarty_internal_templateparser.y"
function yy_r148(){ $this->_retvalue = array_merge($this->yystack[$this->yyidx + -2]->minor,array($this->yystack[$this->yyidx + 0]->minor)); } function yy_r148(){ $this->_retvalue = array_merge($this->yystack[$this->yyidx + -2]->minor,array($this->yystack[$this->yyidx + 0]->minor)); }
#line 2646 "smarty_internal_templateparser.php" #line 2626 "smarty_internal_templateparser.php"
#line 616 "smarty_internal_templateparser.y" #line 596 "smarty_internal_templateparser.y"
function yy_r151(){$this->_retvalue = array_merge($this->yystack[$this->yyidx + -2]->minor,array(array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor))); } function yy_r151(){$this->_retvalue = array_merge($this->yystack[$this->yyidx + -2]->minor,array(array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor))); }
#line 2649 "smarty_internal_templateparser.php" #line 2629 "smarty_internal_templateparser.php"
#line 617 "smarty_internal_templateparser.y" #line 597 "smarty_internal_templateparser.y"
function yy_r152(){$this->_retvalue = array(array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor)); } function yy_r152(){$this->_retvalue = array(array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor)); }
#line 2652 "smarty_internal_templateparser.php" #line 2632 "smarty_internal_templateparser.php"
#line 620 "smarty_internal_templateparser.y" #line 600 "smarty_internal_templateparser.y"
function yy_r154(){ $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor); } function yy_r154(){ $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor); }
#line 2655 "smarty_internal_templateparser.php" #line 2635 "smarty_internal_templateparser.php"
#line 625 "smarty_internal_templateparser.y" #line 605 "smarty_internal_templateparser.y"
function yy_r155(){ $this->_retvalue = array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor); } function yy_r155(){ $this->_retvalue = array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor); }
#line 2658 "smarty_internal_templateparser.php" #line 2638 "smarty_internal_templateparser.php"
#line 627 "smarty_internal_templateparser.y" #line 607 "smarty_internal_templateparser.y"
function yy_r156(){$this->_retvalue = array(); } function yy_r156(){$this->_retvalue = array(); }
#line 2661 "smarty_internal_templateparser.php" #line 2641 "smarty_internal_templateparser.php"
#line 629 "smarty_internal_templateparser.y" #line 609 "smarty_internal_templateparser.y"
function yy_r157(){$this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor); } function yy_r157(){$this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor); }
#line 2664 "smarty_internal_templateparser.php" #line 2644 "smarty_internal_templateparser.php"
#line 639 "smarty_internal_templateparser.y" #line 619 "smarty_internal_templateparser.y"
function yy_r162(){ $this->_retvalue = '$'.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } function yy_r162(){ $this->_retvalue = '$'.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; }
#line 2667 "smarty_internal_templateparser.php" #line 2647 "smarty_internal_templateparser.php"
#line 641 "smarty_internal_templateparser.y" #line 621 "smarty_internal_templateparser.y"
function yy_r163(){ $this->_retvalue = '$'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } function yy_r163(){ $this->_retvalue = '$'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; }
#line 2670 "smarty_internal_templateparser.php" #line 2650 "smarty_internal_templateparser.php"
#line 650 "smarty_internal_templateparser.y" #line 630 "smarty_internal_templateparser.y"
function yy_r164(){$this->_retvalue = '=='; } function yy_r164(){$this->_retvalue = '=='; }
#line 2673 "smarty_internal_templateparser.php" #line 2653 "smarty_internal_templateparser.php"
#line 651 "smarty_internal_templateparser.y" #line 631 "smarty_internal_templateparser.y"
function yy_r165(){$this->_retvalue = '!='; } function yy_r165(){$this->_retvalue = '!='; }
#line 2676 "smarty_internal_templateparser.php" #line 2656 "smarty_internal_templateparser.php"
#line 652 "smarty_internal_templateparser.y" #line 632 "smarty_internal_templateparser.y"
function yy_r166(){$this->_retvalue = '>'; } function yy_r166(){$this->_retvalue = '>'; }
#line 2679 "smarty_internal_templateparser.php" #line 2659 "smarty_internal_templateparser.php"
#line 653 "smarty_internal_templateparser.y" #line 633 "smarty_internal_templateparser.y"
function yy_r167(){$this->_retvalue = '<'; } function yy_r167(){$this->_retvalue = '<'; }
#line 2682 "smarty_internal_templateparser.php" #line 2662 "smarty_internal_templateparser.php"
#line 654 "smarty_internal_templateparser.y" #line 634 "smarty_internal_templateparser.y"
function yy_r168(){$this->_retvalue = '>='; } function yy_r168(){$this->_retvalue = '>='; }
#line 2685 "smarty_internal_templateparser.php" #line 2665 "smarty_internal_templateparser.php"
#line 655 "smarty_internal_templateparser.y" #line 635 "smarty_internal_templateparser.y"
function yy_r169(){$this->_retvalue = '<='; } function yy_r169(){$this->_retvalue = '<='; }
#line 2688 "smarty_internal_templateparser.php" #line 2668 "smarty_internal_templateparser.php"
#line 656 "smarty_internal_templateparser.y" #line 636 "smarty_internal_templateparser.y"
function yy_r170(){$this->_retvalue = '==='; } function yy_r170(){$this->_retvalue = '==='; }
#line 2691 "smarty_internal_templateparser.php" #line 2671 "smarty_internal_templateparser.php"
#line 657 "smarty_internal_templateparser.y" #line 637 "smarty_internal_templateparser.y"
function yy_r171(){$this->_retvalue = '!=='; } function yy_r171(){$this->_retvalue = '!=='; }
#line 2694 "smarty_internal_templateparser.php" #line 2674 "smarty_internal_templateparser.php"
#line 658 "smarty_internal_templateparser.y" #line 638 "smarty_internal_templateparser.y"
function yy_r172(){$this->_retvalue = '%'; } function yy_r172(){$this->_retvalue = '%'; }
#line 2697 "smarty_internal_templateparser.php" #line 2677 "smarty_internal_templateparser.php"
#line 660 "smarty_internal_templateparser.y" #line 640 "smarty_internal_templateparser.y"
function yy_r173(){$this->_retvalue = '&&'; } function yy_r173(){$this->_retvalue = '&&'; }
#line 2700 "smarty_internal_templateparser.php" #line 2680 "smarty_internal_templateparser.php"
#line 661 "smarty_internal_templateparser.y" #line 641 "smarty_internal_templateparser.y"
function yy_r174(){$this->_retvalue = '||'; } function yy_r174(){$this->_retvalue = '||'; }
#line 2703 "smarty_internal_templateparser.php" #line 2683 "smarty_internal_templateparser.php"
#line 662 "smarty_internal_templateparser.y" #line 642 "smarty_internal_templateparser.y"
function yy_r175(){$this->_retvalue = ' XOR '; } function yy_r175(){$this->_retvalue = ' XOR '; }
#line 2706 "smarty_internal_templateparser.php" #line 2686 "smarty_internal_templateparser.php"
#line 667 "smarty_internal_templateparser.y" #line 647 "smarty_internal_templateparser.y"
function yy_r176(){ $this->_retvalue = 'array('.$this->yystack[$this->yyidx + -1]->minor.')'; } function yy_r176(){ $this->_retvalue = 'array('.$this->yystack[$this->yyidx + -1]->minor.')'; }
#line 2709 "smarty_internal_templateparser.php" #line 2689 "smarty_internal_templateparser.php"
#line 669 "smarty_internal_templateparser.y" #line 649 "smarty_internal_templateparser.y"
function yy_r178(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.','.$this->yystack[$this->yyidx + 0]->minor; } function yy_r178(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.','.$this->yystack[$this->yyidx + 0]->minor; }
#line 2712 "smarty_internal_templateparser.php" #line 2692 "smarty_internal_templateparser.php"
#line 670 "smarty_internal_templateparser.y" #line 650 "smarty_internal_templateparser.y"
function yy_r179(){ return; } function yy_r179(){ return; }
#line 2715 "smarty_internal_templateparser.php" #line 2695 "smarty_internal_templateparser.php"
#line 671 "smarty_internal_templateparser.y" #line 651 "smarty_internal_templateparser.y"
function yy_r180(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.'=>'.$this->yystack[$this->yyidx + 0]->minor; } function yy_r180(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.'=>'.$this->yystack[$this->yyidx + 0]->minor; }
#line 2718 "smarty_internal_templateparser.php" #line 2698 "smarty_internal_templateparser.php"
#line 672 "smarty_internal_templateparser.y" #line 652 "smarty_internal_templateparser.y"
function yy_r181(){ $this->_retvalue = '\''.$this->yystack[$this->yyidx + -2]->minor.'\'=>'.$this->yystack[$this->yyidx + 0]->minor; } function yy_r181(){ $this->_retvalue = '\''.$this->yystack[$this->yyidx + -2]->minor.'\'=>'.$this->yystack[$this->yyidx + 0]->minor; }
#line 2721 "smarty_internal_templateparser.php" #line 2701 "smarty_internal_templateparser.php"
#line 679 "smarty_internal_templateparser.y" #line 659 "smarty_internal_templateparser.y"
function yy_r183(){ $this->_retvalue = "''"; } function yy_r183(){ $this->_retvalue = "''"; }
#line 2724 "smarty_internal_templateparser.php" #line 2704 "smarty_internal_templateparser.php"
#line 680 "smarty_internal_templateparser.y" #line 660 "smarty_internal_templateparser.y"
function yy_r184(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor->to_smarty_php(); } function yy_r184(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor->to_smarty_php(); }
#line 2727 "smarty_internal_templateparser.php" #line 2707 "smarty_internal_templateparser.php"
#line 682 "smarty_internal_templateparser.y" #line 662 "smarty_internal_templateparser.y"
function yy_r185(){ $this->yystack[$this->yyidx + -1]->minor->append_subtree($this->yystack[$this->yyidx + 0]->minor); $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; } function yy_r185(){ $this->yystack[$this->yyidx + -1]->minor->append_subtree($this->yystack[$this->yyidx + 0]->minor); $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; }
#line 2730 "smarty_internal_templateparser.php" #line 2710 "smarty_internal_templateparser.php"
#line 683 "smarty_internal_templateparser.y" #line 663 "smarty_internal_templateparser.y"
function yy_r186(){ $this->_retvalue = new _smarty_doublequoted($this, $this->yystack[$this->yyidx + 0]->minor); } function yy_r186(){ $this->_retvalue = new _smarty_doublequoted($this, $this->yystack[$this->yyidx + 0]->minor); }
#line 2733 "smarty_internal_templateparser.php" #line 2713 "smarty_internal_templateparser.php"
#line 685 "smarty_internal_templateparser.y" #line 665 "smarty_internal_templateparser.y"
function yy_r187(){ $this->_retvalue = new _smarty_code($this, $this->yystack[$this->yyidx + -1]->minor); } function yy_r187(){ $this->_retvalue = new _smarty_code($this, $this->yystack[$this->yyidx + -1]->minor); }
#line 2736 "smarty_internal_templateparser.php" #line 2716 "smarty_internal_templateparser.php"
#line 687 "smarty_internal_templateparser.y" #line 667 "smarty_internal_templateparser.y"
function yy_r189(){if (isset($this->compiler->local_var["'".substr($this->yystack[$this->yyidx + 0]->minor,1)."'"])) { function yy_r189(){if (isset($this->compiler->local_var["'".substr($this->yystack[$this->yyidx + 0]->minor,1)."'"])) {
$this->_retvalue = new _smarty_code($this, '$_smarty_tpl->tpl_vars[\''. substr($this->yystack[$this->yyidx + 0]->minor,1) .'\']->value'); $this->_retvalue = new _smarty_code($this, '$_smarty_tpl->tpl_vars[\''. substr($this->yystack[$this->yyidx + 0]->minor,1) .'\']->value');
} else { } else {
@@ -2746,21 +2726,21 @@ static public $yy_action = array(
} }
$this->compiler->tag_nocache = $this->compiler->tag_nocache | $this->template->getVariable(trim($this->yystack[$this->yyidx + 0]->minor,"'"), null, true, false)->nocache; $this->compiler->tag_nocache = $this->compiler->tag_nocache | $this->template->getVariable(trim($this->yystack[$this->yyidx + 0]->minor,"'"), null, true, false)->nocache;
} }
#line 2745 "smarty_internal_templateparser.php" #line 2725 "smarty_internal_templateparser.php"
#line 695 "smarty_internal_templateparser.y" #line 675 "smarty_internal_templateparser.y"
function yy_r191(){ $this->_retvalue = new _smarty_code($this, '('.$this->yystack[$this->yyidx + -1]->minor.')'); } function yy_r191(){ $this->_retvalue = new _smarty_code($this, '('.$this->yystack[$this->yyidx + -1]->minor.')'); }
#line 2748 "smarty_internal_templateparser.php" #line 2728 "smarty_internal_templateparser.php"
#line 696 "smarty_internal_templateparser.y" #line 676 "smarty_internal_templateparser.y"
function yy_r192(){ function yy_r192(){
$this->_retvalue = new _smarty_tag($this, $this->yystack[$this->yyidx + 0]->minor); $this->_retvalue = new _smarty_tag($this, $this->yystack[$this->yyidx + 0]->minor);
} }
#line 2753 "smarty_internal_templateparser.php" #line 2733 "smarty_internal_templateparser.php"
#line 699 "smarty_internal_templateparser.y" #line 679 "smarty_internal_templateparser.y"
function yy_r193(){ $this->_retvalue = new _smarty_dq_content($this, $this->yystack[$this->yyidx + 0]->minor); } function yy_r193(){ $this->_retvalue = new _smarty_dq_content($this, $this->yystack[$this->yyidx + 0]->minor); }
#line 2756 "smarty_internal_templateparser.php" #line 2736 "smarty_internal_templateparser.php"
#line 706 "smarty_internal_templateparser.y" #line 686 "smarty_internal_templateparser.y"
function yy_r195(){$this->_retvalue = ''; } function yy_r195(){$this->_retvalue = ''; }
#line 2759 "smarty_internal_templateparser.php" #line 2739 "smarty_internal_templateparser.php"
private $_retvalue; private $_retvalue;
@@ -2822,7 +2802,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 2822 "smarty_internal_templateparser.php" #line 2802 "smarty_internal_templateparser.php"
} }
function yy_accept() function yy_accept()
@@ -2839,7 +2819,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 2840 "smarty_internal_templateparser.php" #line 2820 "smarty_internal_templateparser.php"
} }
function doParse($yymajor, $yytokenvalue) function doParse($yymajor, $yytokenvalue)

View File

@@ -106,7 +106,12 @@ class Smarty_Internal_Wrapper {
case 'trigger': case 'trigger':
switch($name_parts[1]) { switch($name_parts[1]) {
case 'error': case 'error':
return call_user_func_array(array($this,'trigger_error'),$args); return call_user_func_array('trigger_error',$args);
}
case 'load':
switch($name_parts[1]) {
case 'filter':
return call_user_func_array(array($this->smarty,'loadFilter'),$args);
} }
} }
throw new SmartyException("unknown method '$name'"); throw new SmartyException("unknown method '$name'");