summaryrefslogtreecommitdiff
path: root/demos/site/protected/Common/SimpleMenu.php
diff options
context:
space:
mode:
authorJean-Luc Gyger <jean-luc.gyger@vysual.ch>2016-02-11 10:01:12 +0100
committerJean-Luc Gyger <jean-luc.gyger@vysual.ch>2016-02-11 10:01:12 +0100
commitd70861a8f9368773f2f0291454e9420174e6c14a (patch)
treee44a32e401211422fb05da355c9eef4d5934d9e9 /demos/site/protected/Common/SimpleMenu.php
parentd32f65815eb6feb4bcb8a0c85572f722d7826342 (diff)
parent275f16b90a92c62935cb691d11e0bd124acf64e4 (diff)
Merge branch 'master' of https://github.com/majuca/prado
Diffstat (limited to 'demos/site/protected/Common/SimpleMenu.php')
-rw-r--r--demos/site/protected/Common/SimpleMenu.php86
1 files changed, 86 insertions, 0 deletions
diff --git a/demos/site/protected/Common/SimpleMenu.php b/demos/site/protected/Common/SimpleMenu.php
new file mode 100644
index 00000000..bcbc94cf
--- /dev/null
+++ b/demos/site/protected/Common/SimpleMenu.php
@@ -0,0 +1,86 @@
+<?php
+
+class SimpleMenu extends TControl
+{
+ public function addParsedObject($object)
+ {
+ if ($object instanceof SimpleMenuItem)
+ parent::addParsedObject($object);
+ }
+
+ public function render($writer)
+ {
+ $writer->renderBeginTag("ul");
+ parent::renderChildren($writer);
+ $writer->renderEndTag();
+ }
+
+}
+
+class SimpleMenuItem extends TControl
+{
+
+ public function getPath()
+ {
+ return $this->getControlState("Path", null);
+ }
+
+ public function setPath($value)
+ {
+ $this->setControlState("Path", TPropertyValue::ensureString($value));
+ }
+
+ public function getUrl()
+ {
+ return $this->getControlState("Url", null);
+ }
+
+ public function setUrl($value)
+ {
+ $this->setControlState("Url", TPropertyValue::ensureString($value));
+ }
+
+ public function getTarget()
+ {
+ return $this->getControlState("Target", null);
+ }
+
+ public function setTarget($value)
+ {
+ $this->setControlState("Target", TPropertyValue::ensureString($value));
+ }
+
+ public function getText()
+ {
+ return $this->getControlState("Text", $this->getID());
+ }
+
+ public function setText($value) {
+ $this->setControlState("Text", TPropertyValue::ensureString($value));
+ }
+
+ public function render($writer)
+ {
+ $writer->renderBeginTag("li");
+
+ if(null !== $path = $this->getPath())
+ {
+ $writer->addAttribute('href', $this->Service->constructUrl($path));
+
+ if($path == $this->Page->getPagePath())
+ $writer->addAttribute('class', 'active');
+ } elseif(null !== $url = $this->getUrl()) {
+ $writer->addAttribute('href', $url);
+ }
+
+ if($this->getTarget() !== null)
+ $writer->addAttribute('target', $this->getTarget());
+
+ $writer->renderBeginTag("a");
+
+ $writer->write(THttpUtility::htmlEncode($this->getText()));
+
+ $writer->renderEndTag();
+ $writer->renderEndTag();
+ }
+}