phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
HtmlNavzone.php
Go to the documentation of this file.
1<?php
2
4
12
18class HtmlNavzone extends BaseHtml {
19 protected $class="navbar-nav";
20 protected $elements;
21
26 public function __construct($identifier) {
27 parent::__construct($identifier);
28 $this->tagName="ul";
29 $this->_template='<%tagName% id="%identifier%" class="nav navbar-nav %class%">%elements%</%tagName%>';
30 $this->elements=array ();
31 }
32
33 public function setClass($value) {
34 $this->setMemberCtrl($this->class, $value, CssRef::navbarZoneClasses());
35 }
36
37 public function asForm() {
38 $this->addToMember($this->class, "navbar-form");
39 }
40
41 public function addElement($element) {
42 if($element instanceof HtmlLink){
43 $this->addLink($element);
44 } else if (is_object($element)) {
45 $this->elements []=$element;
46 } else if (\is_array($element)) {
47 $this->addLink(array_pop($element), array_pop($element));
48 } else {
49 $this->addLink($element);
50 }
51 }
52
53 public function setValues($class, $tagName, $elements=array()) {
54 $this->class=$class;
55 $this->tagName=$tagName;
56 $this->elements=$elements;
57 return $this;
58 }
59
60 public function addElements($elements) {
61 if (\is_array($elements)) {
62 foreach ( $elements as $key => $element ) {
63 $iid=$this->getElementsCount()+1;
64 if ($element instanceof HtmlDropdownItem)
65 $this->elements []=$element;
66 else if (\is_array($element)) {
67 if (is_string($key)===true) {
68 $dropdown=new HtmlDropdown($this->identifier."-dropdown-".$iid);
69 $dropdown->addItems($element);
70 $dropdown->setBtnCaption($key);
71 $dropdown->setMTagName("li");
72 $this->addElement($dropdown);
73 } else {
74 $this->addLink(array_pop($element), array_pop($element));
75 }
76 } else if (is_object($element)) {
77 $this->addElement($element);
78 } else if (is_string($element)) {
79 $this->addLink($element);
80 }
81 }
82 }
83 return $this;
84 }
85
86 public function addLink($caption, $href="#") {
87 $iid=$this->getElementsCount()+1;
88 $li=new HtmlBsDoubleElement($this->identifier."-li-".$iid, "li");
89 if($caption instanceof HtmlLink){
90 $link=$caption;
91 }else{
92 $link=new HtmlLink($this->identifier."-link-".$iid, $href, $caption);
93 }
94 $li->setContent($link);
95 $this->addElement($li);
96 }
97
98 public static function form($identifier, $elements=array()) {
99 $result=new HtmlNavzone($identifier);
100 return $result->setValues("navbar-form navbar-left", "form", $elements);
101 }
102
103 public static function left($identifier, $elements=array()) {
104 $result=new HtmlNavzone($identifier);
105 return $result->setValues("navbar-left", "ul", $elements);
106 }
107
108 public static function right($identifier, $elements=array()) {
109 $result=new HtmlNavzone($identifier);
110 return $result->setValues("navbar-right", "ul", $elements);
111 }
112
113 public static function formRight($identifier, $elements=array()) {
114 $result=new HtmlNavzone($identifier);
115 return $result->setValues("navbar-right navbar-form", "ul", $elements);
116 }
117
118 public static function nav($identifier, $elements=array()) {
119 $result=new HtmlNavzone($identifier);
120 return $result->setValues("navbar-nav", "ul", $elements);
121 }
122
123 public function run(JsUtils $js) {
124 foreach ( $this->elements as $element ) {
125 $element->run($js);
126 }
127 }
128
129 public function getElementsCount() {
130 return sizeof($this->elements);
131 }
132
133 public function fromArray($array) {
134 return $this->addElements($array);
135 }
136
137 public function __toString() {
138 return $this->compile();
139 }
140
145 public function getElement($index){
146 return $this->elements[$index];
147 }
148}
JQuery PHP library.
Definition JsUtils.php:23
Twitter Bootstrap HTML Dropdown component.
Default HTML values for Twitter Bootstrap HTML components.
Definition CssRef.php:12
Inner element for Twitter Bootstrap HTML Dropdown component.
Inner element for Twitter Bootstrap HTML Navbar component.
static right($identifier, $elements=array())
static left($identifier, $elements=array())
setValues($class, $tagName, $elements=array())
static formRight($identifier, $elements=array())
static nav($identifier, $elements=array())
static form($identifier, $elements=array())
BaseHtml for HTML components.
Definition BaseHtml.php:17
addToMember(&$name, $value, $separator=' ')
Definition BaseHtml.php:98
setMemberCtrl(&$name, $value, $typeCtrl)
Definition BaseHtml.php:75
compile(JsUtils $js=NULL, &$view=NULL)
Definition BaseHtml.php:207