@@ -108,6 +108,10 @@ discard block |
||
108 | 108 | return true; |
109 | 109 | } |
110 | 110 | |
111 | + /** |
|
112 | + * @param string $propertyName |
|
113 | + * @param string $value |
|
114 | + */ |
|
111 | 115 | protected function propertyContains($propertyName,$value){ |
112 | 116 | $values=$this->getProperty($propertyName); |
113 | 117 | if(isset($values)){ |
@@ -142,12 +146,19 @@ discard block |
||
142 | 146 | return $this; |
143 | 147 | } |
144 | 148 | |
149 | + /** |
|
150 | + * @param string $name |
|
151 | + */ |
|
145 | 152 | protected function removeProperty($name){ |
146 | 153 | if(\array_key_exists($name, $this->properties)) |
147 | 154 | unset($this->properties[$name]); |
148 | 155 | return $this; |
149 | 156 | } |
150 | 157 | |
158 | + /** |
|
159 | + * @param string $name |
|
160 | + * @param string[] $typeCtrl |
|
161 | + */ |
|
151 | 162 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
152 | 163 | if ($this->ctrl($name, $value, $typeCtrl)===true) { |
153 | 164 | if (is_array($typeCtrl)) { |
@@ -172,6 +183,9 @@ discard block |
||
172 | 183 | return $this->addToProperty($name, $value); |
173 | 184 | } |
174 | 185 | |
186 | + /** |
|
187 | + * @param string $name |
|
188 | + */ |
|
175 | 189 | public function addToPropertyCtrl($name, $value, $typeCtrl) { |
176 | 190 | // if($this->ctrl($name, $value, $typeCtrl)===true){ |
177 | 191 | return $this->addToPropertyUnique($name, $value, $typeCtrl); |
@@ -239,6 +253,9 @@ discard block |
||
239 | 253 | |
240 | 254 | } |
241 | 255 | |
256 | + /** |
|
257 | + * @param string $before |
|
258 | + */ |
|
242 | 259 | public function wrap($before, $after="") { |
243 | 260 | if(isset($before)){ |
244 | 261 | $this->wrapBefore.=$before; |
@@ -307,6 +324,9 @@ discard block |
||
307 | 324 | } |
308 | 325 | } |
309 | 326 | |
327 | + /** |
|
328 | + * @param string $operation |
|
329 | + */ |
|
310 | 330 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
311 | 331 | $params=array ( |
312 | 332 | "url" => $url, |
@@ -317,14 +337,23 @@ discard block |
||
317 | 337 | return $this; |
318 | 338 | } |
319 | 339 | |
340 | + /** |
|
341 | + * @param string $event |
|
342 | + */ |
|
320 | 343 | public function getOn($event, $url, $responseElement="", $parameters=array()) { |
321 | 344 | return $this->_ajaxOn("get", $event, $url, $responseElement, $parameters); |
322 | 345 | } |
323 | 346 | |
347 | + /** |
|
348 | + * @param string $url |
|
349 | + */ |
|
324 | 350 | public function getOnClick($url, $responseElement="", $parameters=array()) { |
325 | 351 | return $this->getOn("click", $url, $responseElement, $parameters); |
326 | 352 | } |
327 | 353 | |
354 | + /** |
|
355 | + * @param string $event |
|
356 | + */ |
|
328 | 357 | public function postOn($event, $url, $params="{}", $responseElement="", $parameters=array()) { |
329 | 358 | $parameters ["params"]=$params; |
330 | 359 | return $this->_ajaxOn("post", $event, $url, $responseElement, $parameters); |
@@ -334,6 +363,9 @@ discard block |
||
334 | 363 | return $this->postOn("click", $url, $params, $responseElement, $parameters); |
335 | 364 | } |
336 | 365 | |
366 | + /** |
|
367 | + * @param string $event |
|
368 | + */ |
|
337 | 369 | public function postFormOn($event, $url, $form, $responseElement="", $parameters=array()) { |
338 | 370 | $parameters ["form"]=$form; |
339 | 371 | return $this->_ajaxOn("postForm", $event, $url, $responseElement, $parameters); |
@@ -383,6 +415,9 @@ discard block |
||
383 | 415 | return $value; |
384 | 416 | } |
385 | 417 | |
418 | + /** |
|
419 | + * @param string $jqueryCall |
|
420 | + */ |
|
386 | 421 | public function jsDoJquery($jqueryCall, $param=""){ |
387 | 422 | return "$('#".$this->identifier."').".$jqueryCall."(".$this->_prep_value($param).");"; |
388 | 423 | } |
@@ -50,16 +50,18 @@ discard block |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | public function getProperty($name) { |
53 | - if (array_key_exists($name, $this->properties)) |
|
54 | - return $this->properties [$name]; |
|
53 | + if (array_key_exists($name, $this->properties)) { |
|
54 | + return $this->properties [$name]; |
|
55 | + } |
|
55 | 56 | } |
56 | 57 | |
57 | 58 | public function addToProperty($name, $value, $separator=" ") { |
58 | 59 | $v=@$this->properties[$name]; |
59 | - if (isset($v)&&$v!=="") |
|
60 | - $v=$v.$separator.$value; |
|
61 | - else |
|
62 | - $v=$value; |
|
60 | + if (isset($v)&&$v!=="") { |
|
61 | + $v=$v.$separator.$value; |
|
62 | + } else { |
|
63 | + $v=$value; |
|
64 | + } |
|
63 | 65 | |
64 | 66 | return $this->setProperty($name, $v); |
65 | 67 | } |
@@ -117,8 +119,9 @@ discard block |
||
117 | 119 | } |
118 | 120 | |
119 | 121 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
120 | - if ($this->ctrl($name, $value, $typeCtrl)===true) |
|
121 | - return $this->setProperty($name, $value); |
|
122 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
123 | + return $this->setProperty($name, $value); |
|
124 | + } |
|
122 | 125 | return $this; |
123 | 126 | } |
124 | 127 | |
@@ -143,8 +146,9 @@ discard block |
||
143 | 146 | } |
144 | 147 | |
145 | 148 | protected function removeProperty($name){ |
146 | - if(\array_key_exists($name, $this->properties)) |
|
147 | - unset($this->properties[$name]); |
|
149 | + if(\array_key_exists($name, $this->properties)) { |
|
150 | + unset($this->properties[$name]); |
|
151 | + } |
|
148 | 152 | return $this; |
149 | 153 | } |
150 | 154 | |
@@ -164,8 +168,9 @@ discard block |
||
164 | 168 | } |
165 | 169 | |
166 | 170 | protected function addToPropertyUnique($name, $value, $typeCtrl) { |
167 | - if (@class_exists($typeCtrl, true)) |
|
168 | - $typeCtrl=$typeCtrl::getConstants(); |
|
171 | + if (@class_exists($typeCtrl, true)) { |
|
172 | + $typeCtrl=$typeCtrl::getConstants(); |
|
173 | + } |
|
169 | 174 | if (is_array($typeCtrl)) { |
170 | 175 | $this->removeOldValues($this->properties [$name], $typeCtrl); |
171 | 176 | } |
@@ -348,15 +353,18 @@ discard block |
||
348 | 353 | $flag=false; |
349 | 354 | $index=0; |
350 | 355 | while ( !$flag&&$index<sizeof($elements) ) { |
351 | - if ($elements [$index] instanceof BaseHtml) |
|
352 | - $flag=($elements [$index]->getIdentifier()===$identifier); |
|
356 | + if ($elements [$index] instanceof BaseHtml) { |
|
357 | + $flag=($elements [$index]->getIdentifier()===$identifier); |
|
358 | + } |
|
353 | 359 | $index++; |
354 | 360 | } |
355 | - if ($flag===true) |
|
356 | - return $elements [$index-1]; |
|
361 | + if ($flag===true) { |
|
362 | + return $elements [$index-1]; |
|
363 | + } |
|
357 | 364 | } elseif ($elements instanceof BaseHtml) { |
358 | - if ($elements->getIdentifier()===$identifier) |
|
359 | - return $elements; |
|
365 | + if ($elements->getIdentifier()===$identifier) { |
|
366 | + return $elements; |
|
367 | + } |
|
360 | 368 | } |
361 | 369 | return null; |
362 | 370 | } |
@@ -87,6 +87,9 @@ discard block |
||
87 | 87 | $this->addItem($function($object)); |
88 | 88 | } |
89 | 89 | |
90 | + /** |
|
91 | + * @param \Closure $callBack |
|
92 | + */ |
|
90 | 93 | public function apply($callBack){ |
91 | 94 | foreach ($this->content as $item){ |
92 | 95 | $callBack($item); |
@@ -121,6 +124,9 @@ discard block |
||
121 | 124 | return $this->_bsComponent; |
122 | 125 | } |
123 | 126 | |
127 | + /** |
|
128 | + * @param string $tagName |
|
129 | + */ |
|
124 | 130 | protected function contentAs($tagName){ |
125 | 131 | foreach ($this->content as $item){ |
126 | 132 | $item->setTagName($tagName); |
@@ -22,6 +22,11 @@ discard block |
||
22 | 22 | protected $_contentSeparator=""; |
23 | 23 | |
24 | 24 | |
25 | + /** |
|
26 | + * @param string $identifier |
|
27 | + * @param string $tagName |
|
28 | + * @param string $baseClass |
|
29 | + */ |
|
25 | 30 | public function __construct($identifier,$tagName,$baseClass){ |
26 | 31 | parent::__construct($identifier,$tagName,$baseClass); |
27 | 32 | $this->root=""; |
@@ -32,8 +37,7 @@ discard block |
||
32 | 37 | * Associate an ajax get to the elements, displayed in $targetSelector |
33 | 38 | * $attr member is used to build each element url |
34 | 39 | * @param string $targetSelector the target of the get |
35 | - * @param string $attr the html attribute used to build the elements url |
|
36 | - * @return HtmlNavElement |
|
40 | + * @return HtmlSemNavElement |
|
37 | 41 | */ |
38 | 42 | public function autoGetOnClick($targetSelector){ |
39 | 43 | return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
@@ -65,7 +69,7 @@ discard block |
||
65 | 69 | /** |
66 | 70 | * Define the html attribute for each element url in ajax |
67 | 71 | * @param string $attr html attribute |
68 | - * @return HtmlNavElement |
|
72 | + * @return HtmlSemNavElement |
|
69 | 73 | */ |
70 | 74 | public function setAttr($attr) { |
71 | 75 | $this->attr = $attr; |
@@ -105,6 +109,9 @@ discard block |
||
105 | 109 | return $this; |
106 | 110 | } |
107 | 111 | |
112 | + /** |
|
113 | + * @param integer $index |
|
114 | + */ |
|
108 | 115 | protected function getContentDivider($index){ |
109 | 116 | if(\is_array($this->_contentSeparator)===true){ |
110 | 117 | return @$this->_contentSeparator[$index]; |
@@ -96,10 +96,11 @@ |
||
96 | 96 | |
97 | 97 | protected function setDivider($divider,$index){ |
98 | 98 | if(isset($index)){ |
99 | - if(\is_array($this->_contentSeparator)===false) |
|
100 | - $this->_contentSeparator=array_fill (0, $this->count()-1,$this->_contentSeparator); |
|
99 | + if(\is_array($this->_contentSeparator)===false) { |
|
100 | + $this->_contentSeparator=array_fill (0, $this->count()-1,$this->_contentSeparator); |
|
101 | + } |
|
101 | 102 | $this->_contentSeparator[$index]=$divider; |
102 | - }else{ |
|
103 | + } else{ |
|
103 | 104 | $this->_contentSeparator=$divider; |
104 | 105 | } |
105 | 106 | return $this; |
@@ -7,6 +7,9 @@ |
||
7 | 7 | trait IconTrait { |
8 | 8 | private $_hasIcon=false; |
9 | 9 | |
10 | + /** |
|
11 | + * @param boolean $direction |
|
12 | + */ |
|
10 | 13 | public function addIcon($icon,$direction=Direction::LEFT){ |
11 | 14 | if($this->_hasIcon===false){ |
12 | 15 | $iconO=$icon; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | $this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon")); |
17 | 17 | $this->addContent($iconO,false); |
18 | 18 | $this->_hasIcon=true; |
19 | - }else{ |
|
19 | + } else{ |
|
20 | 20 | $iconO=$this->getIcon(); |
21 | 21 | $iconO->setIcon($icon); |
22 | 22 | $this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon")); |
@@ -27,8 +27,9 @@ discard block |
||
27 | 27 | public function getIcon(){ |
28 | 28 | if(\is_array($this->content)){ |
29 | 29 | foreach ($this->content as $item){ |
30 | - if($item instanceof HtmlIcon) |
|
31 | - return $item; |
|
30 | + if($item instanceof HtmlIcon) { |
|
31 | + return $item; |
|
32 | + } |
|
32 | 33 | } |
33 | 34 | } |
34 | 35 | } |
@@ -11,6 +11,10 @@ discard block |
||
11 | 11 | |
12 | 12 | class HtmlDropdownItem extends HtmlSemDoubleElement { |
13 | 13 | use IconTrait; |
14 | + |
|
15 | + /** |
|
16 | + * @param string $identifier |
|
17 | + */ |
|
14 | 18 | public function __construct($identifier, $content="",$value=NULL,$image=NULL) { |
15 | 19 | parent::__construct($identifier, "a"); |
16 | 20 | $this->setClass("item"); |
@@ -61,6 +65,9 @@ discard block |
||
61 | 65 | return $this; |
62 | 66 | } |
63 | 67 | |
68 | + /** |
|
69 | + * @param string $content |
|
70 | + */ |
|
64 | 71 | public function setContent($content){ |
65 | 72 | if($content==="-"){ |
66 | 73 | $this->asDivider(); |
@@ -92,8 +92,9 @@ discard block |
||
92 | 92 | if(\sizeof($params)>0 || \strtolower($action)!="index" ){ |
93 | 93 | $items[]=$action; |
94 | 94 | foreach ($params as $p){ |
95 | - if(\is_object($p)===false) |
|
96 | - $items[]=$p; |
|
95 | + if(\is_object($p)===false) { |
|
96 | + $items[]=$p; |
|
97 | + } |
|
97 | 98 | } |
98 | 99 | } |
99 | 100 | return $this->addItems($items); |
@@ -111,7 +112,7 @@ discard block |
||
111 | 112 | } |
112 | 113 | if($this->absolutePaths===true){ |
113 | 114 | return $this->_hrefFunction($this->content[$index]); |
114 | - }else{ |
|
115 | + } else{ |
|
115 | 116 | return $this->root.implode($separator, array_slice(array_map(function($e){return $this->_hrefFunction($e);}, $this->content),$this->startIndex,$index+1)); |
116 | 117 | } |
117 | 118 | } |
@@ -165,8 +166,9 @@ discard block |
||
165 | 166 | |
166 | 167 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
167 | 168 | foreach ($this->content as $element){ |
168 | - if($element->getProperty($this->attr)!=NULL) |
|
169 | - $element->_ajaxOn($operation, $event, $url, $responseElement, $parameters); |
|
169 | + if($element->getProperty($this->attr)!=NULL) { |
|
170 | + $element->_ajaxOn($operation, $event, $url, $responseElement, $parameters); |
|
171 | + } |
|
170 | 172 | } |
171 | 173 | return $this; |
172 | 174 | } |
@@ -178,9 +180,9 @@ discard block |
||
178 | 180 | protected function createItem($value) { |
179 | 181 | $count=$this->count(); |
180 | 182 | $itemO=new HtmlSemDoubleElement("item-".$this->identifier."-".$count,"a","section"); |
181 | - if(\is_array($value)) |
|
182 | - $itemO->fromArray($value); |
|
183 | - else{ |
|
183 | + if(\is_array($value)) { |
|
184 | + $itemO->fromArray($value); |
|
185 | + } else{ |
|
184 | 186 | $itemO->setContent($value); |
185 | 187 | $itemO->setProperty($this->attr, $this->getHref($count)); |
186 | 188 | } |
@@ -52,9 +52,9 @@ |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | public function setFocusable($value=true){ |
55 | - if($value===true) |
|
56 | - $this->setProperty("tabindex", "0"); |
|
57 | - else{ |
|
55 | + if($value===true) { |
|
56 | + $this->setProperty("tabindex", "0"); |
|
57 | + } else{ |
|
58 | 58 | $this->removeProperty("tabindex"); |
59 | 59 | } |
60 | 60 | return $this; |
@@ -32,9 +32,10 @@ discard block |
||
32 | 32 | $labelO=$label; |
33 | 33 | if(\is_object($label)===false){ |
34 | 34 | $labelO=new HtmlLabel("label-".$this->identifier,$label); |
35 | - if(isset($icon)) |
|
36 | - $labelO->addIcon($icon); |
|
37 | - }else{ |
|
35 | + if(isset($icon)) { |
|
36 | + $labelO->addIcon($icon); |
|
37 | + } |
|
38 | + } else{ |
|
38 | 39 | $labelO->addToPropertyCtrl("class", "label", array("label")); |
39 | 40 | } |
40 | 41 | $this->addToProperty("class", $direction." labeled"); |
@@ -50,8 +51,9 @@ discard block |
||
50 | 51 | $actionO=$action; |
51 | 52 | if(\is_object($action)===false){ |
52 | 53 | $actionO=new HtmlButton("action-".$this->identifier,$action); |
53 | - if(isset($icon)) |
|
54 | - $actionO->addIcon($icon,true,$labeled); |
|
54 | + if(isset($icon)) { |
|
55 | + $actionO->addIcon($icon,true,$labeled); |
|
56 | + } |
|
55 | 57 | } |
56 | 58 | $this->addToProperty("class", $direction." action"); |
57 | 59 | $this->addContent($actionO,\strstr($direction,Direction::LEFT)!==false); |
@@ -13,15 +13,17 @@ discard block |
||
13 | 13 | return $array [$key]; |
14 | 14 | } |
15 | 15 | $values=array_values($array); |
16 | - if ($pos<sizeof($values)) |
|
17 | - return $values [$pos]; |
|
16 | + if ($pos<sizeof($values)) { |
|
17 | + return $values [$pos]; |
|
18 | + } |
|
18 | 19 | } |
19 | 20 | |
20 | 21 | public static function getDefaultValue($array, $key, $default) { |
21 | 22 | if (array_key_exists($key, $array)) { |
22 | 23 | return $array [$key]; |
23 | - } else |
|
24 | - return $default; |
|
24 | + } else { |
|
25 | + return $default; |
|
26 | + } |
|
25 | 27 | } |
26 | 28 | |
27 | 29 | public static function implode($glue,$pieces){ |
@@ -34,7 +36,7 @@ discard block |
||
34 | 36 | } |
35 | 37 | $result.=$pieces[$size-1]; |
36 | 38 | } |
37 | - }else{ |
|
39 | + } else{ |
|
38 | 40 | $result=\implode($glue, $pieces); |
39 | 41 | } |
40 | 42 | return $result; |