| | 494 | } |
| | 495 | } |
| | 496 | |
| | 497 | class MuIfEqualNode extends MuNode { |
| | 498 | function __construct($var1, $var2, $nodelist_true, $nodelist_false, $negate) { |
| | 499 | $this->var1 = $var1; |
| | 500 | $this->var2 = $var2; |
| | 501 | $this->nodelist_true = $nodelist_true; |
| | 502 | $this->nodelist_false = $nodelist_false; |
| | 503 | $this->negate = $negate; |
| | 504 | } |
| | 505 | |
| | 506 | public function _render($context) { |
| | 507 | try { |
| | 508 | $val1 = $context->resolve($this->var1); |
| | 509 | } catch (MuValueDoesNotExistException $e) { |
| | 510 | } |
| | 511 | try { |
| | 512 | $val2 = $context->resolve($this->var2); |
| | 513 | } catch (MuValueDoesNotExistException $e) { |
| | 514 | } |
| | 515 | if (($this->negate && $val1 != $val2) || (!$this->negate && $val1 == $val2)) { |
| | 516 | return $this->nodelist_true->_render($context); |
| | 517 | } |
| | 518 | return $this->nodelist_false->_render($context); |
| | 937 | case 'ifequal': |
| | 938 | case 'ifnotequal': |
| | 939 | if (count($in) != 3) { |
| | 940 | return $this->make_errornode('numofparam_ifequal_tag'); |
| | 941 | } |
| | 942 | $this->spos = $lpos + 2; |
| | 943 | $negate = ($in[0] == 'ifnotequal'); |
| | 944 | $endtag = 'end' . $in[0]; |
| | 945 | echo $endtag; |
| | 946 | list($nodelist_true, $nexttag) = |
| | 947 | $this->_parse(array('else', $endtag)); |
| | 948 | if ($nexttag == 'else') { |
| | 949 | list($nodelist_false) = $this->_parse(array($endtag)); |
| | 950 | } else { |
| | 951 | $nodelist_false = new MuNodeList(); |
| | 952 | } |
| | 953 | $node = new MuIfEqualNode($in[1], $in[2], $nodelist_true, $nodelist_false, $negate); |
| | 954 | break; |