@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | use Ajax\common\html\traits\BaseHooksTrait; |
21 | 21 | |
22 | 22 | abstract class Widget extends HtmlDoubleElement { |
23 | - use FieldAsTrait,FormTrait,BaseHooksTrait; |
|
23 | + use FieldAsTrait, FormTrait, BaseHooksTrait; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * |
@@ -66,24 +66,24 @@ discard block |
||
66 | 66 | |
67 | 67 | protected $_hasRules; |
68 | 68 | |
69 | - public function __construct($identifier, $model, $modelInstance = NULL) { |
|
69 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
70 | 70 | parent::__construct($identifier); |
71 | - $this->_template = "%wrapContentBefore%%content%%wrapContentAfter%"; |
|
71 | + $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
|
72 | 72 | $this->setModel($model); |
73 | 73 | if (isset($modelInstance)) { |
74 | 74 | $this->show($modelInstance); |
75 | 75 | } |
76 | - $this->_generated = false; |
|
76 | + $this->_generated=false; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | protected function _init($instanceViewer, $contentKey, $content, $edition) { |
80 | - $this->_instanceViewer = $instanceViewer; |
|
81 | - $this->content = [ |
|
80 | + $this->_instanceViewer=$instanceViewer; |
|
81 | + $this->content=[ |
|
82 | 82 | $contentKey => $content |
83 | 83 | ]; |
84 | - $this->_self = $content; |
|
85 | - $this->_toolbarPosition = PositionInTable::BEFORETABLE; |
|
86 | - $this->_edition = $edition; |
|
84 | + $this->_self=$content; |
|
85 | + $this->_toolbarPosition=PositionInTable::BEFORETABLE; |
|
86 | + $this->_edition=$edition; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,16 +92,16 @@ discard block |
||
92 | 92 | * @return int|string|boolean |
93 | 93 | */ |
94 | 94 | protected function _getIndex($fieldName) { |
95 | - $index = $fieldName; |
|
95 | + $index=$fieldName; |
|
96 | 96 | if (\is_string($fieldName)) { |
97 | - $fields = $this->_instanceViewer->getVisibleProperties(); |
|
98 | - $index = \array_search($fieldName, $fields); |
|
97 | + $fields=$this->_instanceViewer->getVisibleProperties(); |
|
98 | + $index=\array_search($fieldName, $fields); |
|
99 | 99 | } |
100 | 100 | return $index; |
101 | 101 | } |
102 | 102 | |
103 | - protected function _getFieldIdentifier($prefix, $name = "") { |
|
104 | - return $this->identifier . "-{$prefix}-" . $this->_instanceViewer->getIdentifier(); |
|
103 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
104 | + return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | protected function _getFieldName($index) { |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | return $this->_instanceViewer->getCaption($index); |
113 | 113 | } |
114 | 114 | |
115 | - abstract protected function _setToolbarPosition($table, $captions = NULL); |
|
115 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
116 | 116 | |
117 | 117 | public function show($modelInstance) { |
118 | 118 | if (\is_array($modelInstance)) { |
119 | - $modelInstance = \json_decode(\json_encode($modelInstance), FALSE); |
|
119 | + $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
120 | 120 | } |
121 | - $this->_modelInstance = $modelInstance; |
|
121 | + $this->_modelInstance=$modelInstance; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | public function getModel() { |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | public function setModel($_model) { |
129 | - $this->_model = $_model; |
|
129 | + $this->_model=$_model; |
|
130 | 130 | return $this; |
131 | 131 | } |
132 | 132 | |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | public function setInstanceViewer($_instanceViewer) { |
138 | - $this->_instanceViewer = $_instanceViewer; |
|
138 | + $this->_instanceViewer=$_instanceViewer; |
|
139 | 139 | return $this; |
140 | 140 | } |
141 | 141 | |
142 | 142 | abstract public function getHtmlComponent(); |
143 | 143 | |
144 | - public function setAttached($value = true) { |
|
144 | + public function setAttached($value=true) { |
|
145 | 145 | return $this->getHtmlComponent()->setAttached($value); |
146 | 146 | } |
147 | 147 | |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * @return Widget |
157 | 157 | */ |
158 | 158 | public function afterCompile($index, $callback) { |
159 | - $index = $this->_getIndex($index); |
|
160 | - if ($index !== false) { |
|
159 | + $index=$this->_getIndex($index); |
|
160 | + if ($index!==false) { |
|
161 | 161 | $this->_instanceViewer->afterCompile($index, $callback); |
162 | 162 | } |
163 | 163 | return $this; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | return $this; |
183 | 183 | } |
184 | 184 | |
185 | - public function addField($field, $key = null) { |
|
185 | + public function addField($field, $key=null) { |
|
186 | 186 | $this->_instanceViewer->addField($field, $key); |
187 | 187 | return $this; |
188 | 188 | } |
@@ -196,10 +196,10 @@ discard block |
||
196 | 196 | return $this->_instanceViewer->visiblePropertiesCount(); |
197 | 197 | } |
198 | 198 | |
199 | - public function addMessage($attributes = NULL, $fieldName = "message") { |
|
199 | + public function addMessage($attributes=NULL, $fieldName="message") { |
|
200 | 200 | $this->_instanceViewer->addField($fieldName); |
201 | - $count = $this->_instanceViewer->visiblePropertiesCount(); |
|
202 | - return $this->fieldAsMessage($count - 1, $attributes); |
|
201 | + $count=$this->_instanceViewer->visiblePropertiesCount(); |
|
202 | + return $this->fieldAsMessage($count-1, $attributes); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | public function addErrorMessage() { |
@@ -208,15 +208,15 @@ discard block |
||
208 | 208 | ], "message"); |
209 | 209 | } |
210 | 210 | |
211 | - public function insertField($index, $field, $key = null) { |
|
212 | - $index = $this->_getIndex($index); |
|
211 | + public function insertField($index, $field, $key=null) { |
|
212 | + $index=$this->_getIndex($index); |
|
213 | 213 | $this->_instanceViewer->insertField($index, $field, $key); |
214 | 214 | return $this; |
215 | 215 | } |
216 | 216 | |
217 | - public function insertInField($index, $field, $key = null) { |
|
218 | - $index = $this->_getIndex($index); |
|
219 | - if ($index !== false) { |
|
217 | + public function insertInField($index, $field, $key=null) { |
|
218 | + $index=$this->_getIndex($index); |
|
219 | + if ($index!==false) { |
|
220 | 220 | $this->_instanceViewer->insertInField($index, $field, $key); |
221 | 221 | } |
222 | 222 | return $this; |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | * @return Widget |
233 | 233 | */ |
234 | 234 | public function setValueFunction($index, $callback) { |
235 | - $index = $this->_getIndex($index); |
|
236 | - if ($index !== false) { |
|
235 | + $index=$this->_getIndex($index); |
|
236 | + if ($index!==false) { |
|
237 | 237 | $this->_instanceViewer->setValueFunction($index, $callback); |
238 | 238 | } |
239 | 239 | return $this; |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
250 | 250 | */ |
251 | 251 | public function getToolbar() { |
252 | - if (isset($this->_toolbar) === false) { |
|
253 | - $this->_toolbar = new HtmlMenu("toolbar-" . $this->identifier); |
|
252 | + if (isset($this->_toolbar)===false) { |
|
253 | + $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
|
254 | 254 | } |
255 | 255 | return $this->_toolbar; |
256 | 256 | } |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | * function to call on $element |
264 | 264 | * @return \Ajax\common\html\HtmlDoubleElement |
265 | 265 | */ |
266 | - public function addInToolbar($element, $callback = NULL) { |
|
267 | - $tb = $this->getToolbar(); |
|
266 | + public function addInToolbar($element, $callback=NULL) { |
|
267 | + $tb=$this->getToolbar(); |
|
268 | 268 | if ($element instanceof BaseWidget) { |
269 | - if ($element->getIdentifier() === "") { |
|
270 | - $element->setIdentifier("tb-item-" . $this->identifier . "-" . $tb->count()); |
|
269 | + if ($element->getIdentifier()==="") { |
|
270 | + $element->setIdentifier("tb-item-".$this->identifier."-".$tb->count()); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | if (isset($callback)) { |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | * function($element) |
287 | 287 | * @return \Ajax\common\html\HtmlDoubleElement |
288 | 288 | */ |
289 | - public function addItemInToolbar($caption, $icon = NULL, $callback = NULL) { |
|
290 | - $result = $this->addInToolbar($caption, $callback); |
|
289 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
290 | + $result=$this->addInToolbar($caption, $callback); |
|
291 | 291 | if (isset($icon) && method_exists($result, "addIcon")) |
292 | 292 | $result->addIcon($icon); |
293 | 293 | return $result; |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * function($element) |
301 | 301 | * @return \Ajax\common\Widget |
302 | 302 | */ |
303 | - public function addItemsInToolbar(array $items, $callback = NULL) { |
|
303 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
304 | 304 | if (JArray::isAssociative($items)) { |
305 | 305 | foreach ($items as $icon => $item) { |
306 | 306 | $this->addItemInToolbar($item, $icon, $callback); |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | * function($element) |
322 | 322 | * @return \Ajax\common\html\HtmlDoubleElement |
323 | 323 | */ |
324 | - public function addDropdownInToolbar($value, $items, $callback = NULL) { |
|
325 | - $dd = $value; |
|
324 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
325 | + $dd=$value; |
|
326 | 326 | if (\is_string($value)) { |
327 | - $dd = new HtmlDropdown("dropdown-" . $this->identifier . "-" . $value, $value, $items); |
|
327 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
328 | 328 | } |
329 | 329 | return $this->addInToolbar($dd, $callback); |
330 | 330 | } |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | * function($element) |
338 | 338 | * @return \Ajax\common\html\HtmlDoubleElement |
339 | 339 | */ |
340 | - public function addButtonInToolbar($caption, $cssStyle = null, $callback = NULL) { |
|
341 | - $bt = new HtmlButton("bt-" . $caption, $caption, $cssStyle); |
|
340 | + public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) { |
|
341 | + $bt=new HtmlButton("bt-".$caption, $caption, $cssStyle); |
|
342 | 342 | return $this->addInToolbar($bt, $callback); |
343 | 343 | } |
344 | 344 | |
@@ -350,8 +350,8 @@ discard block |
||
350 | 350 | * function($element) |
351 | 351 | * @return \Ajax\common\html\HtmlDoubleElement |
352 | 352 | */ |
353 | - public function addButtonsInToolbar(array $captions, $asIcon = false, $callback = NULL) { |
|
354 | - $bts = new HtmlButtonGroups("", $captions, $asIcon); |
|
353 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
354 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
355 | 355 | return $this->addInToolbar($bts, $callback); |
356 | 356 | } |
357 | 357 | |
@@ -363,14 +363,14 @@ discard block |
||
363 | 363 | * @param boolean $labeled |
364 | 364 | * @return \Ajax\common\html\HtmlDoubleElement |
365 | 365 | */ |
366 | - public function addLabelledIconButtonInToolbar($caption, $icon, $before = true, $labeled = false) { |
|
367 | - $bt = new HtmlButton("", $caption); |
|
366 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
367 | + $bt=new HtmlButton("", $caption); |
|
368 | 368 | $bt->addIcon($icon, $before, $labeled); |
369 | 369 | return $this->addInToolbar($bt); |
370 | 370 | } |
371 | 371 | |
372 | - public function addSubmitInToolbar($identifier, $value, $cssStyle = NULL, $url = NULL, $responseElement = NULL, $parameters = NULL) { |
|
373 | - $button = new HtmlButton($identifier, $value, $cssStyle); |
|
372 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
373 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
374 | 374 | $this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters); |
375 | 375 | return $this->addInToolbar($button); |
376 | 376 | } |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | * @param boolean $_edition |
394 | 394 | * @return \Ajax\common\Widget |
395 | 395 | */ |
396 | - public function setEdition($_edition = true) { |
|
397 | - $this->_edition = $_edition; |
|
396 | + public function setEdition($_edition=true) { |
|
397 | + $this->_edition=$_edition; |
|
398 | 398 | return $this; |
399 | 399 | } |
400 | 400 | |
@@ -423,8 +423,8 @@ discard block |
||
423 | 423 | * @param string|boolean $disable |
424 | 424 | * @return string |
425 | 425 | */ |
426 | - public function jsDisabled($disable = true) { |
|
427 | - return "$('#" . $this->identifier . " .ui.input,#" . $this->identifier . " .ui.dropdown,#" . $this->identifier . " .ui.checkbox').toggleClass('disabled'," . $disable . ");"; |
|
426 | + public function jsDisabled($disable=true) { |
|
427 | + return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | /** |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | * function($element) |
435 | 435 | * @return \Ajax\common\html\HtmlDoubleElement |
436 | 436 | */ |
437 | - public function addEditButtonInToolbar($caption, $callback = NULL) { |
|
438 | - $bt = new HtmlButton($this->identifier . "-editBtn", $caption); |
|
437 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
438 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
439 | 439 | $bt->setToggle(); |
440 | 440 | $bt->setActive($this->_edition); |
441 | 441 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
@@ -443,18 +443,18 @@ discard block |
||
443 | 443 | } |
444 | 444 | |
445 | 445 | public function setToolbar(HtmlMenu $_toolbar) { |
446 | - $this->_toolbar = $_toolbar; |
|
446 | + $this->_toolbar=$_toolbar; |
|
447 | 447 | return $this; |
448 | 448 | } |
449 | 449 | |
450 | 450 | public function setToolbarPosition($_toolbarPosition) { |
451 | - $this->_toolbarPosition = $_toolbarPosition; |
|
451 | + $this->_toolbarPosition=$_toolbarPosition; |
|
452 | 452 | return $this; |
453 | 453 | } |
454 | 454 | |
455 | 455 | public function getForm() { |
456 | - if (! isset($this->_form)) { |
|
457 | - $this->_form = new HtmlForm("frm-" . $this->identifier); |
|
456 | + if (!isset($this->_form)) { |
|
457 | + $this->_form=new HtmlForm("frm-".$this->identifier); |
|
458 | 458 | $this->setEdition(true); |
459 | 459 | } |
460 | 460 | return $this->_form; |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | } |
469 | 469 | |
470 | 470 | protected function runForm(JsUtils $js) { |
471 | - $fields = $this->getContentInstances(HtmlFormField::class); |
|
471 | + $fields=$this->getContentInstances(HtmlFormField::class); |
|
472 | 472 | foreach ($fields as $field) { |
473 | 473 | $this->_form->addField($field); |
474 | 474 | } |
@@ -477,10 +477,10 @@ discard block |
||
477 | 477 | |
478 | 478 | protected function _compileForm() { |
479 | 479 | if (isset($this->_form)) { |
480 | - $noValidate = ""; |
|
481 | - if (\sizeof($this->_form->getValidationParams()) > 0) |
|
482 | - $noValidate = "novalidate"; |
|
483 | - $this->wrapContent("<form class='".$this->_form->getProperty('class')."' id='frm-" . $this->identifier . "' name='frm-" . $this->identifier . "' " . $noValidate . ">", "</form>"); |
|
480 | + $noValidate=""; |
|
481 | + if (\sizeof($this->_form->getValidationParams())>0) |
|
482 | + $noValidate="novalidate"; |
|
483 | + $this->wrapContent("<form class='".$this->_form->getProperty('class')."' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>"); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
@@ -502,21 +502,21 @@ discard block |
||
502 | 502 | } |
503 | 503 | |
504 | 504 | public function swapFields($index1, $index2) { |
505 | - $index1 = $this->_getIndex($index1); |
|
506 | - $index2 = $this->_getIndex($index2); |
|
505 | + $index1=$this->_getIndex($index1); |
|
506 | + $index2=$this->_getIndex($index2); |
|
507 | 507 | return $this->_instanceViewer->swapFields($index1, $index2); |
508 | 508 | } |
509 | 509 | |
510 | 510 | public function removeField($index) { |
511 | - $index = $this->_getIndex($index); |
|
512 | - if ($index !== false) { |
|
511 | + $index=$this->_getIndex($index); |
|
512 | + if ($index!==false) { |
|
513 | 513 | $this->_instanceViewer->removeField($index); |
514 | 514 | } |
515 | 515 | return $this; |
516 | 516 | } |
517 | 517 | |
518 | - public function asModal($header = null) { |
|
519 | - $modal = new HtmlModal("modal-" . $this->identifier, $header); |
|
518 | + public function asModal($header=null) { |
|
519 | + $modal=new HtmlModal("modal-".$this->identifier, $header); |
|
520 | 520 | $modal->setContent($this); |
521 | 521 | if (isset($this->_form)) { |
522 | 522 | $this->_form->onSuccess($modal->jsHide()); |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | return $modal; |
525 | 525 | } |
526 | 526 | |
527 | - public function addToProperty($name, $value, $separator = " ") { |
|
527 | + public function addToProperty($name, $value, $separator=" ") { |
|
528 | 528 | return $this->getHtmlComponent()->addToProperty($name, $value, $separator); |
529 | 529 | } |
530 | 530 |
@@ -15,36 +15,36 @@ discard block |
||
15 | 15 | protected $_paramParts=array(); |
16 | 16 | |
17 | 17 | public function __construct($identifier, $header="", $content="", $actions=null) { |
18 | - parent::__construct($identifier, "div","ui modal"); |
|
19 | - if(isset($header)){ |
|
18 | + parent::__construct($identifier, "div", "ui modal"); |
|
19 | + if (isset($header)) { |
|
20 | 20 | $this->setHeader($header); |
21 | 21 | } |
22 | - if(isset($content)){ |
|
22 | + if (isset($content)) { |
|
23 | 23 | $this->setContent($content); |
24 | 24 | } |
25 | - if(isset($actions)){ |
|
25 | + if (isset($actions)) { |
|
26 | 26 | $this->setActions($actions); |
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function setHeader($value) { |
31 | - $this->content["header"]=new HtmlSemDoubleElement("header-" . $this->identifier, "a", "header", $value); |
|
31 | + $this->content["header"]=new HtmlSemDoubleElement("header-".$this->identifier, "a", "header", $value); |
|
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function setContent($value) { |
36 | - $this->content["content"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", $value); |
|
36 | + $this->content["content"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content", $value); |
|
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | 40 | public function setActions($actions) { |
41 | - $this->content["actions"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "actions"); |
|
42 | - if(\is_array($actions)){ |
|
43 | - foreach ($actions as $action){ |
|
41 | + $this->content["actions"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "actions"); |
|
42 | + if (\is_array($actions)) { |
|
43 | + foreach ($actions as $action) { |
|
44 | 44 | $this->addAction($action); |
45 | 45 | } |
46 | 46 | } |
47 | - else{ |
|
47 | + else { |
|
48 | 48 | $this->addAction($actions); |
49 | 49 | } |
50 | 50 | return $this; |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | * @param string|BaseHtml $action |
55 | 55 | * @return HtmlButton |
56 | 56 | */ |
57 | - public function addAction($action){ |
|
58 | - if(!$action instanceof BaseHtml){ |
|
57 | + public function addAction($action) { |
|
58 | + if (!$action instanceof BaseHtml) { |
|
59 | 59 | $class=""; |
60 | - if(\array_search($action, ["Okay","Yes","Validate"])!==false){ |
|
60 | + if (\array_search($action, ["Okay", "Yes", "Validate"])!==false) { |
|
61 | 61 | $class="approve"; |
62 | 62 | } |
63 | - if(\array_search($action, ["Close","Cancel","No"])!==false){ |
|
63 | + if (\array_search($action, ["Close", "Cancel", "No"])!==false) { |
|
64 | 64 | $class="cancel"; |
65 | 65 | } |
66 | - $action=new HtmlButton("action-".$this->identifier."-".JArray::count($this->content["actions"]->getContent()),$action); |
|
67 | - if($class!=="") |
|
66 | + $action=new HtmlButton("action-".$this->identifier."-".JArray::count($this->content["actions"]->getContent()), $action); |
|
67 | + if ($class!=="") |
|
68 | 68 | $action->addToProperty("class", $class); |
69 | 69 | } |
70 | 70 | return $this->addElementInPart($action, "actions"); |
@@ -74,66 +74,66 @@ discard block |
||
74 | 74 | * @param int $index |
75 | 75 | * @return HtmlButton |
76 | 76 | */ |
77 | - public function getAction($index){ |
|
77 | + public function getAction($index) { |
|
78 | 78 | return $this->content["actions"]->getContent()[$index]; |
79 | 79 | } |
80 | 80 | |
81 | - public function addContent($content,$before=false){ |
|
82 | - $this->content["content"]->addContent($content,$before); |
|
81 | + public function addContent($content, $before=false) { |
|
82 | + $this->content["content"]->addContent($content, $before); |
|
83 | 83 | return $this; |
84 | 84 | } |
85 | 85 | |
86 | - public function addImageContent($image,$description=NULL){ |
|
86 | + public function addImageContent($image, $description=NULL) { |
|
87 | 87 | $content=$this->content["content"]; |
88 | - if(isset($description)){ |
|
89 | - $description=new HtmlSemDoubleElement("description-".$this->identifier,"div","description",$description); |
|
90 | - $content->addContent($description,true); |
|
88 | + if (isset($description)) { |
|
89 | + $description=new HtmlSemDoubleElement("description-".$this->identifier, "div", "description", $description); |
|
90 | + $content->addContent($description, true); |
|
91 | 91 | } |
92 | - if($image!==""){ |
|
93 | - $img=new HtmlImage("image-".$this->identifier,$image,"","medium"); |
|
94 | - $content->addContent($img,true); |
|
95 | - $content->addToProperty("class","image"); |
|
92 | + if ($image!=="") { |
|
93 | + $img=new HtmlImage("image-".$this->identifier, $image, "", "medium"); |
|
94 | + $content->addContent($img, true); |
|
95 | + $content->addToProperty("class", "image"); |
|
96 | 96 | } |
97 | 97 | return $this; |
98 | 98 | } |
99 | 99 | |
100 | - public function addIconContent($icon,$description=NULL){ |
|
100 | + public function addIconContent($icon, $description=NULL) { |
|
101 | 101 | $content=$this->content["content"]; |
102 | - if(isset($description)){ |
|
103 | - $description=new HtmlSemDoubleElement("description-".$this->identifier,"div","description",$description); |
|
104 | - $content->addContent($description,true); |
|
102 | + if (isset($description)) { |
|
103 | + $description=new HtmlSemDoubleElement("description-".$this->identifier, "div", "description", $description); |
|
104 | + $content->addContent($description, true); |
|
105 | 105 | } |
106 | - if($icon!==""){ |
|
107 | - $img=new HtmlIcon("image-".$this->identifier,$icon); |
|
108 | - $content->addContent($img,true); |
|
109 | - $content->addToProperty("class","image"); |
|
106 | + if ($icon!=="") { |
|
107 | + $img=new HtmlIcon("image-".$this->identifier, $icon); |
|
108 | + $content->addContent($img, true); |
|
109 | + $content->addToProperty("class", "image"); |
|
110 | 110 | } |
111 | 111 | return $this; |
112 | 112 | } |
113 | 113 | |
114 | - private function addElementInPart($element,$part) { |
|
114 | + private function addElementInPart($element, $part) { |
|
115 | 115 | $this->content[$part]->addContent($element); |
116 | 116 | return $element; |
117 | 117 | } |
118 | 118 | |
119 | - public function showDimmer($value){ |
|
120 | - $value=$value?"show":"hide"; |
|
119 | + public function showDimmer($value) { |
|
120 | + $value=$value ? "show" : "hide"; |
|
121 | 121 | $this->_paramParts[]=["'".$value." dimmer'"]; |
122 | 122 | return $this; |
123 | 123 | } |
124 | 124 | |
125 | - public function setInverted($recursive=true){ |
|
125 | + public function setInverted($recursive=true) { |
|
126 | 126 | $this->_params["inverted"]=true; |
127 | 127 | return $this; |
128 | 128 | } |
129 | 129 | |
130 | - public function setBasic(){ |
|
130 | + public function setBasic() { |
|
131 | 131 | return $this->addToProperty("class", "basic"); |
132 | 132 | } |
133 | 133 | |
134 | 134 | |
135 | - public function setTransition($value){ |
|
136 | - $this->_paramParts[]=["'setting'","'transition'","'".$value."'"]; |
|
135 | + public function setTransition($value) { |
|
136 | + $this->_paramParts[]=["'setting'", "'transition'", "'".$value."'"]; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * @param string $viewName |
144 | 144 | * @param array $params The parameters to pass to the view |
145 | 145 | */ |
146 | - public function renderView(JsUtils $js,$initialController,$viewName, $params=array()) { |
|
147 | - return $this->setContent($js->renderContent($initialController, $viewName,$params)); |
|
146 | + public function renderView(JsUtils $js, $initialController, $viewName, $params=array()) { |
|
147 | + return $this->setContent($js->renderContent($initialController, $viewName, $params)); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | * @param string $actionName the action name |
156 | 156 | * @param array $params |
157 | 157 | */ |
158 | - public function forward(JsUtils $js,$initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
159 | - return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName,$params)); |
|
158 | + public function forward(JsUtils $js, $initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
159 | + return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName, $params)); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile() |
167 | 167 | */ |
168 | 168 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
169 | - $this->content=JArray::sortAssociative($this->content, ["header","content","actions" ]); |
|
170 | - if(isset($this->_params["inverted"]) && $this->_params["inverted"]){ |
|
169 | + $this->content=JArray::sortAssociative($this->content, ["header", "content", "actions"]); |
|
170 | + if (isset($this->_params["inverted"]) && $this->_params["inverted"]) { |
|
171 | 171 | parent::setInverted(true); |
172 | 172 | } |
173 | 173 | return parent::compile($js, $view); |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | * @see BaseHtml::run() |
178 | 178 | */ |
179 | 179 | public function run(JsUtils $js) { |
180 | - if(isset($this->_bsComponent)===false) |
|
181 | - $this->_bsComponent=$js->semantic()->modal("#".$this->identifier,$this->_params,$this->_paramParts); |
|
180 | + if (isset($this->_bsComponent)===false) |
|
181 | + $this->_bsComponent=$js->semantic()->modal("#".$this->identifier, $this->_params, $this->_paramParts); |
|
182 | 182 | $this->addEventsOnRun($js); |
183 | 183 | return $this->_bsComponent; |
184 | 184 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | return $this->jsDo("hide"); |
192 | 192 | } |
193 | 193 | |
194 | - public function onHidden($js){ |
|
194 | + public function onHidden($js) { |
|
195 | 195 | $this->_params["onHidden"]=$js; |
196 | 196 | } |
197 | 197 | } |
@@ -24,39 +24,39 @@ discard block |
||
24 | 24 | private $_inverted; |
25 | 25 | |
26 | 26 | public function __construct($identifier, $modelInstance=NULL) { |
27 | - parent::__construct($identifier, null,$modelInstance); |
|
27 | + parent::__construct($identifier, null, $modelInstance); |
|
28 | 28 | $this->_form=new HtmlForm($identifier); |
29 | 29 | $this->_init(new FormInstanceViewer($identifier), "form", $this->_form, true); |
30 | 30 | } |
31 | 31 | |
32 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
32 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
33 | 33 | return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier(); |
34 | 34 | } |
35 | 35 | |
36 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
37 | - if(!$this->_generated){ |
|
36 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
37 | + if (!$this->_generated) { |
|
38 | 38 | $this->_instanceViewer->setInstance($this->_modelInstance); |
39 | 39 | |
40 | 40 | $form=$this->content["form"]; |
41 | 41 | $this->_generateContent($form); |
42 | 42 | |
43 | - if(isset($this->_toolbar)){ |
|
43 | + if (isset($this->_toolbar)) { |
|
44 | 44 | $this->_setToolbarPosition($form); |
45 | 45 | } |
46 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
47 | - if($this->_inverted){ |
|
46 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
47 | + if ($this->_inverted) { |
|
48 | 48 | $this->content['form']->setInverted(true); |
49 | 49 | } |
50 | 50 | $this->_generated=true; |
51 | 51 | } |
52 | - return parent::compile($js,$view); |
|
52 | + return parent::compile($js, $view); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @param HtmlForm $form |
57 | 57 | */ |
58 | - protected function _generateContent($form){ |
|
59 | - $values= $this->_instanceViewer->getValues(); |
|
58 | + protected function _generateContent($form) { |
|
59 | + $values=$this->_instanceViewer->getValues(); |
|
60 | 60 | $count=$this->_instanceViewer->count(); |
61 | 61 | $separators=$this->_instanceViewer->getSeparators(); |
62 | 62 | $headers=$this->_instanceViewer->getHeaders(); |
@@ -64,41 +64,41 @@ discard block |
||
64 | 64 | \sort($separators); |
65 | 65 | $size=\sizeof($separators); |
66 | 66 | $nb=0; |
67 | - if($size===1){ |
|
67 | + if ($size===1) { |
|
68 | 68 | $i=-1; |
69 | - foreach ($values as $v){ |
|
70 | - $this->_generateFields($form, [$v], $headers, $i, $wrappers,$nb++); |
|
69 | + foreach ($values as $v) { |
|
70 | + $this->_generateFields($form, [$v], $headers, $i, $wrappers, $nb++); |
|
71 | 71 | $i++; |
72 | 72 | } |
73 | - }else{ |
|
73 | + } else { |
|
74 | 74 | $separators[]=$count; |
75 | - for($i=0;$i<$size;$i++){ |
|
76 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
77 | - $this->_generateFields($form, $fields, $headers, $separators[$i], $wrappers,$nb++); |
|
75 | + for ($i=0; $i<$size; $i++) { |
|
76 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
77 | + $this->_generateFields($form, $fields, $headers, $separators[$i], $wrappers, $nb++); |
|
78 | 78 | } |
79 | 79 | } |
80 | - if($this->_hasRules && !$this->getForm()->hasValidationParams()){ |
|
80 | + if ($this->_hasRules && !$this->getForm()->hasValidationParams()) { |
|
81 | 81 | $this->setValidationParams(["inline"=>true]); |
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | - protected function _generateFields($form,$values,$headers,$sepFirst,$wrappers,$nb){ |
|
85 | + protected function _generateFields($form, $values, $headers, $sepFirst, $wrappers, $nb) { |
|
86 | 86 | $wrapper=null; |
87 | - if(isset($headers[$sepFirst+1])) |
|
88 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
89 | - if(isset($wrappers[$sepFirst+1])){ |
|
87 | + if (isset($headers[$sepFirst+1])) |
|
88 | + $form->addHeader($headers[$sepFirst+1], 4, true); |
|
89 | + if (isset($wrappers[$sepFirst+1])) { |
|
90 | 90 | $wrapper=$wrappers[$sepFirst+1]; |
91 | 91 | } |
92 | - if(\sizeof($values)===1){ |
|
92 | + if (\sizeof($values)===1) { |
|
93 | 93 | $added=$form->addField($values[0]); |
94 | - }elseif(\sizeof($values)>1){ |
|
94 | + }elseif (\sizeof($values)>1) { |
|
95 | 95 | $added=$form->addFields($values); |
96 | - }else |
|
96 | + } else |
|
97 | 97 | return; |
98 | - if(isset($wrapper)){ |
|
99 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
98 | + if (isset($wrapper)) { |
|
99 | + $added->wrap($wrapper[0], $wrapper[1]); |
|
100 | 100 | } |
101 | - $this->execHook("onGenerateFields",$added,$nb); |
|
101 | + $this->execHook("onGenerateFields", $added, $nb); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -106,18 +106,18 @@ discard block |
||
106 | 106 | * the generated field is the first parameter |
107 | 107 | * @param callable $callback the fonction to call when a field is generated |
108 | 108 | */ |
109 | - public function onGenerateField($callback){ |
|
110 | - $this->addHook("onGenerateFields",$callback); |
|
109 | + public function onGenerateField($callback) { |
|
110 | + $this->addHook("onGenerateFields", $callback); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
114 | 114 | * @return HtmlForm |
115 | 115 | */ |
116 | - public function getForm(){ |
|
116 | + public function getForm() { |
|
117 | 117 | return $this->content["form"]; |
118 | 118 | } |
119 | 119 | |
120 | - public function addSeparatorAfter($fieldNum){ |
|
120 | + public function addSeparatorAfter($fieldNum) { |
|
121 | 121 | $fieldNum=$this->_getIndex($fieldNum); |
122 | 122 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
123 | 123 | return $this; |
@@ -132,12 +132,12 @@ discard block |
||
132 | 132 | return $this; |
133 | 133 | } |
134 | 134 | |
135 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
136 | - return $this->_fieldAs(function($id,$name,$value) use ($cssStyle){ |
|
137 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
135 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
136 | + return $this->_fieldAs(function($id, $name, $value) use ($cssStyle){ |
|
137 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
138 | 138 | $button->setProperty("type", "reset"); |
139 | 139 | return $button; |
140 | - }, $index,$attributes); |
|
140 | + }, $index, $attributes); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -156,19 +156,19 @@ discard block |
||
156 | 156 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
157 | 157 | } |
158 | 158 | |
159 | - public function addDividerBefore($index,$title){ |
|
159 | + public function addDividerBefore($index, $title) { |
|
160 | 160 | $index=$this->_getIndex($index); |
161 | 161 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
162 | 162 | return $this; |
163 | 163 | } |
164 | 164 | |
165 | - public function addWrapper($index,$contentBefore,$contentAfter=null){ |
|
165 | + public function addWrapper($index, $contentBefore, $contentAfter=null) { |
|
166 | 166 | $index=$this->_getIndex($index); |
167 | - $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
|
167 | + $this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter); |
|
168 | 168 | return $this; |
169 | 169 | } |
170 | 170 | |
171 | - public function run(JsUtils $js){ |
|
171 | + public function run(JsUtils $js) { |
|
172 | 172 | parent::run($js); |
173 | 173 | } |
174 | 174 |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | |
32 | 32 | public function __construct($identifier, $rowCount, $colCount) { |
33 | 33 | parent::__construct($identifier, "table", "ui table"); |
34 | - $this->content=array (); |
|
34 | + $this->content=array(); |
|
35 | 35 | $this->setRowCount($rowCount, $colCount); |
36 | - $this->_variations=[ Variation::CELLED,Variation::PADDED,Variation::COMPACT ]; |
|
37 | - $this->_compileParts=["thead","tbody","tfoot"]; |
|
36 | + $this->_variations=[Variation::CELLED, Variation::PADDED, Variation::COMPACT]; |
|
37 | + $this->_compileParts=["thead", "tbody", "tfoot"]; |
|
38 | 38 | $this->_afterCompileEvents=[]; |
39 | 39 | } |
40 | 40 | |
@@ -44,17 +44,17 @@ discard block |
||
44 | 44 | * @return HtmlTableContent |
45 | 45 | */ |
46 | 46 | public function getPart($key) { |
47 | - if (\array_key_exists($key, $this->content) === false) { |
|
47 | + if (\array_key_exists($key, $this->content)===false) { |
|
48 | 48 | $this->content[$key]=new HtmlTableContent("", $key); |
49 | - if ($key !== "tbody") { |
|
49 | + if ($key!=="tbody") { |
|
50 | 50 | $this->content[$key]->setRowCount(1, $this->_colCount); |
51 | 51 | } |
52 | 52 | } |
53 | 53 | return $this->content[$key]; |
54 | 54 | } |
55 | 55 | |
56 | - protected function _getFirstPart(){ |
|
57 | - if(isset($this->content["thead"])){ |
|
56 | + protected function _getFirstPart() { |
|
57 | + if (isset($this->content["thead"])) { |
|
58 | 58 | return $this->content["thead"]; |
59 | 59 | } |
60 | 60 | return $this->content["tbody"]; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return boolean |
100 | 100 | */ |
101 | 101 | public function hasPart($key) { |
102 | - return \array_key_exists($key, $this->content) === true; |
|
102 | + return \array_key_exists($key, $this->content)===true; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -259,8 +259,8 @@ discard block |
||
259 | 259 | return $this->colAlign($colIndex, "colLeftFromRight"); |
260 | 260 | } |
261 | 261 | |
262 | - public function setColAlignment($colIndex,$alignment){ |
|
263 | - switch ($alignment){ |
|
262 | + public function setColAlignment($colIndex, $alignment) { |
|
263 | + switch ($alignment) { |
|
264 | 264 | case TextAlignment::LEFT: |
265 | 265 | $function="colLeft"; |
266 | 266 | break; |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | return $this; |
281 | 281 | } |
282 | 282 | |
283 | - public function setColAlignmentFromRight($colIndex,$alignment){ |
|
284 | - switch ($alignment){ |
|
283 | + public function setColAlignmentFromRight($colIndex, $alignment) { |
|
284 | + switch ($alignment) { |
|
285 | 285 | case TextAlignment::LEFT: |
286 | 286 | $function="colLeftFromRight"; |
287 | 287 | break; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | |
304 | 304 | private function colAlign($colIndex, $function) { |
305 | 305 | if (\is_array($colIndex)) { |
306 | - foreach ( $colIndex as $cIndex ) { |
|
306 | + foreach ($colIndex as $cIndex) { |
|
307 | 307 | $this->colAlign($cIndex, $function); |
308 | 308 | } |
309 | 309 | } else { |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * @see HtmlSemDoubleElement::compile() |
365 | 365 | */ |
366 | 366 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
367 | - if(\sizeof($this->_compileParts)<3){ |
|
367 | + if (\sizeof($this->_compileParts)<3) { |
|
368 | 368 | $this->_template="%content%"; |
369 | 369 | $this->refresh($js); |
370 | 370 | } |
@@ -373,9 +373,9 @@ discard block |
||
373 | 373 | } |
374 | 374 | |
375 | 375 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
376 | - parent::compile_once($js,$view); |
|
376 | + parent::compile_once($js, $view); |
|
377 | 377 | if ($this->propertyContains("class", "sortable")) { |
378 | - $this->addEvent("execute", "$('#" . $this->identifier . "').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
378 | + $this->addEvent("execute", "$('#".$this->identifier."').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
@@ -388,13 +388,13 @@ discard block |
||
388 | 388 | public function fromDatabaseObject($object, $function) { |
389 | 389 | $result=$function($object); |
390 | 390 | if (\is_array($result)) { |
391 | - $result= $this->addRow($function($object)); |
|
391 | + $result=$this->addRow($function($object)); |
|
392 | 392 | } else { |
393 | - $result= $this->getBody()->_addRow($result); |
|
393 | + $result=$this->getBody()->_addRow($result); |
|
394 | 394 | } |
395 | - if(isset($this->_afterCompileEvents["onNewRow"])){ |
|
396 | - if(\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
397 | - $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
395 | + if (isset($this->_afterCompileEvents["onNewRow"])) { |
|
396 | + if (\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
397 | + $this->_afterCompileEvents["onNewRow"]($result, $object); |
|
398 | 398 | } |
399 | 399 | return $result; |
400 | 400 | } |
@@ -409,26 +409,26 @@ discard block |
||
409 | 409 | return $this; |
410 | 410 | } |
411 | 411 | |
412 | - public function refreshTR(){ |
|
412 | + public function refreshTR() { |
|
413 | 413 | $this->setCompileParts(); |
414 | 414 | $this->getPart("tbody")->refreshTR(); |
415 | 415 | } |
416 | 416 | |
417 | - public function refresh($js){ |
|
417 | + public function refresh($js) { |
|
418 | 418 | $this->_footer=$this->getFooter(); |
419 | - if(isset($js)){ |
|
420 | - $js->exec('$("#'.$this->identifier.' tfoot").replaceWith("'.\addslashes($this->_footer).'");',true); |
|
419 | + if (isset($js)) { |
|
420 | + $js->exec('$("#'.$this->identifier.' tfoot").replaceWith("'.\addslashes($this->_footer).'");', true); |
|
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
424 | - public function run(JsUtils $js){ |
|
425 | - if(!$this->_runned){ |
|
426 | - if(isset($this->_activeRowSelector)){ |
|
424 | + public function run(JsUtils $js) { |
|
425 | + if (!$this->_runned) { |
|
426 | + if (isset($this->_activeRowSelector)) { |
|
427 | 427 | $this->_activeRowSelector->run(); |
428 | 428 | } |
429 | 429 | } |
430 | - $result= parent::run($js); |
|
431 | - if(isset($this->_footer)) |
|
430 | + $result=parent::run($js); |
|
431 | + if (isset($this->_footer)) |
|
432 | 432 | $this->_footer->run($js); |
433 | 433 | $this->_runned=true; |
434 | 434 | return $result; |
@@ -452,51 +452,51 @@ discard block |
||
452 | 452 | * @param boolean $multiple |
453 | 453 | * @return HtmlTable |
454 | 454 | */ |
455 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
456 | - $this->_activeRowSelector=new ActiveRow($this,$class,$event,$multiple); |
|
455 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
456 | + $this->_activeRowSelector=new ActiveRow($this, $class, $event, $multiple); |
|
457 | 457 | return $this; |
458 | 458 | } |
459 | 459 | |
460 | - public function hasActiveRowSelector(){ |
|
460 | + public function hasActiveRowSelector() { |
|
461 | 461 | return isset($this->_activeRowSelector); |
462 | 462 | } |
463 | 463 | |
464 | - public function hideColumn($colIndex){ |
|
465 | - if(isset($this->content["thead"])){ |
|
464 | + public function hideColumn($colIndex) { |
|
465 | + if (isset($this->content["thead"])) { |
|
466 | 466 | $this->content["thead"]->hideColumn($colIndex); |
467 | 467 | } |
468 | 468 | $this->content["tbody"]->hideColumn($colIndex); |
469 | - if(isset($this->content["tfoot"])){ |
|
469 | + if (isset($this->content["tfoot"])) { |
|
470 | 470 | $this->content["tfoot"]->hideColumn($colIndex); |
471 | 471 | } |
472 | 472 | return $this; |
473 | 473 | } |
474 | 474 | |
475 | - public function setColWidth($colIndex,$width){ |
|
475 | + public function setColWidth($colIndex, $width) { |
|
476 | 476 | $part=$this->_getFirstPart(); |
477 | - if($part!==null && $part->count()>0) |
|
477 | + if ($part!==null && $part->count()>0) |
|
478 | 478 | $part->getCell(0, $colIndex)->setWidth($width); |
479 | 479 | return $this; |
480 | 480 | } |
481 | 481 | |
482 | - public function setColWidths($widths){ |
|
482 | + public function setColWidths($widths) { |
|
483 | 483 | $part=$this->_getFirstPart(); |
484 | - if($part!==null && $part->count()>0){ |
|
484 | + if ($part!==null && $part->count()>0) { |
|
485 | 485 | $count=$part->getColCount(); |
486 | - if(!\is_array($widths)){ |
|
486 | + if (!\is_array($widths)) { |
|
487 | 487 | $widths=\array_fill(0, $count, $widths); |
488 | 488 | } |
489 | - $max=\min(\sizeof($widths),$count); |
|
490 | - for($i=0;$i<$max;$i++){ |
|
489 | + $max=\min(\sizeof($widths), $count); |
|
490 | + for ($i=0; $i<$max; $i++) { |
|
491 | 491 | $part->getCell(0, $i)->setWidth($widths[$i]); |
492 | 492 | } |
493 | 493 | } |
494 | 494 | return $this; |
495 | 495 | } |
496 | 496 | |
497 | - public function mergeIdentiqualValues($colIndex,$function="strip_tags"){ |
|
497 | + public function mergeIdentiqualValues($colIndex, $function="strip_tags") { |
|
498 | 498 | $body=$this->getBody(); |
499 | - $body->mergeIdentiqualValues($colIndex,$function); |
|
499 | + $body->mergeIdentiqualValues($colIndex, $function); |
|
500 | 500 | return $this; |
501 | 501 | } |
502 | 502 | /** |
@@ -510,16 +510,16 @@ discard block |
||
510 | 510 | * @param mixed $_innerScript |
511 | 511 | */ |
512 | 512 | public function setInnerScript($_innerScript) { |
513 | - $this->_innerScript = $_innerScript; |
|
513 | + $this->_innerScript=$_innerScript; |
|
514 | 514 | } |
515 | 515 | |
516 | - public function onActiveRowChange($jsCode){ |
|
517 | - $this->on("activeRowChange",$jsCode); |
|
516 | + public function onActiveRowChange($jsCode) { |
|
517 | + $this->on("activeRowChange", $jsCode); |
|
518 | 518 | return $this; |
519 | 519 | } |
520 | 520 | |
521 | - public function addMergeRow($colCount,$value=null){ |
|
522 | - return $this->getBody()->addMergeRow($colCount,$value); |
|
521 | + public function addMergeRow($colCount, $value=null) { |
|
522 | + return $this->getBody()->addMergeRow($colCount, $value); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | */ |
27 | 27 | class DataTable extends Widget { |
28 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait; |
|
28 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait; |
|
29 | 29 | |
30 | 30 | protected $_searchField; |
31 | 31 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | protected $_displayBehavior; |
43 | 43 | |
44 | - protected $_visibleHover = false; |
|
44 | + protected $_visibleHover=false; |
|
45 | 45 | |
46 | 46 | protected $_targetSelector; |
47 | 47 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | protected $_json; |
53 | 53 | |
54 | - protected $_rowClass = "_element"; |
|
54 | + protected $_rowClass="_element"; |
|
55 | 55 | |
56 | 56 | protected $_sortable; |
57 | 57 | |
@@ -61,26 +61,26 @@ discard block |
||
61 | 61 | |
62 | 62 | protected $_paginationToolbar; |
63 | 63 | |
64 | - public function __construct($identifier, $model, $modelInstance = NULL) { |
|
64 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
65 | 65 | parent::__construct($identifier, $model, $modelInstance); |
66 | 66 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
67 | - $this->_urls = []; |
|
68 | - $this->_emptyMessage = new HtmlMessage("", "nothing to display"); |
|
67 | + $this->_urls=[]; |
|
68 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
69 | 69 | $this->_emptyMessage->setIcon("info circle"); |
70 | 70 | } |
71 | 71 | |
72 | 72 | public function run(JsUtils $js) { |
73 | - if ($this->_runned !== true) { |
|
74 | - $offset = $js->scriptCount(); |
|
73 | + if ($this->_runned!==true) { |
|
74 | + $offset=$js->scriptCount(); |
|
75 | 75 | if ($this->_hasCheckboxes && isset($js)) { |
76 | 76 | $this->_runCheckboxes($js); |
77 | 77 | } |
78 | 78 | if ($this->_visibleHover) { |
79 | - $js->execOn("mouseover", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [ |
|
79 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [ |
|
80 | 80 | "preventDefault" => false, |
81 | 81 | "stopPropagation" => true |
82 | 82 | ]); |
83 | - $js->execOn("mouseout", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [ |
|
83 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [ |
|
84 | 84 | "preventDefault" => false, |
85 | 85 | "stopPropagation" => true |
86 | 86 | ]); |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | if (isset($this->_pagination)) |
97 | 97 | $this->_associatePaginationBehavior($js, $offset); |
98 | 98 | $this->_associateSearchFieldBehavior($js, $offset); |
99 | - $this->_runned = true; |
|
99 | + $this->_runned=true; |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | 103 | protected function _generateBehavior($op, $params, JsUtils $js) { |
104 | 104 | if (isset($this->_urls[$op])) { |
105 | - $params = \array_merge($params, [ |
|
105 | + $params=\array_merge($params, [ |
|
106 | 106 | "attr" => "data-ajax" |
107 | 107 | ]); |
108 | - $js->ajaxOnClick("#" . $this->identifier . " ._" . $op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
108 | + $js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
@@ -124,21 +124,21 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | public function refreshTD($fieldName, $jquery, $view) { |
127 | - $index = $this->_getIndex($fieldName); |
|
127 | + $index=$this->_getIndex($fieldName); |
|
128 | 128 | $this->compile($jquery, $view); |
129 | 129 | return $this->refreshTR() |
130 | 130 | ->getTable() |
131 | 131 | ->getCell(0, $index); |
132 | 132 | } |
133 | 133 | |
134 | - public function compile(JsUtils $js = NULL, &$view = NULL) { |
|
135 | - if (! $this->_generated) { |
|
134 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
135 | + if (!$this->_generated) { |
|
136 | 136 | if (isset($this->_buttonsColumn)) { |
137 | 137 | $this->_instanceViewer->sortColumnContent($this->_buttonsColumn, $this->_buttons); |
138 | 138 | } |
139 | 139 | $this->_instanceViewer->setInstance($this->_model); |
140 | - $captions = $this->_instanceViewer->getCaptions(); |
|
141 | - $table = $this->content["table"]; |
|
140 | + $captions=$this->_instanceViewer->getCaptions(); |
|
141 | + $table=$this->content["table"]; |
|
142 | 142 | if ($this->_hasCheckboxes) { |
143 | 143 | $this->_generateMainCheckbox($captions); |
144 | 144 | } |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | $this->compileExtraElements($table, $captions); |
154 | 154 | $this->_compileSearchFieldBehavior($js); |
155 | 155 | |
156 | - $this->content = JArray::sortAssociative($this->content, [ |
|
156 | + $this->content=JArray::sortAssociative($this->content, [ |
|
157 | 157 | PositionInTable::BEFORETABLE, |
158 | 158 | "table", |
159 | 159 | PositionInTable::AFTERTABLE |
160 | 160 | ]); |
161 | 161 | $this->_compileForm(); |
162 | 162 | $this->_applyStyleAttributes($table); |
163 | - $this->_generated = true; |
|
163 | + $this->_generated=true; |
|
164 | 164 | } |
165 | 165 | return parent::compile($js, $view); |
166 | 166 | } |
@@ -205,21 +205,21 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | protected function _generateContent($table) { |
208 | - $objects = $this->_modelInstance; |
|
208 | + $objects=$this->_modelInstance; |
|
209 | 209 | if (isset($this->_pagination)) { |
210 | - $objects = $this->_pagination->getObjects($this->_modelInstance); |
|
210 | + $objects=$this->_pagination->getObjects($this->_modelInstance); |
|
211 | 211 | } |
212 | 212 | InstanceViewer::setIndex(0); |
213 | - $fields = $this->_instanceViewer->getSimpleProperties(); |
|
214 | - $groupByFields = $this->_instanceViewer->getGroupByFields(); |
|
215 | - if (! is_array($groupByFields)) { |
|
216 | - $table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields) { |
|
213 | + $fields=$this->_instanceViewer->getSimpleProperties(); |
|
214 | + $groupByFields=$this->_instanceViewer->getGroupByFields(); |
|
215 | + if (!is_array($groupByFields)) { |
|
216 | + $table->fromDatabaseObjects($objects, function($instance) use ($table, $fields) { |
|
217 | 217 | return $this->_generateRow($instance, $fields, $table); |
218 | 218 | }); |
219 | 219 | } else { |
220 | - $activeValues = array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null)); |
|
221 | - $uuids = []; |
|
222 | - $table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids) { |
|
220 | + $activeValues=array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null)); |
|
221 | + $uuids=[]; |
|
222 | + $table->fromDatabaseObjects($objects, function($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids) { |
|
223 | 223 | $this->_instanceViewer->setInstance($instance); |
224 | 224 | foreach ($groupByFields as $index => $gbField) { |
225 | 225 | $this->_generateGroupByRow($index, $gbField, $table, $fields, $activeValues, $uuids); |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | return $this->_generateRow($instance, $fields, $table, null, $uuids); |
228 | 228 | }); |
229 | 229 | } |
230 | - if ($table->getRowCount() == 0) { |
|
231 | - $result = $table->addRow(); |
|
230 | + if ($table->getRowCount()==0) { |
|
231 | + $result=$table->addRow(); |
|
232 | 232 | $result->mergeRow(); |
233 | 233 | $result->setValues([ |
234 | 234 | $this->_emptyMessage |
@@ -237,20 +237,20 @@ discard block |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | protected function _generateGroupByRow($index, $gbField, $table, $fields, &$activeValues, &$uuids) { |
240 | - $newValue = $this->_instanceViewer->getValue($gbField); |
|
241 | - if ($this->getElementContent($activeValues[$gbField]) !== $this->getElementContent($newValue)) { |
|
242 | - if ($index == 0) { |
|
243 | - $uuids = []; |
|
240 | + $newValue=$this->_instanceViewer->getValue($gbField); |
|
241 | + if ($this->getElementContent($activeValues[$gbField])!==$this->getElementContent($newValue)) { |
|
242 | + if ($index==0) { |
|
243 | + $uuids=[]; |
|
244 | 244 | } |
245 | - $uuid = uniqid("grp"); |
|
246 | - $uuids[$gbField] = $uuid; |
|
247 | - $id = $this->_instanceViewer->getIdentifier(); |
|
248 | - $result = $table->addMergeRow(sizeof($fields) + 1, $newValue); |
|
249 | - $result->setIdentifier($this->identifier . "-tr-gb-" . $id); |
|
245 | + $uuid=uniqid("grp"); |
|
246 | + $uuids[$gbField]=$uuid; |
|
247 | + $id=$this->_instanceViewer->getIdentifier(); |
|
248 | + $result=$table->addMergeRow(sizeof($fields)+1, $newValue); |
|
249 | + $result->setIdentifier($this->identifier."-tr-gb-".$id); |
|
250 | 250 | $result->setProperty("data-ajax", $id); |
251 | 251 | $result->setProperty("data-group", $uuid); |
252 | 252 | $result->addToProperty("class", $this->_rowClass); |
253 | - $activeValues[$gbField] = $newValue; |
|
253 | + $activeValues[$gbField]=$newValue; |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | public function getFieldValue($index) { |
265 | - $index = $this->_getIndex($index); |
|
265 | + $index=$this->_getIndex($index); |
|
266 | 266 | if (is_numeric($index)) { |
267 | - $values = $this->_instanceViewer->getValues(); |
|
267 | + $values=$this->_instanceViewer->getValues(); |
|
268 | 268 | if (isset($values[$index])) { |
269 | 269 | return $values[$index]; |
270 | 270 | } |
@@ -272,31 +272,31 @@ discard block |
||
272 | 272 | return null; |
273 | 273 | } |
274 | 274 | |
275 | - protected function _generateRow($instance, $fields, &$table, $checkedClass = null, $uuids = null) { |
|
275 | + protected function _generateRow($instance, $fields, &$table, $checkedClass=null, $uuids=null) { |
|
276 | 276 | $this->_instanceViewer->setInstance($instance); |
277 | - InstanceViewer::$index ++; |
|
278 | - $values = $this->_instanceViewer->getValues(); |
|
279 | - $id = $this->_instanceViewer->getIdentifier(); |
|
280 | - $dataAjax = $id; |
|
281 | - $id = $this->cleanIdentifier($id); |
|
277 | + InstanceViewer::$index++; |
|
278 | + $values=$this->_instanceViewer->getValues(); |
|
279 | + $id=$this->_instanceViewer->getIdentifier(); |
|
280 | + $dataAjax=$id; |
|
281 | + $id=$this->cleanIdentifier($id); |
|
282 | 282 | if ($this->_hasCheckboxes) { |
283 | - $ck = new HtmlCheckbox("ck-" . $this->identifier . "-" . $id, ""); |
|
284 | - $checked = false; |
|
283 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
284 | + $checked=false; |
|
285 | 285 | if (isset($this->_checkedCallback)) { |
286 | - $func = $this->_checkedCallback; |
|
287 | - $checked = $func($instance); |
|
286 | + $func=$this->_checkedCallback; |
|
287 | + $checked=$func($instance); |
|
288 | 288 | } |
289 | 289 | $ck->setChecked($checked); |
290 | 290 | // $ck->setOnChange("event.stopPropagation();"); |
291 | - $field = $ck->getField(); |
|
291 | + $field=$ck->getField(); |
|
292 | 292 | $field->setProperty("value", $dataAjax); |
293 | 293 | $field->setProperty("name", "selection[]"); |
294 | 294 | if (isset($checkedClass)) |
295 | 295 | $field->setClass($checkedClass); |
296 | 296 | \array_unshift($values, $ck); |
297 | 297 | } |
298 | - $result = $table->newRow(); |
|
299 | - $result->setIdentifier($this->identifier . "-tr-" . $id); |
|
298 | + $result=$table->newRow(); |
|
299 | + $result->setIdentifier($this->identifier."-tr-".$id); |
|
300 | 300 | $result->setProperty("data-ajax", $dataAjax); |
301 | 301 | $result->setValues($values); |
302 | 302 | $result->addToProperty("class", $this->_rowClass); |
@@ -309,63 +309,63 @@ discard block |
||
309 | 309 | |
310 | 310 | protected function _generatePagination($table) { |
311 | 311 | if (isset($this->_toolbar)) { |
312 | - if ($this->_toolbarPosition == PositionInTable::FOOTER) |
|
312 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
313 | 313 | $this->_toolbar->setFloated("left"); |
314 | 314 | } |
315 | - $footer = $table->getFooter(); |
|
315 | + $footer=$table->getFooter(); |
|
316 | 316 | $footer->mergeCol(); |
317 | 317 | $this->_paginationToolbar=$this->_pagination->generateMenu($this->identifier); |
318 | 318 | $footer->addValues($this->_paginationToolbar); |
319 | 319 | } |
320 | 320 | |
321 | - protected function _associatePaginationBehavior(JsUtils $js = NULL, $offset = null) { |
|
321 | + protected function _associatePaginationBehavior(JsUtils $js=NULL, $offset=null) { |
|
322 | 322 | if (isset($this->_urls["refresh"])) { |
323 | - $menu = $this->_pagination->getMenu(); |
|
323 | + $menu=$this->_pagination->getMenu(); |
|
324 | 324 | if (isset($menu) && isset($js)) { |
325 | - $js->postOnClick("#" . $menu->getIdentifier() . " .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", $this->getRefreshSelector(), [ |
|
325 | + $js->postOnClick("#".$menu->getIdentifier()." .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model)."'}", $this->getRefreshSelector(), [ |
|
326 | 326 | "preventDefault" => false, |
327 | 327 | "jqueryDone" => "replaceWith", |
328 | 328 | "hasLoader" => false, |
329 | - "jsCallback" => '$("#' . $this->identifier . '").trigger("pageChange");$("#' . $this->identifier . '").trigger("activeRowChange");' |
|
329 | + "jsCallback" => '$("#'.$this->identifier.'").trigger("pageChange");$("#'.$this->identifier.'").trigger("activeRowChange");' |
|
330 | 330 | ]); |
331 | - $page = $_POST["p"] ?? null; |
|
331 | + $page=$_POST["p"] ?? null; |
|
332 | 332 | if (isset($page)) { |
333 | - $js->execAtLast('$("#' . $this->getIdentifier() . ' .pagination").children("a.item").removeClass("active");$("#' . $this->getIdentifier() . ' .pagination").children("a.item[data-page=' . $page . ']:not(.no-active)").addClass("active");'); |
|
333 | + $js->execAtLast('$("#'.$this->getIdentifier().' .pagination").children("a.item").removeClass("active");$("#'.$this->getIdentifier().' .pagination").children("a.item[data-page='.$page.']:not(.no-active)").addClass("active");'); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | - protected function _compileSearchFieldBehavior(JsUtils $js = NULL) { |
|
339 | + protected function _compileSearchFieldBehavior(JsUtils $js=NULL) { |
|
340 | 340 | if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) { |
341 | - $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", "#" . $this->identifier . " tbody", [ |
|
341 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'".JString::doubleBackSlashes($this->_model)."'}", "#".$this->identifier." tbody", [ |
|
342 | 342 | "preventDefault" => false, |
343 | 343 | "jqueryDone" => "replaceWith", |
344 | 344 | "hasLoader" => "internal", |
345 | - "jsCallback" => '$("#' . $this->identifier . '").trigger("searchTerminate",[$(self).val()]);' |
|
345 | + "jsCallback" => '$("#'.$this->identifier.'").trigger("searchTerminate",[$(self).val()]);' |
|
346 | 346 | ]); |
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | - protected function _associateSearchFieldBehavior(JsUtils $js = NULL, $offset = null) {} |
|
350 | + protected function _associateSearchFieldBehavior(JsUtils $js=NULL, $offset=null) {} |
|
351 | 351 | |
352 | 352 | protected function _getFieldName($index) { |
353 | - $fieldName = parent::_getFieldName($index); |
|
353 | + $fieldName=parent::_getFieldName($index); |
|
354 | 354 | if (\is_object($fieldName)) |
355 | - $fieldName = "field-" . $index; |
|
356 | - return $fieldName . "[]"; |
|
355 | + $fieldName="field-".$index; |
|
356 | + return $fieldName."[]"; |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | protected function _getFieldCaption($index) { |
360 | 360 | return null; |
361 | 361 | } |
362 | 362 | |
363 | - protected function _setToolbarPosition($table, $captions = NULL) { |
|
363 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
364 | 364 | switch ($this->_toolbarPosition) { |
365 | 365 | case PositionInTable::BEFORETABLE: |
366 | 366 | case PositionInTable::AFTERTABLE: |
367 | - if (isset($this->_compileParts) === false) { |
|
368 | - $this->content[$this->_toolbarPosition] = $this->_toolbar; |
|
367 | + if (isset($this->_compileParts)===false) { |
|
368 | + $this->content[$this->_toolbarPosition]=$this->_toolbar; |
|
369 | 369 | } |
370 | 370 | break; |
371 | 371 | case PositionInTable::HEADER: |
@@ -392,11 +392,11 @@ discard block |
||
392 | 392 | } |
393 | 393 | |
394 | 394 | private function addToolbarRow($part, $table, $captions) { |
395 | - $hasPart = $table->hasPart($part); |
|
395 | + $hasPart=$table->hasPart($part); |
|
396 | 396 | if ($hasPart) { |
397 | - $row = $table->getPart($part)->addRow(\sizeof($captions)); |
|
397 | + $row=$table->getPart($part)->addRow(\sizeof($captions)); |
|
398 | 398 | } else { |
399 | - $row = $table->getPart($part)->getRow(0); |
|
399 | + $row=$table->getPart($part)->getRow(0); |
|
400 | 400 | } |
401 | 401 | $row->mergeCol(); |
402 | 402 | $row->setValues([ |
@@ -428,12 +428,12 @@ discard block |
||
428 | 428 | */ |
429 | 429 | public function setUrls($urls) { |
430 | 430 | if (\is_array($urls)) { |
431 | - $this->_urls["refresh"] = JArray::getValue($urls, "refresh", 0); |
|
432 | - $this->_urls["edit"] = JArray::getValue($urls, "edit", 1); |
|
433 | - $this->_urls["delete"] = JArray::getValue($urls, "delete", 2); |
|
434 | - $this->_urls["display"] = JArray::getValue($urls, "display", 3); |
|
431 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
432 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
433 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
434 | + $this->_urls["display"]=JArray::getValue($urls, "display", 3); |
|
435 | 435 | } else { |
436 | - $this->_urls = [ |
|
436 | + $this->_urls=[ |
|
437 | 437 | "refresh" => $urls, |
438 | 438 | "edit" => $urls, |
439 | 439 | "delete" => $urls, |
@@ -456,8 +456,8 @@ discard block |
||
456 | 456 | * The number of visible pages in the Pagination component |
457 | 457 | * @return DataTable |
458 | 458 | */ |
459 | - public function paginate($page, $total_rowcount, $items_per_page = 10, $pages_visibles = null) { |
|
460 | - $this->_pagination = new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
459 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
460 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
461 | 461 | return $this; |
462 | 462 | } |
463 | 463 | |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | * The number of visible pages in the Pagination component |
473 | 473 | * @return DataTable |
474 | 474 | */ |
475 | - public function autoPaginate($page = 1, $items_per_page = 10, $pages_visibles = 4) { |
|
476 | - $this->_pagination = new Pagination($items_per_page, $pages_visibles, $page); |
|
475 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
476 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
477 | 477 | return $this; |
478 | 478 | } |
479 | 479 | |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | * @param array $compileParts |
483 | 483 | * @return DataTable |
484 | 484 | */ |
485 | - public function refresh($compileParts = ['tbody']) { |
|
486 | - $this->_compileParts = $compileParts; |
|
485 | + public function refresh($compileParts=['tbody']) { |
|
486 | + $this->_compileParts=$compileParts; |
|
487 | 487 | return $this; |
488 | 488 | } |
489 | 489 | |
@@ -493,14 +493,14 @@ discard block |
||
493 | 493 | * @param string $position |
494 | 494 | * @return \Ajax\common\html\HtmlDoubleElement |
495 | 495 | */ |
496 | - public function addSearchInToolbar($position = Direction::RIGHT) { |
|
496 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
497 | 497 | return $this->addInToolbar($this->getSearchField()) |
498 | 498 | ->setPosition($position); |
499 | 499 | } |
500 | 500 | |
501 | 501 | public function getSearchField() { |
502 | - if (isset($this->_searchField) === false) { |
|
503 | - $this->_searchField = new HtmlInput("search-" . $this->identifier, "search", "", "Search..."); |
|
502 | + if (isset($this->_searchField)===false) { |
|
503 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
504 | 504 | $this->_searchField->addIcon("search", Direction::RIGHT); |
505 | 505 | } |
506 | 506 | return $this->_searchField; |
@@ -528,9 +528,9 @@ discard block |
||
528 | 528 | } |
529 | 529 | |
530 | 530 | protected function getTargetSelector($op) { |
531 | - $result = $this->_targetSelector; |
|
532 | - if (! isset($result[$op])) |
|
533 | - $result = "#" . $this->identifier; |
|
531 | + $result=$this->_targetSelector; |
|
532 | + if (!isset($result[$op])) |
|
533 | + $result="#".$this->identifier; |
|
534 | 534 | return $result[$op]; |
535 | 535 | } |
536 | 536 | |
@@ -542,20 +542,20 @@ discard block |
||
542 | 542 | * @return DataTable |
543 | 543 | */ |
544 | 544 | public function setTargetSelector($_targetSelector) { |
545 | - if (! \is_array($_targetSelector)) { |
|
546 | - $_targetSelector = [ |
|
545 | + if (!\is_array($_targetSelector)) { |
|
546 | + $_targetSelector=[ |
|
547 | 547 | "edit" => $_targetSelector, |
548 | 548 | "delete" => $_targetSelector |
549 | 549 | ]; |
550 | 550 | } |
551 | - $this->_targetSelector = $_targetSelector; |
|
551 | + $this->_targetSelector=$_targetSelector; |
|
552 | 552 | return $this; |
553 | 553 | } |
554 | 554 | |
555 | 555 | public function getRefreshSelector() { |
556 | 556 | if (isset($this->_refreshSelector)) |
557 | 557 | return $this->_refreshSelector; |
558 | - return "#" . $this->identifier . " tbody"; |
|
558 | + return "#".$this->identifier." tbody"; |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | /** |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | * @return DataTable |
565 | 565 | */ |
566 | 566 | public function setRefreshSelector($_refreshSelector) { |
567 | - $this->_refreshSelector = $_refreshSelector; |
|
567 | + $this->_refreshSelector=$_refreshSelector; |
|
568 | 568 | return $this; |
569 | 569 | } |
570 | 570 | |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | public function show($modelInstance) { |
577 | 577 | if (\is_array($modelInstance)) { |
578 | 578 | if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
579 | - $modelInstance = \json_decode(\json_encode($modelInstance), FALSE); |
|
579 | + $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
580 | 580 | } |
581 | - $this->_modelInstance = $modelInstance; |
|
581 | + $this->_modelInstance=$modelInstance; |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | public function getRowClass() { |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | * @return DataTable |
593 | 593 | */ |
594 | 594 | public function setRowClass($_rowClass) { |
595 | - $this->_rowClass = $_rowClass; |
|
595 | + $this->_rowClass=$_rowClass; |
|
596 | 596 | return $this; |
597 | 597 | } |
598 | 598 | |
@@ -603,38 +603,38 @@ discard block |
||
603 | 603 | * @return DataTable |
604 | 604 | */ |
605 | 605 | public function setEmptyMessage($_emptyMessage) { |
606 | - $this->_emptyMessage = $_emptyMessage; |
|
606 | + $this->_emptyMessage=$_emptyMessage; |
|
607 | 607 | return $this; |
608 | 608 | } |
609 | 609 | |
610 | - public function setSortable($colIndex = NULL) { |
|
611 | - $this->_sortable = $colIndex; |
|
610 | + public function setSortable($colIndex=NULL) { |
|
611 | + $this->_sortable=$colIndex; |
|
612 | 612 | return $this; |
613 | 613 | } |
614 | 614 | |
615 | - public function setActiveRowSelector($class = "active", $event = "click", $multiple = false) { |
|
615 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
616 | 616 | $this->_self->setActiveRowSelector($class, $event, $multiple); |
617 | 617 | return $this; |
618 | 618 | } |
619 | 619 | |
620 | - public function hasActiveRowSelector(){ |
|
620 | + public function hasActiveRowSelector() { |
|
621 | 621 | return $this->_self->hasActiveRowSelector(); |
622 | 622 | } |
623 | 623 | |
624 | 624 | public function hideColumn($colIndex) { |
625 | - if (! \is_array($this->_hiddenColumns)) |
|
626 | - $this->_hiddenColumns = []; |
|
627 | - $this->_hiddenColumns[] = $colIndex; |
|
625 | + if (!\is_array($this->_hiddenColumns)) |
|
626 | + $this->_hiddenColumns=[]; |
|
627 | + $this->_hiddenColumns[]=$colIndex; |
|
628 | 628 | return $this; |
629 | 629 | } |
630 | 630 | |
631 | 631 | public function setColWidth($colIndex, $width) { |
632 | - $this->_colWidths[$colIndex] = $width; |
|
632 | + $this->_colWidths[$colIndex]=$width; |
|
633 | 633 | return $this; |
634 | 634 | } |
635 | 635 | |
636 | 636 | public function setColWidths($_colWidths) { |
637 | - $this->_colWidths = $_colWidths; |
|
637 | + $this->_colWidths=$_colWidths; |
|
638 | 638 | return $this; |
639 | 639 | } |
640 | 640 | |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | return $this; |
644 | 644 | } |
645 | 645 | |
646 | - public function trigger($event, $params = "[]") { |
|
646 | + public function trigger($event, $params="[]") { |
|
647 | 647 | return $this->getHtmlComponent()->trigger($event, $params); |
648 | 648 | } |
649 | 649 | |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | * @param mixed $_displayBehavior |
682 | 682 | */ |
683 | 683 | public function setDisplayBehavior($_displayBehavior) { |
684 | - $this->_displayBehavior = $_displayBehavior; |
|
684 | + $this->_displayBehavior=$_displayBehavior; |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | /** |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | * @param boolean $_visibleHover |
706 | 706 | */ |
707 | 707 | public function setVisibleHover($_visibleHover) { |
708 | - $this->_visibleHover = $_visibleHover; |
|
708 | + $this->_visibleHover=$_visibleHover; |
|
709 | 709 | } |
710 | 710 | /** |
711 | 711 | * @return \Ajax\semantic\html\collections\menus\HtmlPaginationMenu |
@@ -714,9 +714,9 @@ discard block |
||
714 | 714 | return $this->_paginationToolbar; |
715 | 715 | } |
716 | 716 | |
717 | - public function setInverted($recursive=true){ |
|
717 | + public function setInverted($recursive=true) { |
|
718 | 718 | $this->getHtmlComponent()->setInverted($recursive); |
719 | - if($this->_emptyMessage instanceof HtmlSemDoubleElement){ |
|
719 | + if ($this->_emptyMessage instanceof HtmlSemDoubleElement) { |
|
720 | 720 | $this->_emptyMessage->setInverted($recursive); |
721 | 721 | } |
722 | 722 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | trait FieldAsTrait { |
38 | 38 | |
39 | - abstract protected function _getFieldIdentifier($prefix, $name = ""); |
|
39 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
40 | 40 | |
41 | 41 | abstract public function setValueFunction($index, $callback); |
42 | 42 | |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | |
45 | 45 | abstract protected function _getFieldCaption($index); |
46 | 46 | |
47 | - abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement = NULL, $parameters = NULL); |
|
47 | + abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * |
51 | 51 | * @param HtmlFormField $element |
52 | 52 | * @param array $attributes |
53 | 53 | */ |
54 | - protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance = null) { |
|
54 | + protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance=null) { |
|
55 | 55 | if (isset($attributes["jsCallback"])) { |
56 | - $callback = $attributes["jsCallback"]; |
|
56 | + $callback=$attributes["jsCallback"]; |
|
57 | 57 | if (\is_callable($callback)) { |
58 | 58 | $callback($element, $instance, $index, InstanceViewer::$index); |
59 | 59 | } |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | $element->fromArray($attributes); |
65 | 65 | } |
66 | 66 | |
67 | - private function _getLabelField($caption, $icon = NULL) { |
|
68 | - $label = new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
67 | + private function _getLabelField($caption, $icon=NULL) { |
|
68 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
69 | 69 | return $label; |
70 | 70 | } |
71 | 71 | |
72 | 72 | protected function _addRules(HtmlFormField $element, &$attributes) { |
73 | 73 | if (isset($attributes["rules"])) { |
74 | - $this->_hasRules = true; |
|
75 | - $rules = $attributes["rules"]; |
|
74 | + $this->_hasRules=true; |
|
75 | + $rules=$attributes["rules"]; |
|
76 | 76 | if (\is_array($rules)) { |
77 | 77 | $element->addRules($rules); |
78 | 78 | } else { |
@@ -88,62 +88,62 @@ discard block |
||
88 | 88 | return $field; |
89 | 89 | } |
90 | 90 | |
91 | - protected function _fieldAs($elementCallback, &$index, $attributes = NULL, $prefix = null) { |
|
92 | - $this->setValueFunction($index, function ($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix) { |
|
93 | - $caption = $this->_getFieldCaption($index); |
|
94 | - $name = $this->_getFieldName($index); |
|
95 | - $id = $this->_getFieldIdentifier($prefix, $name); |
|
91 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
92 | + $this->setValueFunction($index, function($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix) { |
|
93 | + $caption=$this->_getFieldCaption($index); |
|
94 | + $name=$this->_getFieldName($index); |
|
95 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
96 | 96 | if (isset($attributes["name"])) { |
97 | - $name = $attributes["name"]; |
|
97 | + $name=$attributes["name"]; |
|
98 | 98 | unset($attributes["name"]); |
99 | 99 | } |
100 | - $element = $elementCallback($id, $name, $value, $caption); |
|
100 | + $element=$elementCallback($id, $name, $value, $caption); |
|
101 | 101 | if (\is_array($attributes)) { |
102 | 102 | $this->_applyAttributes($element, $attributes, $index, $instance); |
103 | 103 | } |
104 | - $element->setDisabled(! $this->_edition); |
|
104 | + $element->setDisabled(!$this->_edition); |
|
105 | 105 | return $element; |
106 | 106 | }); |
107 | 107 | return $this; |
108 | 108 | } |
109 | 109 | |
110 | - public function fieldAsProgress($index, $label = NULL, $attributes = array()) { |
|
111 | - $this->setValueFunction($index, function ($value) use ($label, $attributes) { |
|
112 | - $pb = new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
110 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
111 | + $this->setValueFunction($index, function($value) use ($label, $attributes) { |
|
112 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
113 | 113 | return $pb; |
114 | 114 | }); |
115 | 115 | return $this; |
116 | 116 | } |
117 | 117 | |
118 | - public function fieldAsRating($index, $max = 5, $icon = "") { |
|
119 | - $this->setValueFunction($index, function ($value) use ($max, $icon) { |
|
120 | - $rating = new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
118 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
119 | + $this->setValueFunction($index, function($value) use ($max, $icon) { |
|
120 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
121 | 121 | return $rating; |
122 | 122 | }); |
123 | 123 | return $this; |
124 | 124 | } |
125 | 125 | |
126 | - public function fieldAsLabel($index, $icon = NULL, $attributes = NULL) { |
|
127 | - return $this->_fieldAs(function ($id, $name, $value) use ($icon) { |
|
128 | - $lbl = new HtmlLabel($id, $value); |
|
126 | + public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) { |
|
127 | + return $this->_fieldAs(function($id, $name, $value) use ($icon) { |
|
128 | + $lbl=new HtmlLabel($id, $value); |
|
129 | 129 | if (isset($icon)) |
130 | 130 | $lbl->addIcon($icon); |
131 | 131 | return $lbl; |
132 | 132 | }, $index, $attributes, "label"); |
133 | 133 | } |
134 | 134 | |
135 | - public function fieldAsHeader($index, $niveau = 1, $icon = NULL, $attributes = NULL) { |
|
136 | - return $this->_fieldAs(function ($id, $name, $value) use ($niveau, $icon) { |
|
137 | - $header = new HtmlHeader($id, $niveau, $value); |
|
135 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
136 | + return $this->_fieldAs(function($id, $name, $value) use ($niveau, $icon) { |
|
137 | + $header=new HtmlHeader($id, $niveau, $value); |
|
138 | 138 | if (isset($icon)) |
139 | 139 | $header->asIcon($icon, $value); |
140 | 140 | return $header; |
141 | 141 | }, $index, $attributes, "header"); |
142 | 142 | } |
143 | 143 | |
144 | - public function fieldAsImage($index, $size = Size::MINI, $circular = false) { |
|
145 | - $this->setValueFunction($index, function ($img) use ($size, $circular) { |
|
146 | - $image = new HtmlImage($this->_getFieldIdentifier("image"), $img); |
|
144 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
145 | + $this->setValueFunction($index, function($img) use ($size, $circular) { |
|
146 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); |
|
147 | 147 | $image->setSize($size); |
148 | 148 | if ($circular) |
149 | 149 | $image->setCircular(); |
@@ -153,131 +153,131 @@ discard block |
||
153 | 153 | } |
154 | 154 | |
155 | 155 | public function fieldAsFlag($index) { |
156 | - $this->setValueFunction($index, function ($flag) { |
|
157 | - $flag = new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
156 | + $this->setValueFunction($index, function($flag) { |
|
157 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
158 | 158 | return $flag; |
159 | 159 | }); |
160 | 160 | return $this; |
161 | 161 | } |
162 | 162 | |
163 | 163 | public function fieldAsIcon($index) { |
164 | - $this->setValueFunction($index, function ($icon) { |
|
165 | - $icon = new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
164 | + $this->setValueFunction($index, function($icon) { |
|
165 | + $icon=new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
166 | 166 | return $icon; |
167 | 167 | }); |
168 | 168 | return $this; |
169 | 169 | } |
170 | 170 | |
171 | - public function fieldAsAvatar($index, $attributes = NULL) { |
|
172 | - return $this->_fieldAs(function ($id, $name, $value) { |
|
173 | - $img = new HtmlImage($id, $value); |
|
171 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
172 | + return $this->_fieldAs(function($id, $name, $value) { |
|
173 | + $img=new HtmlImage($id, $value); |
|
174 | 174 | $img->asAvatar(); |
175 | 175 | return $img; |
176 | 176 | }, $index, $attributes, "avatar"); |
177 | 177 | } |
178 | 178 | |
179 | - public function fieldAsRadio($index, $attributes = NULL) { |
|
180 | - return $this->_fieldAs(function ($id, $name, $value) use ($attributes) { |
|
181 | - $input = new HtmlFormRadio($id, $name, $value, $value); |
|
179 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
180 | + return $this->_fieldAs(function($id, $name, $value) use ($attributes) { |
|
181 | + $input=new HtmlFormRadio($id, $name, $value, $value); |
|
182 | 182 | return $this->_prepareFormFields($input, $name, $attributes); |
183 | 183 | }, $index, $attributes, "radio"); |
184 | 184 | } |
185 | 185 | |
186 | - public function fieldAsRadios($index, $elements = [], $attributes = NULL) { |
|
187 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($elements) { |
|
186 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
187 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements) { |
|
188 | 188 | return HtmlFormFields::radios($name, $elements, $caption, $value); |
189 | 189 | }, $index, $attributes, "radios"); |
190 | 190 | } |
191 | 191 | |
192 | - public function fieldAsList($index, $classNames = "", $attributes = NULL) { |
|
193 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($classNames) { |
|
194 | - $result = new HtmlList($name, $value); |
|
192 | + public function fieldAsList($index, $classNames="", $attributes=NULL) { |
|
193 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($classNames) { |
|
194 | + $result=new HtmlList($name, $value); |
|
195 | 195 | $result->addClass($classNames); |
196 | 196 | return $result; |
197 | 197 | }, $index, $attributes, "list"); |
198 | 198 | } |
199 | 199 | |
200 | - public function fieldAsInput($index, $attributes = NULL) { |
|
201 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
202 | - $input = new HtmlFormInput($id, $caption, "text", $value); |
|
200 | + public function fieldAsInput($index, $attributes=NULL) { |
|
201 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
202 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
203 | 203 | return $this->_prepareFormFields($input, $name, $attributes); |
204 | 204 | }, $index, $attributes, "input"); |
205 | 205 | } |
206 | 206 | |
207 | - public function fieldAsDataList($index, ?array $items = [], $attributes = NULL) { |
|
208 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes, $items) { |
|
209 | - $input = new HtmlFormInput($id, $caption, "text", $value); |
|
207 | + public function fieldAsDataList($index, ?array $items=[], $attributes=NULL) { |
|
208 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $items) { |
|
209 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
210 | 210 | $input->getField() |
211 | 211 | ->addDataList($items); |
212 | 212 | return $this->_prepareFormFields($input, $name, $attributes); |
213 | 213 | }, $index, $attributes, "input"); |
214 | 214 | } |
215 | 215 | |
216 | - public function fieldAsFile($index, $attributes = NULL) { |
|
216 | + public function fieldAsFile($index, $attributes=NULL) { |
|
217 | 217 | if (isset($this->_form)) { |
218 | 218 | $this->_form->setProperty('enctype', 'multipart/form-data'); |
219 | 219 | } |
220 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
221 | - $input = new HtmlFormInput($id, $caption); |
|
220 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
221 | + $input=new HtmlFormInput($id, $caption); |
|
222 | 222 | $input->asFile(); |
223 | 223 | return $this->_prepareFormFields($input, $name, $attributes); |
224 | 224 | }, $index, $attributes, "input"); |
225 | 225 | } |
226 | 226 | |
227 | - public function fieldAsTextarea($index, $attributes = NULL) { |
|
228 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
229 | - $textarea = new HtmlFormTextarea($id, $caption, $value); |
|
227 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
228 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
229 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
230 | 230 | return $this->_prepareFormFields($textarea, $name, $attributes); |
231 | 231 | }, $index, $attributes, "textarea"); |
232 | 232 | } |
233 | 233 | |
234 | - public function fieldAsElement($index, $tagName = "div", $baseClass = "", $attributes = NULL) { |
|
235 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass) { |
|
236 | - $div = new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
234 | + public function fieldAsElement($index, $tagName="div", $baseClass="", $attributes=NULL) { |
|
235 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass) { |
|
236 | + $div=new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
237 | 237 | $div->setContent(\htmlentities($value)); |
238 | - $textarea = new HtmlFormField("field-" . $id, $div, $caption); |
|
238 | + $textarea=new HtmlFormField("field-".$id, $div, $caption); |
|
239 | 239 | return $this->_prepareFormFields($textarea, $name, $attributes); |
240 | 240 | }, $index, $attributes, "element"); |
241 | 241 | } |
242 | 242 | |
243 | - public function fieldAsHidden($index, $attributes = NULL) { |
|
244 | - if (! \is_array($attributes)) { |
|
245 | - $attributes = []; |
|
243 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
244 | + if (!\is_array($attributes)) { |
|
245 | + $attributes=[]; |
|
246 | 246 | } |
247 | - $attributes["inputType"] = "hidden"; |
|
248 | - $attributes["style"] = "display:none;"; |
|
247 | + $attributes["inputType"]="hidden"; |
|
248 | + $attributes["style"]="display:none;"; |
|
249 | 249 | return $this->fieldAsInput($index, $attributes); |
250 | 250 | } |
251 | 251 | |
252 | - public function fieldAsCheckbox($index, $attributes = NULL) { |
|
253 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
254 | - if ($caption === null || $caption === "") |
|
255 | - $caption = ""; |
|
256 | - $input = new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
252 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
253 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
254 | + if ($caption===null || $caption==="") |
|
255 | + $caption=""; |
|
256 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
257 | 257 | $input->setChecked(JString::isBooleanTrue($value)); |
258 | 258 | return $this->_prepareFormFields($input, $name, $attributes); |
259 | 259 | }, $index, $attributes, "ck"); |
260 | 260 | } |
261 | 261 | |
262 | - public function fieldAsDropDown($index, $elements = [], $multiple = false, $attributes = NULL) { |
|
263 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($elements, $multiple, $attributes) { |
|
264 | - $dd = new HtmlFormDropdown($id, $elements, $caption, $value ?? ''); |
|
262 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
263 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements, $multiple, $attributes) { |
|
264 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value ?? ''); |
|
265 | 265 | $dd->asSelect($name, $multiple); |
266 | 266 | return $this->_prepareFormFields($dd, $name, $attributes); |
267 | 267 | }, $index, $attributes, "dd"); |
268 | 268 | } |
269 | 269 | |
270 | - public function fieldAsMessage($index, $attributes = NULL) { |
|
271 | - return $this->_fieldAs(function ($id, $name, $value, $caption) { |
|
272 | - $mess = new HtmlMessage("message-" . $id, $caption); |
|
270 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
271 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
272 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
273 | 273 | $mess->addHeader($value); |
274 | 274 | return $mess; |
275 | 275 | }, $index, $attributes, "message"); |
276 | 276 | } |
277 | 277 | |
278 | - public function fieldAsLink($index, $attributes = NULL) { |
|
279 | - return $this->_fieldAs(function ($id, $name, $value, $caption) { |
|
280 | - $lnk = new HtmlLink("message-" . $id, "#", $caption); |
|
278 | + public function fieldAsLink($index, $attributes=NULL) { |
|
279 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
280 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
281 | 281 | return $lnk; |
282 | 282 | }, $index, $attributes, "link"); |
283 | 283 | } |
@@ -289,28 +289,28 @@ discard block |
||
289 | 289 | * an array or associative array $type=>$attributes |
290 | 290 | */ |
291 | 291 | public function fieldsAs(array $types) { |
292 | - $i = 0; |
|
292 | + $i=0; |
|
293 | 293 | if (JArray::isAssociative($types)) { |
294 | 294 | foreach ($types as $type => $attributes) { |
295 | 295 | if (\is_int($type)) |
296 | - $this->fieldAs($i ++, $attributes, []); |
|
296 | + $this->fieldAs($i++, $attributes, []); |
|
297 | 297 | else { |
298 | - $type = preg_replace('/\d/', '', $type); |
|
299 | - $this->fieldAs($i ++, $type, $attributes); |
|
298 | + $type=preg_replace('/\d/', '', $type); |
|
299 | + $this->fieldAs($i++, $type, $attributes); |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | } else { |
303 | 303 | foreach ($types as $type) { |
304 | - $this->fieldAs($i ++, $type); |
|
304 | + $this->fieldAs($i++, $type); |
|
305 | 305 | } |
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | - public function fieldAs($index, $type, $attributes = NULL) { |
|
310 | - $method = "fieldAs" . \ucfirst($type); |
|
309 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
310 | + $method="fieldAs".\ucfirst($type); |
|
311 | 311 | if (\method_exists($this, $method)) { |
312 | - if (! \is_array($attributes)) { |
|
313 | - $attributes = [ |
|
312 | + if (!\is_array($attributes)) { |
|
313 | + $attributes=[ |
|
314 | 314 | $index |
315 | 315 | ]; |
316 | 316 | } else { |
@@ -323,17 +323,17 @@ discard block |
||
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
326 | - public function fieldAsSubmit($index, $cssStyle = NULL, $url = NULL, $responseElement = NULL, $attributes = NULL) { |
|
327 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes) { |
|
328 | - $button = new HtmlButton($id, $caption, $cssStyle); |
|
326 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
327 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes) { |
|
328 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
329 | 329 | $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
330 | 330 | return $button; |
331 | 331 | }, $index, $attributes, "submit"); |
332 | 332 | } |
333 | 333 | |
334 | - public function fieldAsButton($index, $cssStyle = NULL, $attributes = NULL) { |
|
335 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($cssStyle) { |
|
336 | - $button = new HtmlButton($id, $value, $cssStyle); |
|
334 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
335 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle) { |
|
336 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
337 | 337 | return $button; |
338 | 338 | }, $index, $attributes, "button"); |
339 | 339 | } |
@@ -15,69 +15,69 @@ discard block |
||
15 | 15 | |
16 | 16 | protected $ajaxTransition; |
17 | 17 | |
18 | - protected $ajaxLoader = "<div class=\"ui active centered inline text loader\">Loading</div>"; |
|
18 | + protected $ajaxLoader="<div class=\"ui active centered inline text loader\">Loading</div>"; |
|
19 | 19 | |
20 | 20 | abstract public function getUrl($url); |
21 | 21 | |
22 | - abstract public function _add_event($element, $js, $event, $preventDefault = false, $stopPropagation = false, $immediatly = true, $listenerOn = false); |
|
22 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true, $listenerOn=false); |
|
23 | 23 | |
24 | - abstract public function interval($jsCode, $time, $globalName = null, $immediatly = true); |
|
24 | + abstract public function interval($jsCode, $time, $globalName=null, $immediatly=true); |
|
25 | 25 | |
26 | - protected function _ajax($method, $url, $responseElement = '', $parameters = []) { |
|
26 | + protected function _ajax($method, $url, $responseElement='', $parameters=[]) { |
|
27 | 27 | if (isset($this->params['ajax'])) { |
28 | 28 | extract($this->params['ajax']); |
29 | 29 | } |
30 | 30 | extract($parameters); |
31 | 31 | |
32 | - $jsCallback = isset($jsCallback) ? $jsCallback : ''; |
|
33 | - $retour = $this->_getAjaxUrl($url, $attr); |
|
34 | - $originalSelector = $responseElement; |
|
35 | - $responseElement = $this->_getResponseElement($responseElement); |
|
36 | - $retour .= "var self=this;\n"; |
|
37 | - $before = isset($before) ? $before : ""; |
|
38 | - $retour .= $before; |
|
39 | - if ($hasLoader === true && JString::isNotNull($responseElement)) { |
|
32 | + $jsCallback=isset($jsCallback) ? $jsCallback : ''; |
|
33 | + $retour=$this->_getAjaxUrl($url, $attr); |
|
34 | + $originalSelector=$responseElement; |
|
35 | + $responseElement=$this->_getResponseElement($responseElement); |
|
36 | + $retour.="var self=this;\n"; |
|
37 | + $before=isset($before) ? $before : ""; |
|
38 | + $retour.=$before; |
|
39 | + if ($hasLoader===true && JString::isNotNull($responseElement)) { |
|
40 | 40 | $this->addLoading($retour, $responseElement, $ajaxLoader); |
41 | - } elseif ($hasLoader === 'response') { |
|
41 | + } elseif ($hasLoader==='response') { |
|
42 | 42 | $this->addResponseLoading($retour, $responseElement, $ajaxLoader); |
43 | - } elseif ($hasLoader === 'internal-x') { |
|
43 | + } elseif ($hasLoader==='internal-x') { |
|
44 | 44 | $this->addLoading($retour, '$(this).closest(".item, .step")', $ajaxLoader); |
45 | - } elseif ($hasLoader === 'internal') { |
|
46 | - $retour .= "\n$(this).addClass('loading');"; |
|
45 | + } elseif ($hasLoader==='internal') { |
|
46 | + $retour.="\n$(this).addClass('loading');"; |
|
47 | 47 | } |
48 | - $ajaxParameters = [ |
|
48 | + $ajaxParameters=[ |
|
49 | 49 | "url" => "url", |
50 | - "method" => "'" . \strtoupper($method) . "'" |
|
50 | + "method" => "'".\strtoupper($method)."'" |
|
51 | 51 | ]; |
52 | 52 | |
53 | - $ajaxParameters["async"] = ($async ? "true" : "false"); |
|
53 | + $ajaxParameters["async"]=($async ? "true" : "false"); |
|
54 | 54 | |
55 | 55 | if (isset($params)) { |
56 | - $ajaxParameters["data"] = self::_correctParams($params, $parameters); |
|
56 | + $ajaxParameters["data"]=self::_correctParams($params, $parameters); |
|
57 | 57 | } |
58 | 58 | if (isset($headers)) { |
59 | - $ajaxParameters["headers"] = $headers; |
|
59 | + $ajaxParameters["headers"]=$headers; |
|
60 | 60 | } |
61 | 61 | if ($csrf) { |
62 | - $csrf = (is_string($csrf)) ? $csrf : 'csrf-token'; |
|
63 | - $parameters["beforeSend"] = "jqXHR.setRequestHeader('{$csrf}', $('meta[name=\"{$csrf}\"]').attr('content'));"; |
|
62 | + $csrf=(is_string($csrf)) ? $csrf : 'csrf-token'; |
|
63 | + $parameters["beforeSend"]="jqXHR.setRequestHeader('{$csrf}', $('meta[name=\"{$csrf}\"]').attr('content'));"; |
|
64 | 64 | } |
65 | 65 | if (isset($partial)) { |
66 | - $ajaxParameters["xhr"] = "xhrProvider"; |
|
67 | - $retour .= "var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;" . $partial . ";}; };"; |
|
66 | + $ajaxParameters["xhr"]="xhrProvider"; |
|
67 | + $retour.="var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;".$partial.";}; };"; |
|
68 | 68 | } |
69 | 69 | $this->createAjaxParameters($ajaxParameters, $parameters); |
70 | - $retour .= "$.ajax({" . $this->implodeAjaxParameters($ajaxParameters) . "}).done(function( data, textStatus, jqXHR ) {\n"; |
|
71 | - $retour .= $this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null)) . "});\n"; |
|
70 | + $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n"; |
|
71 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null))."});\n"; |
|
72 | 72 | |
73 | - $retour = $this->_addJsCondition($jsCondition, $retour); |
|
73 | + $retour=$this->_addJsCondition($jsCondition, $retour); |
|
74 | 74 | if ($immediatly) |
75 | - $this->jquery_code_for_compile[] = $retour; |
|
75 | + $this->jquery_code_for_compile[]=$retour; |
|
76 | 76 | return $retour; |
77 | 77 | } |
78 | 78 | |
79 | 79 | protected function createAjaxParameters(&$original, $parameters) { |
80 | - $validParameters = [ |
|
80 | + $validParameters=[ |
|
81 | 81 | "contentType" => "%value%", |
82 | 82 | "dataType" => "'%value%'", |
83 | 83 | "beforeSend" => "function(jqXHR,settings){%value%}", |
@@ -86,21 +86,21 @@ discard block |
||
86 | 86 | ]; |
87 | 87 | foreach ($validParameters as $param => $mask) { |
88 | 88 | if (isset($parameters[$param])) { |
89 | - $original[$param] = \str_replace("%value%", $parameters[$param], $mask); |
|
89 | + $original[$param]=\str_replace("%value%", $parameters[$param], $mask); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | protected function implodeAjaxParameters($ajaxParameters) { |
95 | - $s = ''; |
|
95 | + $s=''; |
|
96 | 96 | foreach ($ajaxParameters as $k => $v) { |
97 | - if ($s !== '') { |
|
98 | - $s .= ','; |
|
97 | + if ($s!=='') { |
|
98 | + $s.=','; |
|
99 | 99 | } |
100 | 100 | if (is_array($v)) { |
101 | - $s .= "'{$k}':{" . self::implodeAjaxParameters($v) . "}"; |
|
101 | + $s.="'{$k}':{".self::implodeAjaxParameters($v)."}"; |
|
102 | 102 | } else { |
103 | - $s .= "'{$k}':{$v}"; |
|
103 | + $s.="'{$k}':{$v}"; |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | return $s; |
@@ -108,29 +108,29 @@ discard block |
||
108 | 108 | |
109 | 109 | protected function _addJsCondition($jsCondition, $jsSource) { |
110 | 110 | if (isset($jsCondition)) { |
111 | - return "if(" . $jsCondition . "){\n" . $jsSource . "\n}"; |
|
111 | + return "if(".$jsCondition."){\n".$jsSource."\n}"; |
|
112 | 112 | } |
113 | 113 | return $jsSource; |
114 | 114 | } |
115 | 115 | |
116 | 116 | protected function _getAjaxUrl($url, $attr) { |
117 | - $url = $this->_correctAjaxUrl($url); |
|
118 | - $retour = "url='" . $url . "';"; |
|
119 | - $slash = "/"; |
|
120 | - if (JString::endswith($url, "/") === true) { |
|
121 | - $slash = ""; |
|
117 | + $url=$this->_correctAjaxUrl($url); |
|
118 | + $retour="url='".$url."';"; |
|
119 | + $slash="/"; |
|
120 | + if (JString::endswith($url, "/")===true) { |
|
121 | + $slash=""; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | if (JString::isNotNull($attr)) { |
125 | - if ($attr === "value") { |
|
126 | - $retour .= "url=url+'" . $slash . "'+$(this).val();\n"; |
|
127 | - } elseif ($attr === "html") { |
|
128 | - $retour .= "url=url+'" . $slash . "'+$(this).html();\n"; |
|
129 | - } elseif (\substr($attr, 0, 3) === "js:") { |
|
130 | - $retour .= "url=url+'" . $slash . "'+" . \substr($attr, 3) . ";\n"; |
|
131 | - } elseif ($attr !== null && $attr !== "") { |
|
132 | - $retour .= "let elmUrl=$(this).attr('" . $attr . "')||'';"; |
|
133 | - $retour .= "url=(!/^((http|https|ftp):\/\/)/.test(elmUrl))?url+'" . $slash . "'+elmUrl:elmUrl;\n"; |
|
125 | + if ($attr==="value") { |
|
126 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
127 | + } elseif ($attr==="html") { |
|
128 | + $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
129 | + } elseif (\substr($attr, 0, 3)==="js:") { |
|
130 | + $retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n"; |
|
131 | + } elseif ($attr!==null && $attr!=="") { |
|
132 | + $retour.="let elmUrl=$(this).attr('".$attr."')||'';"; |
|
133 | + $retour.="url=(!/^((http|https|ftp):\/\/)/.test(elmUrl))?url+'".$slash."'+elmUrl:elmUrl;\n"; |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | return $retour; |
@@ -140,101 +140,101 @@ discard block |
||
140 | 140 | return "window.onpopstate = function(e){if(e.state){var target=e.state.jqueryDone;$(e.state.selector)[target](e.state.html);}};"; |
141 | 141 | } |
142 | 142 | |
143 | - protected function autoActiveLinks($previousURL = "window.location.href") { |
|
144 | - $result = "\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}"; |
|
145 | - $result .= "\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;"; |
|
143 | + protected function autoActiveLinks($previousURL="window.location.href") { |
|
144 | + $result="\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}"; |
|
145 | + $result.="\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;"; |
|
146 | 146 | return $result; |
147 | 147 | } |
148 | 148 | |
149 | - protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader = false, $history = null) { |
|
150 | - $retour = ""; |
|
151 | - $call = null; |
|
149 | + protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader=false, $history=null) { |
|
150 | + $retour=""; |
|
151 | + $call=null; |
|
152 | 152 | if (JString::isNotNull($responseElement)) { |
153 | 153 | if (isset($ajaxTransition)) { |
154 | - $call = $this->setAjaxDataCall($ajaxTransition); |
|
154 | + $call=$this->setAjaxDataCall($ajaxTransition); |
|
155 | 155 | } elseif (isset($this->ajaxTransition)) { |
156 | - $call = $this->ajaxTransition; |
|
156 | + $call=$this->ajaxTransition; |
|
157 | 157 | } |
158 | 158 | if (\is_callable($call)) |
159 | - $retour = "\t" . $call($responseElement, $jqueryDone) . ";\n"; |
|
159 | + $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
160 | 160 | else |
161 | - $retour = "\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
161 | + $retour="\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
162 | 162 | } |
163 | 163 | if (isset($history)) { |
164 | 164 | if ($this->params["autoActiveLinks"]) { |
165 | - $retour .= $this->autoActiveLinks("url"); |
|
165 | + $retour.=$this->autoActiveLinks("url"); |
|
166 | 166 | } |
167 | - $retour .= "\nwindow.history.pushState({'html':data,'selector':" . Javascript::prep_value($history) . ",'jqueryDone':'{$jqueryDone}'},'', url);"; |
|
167 | + $retour.="\nwindow.history.pushState({'html':data,'selector':".Javascript::prep_value($history).",'jqueryDone':'{$jqueryDone}'},'', url);"; |
|
168 | 168 | } |
169 | - if ($hasLoader === 'internal') { |
|
170 | - $retour .= "\n$(self).removeClass('loading');"; |
|
171 | - } elseif ($hasLoader === 'internal-x') { |
|
172 | - $retour .= "\n$(self).children('.ajax-loader').remove();"; |
|
169 | + if ($hasLoader==='internal') { |
|
170 | + $retour.="\n$(self).removeClass('loading');"; |
|
171 | + } elseif ($hasLoader==='internal-x') { |
|
172 | + $retour.="\n$(self).children('.ajax-loader').remove();"; |
|
173 | 173 | } |
174 | - $retour .= "\t" . $jsCallback . "\n"; |
|
174 | + $retour.="\t".$jsCallback."\n"; |
|
175 | 175 | return $retour; |
176 | 176 | } |
177 | 177 | |
178 | 178 | protected function _getResponseElement($responseElement) { |
179 | 179 | if (JString::isNotNull($responseElement)) { |
180 | - $responseElement = Javascript::prep_jquery_selector($responseElement); |
|
180 | + $responseElement=Javascript::prep_jquery_selector($responseElement); |
|
181 | 181 | } |
182 | 182 | return $responseElement; |
183 | 183 | } |
184 | 184 | |
185 | 185 | protected function _correctAjaxUrl($url) { |
186 | - if ($url !== "/" && JString::endsWith($url, "/") === true) |
|
187 | - $url = substr($url, 0, strlen($url) - 1); |
|
188 | - if (strncmp($url, 'http://', 7) != 0 && strncmp($url, 'https://', 8) != 0) { |
|
189 | - $url = $this->getUrl($url); |
|
186 | + if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
187 | + $url=substr($url, 0, strlen($url)-1); |
|
188 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
189 | + $url=$this->getUrl($url); |
|
190 | 190 | } |
191 | 191 | return $url; |
192 | 192 | } |
193 | 193 | |
194 | - public static function _correctParams($params, $ajaxParameters = []) { |
|
194 | + public static function _correctParams($params, $ajaxParameters=[]) { |
|
195 | 195 | if (JString::isNull($params)) { |
196 | 196 | return ""; |
197 | 197 | } |
198 | 198 | if (\preg_match("@^\{.*?\}$@", $params)) { |
199 | - if (! isset($ajaxParameters['contentType']) || ! JString::contains($ajaxParameters['contentType'], 'json')) { |
|
200 | - return '$.param(' . $params . ')'; |
|
199 | + if (!isset($ajaxParameters['contentType']) || !JString::contains($ajaxParameters['contentType'], 'json')) { |
|
200 | + return '$.param('.$params.')'; |
|
201 | 201 | } else { |
202 | - return 'JSON.stringify(' . $params . ')'; |
|
202 | + return 'JSON.stringify('.$params.')'; |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | return $params; |
206 | 206 | } |
207 | 207 | |
208 | 208 | public static function _implodeParams($parameters) { |
209 | - $allParameters = []; |
|
209 | + $allParameters=[]; |
|
210 | 210 | foreach ($parameters as $params) { |
211 | 211 | if (isset($params)) |
212 | - $allParameters[] = self::_correctParams($params); |
|
212 | + $allParameters[]=self::_correctParams($params); |
|
213 | 213 | } |
214 | 214 | return \implode("+'&'+", $allParameters); |
215 | 215 | } |
216 | 216 | |
217 | - protected function addLoading(&$retour, $responseElement, $ajaxLoader = null) { |
|
218 | - if (! isset($ajaxLoader)) { |
|
219 | - $ajaxLoader = $this->ajaxLoader; |
|
217 | + protected function addLoading(&$retour, $responseElement, $ajaxLoader=null) { |
|
218 | + if (!isset($ajaxLoader)) { |
|
219 | + $ajaxLoader=$this->ajaxLoader; |
|
220 | 220 | } |
221 | - $loading_notifier = '<div class="ajax-loader ui active inverted dimmer">' . $ajaxLoader . '</div>'; |
|
222 | - $retour .= "\t\t{$responseElement}.append('{$loading_notifier}');\n"; |
|
221 | + $loading_notifier='<div class="ajax-loader ui active inverted dimmer">'.$ajaxLoader.'</div>'; |
|
222 | + $retour.="\t\t{$responseElement}.append('{$loading_notifier}');\n"; |
|
223 | 223 | } |
224 | 224 | |
225 | - protected function addResponseLoading(&$retour, $responseElement, $ajaxLoader = null) { |
|
226 | - if (! isset($ajaxLoader)) { |
|
227 | - $ajaxLoader = $this->ajaxLoader; |
|
225 | + protected function addResponseLoading(&$retour, $responseElement, $ajaxLoader=null) { |
|
226 | + if (!isset($ajaxLoader)) { |
|
227 | + $ajaxLoader=$this->ajaxLoader; |
|
228 | 228 | } |
229 | - $loading_notifier = '<div class="ajax-loader">' . $ajaxLoader . '</div>'; |
|
230 | - $retour .= "{$responseElement}.empty();\n"; |
|
231 | - $retour .= "\t\t{$responseElement}.prepend('{$loading_notifier}');\n"; |
|
229 | + $loading_notifier='<div class="ajax-loader">'.$ajaxLoader.'</div>'; |
|
230 | + $retour.="{$responseElement}.empty();\n"; |
|
231 | + $retour.="\t\t{$responseElement}.prepend('{$loading_notifier}');\n"; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | protected function setAjaxDataCall($params) { |
235 | - $result = null; |
|
236 | - if (! \is_callable($params)) { |
|
237 | - $result = function ($responseElement, $jqueryDone = 'html') use ($params) { |
|
235 | + $result=null; |
|
236 | + if (!\is_callable($params)) { |
|
237 | + $result=function($responseElement, $jqueryDone='html') use ($params) { |
|
238 | 238 | return AjaxTransition::{$params}($responseElement, $jqueryDone); |
239 | 239 | }; |
240 | 240 | } |
@@ -243,13 +243,13 @@ discard block |
||
243 | 243 | |
244 | 244 | protected function setDefaultParameters(&$parameters, $default) { |
245 | 245 | foreach ($default as $k => $v) { |
246 | - if (! isset($parameters[$k])) |
|
247 | - $parameters[$k] = $v; |
|
246 | + if (!isset($parameters[$k])) |
|
247 | + $parameters[$k]=$v; |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | 251 | public function setAjaxLoader($loader) { |
252 | - $this->ajaxLoader = $loader; |
|
252 | + $this->ajaxLoader=$loader; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @param string $responseElement |
261 | 261 | * selector of the HTML element displaying the answer |
262 | 262 | */ |
263 | - private function _get($url, $responseElement = '', $parameters = []) { |
|
263 | + private function _get($url, $responseElement='', $parameters=[]) { |
|
264 | 264 | return $this->_ajax('get', $url, $responseElement, $parameters); |
265 | 265 | } |
266 | 266 | |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | * @param array $parameters |
275 | 275 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
276 | 276 | */ |
277 | - public function get($url, $responseElement = '', $parameters = []) { |
|
278 | - $parameters['immediatly'] = true; |
|
277 | + public function get($url, $responseElement='', $parameters=[]) { |
|
278 | + $parameters['immediatly']=true; |
|
279 | 279 | return $this->_get($url, $responseElement, $parameters); |
280 | 280 | } |
281 | 281 | |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | * @param array $parameters |
292 | 292 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
293 | 293 | */ |
294 | - public function ajax($method, $url, $responseElement = '', $parameters = []) { |
|
295 | - $parameters['immediatly'] = true; |
|
294 | + public function ajax($method, $url, $responseElement='', $parameters=[]) { |
|
295 | + $parameters['immediatly']=true; |
|
296 | 296 | return $this->_ajax($method, $url, $responseElement, $parameters); |
297 | 297 | } |
298 | 298 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * $immediatly |
315 | 315 | * @return string |
316 | 316 | */ |
317 | - public function ajaxInterval($method, $url, $interval, $globalName = null, $responseElement = '', $parameters = [], $immediatly = true) { |
|
317 | + public function ajaxInterval($method, $url, $interval, $globalName=null, $responseElement='', $parameters=[], $immediatly=true) { |
|
318 | 318 | return $this->interval($this->ajaxDeferred($method, $url, $responseElement, $parameters), $interval, $globalName, $immediatly); |
319 | 319 | } |
320 | 320 | |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | * @param array $parameters |
331 | 331 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
332 | 332 | */ |
333 | - public function ajaxDeferred($method, $url, $responseElement = '', $parameters = []) { |
|
334 | - $parameters['immediatly'] = false; |
|
333 | + public function ajaxDeferred($method, $url, $responseElement='', $parameters=[]) { |
|
334 | + $parameters['immediatly']=false; |
|
335 | 335 | return $this->_ajax($method, $url, $responseElement, $parameters); |
336 | 336 | } |
337 | 337 | |
@@ -345,15 +345,15 @@ discard block |
||
345 | 345 | * @param array $parameters |
346 | 346 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
347 | 347 | */ |
348 | - private function _json($url, $method = "get", $parameters = []) { |
|
349 | - $parameters = \array_merge($parameters, [ |
|
348 | + private function _json($url, $method="get", $parameters=[]) { |
|
349 | + $parameters=\array_merge($parameters, [ |
|
350 | 350 | "hasLoader" => false |
351 | 351 | ]); |
352 | - $jsCallback = isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
353 | - $context = isset($parameters['context']) ? $parameters['context'] : "document"; |
|
354 | - $retour = "\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t" . $jsCallback . ";" . "\n\tfor(var key in data){" . "if($('#'+key," . $context . ").length){ if($('#'+key," . $context . ").is('[value]')) { $('#'+key," . $context . ").val(data[key]);} else { $('#'+key," . $context . ").html(data[key]); }}};\n"; |
|
355 | - $retour .= "\t$(document).trigger('jsonReady',[data]);\n"; |
|
356 | - $parameters["jsCallback"] = $retour; |
|
352 | + $jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
353 | + $context=isset($parameters['context']) ? $parameters['context'] : "document"; |
|
354 | + $retour="\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t".$jsCallback.";"."\n\tfor(var key in data){"."if($('#'+key,".$context.").length){ if($('#'+key,".$context.").is('[value]')) { $('#'+key,".$context.").val(data[key]);} else { $('#'+key,".$context.").html(data[key]); }}};\n"; |
|
355 | + $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
|
356 | + $parameters["jsCallback"]=$retour; |
|
357 | 357 | return $this->_ajax($method, $url, null, $parameters); |
358 | 358 | } |
359 | 359 | |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * @param array $parameters |
368 | 368 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
369 | 369 | */ |
370 | - public function json($url, $method = "get", $parameters = []) { |
|
370 | + public function json($url, $method="get", $parameters=[]) { |
|
371 | 371 | return $this->_json($url, $method, $parameters); |
372 | 372 | } |
373 | 373 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @param array $parameters |
384 | 384 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true,"before"=>null,"listenerOn"=>false) |
385 | 385 | */ |
386 | - public function jsonOn($event, $element, $url, $method = 'get', $parameters = array()) { |
|
386 | + public function jsonOn($event, $element, $url, $method='get', $parameters=array()) { |
|
387 | 387 | $this->setDefaultParameters($parameters, [ |
388 | 388 | 'preventDefault' => true, |
389 | 389 | 'stopPropagation' => true, |
@@ -403,8 +403,8 @@ discard block |
||
403 | 403 | * @param array $parameters |
404 | 404 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
405 | 405 | */ |
406 | - public function jsonDeferred($url, $method = 'get', $parameters = []) { |
|
407 | - $parameters['immediatly'] = false; |
|
406 | + public function jsonDeferred($url, $method='get', $parameters=[]) { |
|
407 | + $parameters['immediatly']=false; |
|
408 | 408 | return $this->_json($url, $method, $parameters); |
409 | 409 | } |
410 | 410 | |
@@ -419,29 +419,29 @@ discard block |
||
419 | 419 | * @param array $parameters |
420 | 420 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json","before"=>null) |
421 | 421 | */ |
422 | - private function _jsonArray($maskSelector, $url, $method = 'get', $parameters = []) { |
|
423 | - $parameters = \array_merge($parameters, [ |
|
422 | + private function _jsonArray($maskSelector, $url, $method='get', $parameters=[]) { |
|
423 | + $parameters=\array_merge($parameters, [ |
|
424 | 424 | "hasLoader" => false |
425 | 425 | ]); |
426 | - $rowClass = isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json"; |
|
427 | - $jsCallback = isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
428 | - $context = isset($parameters['context']) ? $parameters['context'] : null; |
|
429 | - if ($context === null) { |
|
430 | - $parent = "$('" . $maskSelector . "').parent()"; |
|
431 | - $newElm = "$('#'+newId)"; |
|
426 | + $rowClass=isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json"; |
|
427 | + $jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
428 | + $context=isset($parameters['context']) ? $parameters['context'] : null; |
|
429 | + if ($context===null) { |
|
430 | + $parent="$('".$maskSelector."').parent()"; |
|
431 | + $newElm="$('#'+newId)"; |
|
432 | 432 | } else { |
433 | - $parent = $context; |
|
434 | - $newElm = $context . ".find('#'+newId)"; |
|
433 | + $parent=$context; |
|
434 | + $newElm=$context.".find('#'+newId)"; |
|
435 | 435 | } |
436 | - $appendTo = "\t\tnewElm.appendTo(" . $parent . ");\n"; |
|
437 | - $retour = $parent . ".find('.{$rowClass}').remove();"; |
|
438 | - $retour .= "\tdata=($.isPlainObject(data)||$.isArray(data))?data:JSON.parse(data);\n$.each(data, function(index, value) {\n" . "\tvar created=false;var maskElm=$('" . $maskSelector . "').first();maskElm.hide();" . "\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;" . "\tvar newElm=" . $newElm . ";\n" . "\tif(!newElm.length){\n" . "\t\tnewElm=maskElm.clone(); |
|
436 | + $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
|
437 | + $retour=$parent.".find('.{$rowClass}').remove();"; |
|
438 | + $retour.="\tdata=($.isPlainObject(data)||$.isArray(data))?data:JSON.parse(data);\n$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone(); |
|
439 | 439 | newElm.attr('id',newId);\n;newElm.addClass('{$rowClass}').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n"; |
440 | - $retour .= $appendTo; |
|
441 | - $retour .= "\t}\n" . "\tfor(var key in value){\n" . "\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n" . "\t\t\tif(html.indexOf('__'+key+'__')>-1){\n" . "\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n" . "\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n" . "\t\t\t}\n" . "\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n" . "\t\t\tvar selElm=$(sel,newElm);\n" . "\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n" . "\t\t}\n" . "}\n" . "\t$(newElm).show(true);" . "\n" . "\t$(newElm).removeClass('hide');" . "});\n"; |
|
442 | - $retour .= "\t$(document).trigger('jsonReady',[data]);\n"; |
|
443 | - $retour .= "\t" . $jsCallback; |
|
444 | - $parameters["jsCallback"] = $retour; |
|
440 | + $retour.=$appendTo; |
|
441 | + $retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('__'+key+'__')>-1){\n"."\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n"; |
|
442 | + $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
|
443 | + $retour.="\t".$jsCallback; |
|
444 | + $parameters["jsCallback"]=$retour; |
|
445 | 445 | return $this->_ajax($method, $url, null, $parameters); |
446 | 446 | } |
447 | 447 | |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | * @param array $parameters |
457 | 457 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json","before"=>null) |
458 | 458 | */ |
459 | - public function jsonArray($maskSelector, $url, $method = 'get', $parameters = []) { |
|
459 | + public function jsonArray($maskSelector, $url, $method='get', $parameters=[]) { |
|
460 | 460 | return $this->_jsonArray($maskSelector, $url, $method, $parameters); |
461 | 461 | } |
462 | 462 | |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | * @param array $parameters |
472 | 472 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"rowClass"=>"_json","before"=>null) |
473 | 473 | */ |
474 | - public function jsonArrayDeferred($maskSelector, $url, $method = 'get', $parameters = []) { |
|
475 | - $parameters['immediatly'] = false; |
|
474 | + public function jsonArrayDeferred($maskSelector, $url, $method='get', $parameters=[]) { |
|
475 | + $parameters['immediatly']=false; |
|
476 | 476 | return $this->jsonArray($maskSelector, $url, $method, $parameters); |
477 | 477 | } |
478 | 478 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | * @param array $parameters |
489 | 489 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true,"before"=>null,"listenerOn"=>false) |
490 | 490 | */ |
491 | - public function jsonArrayOn($event, $element, $maskSelector, $url, $method = 'get', $parameters = array()) { |
|
491 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $method='get', $parameters=array()) { |
|
492 | 492 | $this->setDefaultParameters($parameters, [ |
493 | 493 | 'preventDefault' => true, |
494 | 494 | 'stopPropagation' => true, |
@@ -509,8 +509,8 @@ discard block |
||
509 | 509 | * @param array $parameters |
510 | 510 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
511 | 511 | */ |
512 | - public function getDeferred($url, $responseElement = "", $parameters = []) { |
|
513 | - $parameters['immediatly'] = false; |
|
512 | + public function getDeferred($url, $responseElement="", $parameters=[]) { |
|
513 | + $parameters['immediatly']=false; |
|
514 | 514 | return $this->_get($url, $responseElement, $parameters); |
515 | 515 | } |
516 | 516 | |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | * @param array $parameters |
530 | 530 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
531 | 531 | */ |
532 | - public function getOn($event, $element, $url, $responseElement = "", $parameters = array()) { |
|
533 | - $parameters['method'] = 'get'; |
|
532 | + public function getOn($event, $element, $url, $responseElement="", $parameters=array()) { |
|
533 | + $parameters['method']='get'; |
|
534 | 534 | return $this->ajaxOn($event, $element, $url, $responseElement, $parameters); |
535 | 535 | } |
536 | 536 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * @param array $parameters |
550 | 550 | * default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
551 | 551 | */ |
552 | - public function ajaxOn($event, $element, $url, $responseElement = '', $parameters = array()) { |
|
552 | + public function ajaxOn($event, $element, $url, $responseElement='', $parameters=array()) { |
|
553 | 553 | $this->setDefaultParameters($parameters, [ |
554 | 554 | 'preventDefault' => true, |
555 | 555 | 'stopPropagation' => true, |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | * @param array $parameters |
574 | 574 | * default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
575 | 575 | */ |
576 | - public function ajaxOnClick($element, $url, $responseElement = '', $parameters = array()) { |
|
576 | + public function ajaxOnClick($element, $url, $responseElement='', $parameters=array()) { |
|
577 | 577 | return $this->ajaxOn('click', $element, $url, $responseElement, $parameters); |
578 | 578 | } |
579 | 579 | |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * @param array $parameters |
591 | 591 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
592 | 592 | */ |
593 | - public function getOnClick($element, $url, $responseElement = '', $parameters = array()) { |
|
593 | + public function getOnClick($element, $url, $responseElement='', $parameters=array()) { |
|
594 | 594 | return $this->getOn('click', $element, $url, $responseElement, $parameters); |
595 | 595 | } |
596 | 596 | |
@@ -605,15 +605,15 @@ discard block |
||
605 | 605 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null) |
606 | 606 | * @return $this |
607 | 607 | */ |
608 | - public function getHref($element, $responseElement = "", $parameters = array()) { |
|
609 | - $parameters['attr'] = 'href'; |
|
608 | + public function getHref($element, $responseElement="", $parameters=array()) { |
|
609 | + $parameters['attr']='href'; |
|
610 | 610 | if (JString::isNull($responseElement)) { |
611 | - $responseElement = '%$(self).attr("data-target")%'; |
|
611 | + $responseElement='%$(self).attr("data-target")%'; |
|
612 | 612 | } else { |
613 | - $responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%'; |
|
613 | + $responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%'; |
|
614 | 614 | } |
615 | - if (! isset($parameters['historize'])) { |
|
616 | - $parameters['historize'] = true; |
|
615 | + if (!isset($parameters['historize'])) { |
|
616 | + $parameters['historize']=true; |
|
617 | 617 | } |
618 | 618 | return $this->getOnClick($element, "", $responseElement, $parameters); |
619 | 619 | } |
@@ -629,21 +629,21 @@ discard block |
||
629 | 629 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null) |
630 | 630 | * @return $this |
631 | 631 | */ |
632 | - public function postHref($element, $responseElement = "", $parameters = array()) { |
|
633 | - $parameters['attr'] = 'href'; |
|
632 | + public function postHref($element, $responseElement="", $parameters=array()) { |
|
633 | + $parameters['attr']='href'; |
|
634 | 634 | if (JString::isNull($responseElement)) { |
635 | - $responseElement = '%$(this).attr("data-target")%'; |
|
635 | + $responseElement='%$(this).attr("data-target")%'; |
|
636 | 636 | } else { |
637 | - $responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%'; |
|
637 | + $responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%'; |
|
638 | 638 | } |
639 | - if (! isset($parameters['historize'])) { |
|
640 | - $parameters['historize'] = true; |
|
639 | + if (!isset($parameters['historize'])) { |
|
640 | + $parameters['historize']=true; |
|
641 | 641 | } |
642 | 642 | return $this->postOnClick($element, '', '{}', $responseElement, $parameters); |
643 | 643 | } |
644 | 644 | |
645 | - private function _post($url, $params = '{}', $responseElement = '', $parameters = []) { |
|
646 | - $parameters['params'] = $params; |
|
645 | + private function _post($url, $params='{}', $responseElement='', $parameters=[]) { |
|
646 | + $parameters['params']=$params; |
|
647 | 647 | return $this->_ajax('POST', $url, $responseElement, $parameters); |
648 | 648 | } |
649 | 649 | |
@@ -659,8 +659,8 @@ discard block |
||
659 | 659 | * @param array $parameters |
660 | 660 | * default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
661 | 661 | */ |
662 | - public function post($url, $params = "{}", $responseElement = "", $parameters = []) { |
|
663 | - $parameters['immediatly'] = true; |
|
662 | + public function post($url, $params="{}", $responseElement="", $parameters=[]) { |
|
663 | + $parameters['immediatly']=true; |
|
664 | 664 | return $this->_post($url, $params, $responseElement, $parameters); |
665 | 665 | } |
666 | 666 | |
@@ -677,8 +677,8 @@ discard block |
||
677 | 677 | * @param array $parameters |
678 | 678 | * default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
679 | 679 | */ |
680 | - public function postDeferred($url, $params = "{}", $responseElement = "", $parameters = []) { |
|
681 | - $parameters['immediatly'] = false; |
|
680 | + public function postDeferred($url, $params="{}", $responseElement="", $parameters=[]) { |
|
681 | + $parameters['immediatly']=false; |
|
682 | 682 | return $this->_post($url, $params, $responseElement, $parameters); |
683 | 683 | } |
684 | 684 | |
@@ -697,9 +697,9 @@ discard block |
||
697 | 697 | * @param array $parameters |
698 | 698 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
699 | 699 | */ |
700 | - public function postOn($event, $element, $url, $params = "{}", $responseElement = "", $parameters = array()) { |
|
701 | - $parameters['method'] = 'post'; |
|
702 | - $parameters['params'] = $params; |
|
700 | + public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
701 | + $parameters['method']='post'; |
|
702 | + $parameters['params']=$params; |
|
703 | 703 | return $this->ajaxOn($event, $element, $url, $responseElement, $parameters); |
704 | 704 | } |
705 | 705 | |
@@ -717,66 +717,66 @@ discard block |
||
717 | 717 | * @param array $parameters |
718 | 718 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"before"=>null,"listenerOn"=>false) |
719 | 719 | */ |
720 | - public function postOnClick($element, $url, $params = '{}', $responseElement = '', $parameters = array()) { |
|
720 | + public function postOnClick($element, $url, $params='{}', $responseElement='', $parameters=array()) { |
|
721 | 721 | return $this->postOn('click', $element, $url, $params, $responseElement, $parameters); |
722 | 722 | } |
723 | 723 | |
724 | - private function _postForm($url, $form, $responseElement, $parameters = []) { |
|
724 | + private function _postForm($url, $form, $responseElement, $parameters=[]) { |
|
725 | 725 | if (isset($this->params['ajax'])) { |
726 | 726 | extract($this->params['ajax']); |
727 | 727 | } |
728 | - $params = '{}'; |
|
729 | - $validation = false; |
|
728 | + $params='{}'; |
|
729 | + $validation=false; |
|
730 | 730 | \extract($parameters); |
731 | - $async = ($async) ? 'true' : 'false'; |
|
732 | - $jsCallback = isset($jsCallback) ? $jsCallback : ""; |
|
733 | - $retour = $this->_getAjaxUrl($url, $attr); |
|
734 | - $retour .= "\n$('#" . $form . "').trigger('ajaxSubmit');"; |
|
735 | - if (! isset($contentType) || $contentType != 'false') { |
|
736 | - $retour .= "\nvar params=$('#" . $form . "').serialize();\n"; |
|
731 | + $async=($async) ? 'true' : 'false'; |
|
732 | + $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
|
733 | + $retour=$this->_getAjaxUrl($url, $attr); |
|
734 | + $retour.="\n$('#".$form."').trigger('ajaxSubmit');"; |
|
735 | + if (!isset($contentType) || $contentType!='false') { |
|
736 | + $retour.="\nvar params=$('#".$form."').serialize();\n"; |
|
737 | 737 | if (isset($params)) { |
738 | - $retour .= "params+='&'+" . self::_correctParams($params) . ";\n"; |
|
738 | + $retour.="params+='&'+".self::_correctParams($params).";\n"; |
|
739 | 739 | } |
740 | 740 | } else { |
741 | - $retour .= "\nvar params=new FormData($('#" . $form . "')[0]);\n"; |
|
741 | + $retour.="\nvar params=new FormData($('#".$form."')[0]);\n"; |
|
742 | 742 | } |
743 | - $responseElement = $this->_getResponseElement($responseElement); |
|
744 | - $retour .= "var self=this;\n"; |
|
745 | - $before = isset($before) ? $before : ""; |
|
746 | - $retour .= $before; |
|
747 | - if ($hasLoader === true) { |
|
743 | + $responseElement=$this->_getResponseElement($responseElement); |
|
744 | + $retour.="var self=this;\n"; |
|
745 | + $before=isset($before) ? $before : ""; |
|
746 | + $retour.=$before; |
|
747 | + if ($hasLoader===true) { |
|
748 | 748 | $this->addLoading($retour, $responseElement, $ajaxLoader); |
749 | - } elseif ($hasLoader === 'response') { |
|
749 | + } elseif ($hasLoader==='response') { |
|
750 | 750 | $this->addResponseLoading($retour, $responseElement, $ajaxLoader); |
751 | - } elseif ($hasLoader === 'internal') { |
|
752 | - $retour .= "\n$(this).addClass('loading');"; |
|
751 | + } elseif ($hasLoader==='internal') { |
|
752 | + $retour.="\n$(this).addClass('loading');"; |
|
753 | 753 | } |
754 | - $ajaxParameters = [ |
|
754 | + $ajaxParameters=[ |
|
755 | 755 | "url" => "url", |
756 | 756 | "method" => "'POST'", |
757 | 757 | "data" => "params", |
758 | 758 | "async" => $async |
759 | 759 | ]; |
760 | 760 | if (isset($headers)) { |
761 | - $ajaxParameters["headers"] = $headers; |
|
761 | + $ajaxParameters["headers"]=$headers; |
|
762 | 762 | } |
763 | 763 | if (isset($partial)) { |
764 | - $ajaxParameters["xhr"] = "xhrProvider"; |
|
765 | - $retour .= "var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;" . $partial . ";}; };"; |
|
764 | + $ajaxParameters["xhr"]="xhrProvider"; |
|
765 | + $retour.="var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;".$partial.";}; };"; |
|
766 | 766 | } |
767 | 767 | $this->createAjaxParameters($ajaxParameters, $parameters); |
768 | - $retour .= "$.ajax({" . $this->implodeAjaxParameters($ajaxParameters) . "}).done(function( data ) {\n"; |
|
769 | - $retour .= $this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader) . "});\n"; |
|
768 | + $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data ) {\n"; |
|
769 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader)."});\n"; |
|
770 | 770 | |
771 | 771 | if ($validation) { |
772 | - $retour = "$('#" . $form . "').validate({submitHandler: function(form) { |
|
773 | - " . $retour . " |
|
772 | + $retour="$('#".$form."').validate({submitHandler: function(form) { |
|
773 | + " . $retour." |
|
774 | 774 | }});\n"; |
775 | - $retour .= "$('#" . $form . "').submit();\n"; |
|
775 | + $retour.="$('#".$form."').submit();\n"; |
|
776 | 776 | } |
777 | - $retour = $this->_addJsCondition($jsCondition, $retour); |
|
777 | + $retour=$this->_addJsCondition($jsCondition, $retour); |
|
778 | 778 | if ($immediatly) |
779 | - $this->jquery_code_for_compile[] = $retour; |
|
779 | + $this->jquery_code_for_compile[]=$retour; |
|
780 | 780 | return $retour; |
781 | 781 | } |
782 | 782 | |
@@ -792,8 +792,8 @@ discard block |
||
792 | 792 | * @param array $parameters |
793 | 793 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
794 | 794 | */ |
795 | - public function postForm($url, $form, $responseElement, $parameters = []) { |
|
796 | - $parameters['immediatly'] = true; |
|
795 | + public function postForm($url, $form, $responseElement, $parameters=[]) { |
|
796 | + $parameters['immediatly']=true; |
|
797 | 797 | return $this->_postForm($url, $form, $responseElement, $parameters); |
798 | 798 | } |
799 | 799 | |
@@ -810,8 +810,8 @@ discard block |
||
810 | 810 | * @param array $parameters |
811 | 811 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
812 | 812 | */ |
813 | - public function postFormDeferred($url, $form, $responseElement, $parameters = []) { |
|
814 | - $parameters['immediatly'] = false; |
|
813 | + public function postFormDeferred($url, $form, $responseElement, $parameters=[]) { |
|
814 | + $parameters['immediatly']=false; |
|
815 | 815 | return $this->_postForm($url, $form, $responseElement, $parameters); |
816 | 816 | } |
817 | 817 | |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | * @param array $parameters |
829 | 829 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
830 | 830 | */ |
831 | - public function postFormOn($event, $element, $url, $form, $responseElement = "", $parameters = array()) { |
|
831 | + public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
832 | 832 | $this->setDefaultParameters($parameters, [ |
833 | 833 | 'preventDefault' => true, |
834 | 834 | 'stopPropagation' => true, |
@@ -850,11 +850,11 @@ discard block |
||
850 | 850 | * @param array $parameters |
851 | 851 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
852 | 852 | */ |
853 | - public function postFormOnClick($element, $url, $form, $responseElement = "", $parameters = array()) { |
|
853 | + public function postFormOnClick($element, $url, $form, $responseElement="", $parameters=array()) { |
|
854 | 854 | return $this->postFormOn("click", $element, $url, $form, $responseElement, $parameters); |
855 | 855 | } |
856 | 856 | |
857 | - public function addCsrf($name = 'csrf-token') { |
|
857 | + public function addCsrf($name='csrf-token') { |
|
858 | 858 | return " |
859 | 859 | $.ajaxSetup({ |
860 | 860 | beforeSend: function(xhr, settings) { |