@@ -13,6 +13,9 @@ |
||
13 | 13 | */ |
14 | 14 | class HtmlIconGroups extends HtmlSemCollection { |
15 | 15 | |
16 | + /** |
|
17 | + * @param string $identifier |
|
18 | + */ |
|
16 | 19 | public function __construct($identifier, $icons=array(), $size="") { |
17 | 20 | parent::__construct($identifier, "i", "icons"); |
18 | 21 | $this->addItems($icons); |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | $this->params["fields"]=[]; |
22 | 22 | } |
23 | 23 | |
24 | - public function addField($identifier){ |
|
24 | + public function addField($identifier) { |
|
25 | 25 | $this->params["fields"][$identifier]=new FieldValidation($identifier); |
26 | 26 | } |
27 | 27 | |
28 | - public function setInline($value){ |
|
28 | + public function setInline($value) { |
|
29 | 29 | return $this->setParam("inline", true); |
30 | 30 | } |
31 | 31 | |
32 | - public function setOn($value){ |
|
32 | + public function setOn($value) { |
|
33 | 33 | return $this->setParam("on", $value); |
34 | 34 | } |
35 | 35 | |
@@ -41,27 +41,27 @@ discard block |
||
41 | 41 | * @param mixed $value |
42 | 42 | * @param string|NULL $prompt |
43 | 43 | */ |
44 | - public function addFieldRule($identifier,$type,$prompt=NULL,$value=NULL){ |
|
45 | - if(isset($this->params["fields"][$identifier])===false){ |
|
44 | + public function addFieldRule($identifier, $type, $prompt=NULL, $value=NULL) { |
|
45 | + if (isset($this->params["fields"][$identifier])===false) { |
|
46 | 46 | $this->addField($identifier); |
47 | 47 | } |
48 | - $this->params["fields"][$identifier]->addRule($type,$prompt,$value); |
|
48 | + $this->params["fields"][$identifier]->addRule($type, $prompt, $value); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @param FieldValidation $fieldValidation |
53 | 53 | */ |
54 | - public function addFieldValidation($fieldValidation){ |
|
54 | + public function addFieldValidation($fieldValidation) { |
|
55 | 55 | $this->params["fields"][$fieldValidation->getIdentifier()]=$fieldValidation; |
56 | 56 | } |
57 | 57 | |
58 | - public function setJs(JsUtils $js){ |
|
58 | + public function setJs(JsUtils $js) { |
|
59 | 59 | $this->js=$js; |
60 | 60 | } |
61 | 61 | |
62 | 62 | public function getScript() { |
63 | 63 | $allParams=$this->params; |
64 | - $this->jquery_code_for_compile=array (); |
|
64 | + $this->jquery_code_for_compile=array(); |
|
65 | 65 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).");"; |
66 | 66 | $this->compileEvents(); |
67 | 67 | return $this->compileJQueryCode(); |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | * @version 1.001 |
11 | 11 | */ |
12 | 12 | abstract class BaseComponent { |
13 | - public $jquery_code_for_compile=array (); |
|
14 | - protected $params=array (); |
|
13 | + public $jquery_code_for_compile=array(); |
|
14 | + protected $params=array(); |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | public function setParams($params) { |
71 | - foreach ( $params as $k => $v ) { |
|
71 | + foreach ($params as $k => $v) { |
|
72 | 72 | $method="set".ucfirst($k); |
73 | 73 | if (method_exists($this, $method)) |
74 | 74 | $this->$method($v); |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | return $this; |
82 | 82 | } |
83 | 83 | |
84 | - public function addParams($params){ |
|
85 | - foreach ($params as $k=>$v){ |
|
84 | + public function addParams($params) { |
|
85 | + foreach ($params as $k=>$v) { |
|
86 | 86 | $this->setParam($k, $v); |
87 | 87 | } |
88 | 88 | return $this; |
@@ -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 | 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 | 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 | 230 | } else { |
231 | - $setter="set" . ucfirst($key); |
|
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 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | if (is_array($this->_events[$event])) { |
279 | 279 | $this->_events[$event][]=$jsCode; |
280 | 280 | } else { |
281 | - $this->_events[$event]=array ($this->_events[$event],$jsCode ); |
|
281 | + $this->_events[$event]=array($this->_events[$event], $jsCode); |
|
282 | 282 | } |
283 | 283 | } else { |
284 | 284 | $this->_events[$event]=$jsCode; |
@@ -298,35 +298,35 @@ discard block |
||
298 | 298 | return $this->onClick($jsCode); |
299 | 299 | } |
300 | 300 | |
301 | - public function onCreate($jsCode){ |
|
302 | - if(isset($this->_events["_create"])){ |
|
301 | + public function onCreate($jsCode) { |
|
302 | + if (isset($this->_events["_create"])) { |
|
303 | 303 | $this->_events["_create"][]=$jsCode; |
304 | - }else{ |
|
304 | + } else { |
|
305 | 305 | $this->_events["_create"]=[$jsCode]; |
306 | 306 | } |
307 | 307 | return $this; |
308 | 308 | } |
309 | 309 | |
310 | 310 | public function addEventsOnRun(JsUtils $js) { |
311 | - if(isset($this->_events["_create"])){ |
|
311 | + if (isset($this->_events["_create"])) { |
|
312 | 312 | $create=$this->_events["_create"]; |
313 | - if(\is_array($create)){ |
|
313 | + if (\is_array($create)) { |
|
314 | 314 | $create=\implode("", $create); |
315 | 315 | } |
316 | - if($create!=="") |
|
317 | - $js->exec($create,true); |
|
316 | + if ($create!=="") |
|
317 | + $js->exec($create, true); |
|
318 | 318 | unset($this->_events["_create"]); |
319 | 319 | } |
320 | 320 | if (isset($this->_bsComponent)) { |
321 | - foreach ( $this->_events as $event => $jsCode ) { |
|
321 | + foreach ($this->_events as $event => $jsCode) { |
|
322 | 322 | $code=$jsCode; |
323 | 323 | if (is_array($jsCode)) { |
324 | 324 | $code=""; |
325 | - foreach ( $jsCode as $jsC ) { |
|
325 | + foreach ($jsCode as $jsC) { |
|
326 | 326 | if ($jsC instanceof AjaxCall) { |
327 | - $code.="\n" . $jsC->compile($js); |
|
327 | + $code.="\n".$jsC->compile($js); |
|
328 | 328 | } else { |
329 | - $code.="\n" . $jsC; |
|
329 | + $code.="\n".$jsC; |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | } elseif ($jsCode instanceof AjaxCall) { |
@@ -334,12 +334,12 @@ discard block |
||
334 | 334 | } |
335 | 335 | $this->_bsComponent->addEvent($event, $code); |
336 | 336 | } |
337 | - $this->_events=array (); |
|
337 | + $this->_events=array(); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
341 | 341 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
342 | - $params=array ("url" => $url,"responseElement" => $responseElement ); |
|
342 | + $params=array("url" => $url, "responseElement" => $responseElement); |
|
343 | 343 | $params=array_merge($params, $parameters); |
344 | 344 | $this->_addEvent($event, new AjaxCall($operation, $params)); |
345 | 345 | return $this; |
@@ -375,33 +375,33 @@ discard block |
||
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]->getIdentifier() === $identifier); |
|
380 | + $flag=($elements[$index]->getIdentifier()===$identifier); |
|
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->getIdentifier() === $identifier) |
|
386 | + if ($elements->getIdentifier()===$identifier) |
|
387 | 387 | return $elements; |
388 | 388 | } |
389 | 389 | return null; |
390 | 390 | } |
391 | 391 | |
392 | - protected function getElementByPropertyValue($propertyName,$value, $elements) { |
|
392 | + protected function getElementByPropertyValue($propertyName, $value, $elements) { |
|
393 | 393 | if (is_array($elements)) { |
394 | 394 | $flag=false; |
395 | 395 | $index=0; |
396 | - while ( !$flag && $index < sizeof($elements) ) { |
|
396 | + while (!$flag && $index<sizeof($elements)) { |
|
397 | 397 | if ($elements[$index] instanceof BaseHtml) |
398 | - $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
398 | + $flag=($elements[$index]->propertyContains($propertyName, $value)===true); |
|
399 | 399 | $index++; |
400 | 400 | } |
401 | - if ($flag === true) |
|
402 | - return $elements[$index - 1]; |
|
401 | + if ($flag===true) |
|
402 | + return $elements[$index-1]; |
|
403 | 403 | } elseif ($elements instanceof BaseHtml) { |
404 | - if ($elements->propertyContains($propertyName, $value) === true) |
|
404 | + if ($elements->propertyContains($propertyName, $value)===true) |
|
405 | 405 | return $elements; |
406 | 406 | } |
407 | 407 | return null; |
@@ -423,14 +423,14 @@ discard block |
||
423 | 423 | if (is_array($value)) { |
424 | 424 | $value=implode(",", $value); |
425 | 425 | } |
426 | - if (strrpos($value, 'this') === false && strrpos($value, 'event') === false) { |
|
427 | - $value='"' . $value . '"'; |
|
426 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false) { |
|
427 | + $value='"'.$value.'"'; |
|
428 | 428 | } |
429 | 429 | return $value; |
430 | 430 | } |
431 | 431 | |
432 | 432 | public function jsDoJquery($jqueryCall, $param="") { |
433 | - return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . $this->_prep_value($param) . ");"; |
|
433 | + return "$('#".$this->identifier."').".$jqueryCall."(".$this->_prep_value($param).");"; |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | 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 | public 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 | } |
@@ -301,7 +306,7 @@ discard block |
||
301 | 306 | public function onCreate($jsCode){ |
302 | 307 | if(isset($this->_events["_create"])){ |
303 | 308 | $this->_events["_create"][]=$jsCode; |
304 | - }else{ |
|
309 | + } else{ |
|
305 | 310 | $this->_events["_create"]=[$jsCode]; |
306 | 311 | } |
307 | 312 | return $this; |
@@ -313,8 +318,9 @@ discard block |
||
313 | 318 | if(\is_array($create)){ |
314 | 319 | $create=\implode("", $create); |
315 | 320 | } |
316 | - if($create!=="") |
|
317 | - $js->exec($create,true); |
|
321 | + if($create!=="") { |
|
322 | + $js->exec($create,true); |
|
323 | + } |
|
318 | 324 | unset($this->_events["_create"]); |
319 | 325 | } |
320 | 326 | if (isset($this->_bsComponent)) { |
@@ -376,15 +382,18 @@ discard block |
||
376 | 382 | $flag=false; |
377 | 383 | $index=0; |
378 | 384 | while ( !$flag && $index < sizeof($elements) ) { |
379 | - if ($elements[$index] instanceof BaseHtml) |
|
380 | - $flag=($elements[$index]->getIdentifier() === $identifier); |
|
385 | + if ($elements[$index] instanceof BaseHtml) { |
|
386 | + $flag=($elements[$index]->getIdentifier() === $identifier); |
|
387 | + } |
|
381 | 388 | $index++; |
382 | 389 | } |
383 | - if ($flag === true) |
|
384 | - return $elements[$index - 1]; |
|
390 | + if ($flag === true) { |
|
391 | + return $elements[$index - 1]; |
|
392 | + } |
|
385 | 393 | } elseif ($elements instanceof BaseHtml) { |
386 | - if ($elements->getIdentifier() === $identifier) |
|
387 | - return $elements; |
|
394 | + if ($elements->getIdentifier() === $identifier) { |
|
395 | + return $elements; |
|
396 | + } |
|
388 | 397 | } |
389 | 398 | return null; |
390 | 399 | } |
@@ -394,15 +403,18 @@ discard block |
||
394 | 403 | $flag=false; |
395 | 404 | $index=0; |
396 | 405 | while ( !$flag && $index < sizeof($elements) ) { |
397 | - if ($elements[$index] instanceof BaseHtml) |
|
398 | - $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
406 | + if ($elements[$index] instanceof BaseHtml) { |
|
407 | + $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
408 | + } |
|
399 | 409 | $index++; |
400 | 410 | } |
401 | - if ($flag === true) |
|
402 | - return $elements[$index - 1]; |
|
411 | + if ($flag === true) { |
|
412 | + return $elements[$index - 1]; |
|
413 | + } |
|
403 | 414 | } elseif ($elements instanceof BaseHtml) { |
404 | - if ($elements->propertyContains($propertyName, $value) === true) |
|
405 | - return $elements; |
|
415 | + if ($elements->propertyContains($propertyName, $value) === true) { |
|
416 | + return $elements; |
|
417 | + } |
|
406 | 418 | } |
407 | 419 | return null; |
408 | 420 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @version 1.001 |
6 | 6 | * Generates a JSON field validator |
7 | 7 | */ |
8 | -class FieldValidation implements \JsonSerializable{ |
|
8 | +class FieldValidation implements \JsonSerializable { |
|
9 | 9 | /** |
10 | 10 | * @var string |
11 | 11 | */ |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | protected $optional; |
24 | 24 | |
25 | - public function __construct($identifier){ |
|
25 | + public function __construct($identifier) { |
|
26 | 26 | $this->identifier=$identifier; |
27 | 27 | $this->rules=[]; |
28 | 28 | } |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | return $this->rules; |
41 | 41 | } |
42 | 42 | |
43 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
44 | - if($type instanceof Rule) |
|
43 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
44 | + if ($type instanceof Rule) |
|
45 | 45 | $this->rules[]=$type; |
46 | 46 | else |
47 | - $this->rules[]=new Rule($type,$prompt,$value); |
|
47 | + $this->rules[]=new Rule($type, $prompt, $value); |
|
48 | 48 | } |
49 | 49 | |
50 | - public function jsonSerialize(){ |
|
51 | - return ["identifier"=>$this->identifier,"rules"=>$this->rules]; |
|
50 | + public function jsonSerialize() { |
|
51 | + return ["identifier"=>$this->identifier, "rules"=>$this->rules]; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function setDepends($depends) { |
@@ -41,10 +41,11 @@ |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | public function addRule($type,$prompt=NULL,$value=NULL){ |
44 | - if($type instanceof Rule) |
|
45 | - $this->rules[]=$type; |
|
46 | - else |
|
47 | - $this->rules[]=new Rule($type,$prompt,$value); |
|
44 | + if($type instanceof Rule) { |
|
45 | + $this->rules[]=$type; |
|
46 | + } else { |
|
47 | + $this->rules[]=new Rule($type,$prompt,$value); |
|
48 | + } |
|
48 | 49 | } |
49 | 50 | |
50 | 51 | public function jsonSerialize(){ |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @version 1.001 |
6 | 6 | * Generates a JSON Rule for the validation of a field |
7 | 7 | */ |
8 | -class Rule implements \JsonSerializable{ |
|
8 | +class Rule implements \JsonSerializable { |
|
9 | 9 | /** |
10 | 10 | * @var string |
11 | 11 | */ |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | private $value; |
22 | 22 | |
23 | - public function __construct($type,$prompt=NULL,$value=NULL){ |
|
23 | + public function __construct($type, $prompt=NULL, $value=NULL) { |
|
24 | 24 | $this->type=$type; |
25 | 25 | $this->prompt=$prompt; |
26 | 26 | $this->value=$value; |
@@ -54,28 +54,28 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | public function jsonSerialize() { |
57 | - $result= ["type"=>$this->type]; |
|
58 | - if(isset($this->prompt)) |
|
57 | + $result=["type"=>$this->type]; |
|
58 | + if (isset($this->prompt)) |
|
59 | 59 | $result["prompt"]=$this->prompt; |
60 | - if(isset($this->value)) |
|
60 | + if (isset($this->value)) |
|
61 | 61 | $result["value"]=$this->value; |
62 | 62 | return $result; |
63 | 63 | } |
64 | 64 | |
65 | - public static function match($name,$prompt=null){ |
|
66 | - return new Rule("match[".$name."]",$prompt); |
|
65 | + public static function match($name, $prompt=null) { |
|
66 | + return new Rule("match[".$name."]", $prompt); |
|
67 | 67 | } |
68 | 68 | |
69 | - public static function integer($min=0,$max=100,$prompt=null){ |
|
70 | - return new Rule("integer[{$min}..{$max}]",$prompt); |
|
69 | + public static function integer($min=0, $max=100, $prompt=null) { |
|
70 | + return new Rule("integer[{$min}..{$max}]", $prompt); |
|
71 | 71 | } |
72 | 72 | |
73 | - public static function decimal($prompt=null){ |
|
74 | - return new Rule("decimal]",$prompt); |
|
73 | + public static function decimal($prompt=null) { |
|
74 | + return new Rule("decimal]", $prompt); |
|
75 | 75 | } |
76 | 76 | |
77 | - public static function number($prompt=null){ |
|
78 | - return new Rule("number",$prompt); |
|
77 | + public static function number($prompt=null) { |
|
78 | + return new Rule("number", $prompt); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | } |
82 | 82 | \ No newline at end of file |
@@ -55,10 +55,12 @@ |
||
55 | 55 | |
56 | 56 | public function jsonSerialize() { |
57 | 57 | $result= ["type"=>$this->type]; |
58 | - if(isset($this->prompt)) |
|
59 | - $result["prompt"]=$this->prompt; |
|
60 | - if(isset($this->value)) |
|
61 | - $result["value"]=$this->value; |
|
58 | + if(isset($this->prompt)) { |
|
59 | + $result["prompt"]=$this->prompt; |
|
60 | + } |
|
61 | + if(isset($this->value)) { |
|
62 | + $result["value"]=$this->value; |
|
63 | + } |
|
62 | 64 | return $result; |
63 | 65 | } |
64 | 66 |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | * @property string $identifier |
13 | 13 | */ |
14 | 14 | trait BaseTrait { |
15 | - protected $_variations=[ ]; |
|
16 | - protected $_states=[ ]; |
|
15 | + protected $_variations=[]; |
|
16 | + protected $_states=[]; |
|
17 | 17 | protected $_baseClass; |
18 | 18 | |
19 | 19 | protected abstract function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $this->setProperty("class", $this->_baseClass); |
44 | 44 | if (\is_string($variations)) |
45 | 45 | $variations=\explode(" ", $variations); |
46 | - foreach ( $variations as $variation ) { |
|
46 | + foreach ($variations as $variation) { |
|
47 | 47 | $this->addVariation($variation); |
48 | 48 | } |
49 | 49 | return $this; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | public function addVariations($variations=array()) { |
58 | 58 | if (\is_string($variations)) |
59 | 59 | $variations=\explode(" ", $variations); |
60 | - foreach ( $variations as $variation ) { |
|
60 | + foreach ($variations as $variation) { |
|
61 | 61 | $this->addVariation($variation); |
62 | 62 | } |
63 | 63 | return $this; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | public function addStates($states=array()) { |
67 | 67 | if (\is_string($states)) |
68 | 68 | $states=\explode(" ", $states); |
69 | - foreach ( $states as $state ) { |
|
69 | + foreach ($states as $state) { |
|
70 | 70 | $this->addState($state); |
71 | 71 | } |
72 | 72 | return $this; |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | $this->setProperty("class", $this->_baseClass); |
77 | 77 | if (\is_string($states)) |
78 | 78 | $states=\explode(" ", $states); |
79 | - foreach ( $states as $state ) { |
|
79 | + foreach ($states as $state) { |
|
80 | 80 | $this->addState($state); |
81 | 81 | } |
82 | 82 | return $this; |
83 | 83 | } |
84 | 84 | |
85 | 85 | public function addIcon($icon, $before=true) { |
86 | - return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
86 | + return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before); |
|
87 | 87 | } |
88 | 88 | |
89 | - public function addSticky($context="body"){ |
|
89 | + public function addSticky($context="body") { |
|
90 | 90 | $this->onCreate("$('#".$this->identifier."').sticky({ context: '".$context."'});"); |
91 | 91 | return $this; |
92 | 92 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
132 | 132 | */ |
133 | - public function asHeader(){ |
|
133 | + public function asHeader() { |
|
134 | 134 | return $this->addToProperty("class", "header"); |
135 | 135 | } |
136 | 136 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * show it is currently the active user selection |
139 | 139 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
140 | 140 | */ |
141 | - public function setActive($value=true){ |
|
141 | + public function setActive($value=true) { |
|
142 | 142 | return $this->addToProperty("class", "active"); |
143 | 143 | } |
144 | 144 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | public function setFloated($direction="right") { |
157 | - return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
157 | + return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | public function floatRight() { |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | use BaseTrait; |
22 | 22 | protected $_popup=NULL; |
23 | 23 | protected $_dimmer=NULL; |
24 | - protected $_params=array (); |
|
24 | + protected $_params=array(); |
|
25 | 25 | |
26 | 26 | |
27 | 27 | public function __construct($identifier, $tagName="p", $baseClass="ui", $content=NULL) { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | public function addDimmer($params=array(), $content=NULL) { |
54 | - $dimmer=new HtmlDimmer("dimmer-" . $this->identifier, $content); |
|
54 | + $dimmer=new HtmlDimmer("dimmer-".$this->identifier, $content); |
|
55 | 55 | $dimmer->setParams($params); |
56 | 56 | $dimmer->setContainer($this); |
57 | 57 | $this->addContent($dimmer); |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | |
61 | 61 | public function addLabel($label, $before=false, $icon=NULL) { |
62 | 62 | $labelO=$label; |
63 | - if (\is_object($label) === false) { |
|
64 | - $labelO=new HtmlLabel("label-" . $this->identifier, $label); |
|
63 | + if (\is_object($label)===false) { |
|
64 | + $labelO=new HtmlLabel("label-".$this->identifier, $label); |
|
65 | 65 | if (isset($icon)) |
66 | 66 | $labelO->addIcon($icon); |
67 | 67 | } else { |
68 | - $labelO->addToPropertyCtrl("class", "label", array ("label" )); |
|
68 | + $labelO->addToPropertyCtrl("class", "label", array("label")); |
|
69 | 69 | } |
70 | 70 | $this->addContent($labelO, $before); |
71 | 71 | return $labelO; |
72 | 72 | } |
73 | 73 | |
74 | - public function attachLabel($label,$side,$direction=Direction::NONE,$icon=NULL){ |
|
75 | - $label=$this->addLabel($label,true,$icon); |
|
76 | - $label->setAttached($side,$direction); |
|
74 | + public function attachLabel($label, $side, $direction=Direction::NONE, $icon=NULL) { |
|
75 | + $label=$this->addLabel($label, true, $icon); |
|
76 | + $label->setAttached($side, $direction); |
|
77 | 77 | return $this; |
78 | 78 | } |
79 | 79 | |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | |
90 | 90 | public function jsShowDimmer($show=true) { |
91 | 91 | $status="hide"; |
92 | - if ($show === true) |
|
92 | + if ($show===true) |
|
93 | 93 | $status="show"; |
94 | - return '$("#.' . $this->identifier . ').dimmer("' . $status . '");'; |
|
94 | + return '$("#.'.$this->identifier.').dimmer("'.$status.'");'; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | public function run(JsUtils $js) { |
104 | - $this->_bsComponent=$js->semantic()->generic("#" . $this->identifier); |
|
104 | + $this->_bsComponent=$js->semantic()->generic("#".$this->identifier); |
|
105 | 105 | parent::run($js); |
106 | 106 | $this->addEventsOnRun($js); |
107 | 107 | if (isset($this->_popup)) { |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | use Ajax\semantic\html\base\constants\Direction; |
9 | 9 | |
10 | 10 | class HtmlSearch extends HtmlSemDoubleElement { |
11 | - private $_elements=array (); |
|
12 | - private $_searchFields=array ("title" ); |
|
11 | + private $_elements=array(); |
|
12 | + private $_searchFields=array("title"); |
|
13 | 13 | private $_local=false; |
14 | 14 | |
15 | 15 | public function __construct($identifier, $placeholder=NULL, $icon=NULL) { |
16 | - parent::__construct("search-" . $identifier, "div", "ui search", array ()); |
|
16 | + parent::__construct("search-".$identifier, "div", "ui search", array()); |
|
17 | 17 | $this->createField($placeholder, $icon); |
18 | 18 | $this->createResult(); |
19 | 19 | $this->_params["type"]="standard"; |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | |
22 | 22 | private function createField($placeholder=NULL, $icon=NULL) { |
23 | 23 | $field=new HtmlInput($this->identifier); |
24 | - if (isset($placeholder) === true) |
|
24 | + if (isset($placeholder)===true) |
|
25 | 25 | $field->setPlaceholder($placeholder); |
26 | - if (isset($icon) === true) |
|
26 | + if (isset($icon)===true) |
|
27 | 27 | $field->addIcon($icon, Direction::RIGHT); |
28 | 28 | $field->getField()->setClass("prompt"); |
29 | 29 | $this->content["field"]=$field; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | private function createResult() { |
34 | - $this->content["result"]=new HtmlSemDoubleElement("results-" . $this->identifier, "div", "results"); |
|
34 | + $this->content["result"]=new HtmlSemDoubleElement("results-".$this->identifier, "div", "results"); |
|
35 | 35 | return $this->content["result"]; |
36 | 36 | } |
37 | 37 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | public function setUrl($url) { |
51 | - $this->_params["apiSettings"]="%{url: %quote%" . $url . "%quote%}%"; |
|
51 | + $this->_params["apiSettings"]="%{url: %quote%".$url."%quote%}%"; |
|
52 | 52 | return $this; |
53 | 53 | } |
54 | 54 | |
@@ -71,16 +71,16 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | public function run(JsUtils $js) { |
74 | - $this->_params["onSelect"]='%function(result,response){$(%quote%#' . $this->identifier . '%quote%).trigger(%quote%onSelect%quote%, {%quote%result%quote%: result, %quote%response%quote%:response} );}%'; |
|
74 | + $this->_params["onSelect"]='%function(result,response){$(%quote%#'.$this->identifier.'%quote%).trigger(%quote%onSelect%quote%, {%quote%result%quote%: result, %quote%response%quote%:response} );}%'; |
|
75 | 75 | $searchFields=\json_encode($this->_searchFields); |
76 | 76 | $searchFields=str_ireplace("\"", "%quote%", $searchFields); |
77 | - $this->_params["searchFields"]="%" . $searchFields . "%"; |
|
78 | - if ($this->_local === true) { |
|
77 | + $this->_params["searchFields"]="%".$searchFields."%"; |
|
78 | + if ($this->_local===true) { |
|
79 | 79 | $this->_params["source"]="%content%"; |
80 | - $this->addEvent("beforeExecute", "var content=" . $this->resultsToJson() . ";"); |
|
80 | + $this->addEvent("beforeExecute", "var content=".$this->resultsToJson().";"); |
|
81 | 81 | } |
82 | - if (isset($this->_bsComponent) === false) { |
|
83 | - $this->_bsComponent=$js->semantic()->search("#" . $this->identifier, $this->_params); |
|
82 | + if (isset($this->_bsComponent)===false) { |
|
83 | + $this->_bsComponent=$js->semantic()->search("#".$this->identifier, $this->_params); |
|
84 | 84 | } |
85 | 85 | $this->addEventsOnRun($js); |
86 | 86 | return $this->_bsComponent; |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | } |
19 | 19 | |
20 | 20 | public function setContent($content) { |
21 | - $this->content=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content)); |
|
21 | + $this->content=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content)); |
|
22 | 22 | return $this; |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function asIcon($icon, $title, $subHeader=NULL) { |
26 | - $header=new HtmlHeader("header-" . $this->identifier); |
|
26 | + $header=new HtmlHeader("header-".$this->identifier); |
|
27 | 27 | $header->asIcon($icon, $title, $subHeader); |
28 | - if ($this->_inverted === false) |
|
28 | + if ($this->_inverted===false) |
|
29 | 29 | $header->setInverted(); |
30 | 30 | return $this->setContent($header); |
31 | 31 | } |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | |
43 | 43 | public function run(JsUtils $js) { |
44 | 44 | if ($this->_container instanceof HtmlSingleElement) |
45 | - $this->_bsComponent=$js->semantic()->dimmer("#" . $this->_container->getIdentifier(), $this->_params); |
|
45 | + $this->_bsComponent=$js->semantic()->dimmer("#".$this->_container->getIdentifier(), $this->_params); |
|
46 | 46 | return parent::run($js); |
47 | 47 | } |
48 | 48 | |
49 | 49 | public function jsShow() { |
50 | - if (isset($this->_container) === true) |
|
51 | - return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");'; |
|
50 | + if (isset($this->_container)===true) |
|
51 | + return '$("#.'.$this->_container->getIdentifier().').dimmer("show");'; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function setBlurring() { |