@@ -15,29 +15,29 @@ discard block |
||
15 | 15 | use Ajax\common\html\HtmlDoubleElement; |
16 | 16 | |
17 | 17 | class HtmlDropdown extends HtmlSemDoubleElement { |
18 | - use FieldTrait,LabeledIconTrait { |
|
18 | + use FieldTrait, LabeledIconTrait { |
|
19 | 19 | addIcon as addIconP; |
20 | 20 | } |
21 | 21 | protected $mClass="menu"; |
22 | 22 | protected $mTagName="div"; |
23 | - protected $items=array (); |
|
24 | - protected $_params=array("action"=>"nothing","on"=>"hover","showOnFocus"=>false); |
|
23 | + protected $items=array(); |
|
24 | + protected $_params=array("action"=>"nothing", "on"=>"hover", "showOnFocus"=>false); |
|
25 | 25 | protected $input; |
26 | 26 | protected $value; |
27 | 27 | protected $_associative; |
28 | 28 | protected $_multiple; |
29 | 29 | |
30 | - public function __construct($identifier, $value="", $items=array(),$associative=true) { |
|
30 | + public function __construct($identifier, $value="", $items=array(), $associative=true) { |
|
31 | 31 | parent::__construct($identifier, "div"); |
32 | 32 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
33 | 33 | $this->setProperty("class", "ui dropdown"); |
34 | 34 | $this->_multiple=false; |
35 | 35 | $content=[]; |
36 | - if(isset($value)){ |
|
37 | - if($value instanceof HtmlSemDoubleElement){ |
|
36 | + if (isset($value)) { |
|
37 | + if ($value instanceof HtmlSemDoubleElement) { |
|
38 | 38 | $text=$value; |
39 | - }else{ |
|
40 | - $text=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
39 | + } else { |
|
40 | + $text=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
41 | 41 | $text->setClass("text"); |
42 | 42 | $this->setValue($value); |
43 | 43 | } |
@@ -50,29 +50,29 @@ discard block |
||
50 | 50 | $this->addItems($items); |
51 | 51 | } |
52 | 52 | |
53 | - public function getField(){ |
|
53 | + public function getField() { |
|
54 | 54 | return $this->input; |
55 | 55 | } |
56 | 56 | |
57 | - public function getDataField(){ |
|
57 | + public function getDataField() { |
|
58 | 58 | return $this->input; |
59 | 59 | } |
60 | 60 | |
61 | - public function addItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
62 | - $itemO=$this->beforeAddItem($item,$value,$image,$description); |
|
61 | + public function addItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
62 | + $itemO=$this->beforeAddItem($item, $value, $image, $description); |
|
63 | 63 | $this->items[]=$itemO; |
64 | 64 | return $itemO; |
65 | 65 | } |
66 | 66 | |
67 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
67 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
68 | 68 | $this->removeArrow(); |
69 | - $this->addIconP($icon,$before,$labeled); |
|
69 | + $this->addIconP($icon, $before, $labeled); |
|
70 | 70 | return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter(""); |
71 | 71 | } |
72 | 72 | |
73 | - public function addIcons($icons){ |
|
73 | + public function addIcons($icons) { |
|
74 | 74 | $count=$this->count(); |
75 | - for ($i=0;$i<\sizeof($icons) && $i<$count;$i++){ |
|
75 | + for ($i=0; $i<\sizeof($icons) && $i<$count; $i++) { |
|
76 | 76 | $this->getItem($i)->addIcon($icons[$i]); |
77 | 77 | } |
78 | 78 | } |
@@ -83,33 +83,33 @@ discard block |
||
83 | 83 | * @param int $position |
84 | 84 | * @return HtmlDropdownItem |
85 | 85 | */ |
86 | - public function insertItem($item,$position=0){ |
|
86 | + public function insertItem($item, $position=0) { |
|
87 | 87 | $itemO=$this->beforeAddItem($item); |
88 | - $start = array_slice($this->items, 0, $position); |
|
89 | - $end = array_slice($this->items, $position); |
|
90 | - $start[] = $item; |
|
88 | + $start=array_slice($this->items, 0, $position); |
|
89 | + $end=array_slice($this->items, $position); |
|
90 | + $start[]=$item; |
|
91 | 91 | $this->items=array_merge($start, $end); |
92 | 92 | return $itemO; |
93 | 93 | } |
94 | 94 | |
95 | - protected function removeArrow(){ |
|
96 | - if(\sizeof($this->content)>1){ |
|
95 | + protected function removeArrow() { |
|
96 | + if (\sizeof($this->content)>1) { |
|
97 | 97 | unset($this->content["arrow"]); |
98 | 98 | $this->content=\array_values($this->content); |
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - protected function beforeAddItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
102 | + protected function beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
103 | 103 | $itemO=$item; |
104 | - if(\is_array($item)){ |
|
104 | + if (\is_array($item)) { |
|
105 | 105 | $description=JArray::getValue($item, "description", 3); |
106 | 106 | $value=JArray::getValue($item, "value", 1); |
107 | 107 | $image=JArray::getValue($item, "image", 2); |
108 | 108 | $item=JArray::getValue($item, "item", 0); |
109 | 109 | } |
110 | - if(!$item instanceof HtmlDropdownItem){ |
|
111 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
|
112 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
110 | + if (!$item instanceof HtmlDropdownItem) { |
|
111 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image, $description); |
|
112 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
113 | 113 | $this->addToProperty("class", "vertical"); |
114 | 114 | } |
115 | 115 | return $itemO; |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | $this->addItem($function($object)); |
123 | 123 | } |
124 | 124 | |
125 | - public function addInput($name){ |
|
126 | - if(!isset($name)) |
|
125 | + public function addInput($name) { |
|
126 | + if (!isset($name)) |
|
127 | 127 | $name="input-".$this->identifier; |
128 | 128 | $this->setAction("activate"); |
129 | - $this->input=new HtmlInput($name,"hidden"); |
|
129 | + $this->input=new HtmlInput($name, "hidden"); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -135,15 +135,15 @@ discard block |
||
135 | 135 | * @param string $icon |
136 | 136 | * @return HtmlDropdownItem |
137 | 137 | */ |
138 | - public function addSearchInputItem($placeHolder=NULL,$icon=NULL){ |
|
139 | - return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon)); |
|
138 | + public function addSearchInputItem($placeHolder=NULL, $icon=NULL) { |
|
139 | + return $this->addItem(HtmlDropdownItem::searchInput($placeHolder, $icon)); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
143 | 143 | * Adds a divider item |
144 | 144 | * @return HtmlDropdownItem |
145 | 145 | */ |
146 | - public function addDividerItem(){ |
|
146 | + public function addDividerItem() { |
|
147 | 147 | return $this->addItem(HtmlDropdownItem::divider()); |
148 | 148 | } |
149 | 149 | |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | * @param string $icon |
154 | 154 | * @return HtmlDropdownItem |
155 | 155 | */ |
156 | - public function addHeaderItem($caption=NULL,$icon=NULL){ |
|
157 | - return $this->addItem(HtmlDropdownItem::header($caption,$icon)); |
|
156 | + public function addHeaderItem($caption=NULL, $icon=NULL) { |
|
157 | + return $this->addItem(HtmlDropdownItem::header($caption, $icon)); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param string $color |
164 | 164 | * @return HtmlDropdownItem |
165 | 165 | */ |
166 | - public function addCircularLabelItem($caption,$color){ |
|
166 | + public function addCircularLabelItem($caption, $color) { |
|
167 | 167 | return $this->addItem(HtmlDropdownItem::circular($caption, $color)); |
168 | 168 | } |
169 | 169 | |
@@ -172,17 +172,17 @@ discard block |
||
172 | 172 | * @param string $image |
173 | 173 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
174 | 174 | */ |
175 | - public function addMiniAvatarImageItem($caption,$image){ |
|
175 | + public function addMiniAvatarImageItem($caption, $image) { |
|
176 | 176 | return $this->addItem(HtmlDropdownItem::avatar($caption, $image)); |
177 | 177 | } |
178 | 178 | |
179 | - public function addItems($items){ |
|
180 | - if(\is_array($items) && $this->_associative){ |
|
181 | - foreach ($items as $k=>$v){ |
|
179 | + public function addItems($items) { |
|
180 | + if (\is_array($items) && $this->_associative) { |
|
181 | + foreach ($items as $k=>$v) { |
|
182 | 182 | $this->addItem($v)->setData($k); |
183 | 183 | } |
184 | - }else{ |
|
185 | - foreach ($items as $item){ |
|
184 | + } else { |
|
185 | + foreach ($items as $item) { |
|
186 | 186 | $this->addItem($item); |
187 | 187 | } |
188 | 188 | } |
@@ -194,98 +194,98 @@ discard block |
||
194 | 194 | * @param array $values |
195 | 195 | * @return HtmlCollection |
196 | 196 | */ |
197 | - public function setPropertyValues($property,$values){ |
|
197 | + public function setPropertyValues($property, $values) { |
|
198 | 198 | $i=0; |
199 | - if(\is_array($values)===false){ |
|
200 | - $values=\array_fill(0, $this->count(),$values); |
|
199 | + if (\is_array($values)===false) { |
|
200 | + $values=\array_fill(0, $this->count(), $values); |
|
201 | 201 | } |
202 | - foreach ($values as $value){ |
|
202 | + foreach ($values as $value) { |
|
203 | 203 | $c=$this->items[$i++]; |
204 | - if(isset($c)){ |
|
205 | - $c->setProperty($property,$value); |
|
204 | + if (isset($c)) { |
|
205 | + $c->setProperty($property, $value); |
|
206 | 206 | } |
207 | - else{ |
|
207 | + else { |
|
208 | 208 | return $this; |
209 | 209 | } |
210 | 210 | } |
211 | 211 | return $this; |
212 | 212 | } |
213 | 213 | |
214 | - public function each($callBack){ |
|
215 | - foreach ($this->items as $index=>$value){ |
|
216 | - $callBack($index,$value); |
|
214 | + public function each($callBack) { |
|
215 | + foreach ($this->items as $index=>$value) { |
|
216 | + $callBack($index, $value); |
|
217 | 217 | } |
218 | 218 | return $this; |
219 | 219 | } |
220 | 220 | |
221 | - public function getItem($index){ |
|
221 | + public function getItem($index) { |
|
222 | 222 | return $this->items[$index]; |
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
226 | 226 | * @return int |
227 | 227 | */ |
228 | - public function count(){ |
|
228 | + public function count() { |
|
229 | 229 | return \sizeof($this->items); |
230 | 230 | } |
231 | 231 | /** |
232 | 232 | * @param boolean $dropdown |
233 | 233 | */ |
234 | - public function asDropdown($dropdown){ |
|
235 | - if($dropdown===false){ |
|
234 | + public function asDropdown($dropdown) { |
|
235 | + if ($dropdown===false) { |
|
236 | 236 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
237 | 237 | $dropdown="menu"; |
238 | - }else{ |
|
238 | + } else { |
|
239 | 239 | $dropdown="dropdown"; |
240 | 240 | $this->mClass="menu"; |
241 | 241 | } |
242 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
242 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
243 | 243 | } |
244 | 244 | |
245 | - public function setVertical(){ |
|
246 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
245 | + public function setVertical() { |
|
246 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
247 | 247 | } |
248 | 248 | |
249 | - public function setInline(){ |
|
250 | - return $this->addToPropertyCtrl("class", "inline",["inline"]); |
|
249 | + public function setInline() { |
|
250 | + return $this->addToPropertyCtrl("class", "inline", ["inline"]); |
|
251 | 251 | } |
252 | 252 | |
253 | - public function setSimple(){ |
|
254 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
253 | + public function setSimple() { |
|
254 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
255 | 255 | } |
256 | 256 | |
257 | - public function asButton($floating=false){ |
|
257 | + public function asButton($floating=false) { |
|
258 | 258 | $this->removeArrow(); |
259 | - if($floating) |
|
259 | + if ($floating) |
|
260 | 260 | $this->addToProperty("class", "floating"); |
261 | 261 | $this->removePropertyValue("class", "selection"); |
262 | 262 | return $this->addToProperty("class", "button"); |
263 | 263 | } |
264 | 264 | |
265 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
265 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
266 | 266 | $this->_multiple=$multiple; |
267 | - if(isset($name)) |
|
267 | + if (isset($name)) |
|
268 | 268 | $this->addInput($name); |
269 | - if($multiple){ |
|
269 | + if ($multiple) { |
|
270 | 270 | $this->addToProperty("class", "multiple"); |
271 | 271 | } |
272 | - if ($selection){ |
|
273 | - if($this->propertyContains("class", "button")===false) |
|
274 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
272 | + if ($selection) { |
|
273 | + if ($this->propertyContains("class", "button")===false) |
|
274 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
275 | 275 | } |
276 | 276 | return $this; |
277 | 277 | } |
278 | 278 | |
279 | - public function asSearch($name=NULL,$multiple=false,$selection=true){ |
|
280 | - $this->asSelect($name,$multiple,$selection); |
|
279 | + public function asSearch($name=NULL, $multiple=false, $selection=true) { |
|
280 | + $this->asSelect($name, $multiple, $selection); |
|
281 | 281 | return $this->addToProperty("class", "search"); |
282 | 282 | } |
283 | 283 | |
284 | - public function setSelect($name=NULL,$multiple=false){ |
|
285 | - if(!isset($name)) |
|
284 | + public function setSelect($name=NULL, $multiple=false) { |
|
285 | + if (!isset($name)) |
|
286 | 286 | $name="select-".$this->identifier; |
287 | 287 | $this->input=null; |
288 | - if($multiple){ |
|
288 | + if ($multiple) { |
|
289 | 289 | $this->setProperty("multiple", true); |
290 | 290 | $this->addToProperty("class", "multiple"); |
291 | 291 | } |
@@ -293,37 +293,37 @@ discard block |
||
293 | 293 | $this->tagName="select"; |
294 | 294 | $this->setProperty("name", $name); |
295 | 295 | $this->content=null; |
296 | - foreach ($this->items as $item){ |
|
296 | + foreach ($this->items as $item) { |
|
297 | 297 | $item->asOption(); |
298 | 298 | } |
299 | 299 | return $this; |
300 | 300 | } |
301 | 301 | |
302 | - public function asSubmenu($pointing=NULL){ |
|
302 | + public function asSubmenu($pointing=NULL) { |
|
303 | 303 | $this->setClass("ui dropdown link item"); |
304 | - if(isset($pointing)){ |
|
304 | + if (isset($pointing)) { |
|
305 | 305 | $this->setPointing($pointing); |
306 | 306 | } |
307 | 307 | return $this; |
308 | 308 | } |
309 | 309 | |
310 | - public function setPointing($value=Direction::NONE){ |
|
311 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
310 | + public function setPointing($value=Direction::NONE) { |
|
311 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
312 | 312 | } |
313 | 313 | |
314 | - public function setValue($value){ |
|
314 | + public function setValue($value) { |
|
315 | 315 | $this->value=$value; |
316 | 316 | return $this; |
317 | 317 | } |
318 | - private function applyValue(){ |
|
318 | + private function applyValue() { |
|
319 | 319 | $value=$this->value; |
320 | - if(isset($this->input) && isset($value)){ |
|
320 | + if (isset($this->input) && isset($value)) { |
|
321 | 321 | $this->input->setProperty("value", $value); |
322 | - }else{ |
|
322 | + } else { |
|
323 | 323 | $this->setProperty("value", $value); |
324 | 324 | } |
325 | 325 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
326 | - if(isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple) |
|
326 | + if (isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple) |
|
327 | 327 | $textElement->setContent($value); |
328 | 328 | return $this; |
329 | 329 | } |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | * @see BaseHtml::run() |
334 | 334 | */ |
335 | 335 | public function run(JsUtils $js) { |
336 | - if($this->propertyContains("class", "simple")===false){ |
|
337 | - if(isset($this->_bsComponent)===false){ |
|
338 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
336 | + if ($this->propertyContains("class", "simple")===false) { |
|
337 | + if (isset($this->_bsComponent)===false) { |
|
338 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params); |
|
339 | 339 | $this->_bsComponent->setItemSelector(".item"); |
340 | 340 | } |
341 | 341 | $this->addEventsOnRun($js); |
@@ -343,41 +343,41 @@ discard block |
||
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
346 | - public function setCompact(){ |
|
346 | + public function setCompact() { |
|
347 | 347 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
348 | 348 | } |
349 | 349 | |
350 | - public function setAction($action){ |
|
350 | + public function setAction($action) { |
|
351 | 351 | $this->_params["action"]=$action; |
352 | 352 | } |
353 | 353 | |
354 | - public function setOn($on){ |
|
354 | + public function setOn($on) { |
|
355 | 355 | $this->_params["on"]=$on; |
356 | 356 | } |
357 | 357 | |
358 | - public function setShowOnFocus($value){ |
|
358 | + public function setShowOnFocus($value) { |
|
359 | 359 | $this->_params["showOnFocus"]=$value; |
360 | 360 | } |
361 | 361 | |
362 | - public function setFullTextSearch($value){ |
|
362 | + public function setFullTextSearch($value) { |
|
363 | 363 | $this->_params["fullTextSearch"]=$value; |
364 | 364 | } |
365 | 365 | |
366 | 366 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
367 | 367 | $this->applyValue(); |
368 | - return parent::compile($js,$view); |
|
368 | + return parent::compile($js, $view); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | public function getInput() { |
372 | 372 | return $this->input; |
373 | 373 | } |
374 | 374 | |
375 | - public function setIcon($icon="dropdown"){ |
|
375 | + public function setIcon($icon="dropdown") { |
|
376 | 376 | $this->content["arrow"]=new HtmlIcon($this->identifier."-icon", $icon); |
377 | 377 | return $this; |
378 | 378 | } |
379 | 379 | |
380 | - public function jsAddItem($caption){ |
|
380 | + public function jsAddItem($caption) { |
|
381 | 381 | $js="var first=$('#{$this->identifier} .item').first();if(first!=undefined){var new =first.clone();first.parent().append(new);first.html('{$caption}};')"; |
382 | 382 | return $js; |
383 | 383 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | if(isset($value)){ |
37 | 37 | if($value instanceof HtmlSemDoubleElement){ |
38 | 38 | $text=$value; |
39 | - }else{ |
|
39 | + } else{ |
|
40 | 40 | $text=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
41 | 41 | $text->setClass("text"); |
42 | 42 | $this->setValue($value); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } |
110 | 110 | if(!$item instanceof HtmlDropdownItem){ |
111 | 111 | $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
112 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
112 | + } elseif($itemO instanceof HtmlDropdownItem){ |
|
113 | 113 | $this->addToProperty("class", "vertical"); |
114 | 114 | } |
115 | 115 | return $itemO; |
@@ -123,8 +123,9 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | public function addInput($name){ |
126 | - if(!isset($name)) |
|
127 | - $name="input-".$this->identifier; |
|
126 | + if(!isset($name)) { |
|
127 | + $name="input-".$this->identifier; |
|
128 | + } |
|
128 | 129 | $this->setAction("activate"); |
129 | 130 | $this->input=new HtmlInput($name,"hidden"); |
130 | 131 | } |
@@ -181,7 +182,7 @@ discard block |
||
181 | 182 | foreach ($items as $k=>$v){ |
182 | 183 | $this->addItem($v)->setData($k); |
183 | 184 | } |
184 | - }else{ |
|
185 | + } else{ |
|
185 | 186 | foreach ($items as $item){ |
186 | 187 | $this->addItem($item); |
187 | 188 | } |
@@ -203,8 +204,7 @@ discard block |
||
203 | 204 | $c=$this->items[$i++]; |
204 | 205 | if(isset($c)){ |
205 | 206 | $c->setProperty($property,$value); |
206 | - } |
|
207 | - else{ |
|
207 | + } else{ |
|
208 | 208 | return $this; |
209 | 209 | } |
210 | 210 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | if($dropdown===false){ |
236 | 236 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
237 | 237 | $dropdown="menu"; |
238 | - }else{ |
|
238 | + } else{ |
|
239 | 239 | $dropdown="dropdown"; |
240 | 240 | $this->mClass="menu"; |
241 | 241 | } |
@@ -256,22 +256,25 @@ discard block |
||
256 | 256 | |
257 | 257 | public function asButton($floating=false){ |
258 | 258 | $this->removeArrow(); |
259 | - if($floating) |
|
260 | - $this->addToProperty("class", "floating"); |
|
259 | + if($floating) { |
|
260 | + $this->addToProperty("class", "floating"); |
|
261 | + } |
|
261 | 262 | $this->removePropertyValue("class", "selection"); |
262 | 263 | return $this->addToProperty("class", "button"); |
263 | 264 | } |
264 | 265 | |
265 | 266 | public function asSelect($name=NULL,$multiple=false,$selection=true){ |
266 | 267 | $this->_multiple=$multiple; |
267 | - if(isset($name)) |
|
268 | - $this->addInput($name); |
|
268 | + if(isset($name)) { |
|
269 | + $this->addInput($name); |
|
270 | + } |
|
269 | 271 | if($multiple){ |
270 | 272 | $this->addToProperty("class", "multiple"); |
271 | 273 | } |
272 | 274 | if ($selection){ |
273 | - if($this->propertyContains("class", "button")===false) |
|
274 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
275 | + if($this->propertyContains("class", "button")===false) { |
|
276 | + $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
277 | + } |
|
275 | 278 | } |
276 | 279 | return $this; |
277 | 280 | } |
@@ -282,8 +285,9 @@ discard block |
||
282 | 285 | } |
283 | 286 | |
284 | 287 | public function setSelect($name=NULL,$multiple=false){ |
285 | - if(!isset($name)) |
|
286 | - $name="select-".$this->identifier; |
|
288 | + if(!isset($name)) { |
|
289 | + $name="select-".$this->identifier; |
|
290 | + } |
|
287 | 291 | $this->input=null; |
288 | 292 | if($multiple){ |
289 | 293 | $this->setProperty("multiple", true); |
@@ -319,12 +323,13 @@ discard block |
||
319 | 323 | $value=$this->value; |
320 | 324 | if(isset($this->input) && isset($value)){ |
321 | 325 | $this->input->setProperty("value", $value); |
322 | - }else{ |
|
326 | + } else{ |
|
323 | 327 | $this->setProperty("value", $value); |
324 | 328 | } |
325 | 329 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
326 | - if(isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple) |
|
327 | - $textElement->setContent($value); |
|
330 | + if(isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple) { |
|
331 | + $textElement->setContent($value); |
|
332 | + } |
|
328 | 333 | return $this; |
329 | 334 | } |
330 | 335 |
@@ -13,34 +13,34 @@ discard block |
||
13 | 13 | use Ajax\bootstrap\html\content\HtmlDropdownItem; |
14 | 14 | |
15 | 15 | class HtmlDropdownItem extends HtmlSemDoubleElement { |
16 | - use IconTrait,MenuItemTrait; |
|
17 | - public function __construct($identifier, $content="",$value=NULL,$image=NULL,$description=NULL) { |
|
16 | + use IconTrait, MenuItemTrait; |
|
17 | + public function __construct($identifier, $content="", $value=NULL, $image=NULL, $description=NULL) { |
|
18 | 18 | parent::__construct($identifier, "a"); |
19 | 19 | $this->setClass("item"); |
20 | 20 | $this->setContent($content); |
21 | - if($value!==NULL) |
|
21 | + if ($value!==NULL) |
|
22 | 22 | $this->setData($value); |
23 | - if($image!==NULL) |
|
23 | + if ($image!==NULL) |
|
24 | 24 | $this->asMiniAvatar($image); |
25 | - if($description!==NULL) |
|
25 | + if ($description!==NULL) |
|
26 | 26 | $this->setDescription($description); |
27 | 27 | } |
28 | 28 | |
29 | - public function setDescription($description){ |
|
30 | - $descO=new HtmlDoubleElement("desc-".$this->identifier,"span"); |
|
29 | + public function setDescription($description) { |
|
30 | + $descO=new HtmlDoubleElement("desc-".$this->identifier, "span"); |
|
31 | 31 | $descO->setClass("description"); |
32 | 32 | $descO->setContent($description); |
33 | - return $this->addContent($descO,true); |
|
33 | + return $this->addContent($descO, true); |
|
34 | 34 | } |
35 | 35 | |
36 | - public function setData($value){ |
|
36 | + public function setData($value) { |
|
37 | 37 | $this->setProperty("data-value", $value); |
38 | 38 | return $this; |
39 | 39 | } |
40 | 40 | |
41 | - public function asOption(){ |
|
41 | + public function asOption() { |
|
42 | 42 | $this->tagName="option"; |
43 | - if($this->getProperty("data-value")!==null) |
|
43 | + if ($this->getProperty("data-value")!==null) |
|
44 | 44 | $this->setProperty("value", $this->getProperty("data-value")); |
45 | 45 | } |
46 | 46 | |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | * @param string $image the image src |
49 | 49 | * @return HtmlImg |
50 | 50 | */ |
51 | - public function asMiniAvatar($image){ |
|
51 | + public function asMiniAvatar($image) { |
|
52 | 52 | $this->tagName="div"; |
53 | - $img=new HtmlImg("image-".$this->identifier,$image); |
|
53 | + $img=new HtmlImg("image-".$this->identifier, $image); |
|
54 | 54 | $img->setClass("ui mini avatar image"); |
55 | - $this->addContent($img,true); |
|
55 | + $this->addContent($img, true); |
|
56 | 56 | return $this; |
57 | 57 | } |
58 | 58 | |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | * @param string $icon |
62 | 62 | * @return HtmlDropdownItem |
63 | 63 | */ |
64 | - public function asIcon($caption,$icon){ |
|
64 | + public function asIcon($caption, $icon) { |
|
65 | 65 | $this->setContent($caption); |
66 | - $this->addContent(new HtmlIcon("", $icon),true); |
|
66 | + $this->addContent(new HtmlIcon("", $icon), true); |
|
67 | 67 | return $this; |
68 | 68 | } |
69 | 69 | |
@@ -72,23 +72,23 @@ discard block |
||
72 | 72 | * @param string $color |
73 | 73 | * @return HtmlDropdownItem |
74 | 74 | */ |
75 | - public function asCircularLabel($caption,$color){ |
|
75 | + public function asCircularLabel($caption, $color) { |
|
76 | 76 | $this->setContent($caption); |
77 | 77 | $lbl=new HtmlLabel(""); |
78 | 78 | $lbl->setCircular()->setColor($color)->setEmpty(); |
79 | - $this->addContent($lbl,true); |
|
79 | + $this->addContent($lbl, true); |
|
80 | 80 | return $this; |
81 | 81 | } |
82 | 82 | |
83 | 83 | |
84 | 84 | |
85 | 85 | public function addMenuItem($items) { |
86 | - $menu=new HtmlMenu("menu-" . $this->identifier, $items); |
|
86 | + $menu=new HtmlMenu("menu-".$this->identifier, $items); |
|
87 | 87 | $content=$this->content; |
88 | 88 | $this->setTagName("div"); |
89 | 89 | $this->setProperty("class", "item"); |
90 | 90 | $icon=new HtmlIcon("", "dropdown"); |
91 | - $this->content=[$icon,new HtmlSemDoubleElement("","span","text",$content),$menu]; |
|
91 | + $this->content=[$icon, new HtmlSemDoubleElement("", "span", "text", $content), $menu]; |
|
92 | 92 | return $menu; |
93 | 93 | } |
94 | 94 | |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | * @param string $icon |
98 | 98 | * @return HtmlDropdownItem |
99 | 99 | */ |
100 | - public static function searchInput($placeholder=NULL,$icon=NULL){ |
|
101 | - return (new HtmlDropdownItem(""))->asSearchInput($placeholder,$icon); |
|
100 | + public static function searchInput($placeholder=NULL, $icon=NULL) { |
|
101 | + return (new HtmlDropdownItem(""))->asSearchInput($placeholder, $icon); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | 105 | * @return HtmlDropdownItem |
106 | 106 | */ |
107 | - public static function divider(){ |
|
107 | + public static function divider() { |
|
108 | 108 | return (new HtmlDropdownItem(""))->asDivider(); |
109 | 109 | } |
110 | 110 | |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | * @param string $icon |
114 | 114 | * @return HtmlDropdownItem |
115 | 115 | */ |
116 | - public static function header($caption=NULL,$icon=NULL){ |
|
117 | - return (new HtmlDropdownItem(""))->asHeader($caption,$icon); |
|
116 | + public static function header($caption=NULL, $icon=NULL) { |
|
117 | + return (new HtmlDropdownItem(""))->asHeader($caption, $icon); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @param string $color |
123 | 123 | * @return HtmlDropdownItem |
124 | 124 | */ |
125 | - public static function circular($caption,$color){ |
|
126 | - return (new HtmlDropdownItem(""))->asCircularLabel($caption,$color); |
|
125 | + public static function circular($caption, $color) { |
|
126 | + return (new HtmlDropdownItem(""))->asCircularLabel($caption, $color); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param string $icon |
132 | 132 | * @return HtmlDropdownItem |
133 | 133 | */ |
134 | - public static function icon($caption,$icon){ |
|
135 | - return (new HtmlDropdownItem(""))->asIcon($caption,$icon); |
|
134 | + public static function icon($caption, $icon) { |
|
135 | + return (new HtmlDropdownItem(""))->asIcon($caption, $icon); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param string $image |
141 | 141 | * @return HtmlDropdownItem |
142 | 142 | */ |
143 | - public static function avatar($caption,$image){ |
|
144 | - return (new HtmlDropdownItem("",$caption))->asMiniAvatar($image); |
|
143 | + public static function avatar($caption, $image) { |
|
144 | + return (new HtmlDropdownItem("", $caption))->asMiniAvatar($image); |
|
145 | 145 | } |
146 | 146 | } |