|
|
|
@ -530,7 +530,22 @@ class Templater
|
|
|
|
|
if($identifier == "if")
|
|
|
|
|
{
|
|
|
|
|
$statement_parts = explode(" ", $statement, 3);
|
|
|
|
|
$element->left = $statement_parts[0];
|
|
|
|
|
|
|
|
|
|
$variable = $statement_parts[0];
|
|
|
|
|
|
|
|
|
|
if(strpos($variable, "|") !== false)
|
|
|
|
|
{
|
|
|
|
|
$variable_parts = explode("|", $variable, 2);
|
|
|
|
|
|
|
|
|
|
$element->operation = $variable_parts[0];
|
|
|
|
|
$element->left = $variable_parts[1];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$element->left = $variable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$element->operator = $statement_parts[1];
|
|
|
|
|
$element->right = $statement_parts[2];
|
|
|
|
|
}
|
|
|
|
@ -648,8 +663,11 @@ class TemplateIfElement extends TemplateSyntaxElement
|
|
|
|
|
public $left = "";
|
|
|
|
|
public $right = "";
|
|
|
|
|
public $operator = "";
|
|
|
|
|
public $operation = "";
|
|
|
|
|
|
|
|
|
|
public function Evaluate($data)
|
|
|
|
|
{
|
|
|
|
|
if(empty($this->operation))
|
|
|
|
|
{
|
|
|
|
|
$a = $this->FetchVariable($this->left, $data);
|
|
|
|
|
$b = $this->right;
|
|
|
|
@ -693,6 +711,38 @@ class TemplateIfElement extends TemplateSyntaxElement
|
|
|
|
|
return parent::Evaluate($data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
elseif($this->operation == "isset")
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
$this->FetchVariable($this->left, $data);
|
|
|
|
|
|
|
|
|
|
$found = true;
|
|
|
|
|
}
|
|
|
|
|
catch (TemplateEvaluationException $e)
|
|
|
|
|
{
|
|
|
|
|
$found = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($this->right == "false")
|
|
|
|
|
{
|
|
|
|
|
$desired = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$desired = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($found === $desired)
|
|
|
|
|
{
|
|
|
|
|
return parent::Evaluate($data);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TemplateForEachElement extends TemplateSyntaxElement
|
|
|
|
|