From dad4b991ea9fd53911c2ecc273308c28d692cd82 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sun, 30 Nov 2014 11:57:47 +0100 Subject: [PATCH] BpNode: rendering --- library/Bpapp/BpNode.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/library/Bpapp/BpNode.php b/library/Bpapp/BpNode.php index cab35e8..4d57b85 100644 --- a/library/Bpapp/BpNode.php +++ b/library/Bpapp/BpNode.php @@ -190,4 +190,43 @@ class BpNode extends Node } return $this->children; } + + protected function assertNumericOperator() + { + if (! is_numeric($this->operator)) { + // TODO: ConfigurationError + throw new Exception( + sprintf( + 'Got invalid operator: %s', + $this->operator + ) + ); + } + } + + public function renderLink($view) + { + if (! $this->bp->isEditMode()) { + return parent::renderLink($view); + } + return $view->qlink($this->name, 'bpapp/node/edit', array( + 'node' => $this->name + )); + } + + public function operatorHtml() + { + switch ($this->operator) { + case self::OP_AND: + return 'and'; + break; + case self::OP_OR: + return 'or'; + break; + default: + // MIN + $this->assertNumericOperator(); + return 'min:' . $this->operator; + } + } }