/** * Processes and outputs one simple value. * * 1. Check for expression and comparison attributes * 2. Execute process_value() if no expression / comparison * 3. Execute wrap() and outputs the value * * @param FTL_Binding * @param mixed * * @return string * */ public static function output_value(FTL_Binding $tag, $value) { $is = $tag->getAttribute('is'); $in = $tag->getAttribute('in'); $is_not = $tag->getAttribute('is_not'); $expression = $tag->getAttribute('expression'); // "is" and "expression" cannot be used together. if (!is_null($is)) { // Do not pass the attribute to child $tag->removeAttribute('is'); if (strtolower($is) == 'true') { $is = TRUE; } if (strtolower($is) == 'false') { $is = FALSE; } if ($value == $is) { if (self::$trigger_else > 0) { self::$trigger_else = 0; } return self::wrap($tag, $tag->expand()); } else { self::$trigger_else++; return ''; } } else { if (!is_null($in)) { // Do not pass the attribute to child $tag->removeAttribute('in'); $in = explode(',', $in); foreach ($in as $i) { $i = trim($i); if (strtolower($i) == 'true') { $is = TRUE; } if (strtolower($i) == 'false') { $is = FALSE; } if ($value == $i) { if (self::$trigger_else > 0) { self::$trigger_else = 0; } return self::wrap($tag, $tag->expand()); } } self::$trigger_else++; return ''; } else { if (!is_null($is_not)) { $tag->removeAttribute('is_not'); if (strtolower($is_not) == 'true') { $is_not = TRUE; } if (strtolower($is_not) == 'false') { $is_not = FALSE; } if ($value != $is_not) { if (self::$trigger_else > 0) { self::$trigger_else = 0; } return self::wrap($tag, $tag->expand()); } else { self::$trigger_else++; return ''; } } else { if (!is_null($expression)) { // Do not pass the attribute to child $tag->removeAttribute('expression'); $result = self::eval_expression($tag, $expression); switch ($result) { case TRUE: if (self::$trigger_else > 0) { self::$trigger_else = 0; } return self::wrap($tag, $tag->expand()); break; case FALSE: self::$trigger_else++; return ''; break; case NULL: return self::show_tag_error($tag, 'Condition incorrect: ' . $expression); } } else { if (!is_null($value)) { // Process PHP, helper, prefix/suffix $value = self::process_value($tag, $value); // Make sub tags like "nesting" or "trace" working $tag->expand(); return self::wrap($tag, $value); } } } } } return $tag->expand(); }