aboutsummaryrefslogtreecommitdiffstats
path: root/library/Smarty/libs/sysplugins/smarty_internal_compile_if.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2015-12-06 21:09:58 +0100
committerMario Vavti <mario@mariovavti.com>2015-12-06 21:09:58 +0100
commit26c465ad0c1d5b6801507ed190430f44ac92c672 (patch)
tree9e80c34da1235e6dd55942c23bf9511fac31344d /library/Smarty/libs/sysplugins/smarty_internal_compile_if.php
parentf2d70831838b0738e6895296f3e8ce02f86fec2f (diff)
downloadvolse-hubzilla-26c465ad0c1d5b6801507ed190430f44ac92c672.tar.gz
volse-hubzilla-26c465ad0c1d5b6801507ed190430f44ac92c672.tar.bz2
volse-hubzilla-26c465ad0c1d5b6801507ed190430f44ac92c672.zip
update smarty to 3.1.28-dev which fixes a bug where changes in a template are only visible on the second pageload which is annoying for developing
Diffstat (limited to 'library/Smarty/libs/sysplugins/smarty_internal_compile_if.php')
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_if.php95
1 files changed, 63 insertions, 32 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_if.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_if.php
index d4fd30e9f..541e21816 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_if.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_if.php
@@ -19,13 +19,14 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
/**
* Compiles code for the {if} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
@@ -34,7 +35,7 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
if (!array_key_exists("if condition", $parameter)) {
- $compiler->trigger_template_error("missing if condition", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("missing if condition", null, true);
}
if (is_array($parameter['if condition'])) {
@@ -45,7 +46,7 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
$var = trim($parameter['if condition']['var']['var'], "'");
} else {
$var = trim($parameter['if condition']['var'], "'");
- }
+ }
if (isset($compiler->template->tpl_vars[$var])) {
$compiler->template->tpl_vars[$var]->nocache = true;
} else {
@@ -55,11 +56,19 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
$_nocache = '';
}
if (is_array($parameter['if condition']['var'])) {
- $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value)) \$_smarty_tpl->createLocalArrayVariable(" . $parameter['if condition']['var']['var'] . "$_nocache);\n";
- $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . ") {?>";
+ $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] .
+ "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] .
+ "]->value)) \$_smarty_tpl->smarty->ext->_var->createLocalArrayVariable(\$_smarty_tpl, " . $parameter['if condition']['var']['var'] .
+ "$_nocache);\n";
+ $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
+ $parameter['if condition']['var']['smarty_internal_index'] . " = " .
+ $parameter['if condition']['value'] . ") {?>";
} else {
- $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
- $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
+ $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] .
+ "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] .
+ "] = new Smarty_Variable(null{$_nocache});";
+ $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " .
+ $parameter['if condition']['value'] . ") {?>";
}
return $_output;
@@ -80,13 +89,13 @@ class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase
/**
* Compiles code for the {else} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
$this->openTag($compiler, 'else', array($nesting, $compiler->tag_nocache));
@@ -106,13 +115,14 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
/**
* Compiles code for the {elseif} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
@@ -120,7 +130,7 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
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);
+ $compiler->trigger_template_error("missing elseif condition", null, true);
}
if (is_array($parameter['if condition'])) {
@@ -149,11 +159,20 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
if ($condition_by_assign) {
$this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
if (is_array($parameter['if condition']['var'])) {
- $_output = "<?php } else { if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value)) \$_smarty_tpl->createLocalArrayVariable(" . $parameter['if condition']['var']['var'] . "$_nocache);\n";
- $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . ") {?>";
+ $_output = "<?php } else { if (!isset(\$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var']['var'] .
+ "]->value)) \$_smarty_tpl->smarty->ext->_var->createLocalArrayVariable(\$_smarty_tpl, " .
+ $parameter['if condition']['var']['var'] . "$_nocache);\n";
+ $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
+ $parameter['if condition']['var']['smarty_internal_index'] . " = " .
+ $parameter['if condition']['value'] . ") {?>";
} else {
- $_output = "<?php } else { if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
- $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
+ $_output = "<?php } else { if (!isset(\$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
+ $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " .
+ $parameter['if condition']['value'] . ") {?>";
}
return $_output;
@@ -166,17 +185,29 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
$tmp = '';
foreach ($compiler->prefix_code as $code) {
$tmp = $compiler->appendCode($tmp, $code);
- }
+ }
$compiler->prefix_code = array();
$tmp = $compiler->appendCode("<?php } else {?>", $tmp);
$this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
if ($condition_by_assign) {
if (is_array($parameter['if condition']['var'])) {
- $_output = $compiler->appendCode($tmp, "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value)) \$_smarty_tpl->createLocalArrayVariable(" . $parameter['if condition']['var']['var'] . "$_nocache);\n");
- $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . ") {?>";
+ $_output = $compiler->appendCode($tmp, "<?php if (!isset(\$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var']['var'] .
+ "]) || !is_array(\$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var']['var'] .
+ "]->value)) \$_smarty_tpl->smarty->ext->_var->createLocalArrayVariable(\$_smarty_tpl, " .
+ $parameter['if condition']['var']['var'] . "$_nocache);\n");
+ $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
+ $parameter['if condition']['var']['smarty_internal_index'] . " = " .
+ $parameter['if condition']['value'] . ") {?>";
} else {
- $_output = $compiler->appendCode($tmp, "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});");
- $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
+ $_output = $compiler->appendCode($tmp, "<?php if (!isset(\$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var'] .
+ "])) \$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var'] .
+ "] = new Smarty_Variable(null{$_nocache});");
+ $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " .
+ $parameter['if condition']['value'] . ") {?>";
}
return $_output;
@@ -198,13 +229,13 @@ class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase
/**
* Compiles code for the {/if} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
// must endblock be nocache?
if ($compiler->nocache) {