mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
- bugfix {if} and {while} tags without condition did not throw a SmartyCompilerException (Issue #57)
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
===== trunk =====
|
===== trunk =====
|
||||||
|
01.11.2011
|
||||||
|
- bugfix {if} and {while} tags without condition did not throw a SmartyCompilerException (Issue #57)
|
||||||
|
|
||||||
22.10.2011
|
22.10.2011
|
||||||
- bugfix smarty_mb_from_unicode() would not decode unicode-points properly
|
- bugfix smarty_mb_from_unicode() would not decode unicode-points properly
|
||||||
- bugfix use catch Exception instead UnexpectedValueException in
|
- bugfix use catch Exception instead UnexpectedValueException in
|
||||||
|
@@ -1,30 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile If
|
* Smarty Internal Plugin Compile If
|
||||||
*
|
*
|
||||||
* Compiles the {if} {else} {elseif} {/if} tags
|
* Compiles the {if} {else} {elseif} {/if} tags
|
||||||
*
|
*
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage Compiler
|
* @subpackage Compiler
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile If Class
|
* Smarty Internal Plugin Compile If Class
|
||||||
*
|
*
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage Compiler
|
* @subpackage Compiler
|
||||||
*/
|
*/
|
||||||
class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {
|
class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles code for the {if} tag
|
* Compiles code for the {if} 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
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
public function compile($args, $compiler, $parameter)
|
public function compile($args, $compiler, $parameter)
|
||||||
{
|
{
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
@@ -32,6 +32,11 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {
|
|||||||
$this->openTag($compiler, 'if', array(1, $compiler->nocache));
|
$this->openTag($compiler, 'if', array(1, $compiler->nocache));
|
||||||
// must whole block be nocache ?
|
// must whole block be nocache ?
|
||||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||||
|
|
||||||
|
if (!array_key_exists("if condition",$parameter)) {
|
||||||
|
$compiler->trigger_template_error("missing if condition", $compiler->lex->taglineno);
|
||||||
|
}
|
||||||
|
|
||||||
if (is_array($parameter['if condition'])) {
|
if (is_array($parameter['if condition'])) {
|
||||||
if ($compiler->nocache) {
|
if ($compiler->nocache) {
|
||||||
$_nocache = ',true';
|
$_nocache = ',true';
|
||||||
@@ -60,21 +65,21 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Else Class
|
* Smarty Internal Plugin Compile Else Class
|
||||||
*
|
*
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage Compiler
|
* @subpackage Compiler
|
||||||
*/
|
*/
|
||||||
class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase {
|
class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles code for the {else} tag
|
* Compiles code for the {else} 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
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
public function compile($args, $compiler, $parameter)
|
public function compile($args, $compiler, $parameter)
|
||||||
{
|
{
|
||||||
list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
|
list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
|
||||||
@@ -86,21 +91,21 @@ class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile ElseIf Class
|
* Smarty Internal Plugin Compile ElseIf Class
|
||||||
*
|
*
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage Compiler
|
* @subpackage Compiler
|
||||||
*/
|
*/
|
||||||
class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
|
class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles code for the {elseif} tag
|
* Compiles code for the {elseif} 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
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
public function compile($args, $compiler, $parameter)
|
public function compile($args, $compiler, $parameter)
|
||||||
{
|
{
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
@@ -108,6 +113,10 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
|
|||||||
|
|
||||||
list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
|
list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
|
||||||
|
|
||||||
|
if (!array_key_exists("if condition",$parameter)) {
|
||||||
|
$compiler->trigger_template_error("missing elseif condition", $compiler->lex->taglineno);
|
||||||
|
}
|
||||||
|
|
||||||
if (is_array($parameter['if condition'])) {
|
if (is_array($parameter['if condition'])) {
|
||||||
$condition_by_assign = true;
|
$condition_by_assign = true;
|
||||||
if ($compiler->nocache) {
|
if ($compiler->nocache) {
|
||||||
@@ -143,7 +152,7 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
|
|||||||
} else {
|
} else {
|
||||||
$tmp = '';
|
$tmp = '';
|
||||||
foreach ($compiler->prefix_code as $code)
|
foreach ($compiler->prefix_code as $code)
|
||||||
$tmp .= $code;
|
$tmp .= $code;
|
||||||
$compiler->prefix_code = array();
|
$compiler->prefix_code = array();
|
||||||
$this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
|
$this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
|
||||||
if ($condition_by_assign) {
|
if ($condition_by_assign) {
|
||||||
@@ -164,21 +173,21 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Ifclose Class
|
* Smarty Internal Plugin Compile Ifclose Class
|
||||||
*
|
*
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage Compiler
|
* @subpackage Compiler
|
||||||
*/
|
*/
|
||||||
class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase {
|
class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles code for the {/if} tag
|
* Compiles code for the {/if} 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
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
public function compile($args, $compiler, $parameter)
|
public function compile($args, $compiler, $parameter)
|
||||||
{
|
{
|
||||||
// must endblock be nocache?
|
// must endblock be nocache?
|
||||||
|
@@ -31,6 +31,10 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase {
|
|||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
$this->openTag($compiler, 'while', $compiler->nocache);
|
$this->openTag($compiler, 'while', $compiler->nocache);
|
||||||
|
|
||||||
|
if (!array_key_exists("if condition",$parameter)) {
|
||||||
|
$compiler->trigger_template_error("missing while condition", $compiler->lex->taglineno);
|
||||||
|
}
|
||||||
|
|
||||||
// maybe nocache because of nocache variables
|
// maybe nocache because of nocache variables
|
||||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||||
if (is_array($parameter['if condition'])) {
|
if (is_array($parameter['if condition'])) {
|
||||||
|
Reference in New Issue
Block a user