@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | * @version 1.001 |
19 | 19 | */ |
20 | 20 | class HtmlSegment extends HtmlSemDoubleElement { |
21 | - use AttachedTrait,TextAlignmentTrait; |
|
21 | + use AttachedTrait, TextAlignmentTrait; |
|
22 | 22 | |
23 | 23 | public function __construct($identifier, $content="") { |
24 | 24 | parent::__construct($identifier, "div", "ui segment"); |
25 | - $this->_variations=\array_merge($this->_variations, [ Variation::PADDED,Variation::COMPACT ]); |
|
26 | - $this->_states=\array_merge($this->_states, [ State::LOADING ]); |
|
25 | + $this->_variations=\array_merge($this->_variations, [Variation::PADDED, Variation::COMPACT]); |
|
26 | + $this->_states=\array_merge($this->_states, [State::LOADING]); |
|
27 | 27 | $this->content=$content; |
28 | 28 | } |
29 | 29 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | public function setSens($sens="vertical") { |
40 | - return $this->addToPropertyCtrl("class", $sens, array ("vertical","horizontal" )); |
|
40 | + return $this->addToPropertyCtrl("class", $sens, array("vertical", "horizontal")); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | public function setEmphasis($value=Emphasis::SECONDARY) { |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | public function asContainer() { |
64 | - return $this->addToPropertyCtrl("class", "container", array ("container" )); |
|
64 | + return $this->addToPropertyCtrl("class", "container", array("container")); |
|
65 | 65 | } |
66 | 66 | |
67 | - public function addGrid($numRows=1, $numCols=NULL){ |
|
68 | - $grid=new HtmlGrid("Grid-".$this->identifier,$numRows,$numCols); |
|
67 | + public function addGrid($numRows=1, $numCols=NULL) { |
|
68 | + $grid=new HtmlGrid("Grid-".$this->identifier, $numRows, $numCols); |
|
69 | 69 | $this->content=$grid; |
70 | 70 | return $grid; |
71 | 71 | } |
@@ -13,11 +13,11 @@ |
||
13 | 13 | class HtmlContainer extends HtmlSemDoubleElement { |
14 | 14 | use TextAlignmentTrait; |
15 | 15 | public function __construct($identifier, $content="") { |
16 | - parent::__construct($identifier, "div","ui container"); |
|
16 | + parent::__construct($identifier, "div", "ui container"); |
|
17 | 17 | $this->content=$content; |
18 | 18 | } |
19 | 19 | |
20 | - public function asText(){ |
|
20 | + public function asText() { |
|
21 | 21 | return $this->addToProperty("class", "text"); |
22 | 22 | } |
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -124,6 +124,10 @@ discard block |
||
124 | 124 | return $this; |
125 | 125 | } |
126 | 126 | |
127 | + /** |
|
128 | + * @param string $name |
|
129 | + * @param string[] $typeCtrl |
|
130 | + */ |
|
127 | 131 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
128 | 132 | if ($this->ctrl($name, $value, $typeCtrl) === true) { |
129 | 133 | return $name=$value; |
@@ -139,22 +143,35 @@ discard block |
||
139 | 143 | return $this; |
140 | 144 | } |
141 | 145 | |
146 | + /** |
|
147 | + * @param string $name |
|
148 | + */ |
|
142 | 149 | protected function removePropertyValue($name, $value) { |
143 | 150 | $this->properties[$name]=\str_replace($value, "", $this->properties[$name]); |
144 | 151 | return $this; |
145 | 152 | } |
146 | 153 | |
154 | + /** |
|
155 | + * @param string $name |
|
156 | + */ |
|
147 | 157 | protected function removePropertyValues($name, $values) { |
148 | 158 | $this->removeOldValues($this->properties[$name], $values); |
149 | 159 | return $this; |
150 | 160 | } |
151 | 161 | |
162 | + /** |
|
163 | + * @param string $name |
|
164 | + */ |
|
152 | 165 | protected function removeProperty($name) { |
153 | 166 | if (\array_key_exists($name, $this->properties)) |
154 | 167 | unset($this->properties[$name]); |
155 | 168 | return $this; |
156 | 169 | } |
157 | 170 | |
171 | + /** |
|
172 | + * @param string $name |
|
173 | + * @param string[] $typeCtrl |
|
174 | + */ |
|
158 | 175 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
159 | 176 | if ($this->ctrl($name, $value, $typeCtrl) === true) { |
160 | 177 | if (is_array($typeCtrl)) { |
@@ -165,6 +182,9 @@ discard block |
||
165 | 182 | return $this; |
166 | 183 | } |
167 | 184 | |
185 | + /** |
|
186 | + * @param string $name |
|
187 | + */ |
|
168 | 188 | protected function addToMember(&$name, $value, $separator=" ") { |
169 | 189 | $name=str_ireplace($value, "", $name) . $separator . $value; |
170 | 190 | return $this; |
@@ -179,6 +199,9 @@ discard block |
||
179 | 199 | return $this->addToProperty($name, $value); |
180 | 200 | } |
181 | 201 | |
202 | + /** |
|
203 | + * @param string $name |
|
204 | + */ |
|
182 | 205 | public function addToPropertyCtrl($name, $value, $typeCtrl) { |
183 | 206 | return $this->addToPropertyUnique($name, $value, $typeCtrl); |
184 | 207 | } |
@@ -327,14 +350,23 @@ discard block |
||
327 | 350 | return $this; |
328 | 351 | } |
329 | 352 | |
353 | + /** |
|
354 | + * @param string $event |
|
355 | + */ |
|
330 | 356 | public function getOn($event, $url, $responseElement="", $parameters=array()) { |
331 | 357 | return $this->_ajaxOn("get", $event, $url, $responseElement, $parameters); |
332 | 358 | } |
333 | 359 | |
360 | + /** |
|
361 | + * @param string $url |
|
362 | + */ |
|
334 | 363 | public function getOnClick($url, $responseElement="", $parameters=array()) { |
335 | 364 | return $this->getOn("click", $url, $responseElement, $parameters); |
336 | 365 | } |
337 | 366 | |
367 | + /** |
|
368 | + * @param string $event |
|
369 | + */ |
|
338 | 370 | public function postOn($event, $url, $params="{}", $responseElement="", $parameters=array()) { |
339 | 371 | $parameters["params"]=$params; |
340 | 372 | return $this->_ajaxOn("post", $event, $url, $responseElement, $parameters); |
@@ -344,6 +376,9 @@ discard block |
||
344 | 376 | return $this->postOn("click", $url, $params, $responseElement, $parameters); |
345 | 377 | } |
346 | 378 | |
379 | + /** |
|
380 | + * @param string $event |
|
381 | + */ |
|
347 | 382 | public function postFormOn($event, $url, $form, $responseElement="", $parameters=array()) { |
348 | 383 | $parameters["form"]=$form; |
349 | 384 | return $this->_ajaxOn("postForm", $event, $url, $responseElement, $parameters); |
@@ -371,6 +406,10 @@ discard block |
||
371 | 406 | return null; |
372 | 407 | } |
373 | 408 | |
409 | + /** |
|
410 | + * @param string $propertyName |
|
411 | + * @param string $value |
|
412 | + */ |
|
374 | 413 | protected function getElementByPropertyValue($propertyName,$value, $elements) { |
375 | 414 | if (is_array($elements)) { |
376 | 415 | $flag=false; |
@@ -411,6 +450,9 @@ discard block |
||
411 | 450 | return $value; |
412 | 451 | } |
413 | 452 | |
453 | + /** |
|
454 | + * @param string $jqueryCall |
|
455 | + */ |
|
414 | 456 | public function jsDoJquery($jqueryCall, $param="") { |
415 | 457 | return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . $this->_prep_value($param) . ");"; |
416 | 458 | } |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | abstract class BaseHtml extends BaseWidget { |
17 | 17 | protected $_template; |
18 | 18 | protected $tagName; |
19 | - protected $properties=array (); |
|
20 | - protected $_events=array (); |
|
21 | - protected $_wrapBefore=array (); |
|
22 | - protected $_wrapAfter=array (); |
|
19 | + protected $properties=array(); |
|
20 | + protected $_events=array(); |
|
21 | + protected $_wrapBefore=array(); |
|
22 | + protected $_wrapAfter=array(); |
|
23 | 23 | protected $_bsComponent; |
24 | 24 | |
25 | 25 | public function getBsComponent() { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | protected function getTemplate(JsUtils $js=NULL) { |
35 | - return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
35 | + return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function getProperties() { |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | |
57 | 57 | public function addToProperty($name, $value, $separator=" ") { |
58 | 58 | if (\is_array($value)) { |
59 | - foreach ( $value as $v ) { |
|
59 | + foreach ($value as $v) { |
|
60 | 60 | $this->addToProperty($name, $v, $separator); |
61 | 61 | } |
62 | - } else if ($value !== "" && $this->propertyContains($name, $value) === false) { |
|
62 | + }else if ($value!=="" && $this->propertyContains($name, $value)===false) { |
|
63 | 63 | $v=@$this->properties[$name]; |
64 | - if (isset($v) && $v !== "") |
|
65 | - $v=$v . $separator . $value; |
|
64 | + if (isset($v) && $v!=="") |
|
65 | + $v=$v.$separator.$value; |
|
66 | 66 | else |
67 | 67 | $v=$value; |
68 | 68 | |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | |
79 | 79 | public function compile(JsUtils $js=NULL, $view=NULL) { |
80 | 80 | $result=$this->getTemplate($js); |
81 | - foreach ( $this as $key => $value ) { |
|
82 | - if (JString::startswith($key, "_") === false && $key !== "events") { |
|
81 | + foreach ($this as $key => $value) { |
|
82 | + if (JString::startswith($key, "_")===false && $key!=="events") { |
|
83 | 83 | if (is_array($value)) { |
84 | 84 | $v=PropertyWrapper::wrap($value, $js); |
85 | - } else { |
|
85 | + }else { |
|
86 | 86 | $v=$value; |
87 | 87 | } |
88 | - $result=str_ireplace("%" . $key . "%", $v, $result); |
|
88 | + $result=str_ireplace("%".$key."%", $v, $result); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | if (isset($js)===true) { |
92 | 92 | $this->run($js); |
93 | - if (isset($view) === true) { |
|
93 | + if (isset($view)===true) { |
|
94 | 94 | $js->addViewElement($this->identifier, $result, $view); |
95 | 95 | } |
96 | 96 | } |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | |
100 | 100 | protected function ctrl($name, $value, $typeCtrl) { |
101 | 101 | if (is_array($typeCtrl)) { |
102 | - if (array_search($value, $typeCtrl) === false) { |
|
103 | - throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}"); |
|
102 | + if (array_search($value, $typeCtrl)===false) { |
|
103 | + throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
104 | 104 | } |
105 | - } else { |
|
105 | + }else { |
|
106 | 106 | if (!$typeCtrl($value)) { |
107 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name); |
|
107 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | return true; |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
122 | - if ($this->ctrl($name, $value, $typeCtrl) === true) |
|
122 | + if ($this->ctrl($name, $value, $typeCtrl)===true) |
|
123 | 123 | return $this->setProperty($name, $value); |
124 | 124 | return $this; |
125 | 125 | } |
126 | 126 | |
127 | 127 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
128 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
128 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
129 | 129 | return $name=$value; |
130 | 130 | } |
131 | 131 | return $this; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") { |
135 | 135 | if (is_array($typeCtrl)) { |
136 | 136 | $this->removeOldValues($name, $typeCtrl); |
137 | - $name.=$separator . $value; |
|
137 | + $name.=$separator.$value; |
|
138 | 138 | } |
139 | 139 | return $this; |
140 | 140 | } |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
159 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
159 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
160 | 160 | if (is_array($typeCtrl)) { |
161 | 161 | $this->removeOldValues($name, $typeCtrl); |
162 | 162 | } |
163 | - $name.=$separator . $value; |
|
163 | + $name.=$separator.$value; |
|
164 | 164 | } |
165 | 165 | return $this; |
166 | 166 | } |
167 | 167 | |
168 | 168 | protected function addToMember(&$name, $value, $separator=" ") { |
169 | - $name=str_ireplace($value, "", $name) . $separator . $value; |
|
169 | + $name=str_ireplace($value, "", $name).$separator.$value; |
|
170 | 170 | return $this; |
171 | 171 | } |
172 | 172 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | public function addToPropertyCtrlCheck($name, $value, $typeCtrl) { |
187 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
187 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
188 | 188 | return $this->addToProperty($name, $value); |
189 | 189 | } |
190 | 190 | return $this; |
@@ -212,28 +212,28 @@ discard block |
||
212 | 212 | } |
213 | 213 | |
214 | 214 | public function fromArray($array) { |
215 | - foreach ( $this as $key => $value ) { |
|
215 | + foreach ($this as $key => $value) { |
|
216 | 216 | if (array_key_exists($key, $array) && !JString::startswith($key, "_")) { |
217 | - $setter="set" . ucfirst($key); |
|
217 | + $setter="set".ucfirst($key); |
|
218 | 218 | $this->$setter($array[$key]); |
219 | 219 | unset($array[$key]); |
220 | 220 | } |
221 | 221 | } |
222 | - foreach ( $array as $key => $value ) { |
|
222 | + foreach ($array as $key => $value) { |
|
223 | 223 | if (method_exists($this, $key)) { |
224 | 224 | try { |
225 | 225 | $this->$key($value); |
226 | 226 | unset($array[$key]); |
227 | - } catch ( \Exception $e ) { |
|
227 | + } catch (\Exception $e) { |
|
228 | 228 | // Nothing to do |
229 | 229 | } |
230 | - } else { |
|
231 | - $setter="set" . ucfirst($key); |
|
230 | + }else { |
|
231 | + $setter="set".ucfirst($key); |
|
232 | 232 | if (method_exists($this, $setter)) { |
233 | 233 | try { |
234 | 234 | $this->$setter($value); |
235 | 235 | unset($array[$key]); |
236 | - } catch ( \Exception $e ) { |
|
236 | + } catch (\Exception $e) { |
|
237 | 237 | // Nothing to do |
238 | 238 | } |
239 | 239 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | public function fromDatabaseObjects($objects, $function) { |
246 | 246 | if (isset($objects)) { |
247 | - foreach ( $objects as $object ) { |
|
247 | + foreach ($objects as $object) { |
|
248 | 248 | $this->fromDatabaseObject($object, $function); |
249 | 249 | } |
250 | 250 | } |
@@ -264,11 +264,11 @@ discard block |
||
264 | 264 | } |
265 | 265 | |
266 | 266 | public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
267 | - if ($stopPropagation === true) { |
|
268 | - $jsCode="event.stopPropagation();" . $jsCode; |
|
267 | + if ($stopPropagation===true) { |
|
268 | + $jsCode="event.stopPropagation();".$jsCode; |
|
269 | 269 | } |
270 | - if ($preventDefault === true) { |
|
271 | - $jsCode="event.preventDefault();" . $jsCode; |
|
270 | + if ($preventDefault===true) { |
|
271 | + $jsCode="event.preventDefault();".$jsCode; |
|
272 | 272 | } |
273 | 273 | return $this->_addEvent($event, $jsCode); |
274 | 274 | } |
@@ -277,10 +277,10 @@ discard block |
||
277 | 277 | if (array_key_exists($event, $this->_events)) { |
278 | 278 | if (is_array($this->_events[$event])) { |
279 | 279 | $this->_events[$event][]=$jsCode; |
280 | - } else { |
|
281 | - $this->_events[$event]=array ($this->_events[$event],$jsCode ); |
|
280 | + }else { |
|
281 | + $this->_events[$event]=array($this->_events[$event], $jsCode); |
|
282 | 282 | } |
283 | - } else { |
|
283 | + }else { |
|
284 | 284 | $this->_events[$event]=$jsCode; |
285 | 285 | } |
286 | 286 | return $this; |
@@ -300,15 +300,15 @@ discard block |
||
300 | 300 | |
301 | 301 | public function addEventsOnRun(JsUtils $js) { |
302 | 302 | if (isset($this->_bsComponent)) { |
303 | - foreach ( $this->_events as $event => $jsCode ) { |
|
303 | + foreach ($this->_events as $event => $jsCode) { |
|
304 | 304 | $code=$jsCode; |
305 | 305 | if (is_array($jsCode)) { |
306 | 306 | $code=""; |
307 | - foreach ( $jsCode as $jsC ) { |
|
307 | + foreach ($jsCode as $jsC) { |
|
308 | 308 | if ($jsC instanceof AjaxCall) { |
309 | - $code.="\n" . $jsC->compile($js); |
|
310 | - } else { |
|
311 | - $code.="\n" . $jsC; |
|
309 | + $code.="\n".$jsC->compile($js); |
|
310 | + }else { |
|
311 | + $code.="\n".$jsC; |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | } elseif ($jsCode instanceof AjaxCall) { |
@@ -316,12 +316,12 @@ discard block |
||
316 | 316 | } |
317 | 317 | $this->_bsComponent->addEvent($event, $code); |
318 | 318 | } |
319 | - $this->_events=array (); |
|
319 | + $this->_events=array(); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | 323 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
324 | - $params=array ("url" => $url,"responseElement" => $responseElement ); |
|
324 | + $params=array("url" => $url, "responseElement" => $responseElement); |
|
325 | 325 | $params=array_merge($params, $parameters); |
326 | 326 | $this->_addEvent($event, new AjaxCall($operation, $params)); |
327 | 327 | return $this; |
@@ -357,33 +357,33 @@ discard block |
||
357 | 357 | if (is_array($elements)) { |
358 | 358 | $flag=false; |
359 | 359 | $index=0; |
360 | - while ( !$flag && $index < sizeof($elements) ) { |
|
360 | + while (!$flag && $index<sizeof($elements)) { |
|
361 | 361 | if ($elements[$index] instanceof BaseHtml) |
362 | - $flag=($elements[$index]->getIdentifier() === $identifier); |
|
362 | + $flag=($elements[$index]->getIdentifier()===$identifier); |
|
363 | 363 | $index++; |
364 | 364 | } |
365 | - if ($flag === true) |
|
366 | - return $elements[$index - 1]; |
|
365 | + if ($flag===true) |
|
366 | + return $elements[$index-1]; |
|
367 | 367 | } elseif ($elements instanceof BaseHtml) { |
368 | - if ($elements->getIdentifier() === $identifier) |
|
368 | + if ($elements->getIdentifier()===$identifier) |
|
369 | 369 | return $elements; |
370 | 370 | } |
371 | 371 | return null; |
372 | 372 | } |
373 | 373 | |
374 | - protected function getElementByPropertyValue($propertyName,$value, $elements) { |
|
374 | + protected function getElementByPropertyValue($propertyName, $value, $elements) { |
|
375 | 375 | if (is_array($elements)) { |
376 | 376 | $flag=false; |
377 | 377 | $index=0; |
378 | - while ( !$flag && $index < sizeof($elements) ) { |
|
378 | + while (!$flag && $index<sizeof($elements)) { |
|
379 | 379 | if ($elements[$index] instanceof BaseHtml) |
380 | - $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
380 | + $flag=($elements[$index]->propertyContains($propertyName, $value)===true); |
|
381 | 381 | $index++; |
382 | 382 | } |
383 | - if ($flag === true) |
|
384 | - return $elements[$index - 1]; |
|
383 | + if ($flag===true) |
|
384 | + return $elements[$index-1]; |
|
385 | 385 | } elseif ($elements instanceof BaseHtml) { |
386 | - if ($elements->propertyContains($propertyName, $value) === true) |
|
386 | + if ($elements->propertyContains($propertyName, $value)===true) |
|
387 | 387 | return $elements; |
388 | 388 | } |
389 | 389 | return null; |
@@ -405,14 +405,14 @@ discard block |
||
405 | 405 | if (is_array($value)) { |
406 | 406 | $value=implode(",", $value); |
407 | 407 | } |
408 | - if (strrpos($value, 'this') === false && strrpos($value, 'event') === false) { |
|
409 | - $value='"' . $value . '"'; |
|
408 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false) { |
|
409 | + $value='"'.$value.'"'; |
|
410 | 410 | } |
411 | 411 | return $value; |
412 | 412 | } |
413 | 413 | |
414 | 414 | public function jsDoJquery($jqueryCall, $param="") { |
415 | - return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . $this->_prep_value($param) . ");"; |
|
415 | + return "$('#".$this->identifier."').".$jqueryCall."(".$this->_prep_value($param).");"; |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | public function executeOnRun($jsCode) { |
@@ -50,8 +50,9 @@ 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=" ") { |
@@ -61,10 +62,11 @@ discard block |
||
61 | 62 | } |
62 | 63 | } else if ($value !== "" && $this->propertyContains($name, $value) === false) { |
63 | 64 | $v=@$this->properties[$name]; |
64 | - if (isset($v) && $v !== "") |
|
65 | - $v=$v . $separator . $value; |
|
66 | - else |
|
67 | - $v=$value; |
|
65 | + if (isset($v) && $v !== "") { |
|
66 | + $v=$v . $separator . $value; |
|
67 | + } else { |
|
68 | + $v=$value; |
|
69 | + } |
|
68 | 70 | |
69 | 71 | return $this->setProperty($name, $v); |
70 | 72 | } |
@@ -119,8 +121,9 @@ discard block |
||
119 | 121 | } |
120 | 122 | |
121 | 123 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
122 | - if ($this->ctrl($name, $value, $typeCtrl) === true) |
|
123 | - return $this->setProperty($name, $value); |
|
124 | + if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
125 | + return $this->setProperty($name, $value); |
|
126 | + } |
|
124 | 127 | return $this; |
125 | 128 | } |
126 | 129 | |
@@ -150,8 +153,9 @@ discard block |
||
150 | 153 | } |
151 | 154 | |
152 | 155 | protected function removeProperty($name) { |
153 | - if (\array_key_exists($name, $this->properties)) |
|
154 | - unset($this->properties[$name]); |
|
156 | + if (\array_key_exists($name, $this->properties)) { |
|
157 | + unset($this->properties[$name]); |
|
158 | + } |
|
155 | 159 | return $this; |
156 | 160 | } |
157 | 161 | |
@@ -171,8 +175,9 @@ discard block |
||
171 | 175 | } |
172 | 176 | |
173 | 177 | protected function addToPropertyUnique($name, $value, $typeCtrl) { |
174 | - if (@class_exists($typeCtrl, true)) |
|
175 | - $typeCtrl=$typeCtrl::getConstants(); |
|
178 | + if (@class_exists($typeCtrl, true)) { |
|
179 | + $typeCtrl=$typeCtrl::getConstants(); |
|
180 | + } |
|
176 | 181 | if (is_array($typeCtrl)) { |
177 | 182 | $this->removeOldValues($this->properties[$name], $typeCtrl); |
178 | 183 | } |
@@ -358,15 +363,18 @@ discard block |
||
358 | 363 | $flag=false; |
359 | 364 | $index=0; |
360 | 365 | while ( !$flag && $index < sizeof($elements) ) { |
361 | - if ($elements[$index] instanceof BaseHtml) |
|
362 | - $flag=($elements[$index]->getIdentifier() === $identifier); |
|
366 | + if ($elements[$index] instanceof BaseHtml) { |
|
367 | + $flag=($elements[$index]->getIdentifier() === $identifier); |
|
368 | + } |
|
363 | 369 | $index++; |
364 | 370 | } |
365 | - if ($flag === true) |
|
366 | - return $elements[$index - 1]; |
|
371 | + if ($flag === true) { |
|
372 | + return $elements[$index - 1]; |
|
373 | + } |
|
367 | 374 | } elseif ($elements instanceof BaseHtml) { |
368 | - if ($elements->getIdentifier() === $identifier) |
|
369 | - return $elements; |
|
375 | + if ($elements->getIdentifier() === $identifier) { |
|
376 | + return $elements; |
|
377 | + } |
|
370 | 378 | } |
371 | 379 | return null; |
372 | 380 | } |
@@ -376,15 +384,18 @@ discard block |
||
376 | 384 | $flag=false; |
377 | 385 | $index=0; |
378 | 386 | while ( !$flag && $index < sizeof($elements) ) { |
379 | - if ($elements[$index] instanceof BaseHtml) |
|
380 | - $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
387 | + if ($elements[$index] instanceof BaseHtml) { |
|
388 | + $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
389 | + } |
|
381 | 390 | $index++; |
382 | 391 | } |
383 | - if ($flag === true) |
|
384 | - return $elements[$index - 1]; |
|
392 | + if ($flag === true) { |
|
393 | + return $elements[$index - 1]; |
|
394 | + } |
|
385 | 395 | } elseif ($elements instanceof BaseHtml) { |
386 | - if ($elements->propertyContains($propertyName, $value) === true) |
|
387 | - return $elements; |
|
396 | + if ($elements->propertyContains($propertyName, $value) === true) { |
|
397 | + return $elements; |
|
398 | + } |
|
388 | 399 | } |
389 | 400 | return null; |
390 | 401 | } |
@@ -55,6 +55,9 @@ discard block |
||
55 | 55 | return $this->_semantic; |
56 | 56 | } |
57 | 57 | |
58 | + /** |
|
59 | + * @param JsUtils $jsUtils |
|
60 | + */ |
|
58 | 61 | public function __construct($params,$jsUtils) { |
59 | 62 | $this->params=array(); |
60 | 63 | foreach ( $params as $key => $val ) { |
@@ -175,7 +178,7 @@ discard block |
||
175 | 178 | * |
176 | 179 | * @param string $element |
177 | 180 | * @param array $options |
178 | - * @return void |
|
181 | + * @return string |
|
179 | 182 | */ |
180 | 183 | public function sortable($element, $options=array()) { |
181 | 184 | if (count($options)>0) { |
@@ -306,6 +309,7 @@ discard block |
||
306 | 309 | |
307 | 310 | /** |
308 | 311 | * A wrapper for writing document.ready() |
312 | + * @param string $js |
|
309 | 313 | * @return string |
310 | 314 | */ |
311 | 315 | public function _document_ready($js) { |
@@ -353,6 +357,9 @@ discard block |
||
353 | 357 | return $value; |
354 | 358 | } |
355 | 359 | |
360 | + /** |
|
361 | + * @param string $input |
|
362 | + */ |
|
356 | 363 | private function minify($input) { |
357 | 364 | if(trim($input) === "") return $input; |
358 | 365 | return preg_replace( |
@@ -17,21 +17,21 @@ discard block |
||
17 | 17 | * jQuery Class |
18 | 18 | */ |
19 | 19 | class Jquery { |
20 | - use JqueryEventsTrait,JqueryAjaxTrait,JqueryActionsTrait; |
|
20 | + use JqueryEventsTrait, JqueryAjaxTrait, JqueryActionsTrait; |
|
21 | 21 | protected $_ui; |
22 | 22 | protected $_bootstrap; |
23 | 23 | protected $_semantic; |
24 | 24 | protected $libraryFile; |
25 | 25 | protected $_javascript_folder='js'; |
26 | - protected $jquery_code_for_load=array (); |
|
27 | - protected $jquery_code_for_compile=array (); |
|
26 | + protected $jquery_code_for_load=array(); |
|
27 | + protected $jquery_code_for_compile=array(); |
|
28 | 28 | protected $jquery_corner_active=FALSE; |
29 | 29 | protected $jquery_table_sorter_active=FALSE; |
30 | 30 | protected $jquery_table_sorter_pager_active=FALSE; |
31 | 31 | protected $jsUtils; |
32 | 32 | |
33 | - protected $jquery_events=array ( |
|
34 | - "bind","blur","change","click","dblclick","delegate","die","error","focus","focusin","focusout","hover","keydown","keypress","keyup","live","load","mousedown","mousseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","off","on","one","ready","resize","scroll","select","submit","toggle","trigger","triggerHandler","undind","undelegate","unload" |
|
33 | + protected $jquery_events=array( |
|
34 | + "bind", "blur", "change", "click", "dblclick", "delegate", "die", "error", "focus", "focusin", "focusout", "hover", "keydown", "keypress", "keyup", "live", "load", "mousedown", "mousseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "off", "on", "one", "ready", "resize", "scroll", "select", "submit", "toggle", "trigger", "triggerHandler", "undind", "undelegate", "unload" |
|
35 | 35 | ); |
36 | 36 | |
37 | 37 | public function ui($ui=NULL) { |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | return $this->_semantic; |
56 | 56 | } |
57 | 57 | |
58 | - public function __construct($params,$jsUtils) { |
|
58 | + public function __construct($params, $jsUtils) { |
|
59 | 59 | $this->params=array(); |
60 | - foreach ( $params as $key => $val ) { |
|
60 | + foreach ($params as $key => $val) { |
|
61 | 61 | $this->params[$key]=$params[$key]; |
62 | 62 | } |
63 | 63 | $this->jsUtils=$jsUtils; |
@@ -125,12 +125,12 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function _output($array_js='') { |
127 | 127 | if (!is_array($array_js)) { |
128 | - $array_js=array ( |
|
128 | + $array_js=array( |
|
129 | 129 | $array_js |
130 | 130 | ); |
131 | 131 | } |
132 | 132 | |
133 | - foreach ( $array_js as $js ) { |
|
133 | + foreach ($array_js as $js) { |
|
134 | 134 | $this->jquery_code_for_compile[]="\t$js\n"; |
135 | 135 | } |
136 | 136 | } |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | * @param string $param |
143 | 143 | * @param boolean $immediatly delayed if false |
144 | 144 | */ |
145 | - public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) { |
|
145 | + public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) { |
|
146 | 146 | $element=$this->_prep_element($element); |
147 | 147 | if (isset($param)) { |
148 | 148 | $param=$this->_prep_value($param); |
149 | 149 | $str="$({$element}).{$jQueryCall}({$param});"; |
150 | - } else |
|
150 | + }else |
|
151 | 151 | $str="$({$element}).{$jQueryCall}();"; |
152 | 152 | if ($immediatly) |
153 | 153 | $this->jquery_code_for_compile[]=$str; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @param boolean $immediatly delayed if false |
162 | 162 | * @return string |
163 | 163 | */ |
164 | - public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) { |
|
164 | + public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) { |
|
165 | 165 | $to=$this->_prep_element($to); |
166 | 166 | $element=$this->_prep_element($element); |
167 | 167 | $str="$({$to}).{$jQueryCall}({$element});"; |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function sortable($element, $options=array()) { |
181 | 181 | if (count($options)>0) { |
182 | - $sort_options=array (); |
|
183 | - foreach ( $options as $k => $v ) { |
|
182 | + $sort_options=array(); |
|
183 | + foreach ($options as $k => $v) { |
|
184 | 184 | $sort_options[]="\n\t\t".$k.': '.$v.""; |
185 | 185 | } |
186 | 186 | $sort_options=implode(",", $sort_options); |
187 | - } else { |
|
187 | + }else { |
|
188 | 188 | $sort_options=''; |
189 | 189 | } |
190 | 190 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @param boolean $stopPropagation Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. |
213 | 213 | * @return string |
214 | 214 | */ |
215 | - public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true) { |
|
215 | + public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true) { |
|
216 | 216 | if (is_array($js)) { |
217 | 217 | $js=implode("\n\t\t", $js); |
218 | 218 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
227 | 227 | else |
228 | 228 | $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
229 | - if($immediatly) |
|
229 | + if ($immediatly) |
|
230 | 230 | $this->jquery_code_for_compile[]=$event; |
231 | 231 | return $event; |
232 | 232 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | // External references |
268 | 268 | $external_scripts=implode('', $this->jquery_code_for_load); |
269 | - extract(array ( |
|
269 | + extract(array( |
|
270 | 270 | 'library_src' => $external_scripts |
271 | 271 | )); |
272 | 272 | |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | $script.='});'; |
282 | 282 | |
283 | 283 | $this->jquery_code_for_compile=array(); |
284 | - if($this->params["debug"]==false){ |
|
284 | + if ($this->params["debug"]==false) { |
|
285 | 285 | $script=$this->minify($script); |
286 | 286 | } |
287 | 287 | $output=($script_tags===FALSE) ? $script : $this->inline($script); |
288 | 288 | |
289 | - if ($view!==NULL){ |
|
290 | - $this->jsUtils->createScriptVariable($view,$view_var, $output); |
|
289 | + if ($view!==NULL) { |
|
290 | + $this->jsUtils->createScriptVariable($view, $view_var, $output); |
|
291 | 291 | } |
292 | 292 | return $output; |
293 | 293 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @return void |
303 | 303 | */ |
304 | 304 | public function _clear_compile() { |
305 | - $this->jquery_code_for_compile=array (); |
|
305 | + $this->jquery_code_for_compile=array(); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -311,12 +311,12 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function _document_ready($js) { |
313 | 313 | if (!is_array($js)) { |
314 | - $js=array ( |
|
314 | + $js=array( |
|
315 | 315 | $js |
316 | 316 | ); |
317 | 317 | } |
318 | 318 | |
319 | - foreach ( $js as $script ) { |
|
319 | + foreach ($js as $script) { |
|
320 | 320 | $this->jquery_code_for_compile[]=$script; |
321 | 321 | } |
322 | 322 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @return string |
331 | 331 | */ |
332 | 332 | public function _prep_element($element) { |
333 | - if (strrpos($element, 'this')===false&&strrpos($element, 'event')===false&&strrpos($element, 'self')===false) { |
|
333 | + if (strrpos($element, 'this')===false && strrpos($element, 'event')===false && strrpos($element, 'self')===false) { |
|
334 | 334 | $element='"'.addslashes($element).'"'; |
335 | 335 | } |
336 | 336 | return $element; |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | if (is_array($value)) { |
349 | 349 | $value=implode(",", $value); |
350 | 350 | } |
351 | - if (strrpos($value, 'this')===false&&strrpos($value, 'event')===false&&strrpos($value, 'self')===false) { |
|
351 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false && strrpos($value, 'self')===false) { |
|
352 | 352 | $value='"'.$value.'"'; |
353 | 353 | } |
354 | 354 | return $value; |
355 | 355 | } |
356 | 356 | |
357 | 357 | private function minify($input) { |
358 | - if(trim($input) === "") return $input; |
|
358 | + if (trim($input)==="") return $input; |
|
359 | 359 | return preg_replace( |
360 | 360 | array( |
361 | 361 | // Remove comment(s) |
@@ -147,10 +147,12 @@ discard block |
||
147 | 147 | if (isset($param)) { |
148 | 148 | $param=$this->_prep_value($param); |
149 | 149 | $str="$({$element}).{$jQueryCall}({$param});"; |
150 | - } else |
|
151 | - $str="$({$element}).{$jQueryCall}();"; |
|
152 | - if ($immediatly) |
|
153 | - $this->jquery_code_for_compile[]=$str; |
|
150 | + } else { |
|
151 | + $str="$({$element}).{$jQueryCall}();"; |
|
152 | + } |
|
153 | + if ($immediatly) { |
|
154 | + $this->jquery_code_for_compile[]=$str; |
|
155 | + } |
|
154 | 156 | return $str; |
155 | 157 | } |
156 | 158 | /** |
@@ -165,8 +167,9 @@ discard block |
||
165 | 167 | $to=$this->_prep_element($to); |
166 | 168 | $element=$this->_prep_element($element); |
167 | 169 | $str="$({$to}).{$jQueryCall}({$element});"; |
168 | - if ($immediatly) |
|
169 | - $this->jquery_code_for_compile[]=$str; |
|
170 | + if ($immediatly) { |
|
171 | + $this->jquery_code_for_compile[]=$str; |
|
172 | + } |
|
170 | 173 | return $str; |
171 | 174 | } |
172 | 175 | |
@@ -222,12 +225,14 @@ discard block |
||
222 | 225 | if ($stopPropagation===true) { |
223 | 226 | $js="event.stopPropagation();\n".$js; |
224 | 227 | } |
225 | - if (array_search($event, $this->jquery_events)===false) |
|
226 | - $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
227 | - else |
|
228 | - $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
229 | - if($immediatly) |
|
230 | - $this->jquery_code_for_compile[]=$event; |
|
228 | + if (array_search($event, $this->jquery_events)===false) { |
|
229 | + $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
230 | + } else { |
|
231 | + $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
232 | + } |
|
233 | + if($immediatly) { |
|
234 | + $this->jquery_code_for_compile[]=$event; |
|
235 | + } |
|
231 | 236 | return $event; |
232 | 237 | } |
233 | 238 | |
@@ -355,7 +360,9 @@ discard block |
||
355 | 360 | } |
356 | 361 | |
357 | 362 | private function minify($input) { |
358 | - if(trim($input) === "") return $input; |
|
363 | + if(trim($input) === "") { |
|
364 | + return $input; |
|
365 | + } |
|
359 | 366 | return preg_replace( |
360 | 367 | array( |
361 | 368 | // Remove comment(s) |
@@ -11,6 +11,9 @@ |
||
11 | 11 | |
12 | 12 | abstract class HtmlAbsractItem extends HtmlSemDoubleElement { |
13 | 13 | |
14 | + /** |
|
15 | + * @param string $baseClass |
|
16 | + */ |
|
14 | 17 | public function __construct($identifier, $baseClass,$content=NULL) { |
15 | 18 | parent::__construct($identifier, "div", $baseClass); |
16 | 19 | $this->content=array(); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | abstract class HtmlAbsractItem extends HtmlSemDoubleElement { |
13 | 13 | |
14 | - public function __construct($identifier, $baseClass,$content=NULL) { |
|
14 | + public function __construct($identifier, $baseClass, $content=NULL) { |
|
15 | 15 | parent::__construct($identifier, "div", $baseClass); |
16 | 16 | $this->content=array(); |
17 | 17 | $this->initContent($content); |
@@ -19,48 +19,48 @@ discard block |
||
19 | 19 | |
20 | 20 | protected abstract function initContent($content); |
21 | 21 | |
22 | - public function setIcon($icon){ |
|
22 | + public function setIcon($icon) { |
|
23 | 23 | $this->content["icon"]=new HtmlIcon("icon-".$this->identifier, $icon); |
24 | 24 | } |
25 | 25 | |
26 | - public function setImage($image){ |
|
26 | + public function setImage($image) { |
|
27 | 27 | $image=new HtmlImg("icon-".$this->identifier, $image); |
28 | 28 | $image->asAvatar(); |
29 | 29 | $this->content["image"]=$image; |
30 | 30 | } |
31 | 31 | |
32 | - private function createContent(){ |
|
33 | - $this->content["content"]=new HtmlSemDoubleElement("content-".$this->identifier,"div","content"); |
|
32 | + private function createContent() { |
|
33 | + $this->content["content"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content"); |
|
34 | 34 | return $this->content["content"]; |
35 | 35 | } |
36 | 36 | |
37 | - public function setTitle($title,$description=NULL,$baseClass="title"){ |
|
38 | - $title=new HtmlSemDoubleElement("","div",$baseClass,$title); |
|
39 | - if(\array_key_exists("content", $this->content)===false){ |
|
37 | + public function setTitle($title, $description=NULL, $baseClass="title") { |
|
38 | + $title=new HtmlSemDoubleElement("", "div", $baseClass, $title); |
|
39 | + if (\array_key_exists("content", $this->content)===false) { |
|
40 | 40 | $this->createContent(); |
41 | 41 | } |
42 | 42 | $this->content["content"]->addContent($title); |
43 | - if(isset($description)){ |
|
44 | - $description=new HtmlSemDoubleElement("","div","description",$description); |
|
43 | + if (isset($description)) { |
|
44 | + $description=new HtmlSemDoubleElement("", "div", "description", $description); |
|
45 | 45 | $this->content["content"]->addContent($description); |
46 | 46 | } |
47 | 47 | return $this; |
48 | 48 | } |
49 | 49 | |
50 | - public function getPart($partName="header"){ |
|
51 | - $content=\array_merge($this->content["content"]->getContent(),array(@$this->content["icon"],@$this->content["image"])); |
|
50 | + public function getPart($partName="header") { |
|
51 | + $content=\array_merge($this->content["content"]->getContent(), array(@$this->content["icon"], @$this->content["image"])); |
|
52 | 52 | return $this->getElementByPropertyValue("class", $partName, $content); |
53 | 53 | } |
54 | 54 | |
55 | - public function setActive(){ |
|
55 | + public function setActive() { |
|
56 | 56 | $this->setTagName("div"); |
57 | 57 | $this->removeProperty("href"); |
58 | 58 | return $this->addToPropertyCtrl("class", "active", array("active")); |
59 | 59 | } |
60 | 60 | |
61 | - public function asLink($href=NULL,$part=NULL){ |
|
61 | + public function asLink($href=NULL, $part=NULL) { |
|
62 | 62 | $this->setTagName("a"); |
63 | - if(isset($href)) |
|
63 | + if (isset($href)) |
|
64 | 64 | $this->setProperty("href", $href); |
65 | 65 | return $this; |
66 | 66 | } |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile() |
73 | 73 | */ |
74 | 74 | public function compile(JsUtils $js=NULL, $view=NULL) { |
75 | - if(\is_array($this->content)) |
|
76 | - $this->content=JArray::sortAssociative($this->content, [ "icon","image","content" ]); |
|
75 | + if (\is_array($this->content)) |
|
76 | + $this->content=JArray::sortAssociative($this->content, ["icon", "image", "content"]); |
|
77 | 77 | return parent::compile($js, $view); |
78 | 78 | } |
79 | 79 | } |
80 | 80 | \ No newline at end of file |
@@ -60,8 +60,9 @@ discard block |
||
60 | 60 | |
61 | 61 | public function asLink($href=NULL,$part=NULL){ |
62 | 62 | $this->setTagName("a"); |
63 | - if(isset($href)) |
|
64 | - $this->setProperty("href", $href); |
|
63 | + if(isset($href)) { |
|
64 | + $this->setProperty("href", $href); |
|
65 | + } |
|
65 | 66 | return $this; |
66 | 67 | } |
67 | 68 | |
@@ -72,8 +73,9 @@ discard block |
||
72 | 73 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile() |
73 | 74 | */ |
74 | 75 | public function compile(JsUtils $js=NULL, $view=NULL) { |
75 | - if(\is_array($this->content)) |
|
76 | - $this->content=JArray::sortAssociative($this->content, [ "icon","image","content" ]); |
|
76 | + if(\is_array($this->content)) { |
|
77 | + $this->content=JArray::sortAssociative($this->content, [ "icon","image","content" ]); |
|
78 | + } |
|
77 | 79 | return parent::compile($js, $view); |
78 | 80 | } |
79 | 81 | } |
80 | 82 | \ No newline at end of file |
@@ -5,7 +5,6 @@ |
||
5 | 5 | use Ajax\semantic\html\base\HtmlSemDoubleElement; |
6 | 6 | use Ajax\JsUtils; |
7 | 7 | use Ajax\service\JArray; |
8 | - |
|
9 | 8 | use Ajax\semantic\html\base\constants\State; |
10 | 9 | |
11 | 10 | class HtmlProgress extends HtmlSemDoubleElement { |
@@ -20,6 +20,9 @@ |
||
20 | 20 | protected $_tabsType="tabs"; |
21 | 21 | protected $stacked=""; |
22 | 22 | |
23 | + /** |
|
24 | + * @param string $identifier |
|
25 | + */ |
|
23 | 26 | public function __construct($identifier, $tagName="ul") { |
24 | 27 | parent::__construct($identifier, $tagName); |
25 | 28 | $this->_template="<%tagName% %properties%>%tabs%</%tagName%>%content%"; |
@@ -9,15 +9,15 @@ discard block |
||
9 | 9 | protected $image; |
10 | 10 | |
11 | 11 | public function __construct($identifier, $content=NULL) { |
12 | - parent::__construct($identifier,"item",$content); |
|
12 | + parent::__construct($identifier, "item", $content); |
|
13 | 13 | } |
14 | - protected function initContent($content){ |
|
15 | - if(\is_array($content)){ |
|
16 | - if(JArray::isAssociative($content)===false){ |
|
14 | + protected function initContent($content) { |
|
15 | + if (\is_array($content)) { |
|
16 | + if (JArray::isAssociative($content)===false) { |
|
17 | 17 | $icon=@$content[0]; |
18 | 18 | $title=@$content[1]; |
19 | 19 | $desc=@$content[2]; |
20 | - }else{ |
|
20 | + }else { |
|
21 | 21 | $icon=@$content["icon"]; |
22 | 22 | $image=@$content["image"]; |
23 | 23 | $title=@$content["title"]; |
@@ -25,21 +25,21 @@ discard block |
||
25 | 25 | $desc=@$content["description"]; |
26 | 26 | $items=@$content["items"]; |
27 | 27 | } |
28 | - if(isset($icon)===true){ |
|
28 | + if (isset($icon)===true) { |
|
29 | 29 | $this->setIcon($icon); |
30 | 30 | } |
31 | - if(isset($image)===true){ |
|
31 | + if (isset($image)===true) { |
|
32 | 32 | $this->setImage($image); |
33 | 33 | } |
34 | - if(isset($title)===true){ |
|
35 | - $this->setTitle($title,$desc); |
|
36 | - }elseif (isset($header)===true){ |
|
37 | - $this->setTitle($header,$desc,"header"); |
|
34 | + if (isset($title)===true) { |
|
35 | + $this->setTitle($title, $desc); |
|
36 | + }elseif (isset($header)===true) { |
|
37 | + $this->setTitle($header, $desc, "header"); |
|
38 | 38 | } |
39 | - if(isset($items)===true){ |
|
39 | + if (isset($items)===true) { |
|
40 | 40 | $this->addList($items); |
41 | 41 | } |
42 | - }else{ |
|
42 | + }else { |
|
43 | 43 | $this->setContent($content); |
44 | 44 | } |
45 | 45 | } |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | return $list; |
51 | 51 | } |
52 | 52 | |
53 | - public function getList(){ |
|
53 | + public function getList() { |
|
54 | 54 | return $this->content["list"]; |
55 | 55 | } |
56 | 56 | |
57 | - public function getItem($index){ |
|
57 | + public function getItem($index) { |
|
58 | 58 | return $this->getList()->getItem($index); |
59 | 59 | } |
60 | 60 | } |
61 | 61 | \ No newline at end of file |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | $icon=@$content[0]; |
18 | 18 | $title=@$content[1]; |
19 | 19 | $desc=@$content[2]; |
20 | - }else{ |
|
20 | + } else{ |
|
21 | 21 | $icon=@$content["icon"]; |
22 | 22 | $image=@$content["image"]; |
23 | 23 | $title=@$content["title"]; |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | } |
34 | 34 | if(isset($title)===true){ |
35 | 35 | $this->setTitle($title,$desc); |
36 | - }elseif (isset($header)===true){ |
|
36 | + } elseif (isset($header)===true){ |
|
37 | 37 | $this->setTitle($header,$desc,"header"); |
38 | 38 | } |
39 | 39 | if(isset($items)===true){ |
40 | 40 | $this->addList($items); |
41 | 41 | } |
42 | - }else{ |
|
42 | + } else{ |
|
43 | 43 | $this->setContent($content); |
44 | 44 | } |
45 | 45 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * Set the button value |
40 | 40 | * @param string $value |
41 | - * @return \Ajax\semantic\html\HtmlButton |
|
41 | + * @return HtmlButton |
|
42 | 42 | */ |
43 | 43 | public function setValue($value) { |
44 | 44 | $this->content=$value; |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | |
48 | 48 | /** |
49 | 49 | * define the button style |
50 | - * @param string|int $cssStyle |
|
51 | - * @return \Ajax\semantic\html\HtmlButton default : "" |
|
50 | + * @param string $cssStyle |
|
51 | + * @return HtmlButton default : "" |
|
52 | 52 | */ |
53 | 53 | public function setStyle($cssStyle) { |
54 | 54 | return $this->addToProperty("class", $cssStyle); |
@@ -98,7 +98,6 @@ discard block |
||
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Add and return a button label |
101 | - * @param string $caption |
|
102 | 101 | * @param string $before |
103 | 102 | * @param string $icon |
104 | 103 | * @return \Ajax\semantic\html\elements\HtmlLabel |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | public function setFocusable($value=true) { |
58 | - if ($value === true) |
|
58 | + if ($value===true) |
|
59 | 59 | $this->setProperty("tabindex", "0"); |
60 | 60 | else { |
61 | 61 | $this->removeProperty("tabindex"); |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | |
66 | 66 | public function setAnimated($content, $animation="") { |
67 | 67 | $this->setTagName("div"); |
68 | - $this->addToProperty("class", "animated " . $animation); |
|
69 | - $visible=new HtmlSemDoubleElement("visible-" . $this->identifier, "div"); |
|
68 | + $this->addToProperty("class", "animated ".$animation); |
|
69 | + $visible=new HtmlSemDoubleElement("visible-".$this->identifier, "div"); |
|
70 | 70 | $visible->setClass("visible content"); |
71 | 71 | $visible->setContent($this->content); |
72 | - $hidden=new HtmlSemDoubleElement("hidden-" . $this->identifier, "div"); |
|
72 | + $hidden=new HtmlSemDoubleElement("hidden-".$this->identifier, "div"); |
|
73 | 73 | $hidden->setClass("hidden content"); |
74 | 74 | $hidden->setContent($content); |
75 | - $this->content=array ($visible,$hidden ); |
|
75 | + $this->content=array($visible, $hidden); |
|
76 | 76 | return $hidden; |
77 | 77 | } |
78 | 78 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | public function asIcon($icon) { |
85 | 85 | $iconO=$icon; |
86 | 86 | if (\is_string($icon)) { |
87 | - $iconO=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
87 | + $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
|
88 | 88 | } |
89 | 89 | $this->addToProperty("class", "icon"); |
90 | 90 | $this->content=$iconO; |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | public function addLabel($label, $before=false, $icon=NULL) { |
107 | 107 | $this->tagName="div"; |
108 | 108 | $this->addToProperty("class", "labeled"); |
109 | - $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
|
109 | + $this->content=new HtmlButton("button-".$this->identifier, $this->content); |
|
110 | 110 | $this->content->setTagName("div"); |
111 | - $label=new HtmlLabel("label-" . $this->identifier, $label, "a"); |
|
112 | - if(isset($icon)) |
|
111 | + $label=new HtmlLabel("label-".$this->identifier, $label, "a"); |
|
112 | + if (isset($icon)) |
|
113 | 113 | $label->addIcon($icon); |
114 | 114 | $label->setBasic(); |
115 | 115 | $this->addContent($label, $before); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function fromArray($array) { |
124 | 124 | $array=parent::fromArray($array); |
125 | - foreach ( $array as $key => $value ) { |
|
125 | + foreach ($array as $key => $value) { |
|
126 | 126 | $this->setProperty($key, $value); |
127 | 127 | } |
128 | 128 | return $array; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | public static function social($identifier, $social, $value=NULL) { |
188 | - if ($value === NULL) |
|
188 | + if ($value===NULL) |
|
189 | 189 | $value=\ucfirst($social); |
190 | 190 | $return=new HtmlButton($identifier, $value); |
191 | 191 | $return->addIcon($social); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | public function asLink($href=NULL) { |
208 | - $lnk=new HtmlLink("lnk-".$this->identifier,$href,$this->content); |
|
208 | + $lnk=new HtmlLink("lnk-".$this->identifier, $href, $this->content); |
|
209 | 209 | $this->content=$lnk; |
210 | 210 | return $this; |
211 | 211 | } |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | public function setFocusable($value=true) { |
58 | - if ($value === true) |
|
59 | - $this->setProperty("tabindex", "0"); |
|
60 | - else { |
|
58 | + if ($value === true) { |
|
59 | + $this->setProperty("tabindex", "0"); |
|
60 | + } else { |
|
61 | 61 | $this->removeProperty("tabindex"); |
62 | 62 | } |
63 | 63 | return $this; |
@@ -109,8 +109,9 @@ discard block |
||
109 | 109 | $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
110 | 110 | $this->content->setTagName("div"); |
111 | 111 | $label=new HtmlLabel("label-" . $this->identifier, $label, "a"); |
112 | - if(isset($icon)) |
|
113 | - $label->addIcon($icon); |
|
112 | + if(isset($icon)) { |
|
113 | + $label->addIcon($icon); |
|
114 | + } |
|
114 | 115 | $label->setBasic(); |
115 | 116 | $this->addContent($label, $before); |
116 | 117 | return $label; |
@@ -185,8 +186,9 @@ discard block |
||
185 | 186 | } |
186 | 187 | |
187 | 188 | public static function social($identifier, $social, $value=NULL) { |
188 | - if ($value === NULL) |
|
189 | - $value=\ucfirst($social); |
|
189 | + if ($value === NULL) { |
|
190 | + $value=\ucfirst($social); |
|
191 | + } |
|
190 | 192 | $return=new HtmlButton($identifier, $value); |
191 | 193 | $return->addIcon($social); |
192 | 194 | return $return->addToPropertyCtrl("class", $social, Social::getConstants()); |
@@ -4,7 +4,6 @@ |
||
4 | 4 | use Ajax\semantic\html\base\constants\Side; |
5 | 5 | trait AttachedTrait { |
6 | 6 | /** |
7 | - * @param string $side |
|
8 | 7 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
9 | 8 | */ |
10 | 9 | public function setAttachment($value=Side::BOTH){ |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | * @return \Ajax\semantic\html\elements\HtmlLabel |
25 | 25 | */ |
26 | 26 | public function setPointing($value=Direction::NONE) { |
27 | - if($value==="left" || $value==="right") |
|
27 | + if ($value==="left" || $value==="right") |
|
28 | 28 | return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
29 | 29 | else |
30 | - return $this->addToPropertyCtrl("class", "pointing ".$value, Direction::getConstantValues("pointing",true)); |
|
30 | + return $this->addToPropertyCtrl("class", "pointing ".$value, Direction::getConstantValues("pointing", true)); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | * @return \Ajax\semantic\html\elements\HtmlLabel |
37 | 37 | */ |
38 | 38 | public function toCorner($side="left") { |
39 | - return $this->addToPropertyCtrl("class", $side . " corner", array ("right corner","left corner" )); |
|
39 | + return $this->addToPropertyCtrl("class", $side." corner", array("right corner", "left corner")); |
|
40 | 40 | } |
41 | 41 | |
42 | - public function setHorizontal(){ |
|
43 | - return $this->addToPropertyCtrl("class", "hozizontal",array("horizontal")); |
|
42 | + public function setHorizontal() { |
|
43 | + return $this->addToPropertyCtrl("class", "hozizontal", array("horizontal")); |
|
44 | 44 | } |
45 | 45 | |
46 | - public function setFloating(){ |
|
47 | - return $this->addToPropertyCtrl("class", "floating",array("floating")); |
|
46 | + public function setFloating() { |
|
47 | + return $this->addToPropertyCtrl("class", "floating", array("floating")); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | return $this->addToProperty("class", "tag"); |
56 | 56 | } |
57 | 57 | |
58 | - public function setEmpty(){ |
|
58 | + public function setEmpty() { |
|
59 | 59 | $this->content=NULL; |
60 | - return $this->addToPropertyCtrl("class", "empty",array("empty")); |
|
60 | + return $this->addToPropertyCtrl("class", "empty", array("empty")); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | public function setBasic() { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function addEmphasisImage($src, $alt="", $before=true) { |
75 | 75 | $this->addToProperty("class", "image"); |
76 | - return $this->addImage($src,$alt,$before); |
|
76 | + return $this->addImage($src, $alt, $before); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @return \Ajax\semantic\html\elements\html5\HtmlImg |
85 | 85 | */ |
86 | 86 | public function addAvatarImage($src, $alt="", $before=true) { |
87 | - $img=$this->addImage($src,$alt,$before); |
|
87 | + $img=$this->addImage($src, $alt, $before); |
|
88 | 88 | $img->setClass("ui image"); |
89 | 89 | $img->asAvatar(); |
90 | 90 | return $img; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @return \Ajax\semantic\html\elements\html5\HtmlImg |
99 | 99 | */ |
100 | 100 | public function addImage($src, $alt="", $before=true) { |
101 | - $img=new HtmlImg("image-" . $this->identifier, $src, $alt); |
|
101 | + $img=new HtmlImg("image-".$this->identifier, $src, $alt); |
|
102 | 102 | $img->setClass(""); |
103 | 103 | $this->addContent($img, $before); |
104 | 104 | return $img; |
@@ -110,21 +110,21 @@ discard block |
||
110 | 110 | * @return \Ajax\common\html\HtmlDoubleElement |
111 | 111 | */ |
112 | 112 | public function addDetail($detail) { |
113 | - $div=new HtmlSemDoubleElement("detail-" . $this->identifier, $this->tagName,"detail"); |
|
113 | + $div=new HtmlSemDoubleElement("detail-".$this->identifier, $this->tagName, "detail"); |
|
114 | 114 | $div->setContent($detail); |
115 | 115 | $this->addContent($div); |
116 | 116 | return $div; |
117 | 117 | } |
118 | 118 | |
119 | 119 | public function asRibbon($direction=Direction::NONE) { |
120 | - return $this->addToPropertyCtrl("class", $direction." ribbon", array ("ribbon","right ribbon","left ribbon" )); |
|
120 | + return $this->addToPropertyCtrl("class", $direction." ribbon", array("ribbon", "right ribbon", "left ribbon")); |
|
121 | 121 | } |
122 | 122 | |
123 | - public function setAttached($side=Side::TOP,$direction=Direction::NONE){ |
|
124 | - if($direction!==Direction::NONE) |
|
125 | - return $this->addToPropertyCtrl("class", $side." ".$direction." attached",Side::getConstantValues($direction." attached")); |
|
123 | + public function setAttached($side=Side::TOP, $direction=Direction::NONE) { |
|
124 | + if ($direction!==Direction::NONE) |
|
125 | + return $this->addToPropertyCtrl("class", $side." ".$direction." attached", Side::getConstantValues($direction." attached")); |
|
126 | 126 | else |
127 | - return $this->addToPropertyCtrl("class", $side." attached",Side::getConstantValues("attached")); |
|
127 | + return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached")); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | public static function ribbon($identifier, $caption) { |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | public function __construct($identifier, $caption="", $icon=NULL, $tagName="div") { |
15 | 15 | parent::__construct($identifier, $tagName, "ui label"); |
16 | 16 | $this->content=$caption; |
17 | - if (isset($icon)===true) |
|
18 | - $this->addIcon($icon); |
|
17 | + if (isset($icon)===true) { |
|
18 | + $this->addIcon($icon); |
|
19 | + } |
|
19 | 20 | } |
20 | 21 | |
21 | 22 | /** |
@@ -24,10 +25,11 @@ discard block |
||
24 | 25 | * @return \Ajax\semantic\html\elements\HtmlLabel |
25 | 26 | */ |
26 | 27 | public function setPointing($value=Direction::NONE) { |
27 | - if($value==="left" || $value==="right") |
|
28 | - return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
29 | - else |
|
30 | - return $this->addToPropertyCtrl("class", "pointing ".$value, Direction::getConstantValues("pointing",true)); |
|
28 | + if($value==="left" || $value==="right") { |
|
29 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
30 | + } else { |
|
31 | + return $this->addToPropertyCtrl("class", "pointing ".$value, Direction::getConstantValues("pointing",true)); |
|
32 | + } |
|
31 | 33 | } |
32 | 34 | |
33 | 35 | /** |
@@ -121,10 +123,11 @@ discard block |
||
121 | 123 | } |
122 | 124 | |
123 | 125 | public function setAttached($side=Side::TOP,$direction=Direction::NONE){ |
124 | - if($direction!==Direction::NONE) |
|
125 | - return $this->addToPropertyCtrl("class", $side." ".$direction." attached",Side::getConstantValues($direction." attached")); |
|
126 | - else |
|
127 | - return $this->addToPropertyCtrl("class", $side." attached",Side::getConstantValues("attached")); |
|
126 | + if($direction!==Direction::NONE) { |
|
127 | + return $this->addToPropertyCtrl("class", $side." ".$direction." attached",Side::getConstantValues($direction." attached")); |
|
128 | + } else { |
|
129 | + return $this->addToPropertyCtrl("class", $side." attached",Side::getConstantValues("attached")); |
|
130 | + } |
|
128 | 131 | } |
129 | 132 | |
130 | 133 | public static function ribbon($identifier, $caption) { |
@@ -91,12 +91,12 @@ |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | - * Adds an image |
|
95 | - * @param string $src |
|
96 | - * @param string $alt |
|
97 | - * @param boolean $before |
|
98 | - * @return \Ajax\semantic\html\elements\html5\HtmlImg |
|
99 | - */ |
|
94 | + * Adds an image |
|
95 | + * @param string $src |
|
96 | + * @param string $alt |
|
97 | + * @param boolean $before |
|
98 | + * @return \Ajax\semantic\html\elements\html5\HtmlImg |
|
99 | + */ |
|
100 | 100 | public function addImage($src, $alt="", $before=true) { |
101 | 101 | $img=new HtmlImg("image-" . $this->identifier, $src, $alt); |
102 | 102 | $img->setClass(""); |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | private static $constCacheArray=NULL; |
13 | 13 | |
14 | 14 | public static function getConstants() { |
15 | - if (self::$constCacheArray == NULL) { |
|
16 | - self::$constCacheArray=[ ]; |
|
15 | + if (self::$constCacheArray==NULL) { |
|
16 | + self::$constCacheArray=[]; |
|
17 | 17 | } |
18 | 18 | $calledClass=get_called_class(); |
19 | 19 | if (!array_key_exists($calledClass, self::$constCacheArray)) { |
@@ -23,16 +23,16 @@ discard block |
||
23 | 23 | return self::$constCacheArray[$calledClass]; |
24 | 24 | } |
25 | 25 | |
26 | - public static function getConstantValues($postFix="",$prefixBefore=false) { |
|
27 | - if ($postFix == "") |
|
26 | + public static function getConstantValues($postFix="", $prefixBefore=false) { |
|
27 | + if ($postFix=="") |
|
28 | 28 | return \array_values(self::getConstants()); |
29 | 29 | else { |
30 | - if($prefixBefore===false){ |
|
31 | - return \array_map(function ($elem) use($postFix) { |
|
32 | - return $elem . " " . $postFix; |
|
30 | + if ($prefixBefore===false) { |
|
31 | + return \array_map(function($elem) use($postFix) { |
|
32 | + return $elem." ".$postFix; |
|
33 | 33 | }, \array_values(self::getConstants())); |
34 | - }else{ |
|
35 | - return \array_map(function ($elem) use($postFix) { |
|
34 | + }else { |
|
35 | + return \array_map(function($elem) use($postFix) { |
|
36 | 36 | return $postFix." ".$elem; |
37 | 37 | }, \array_values(self::getConstants())); |
38 | 38 | } |
@@ -24,14 +24,14 @@ |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | public static function getConstantValues($postFix="",$prefixBefore=false) { |
27 | - if ($postFix == "") |
|
28 | - return \array_values(self::getConstants()); |
|
29 | - else { |
|
27 | + if ($postFix == "") { |
|
28 | + return \array_values(self::getConstants()); |
|
29 | + } else { |
|
30 | 30 | if($prefixBefore===false){ |
31 | 31 | return \array_map(function ($elem) use($postFix) { |
32 | 32 | return $elem . " " . $postFix; |
33 | 33 | }, \array_values(self::getConstants())); |
34 | - }else{ |
|
34 | + } else{ |
|
35 | 35 | return \array_map(function ($elem) use($postFix) { |
36 | 36 | return $postFix." ".$elem; |
37 | 37 | }, \array_values(self::getConstants())); |