@@ -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,27 +66,27 @@ 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 | if (\is_object($modelInstance)) { |
75 | - $this->_model = \get_class($modelInstance); |
|
75 | + $this->_model=\get_class($modelInstance); |
|
76 | 76 | } |
77 | 77 | $this->show($modelInstance); |
78 | 78 | } |
79 | - $this->_generated = false; |
|
79 | + $this->_generated=false; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | protected function _init($instanceViewer, $contentKey, $content, $edition) { |
83 | - $this->_instanceViewer = $instanceViewer; |
|
84 | - $this->content = [ |
|
83 | + $this->_instanceViewer=$instanceViewer; |
|
84 | + $this->content=[ |
|
85 | 85 | $contentKey => $content |
86 | 86 | ]; |
87 | - $this->_self = $content; |
|
88 | - $this->_toolbarPosition = PositionInTable::BEFORETABLE; |
|
89 | - $this->_edition = $edition; |
|
87 | + $this->_self=$content; |
|
88 | + $this->_toolbarPosition=PositionInTable::BEFORETABLE; |
|
89 | + $this->_edition=$edition; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -95,16 +95,16 @@ discard block |
||
95 | 95 | * @return int|string|boolean |
96 | 96 | */ |
97 | 97 | protected function _getIndex($fieldName) { |
98 | - $index = $fieldName; |
|
98 | + $index=$fieldName; |
|
99 | 99 | if (\is_string($fieldName)) { |
100 | - $fields = $this->_instanceViewer->getVisibleProperties(); |
|
101 | - $index = \array_search($fieldName, $fields); |
|
100 | + $fields=$this->_instanceViewer->getVisibleProperties(); |
|
101 | + $index=\array_search($fieldName, $fields); |
|
102 | 102 | } |
103 | 103 | return $index; |
104 | 104 | } |
105 | 105 | |
106 | - protected function _getFieldIdentifier($prefix, $name = "") { |
|
107 | - return $this->identifier . "-{$prefix}-" . $this->_instanceViewer->getIdentifier(); |
|
106 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
107 | + return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | protected function _getFieldName($index) { |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | return $this->_instanceViewer->getCaption($index); |
116 | 116 | } |
117 | 117 | |
118 | - abstract protected function _setToolbarPosition($table, $captions = NULL); |
|
118 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
119 | 119 | |
120 | 120 | public function show($modelInstance) { |
121 | 121 | if (\is_array($modelInstance)) { |
122 | - $modelInstance = \json_decode(\json_encode($modelInstance), FALSE); |
|
122 | + $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
123 | 123 | } |
124 | - $this->_modelInstance = $modelInstance; |
|
124 | + $this->_modelInstance=$modelInstance; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | public function getModel() { |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | public function setModel($_model) { |
132 | - $this->_model = $_model; |
|
132 | + $this->_model=$_model; |
|
133 | 133 | return $this; |
134 | 134 | } |
135 | 135 | |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | public function setInstanceViewer($_instanceViewer) { |
141 | - $this->_instanceViewer = $_instanceViewer; |
|
141 | + $this->_instanceViewer=$_instanceViewer; |
|
142 | 142 | return $this; |
143 | 143 | } |
144 | 144 | |
145 | 145 | abstract public function getHtmlComponent(); |
146 | 146 | |
147 | - public function setAttached($value = true) { |
|
147 | + public function setAttached($value=true) { |
|
148 | 148 | return $this->getHtmlComponent()->setAttached($value); |
149 | 149 | } |
150 | 150 | |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | * @return Widget |
160 | 160 | */ |
161 | 161 | public function afterCompile($index, $callback) { |
162 | - $index = $this->_getIndex($index); |
|
163 | - if ($index !== false) { |
|
162 | + $index=$this->_getIndex($index); |
|
163 | + if ($index!==false) { |
|
164 | 164 | $this->_instanceViewer->afterCompile($index, $callback); |
165 | 165 | } |
166 | 166 | return $this; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | return $this; |
186 | 186 | } |
187 | 187 | |
188 | - public function addField($field, $key = null) { |
|
188 | + public function addField($field, $key=null) { |
|
189 | 189 | $this->_instanceViewer->addField($field, $key); |
190 | 190 | return $this; |
191 | 191 | } |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | return $this->_instanceViewer->visiblePropertiesCount(); |
200 | 200 | } |
201 | 201 | |
202 | - public function addMessage($attributes = NULL, $fieldName = "message") { |
|
202 | + public function addMessage($attributes=NULL, $fieldName="message") { |
|
203 | 203 | $this->_instanceViewer->addField($fieldName); |
204 | - $count = $this->_instanceViewer->visiblePropertiesCount(); |
|
205 | - return $this->fieldAsMessage($count - 1, $attributes); |
|
204 | + $count=$this->_instanceViewer->visiblePropertiesCount(); |
|
205 | + return $this->fieldAsMessage($count-1, $attributes); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | public function addErrorMessage() { |
@@ -211,15 +211,15 @@ discard block |
||
211 | 211 | ], "message"); |
212 | 212 | } |
213 | 213 | |
214 | - public function insertField($index, $field, $key = null) { |
|
215 | - $index = $this->_getIndex($index); |
|
214 | + public function insertField($index, $field, $key=null) { |
|
215 | + $index=$this->_getIndex($index); |
|
216 | 216 | $this->_instanceViewer->insertField($index, $field, $key); |
217 | 217 | return $this; |
218 | 218 | } |
219 | 219 | |
220 | - public function insertInField($index, $field, $key = null) { |
|
221 | - $index = $this->_getIndex($index); |
|
222 | - if ($index !== false) { |
|
220 | + public function insertInField($index, $field, $key=null) { |
|
221 | + $index=$this->_getIndex($index); |
|
222 | + if ($index!==false) { |
|
223 | 223 | $this->_instanceViewer->insertInField($index, $field, $key); |
224 | 224 | } |
225 | 225 | return $this; |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | * @return Widget |
236 | 236 | */ |
237 | 237 | public function setValueFunction($index, $callback) { |
238 | - $index = $this->_getIndex($index); |
|
239 | - if ($index !== false) { |
|
238 | + $index=$this->_getIndex($index); |
|
239 | + if ($index!==false) { |
|
240 | 240 | $this->_instanceViewer->setValueFunction($index, $callback); |
241 | 241 | } |
242 | 242 | return $this; |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
253 | 253 | */ |
254 | 254 | public function getToolbar() { |
255 | - if (isset($this->_toolbar) === false) { |
|
256 | - $this->_toolbar = new HtmlMenu("toolbar-" . $this->identifier); |
|
255 | + if (isset($this->_toolbar)===false) { |
|
256 | + $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
|
257 | 257 | } |
258 | 258 | return $this->_toolbar; |
259 | 259 | } |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | * function to call on $element |
267 | 267 | * @return \Ajax\common\html\HtmlDoubleElement |
268 | 268 | */ |
269 | - public function addInToolbar($element, $callback = NULL) { |
|
270 | - $tb = $this->getToolbar(); |
|
269 | + public function addInToolbar($element, $callback=NULL) { |
|
270 | + $tb=$this->getToolbar(); |
|
271 | 271 | if ($element instanceof BaseWidget) { |
272 | - if ($element->getIdentifier() === "") { |
|
273 | - $element->setIdentifier("tb-item-" . $this->identifier . "-" . $tb->count()); |
|
272 | + if ($element->getIdentifier()==="") { |
|
273 | + $element->setIdentifier("tb-item-".$this->identifier."-".$tb->count()); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | if (isset($callback)) { |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | * function($element) |
290 | 290 | * @return \Ajax\common\html\HtmlDoubleElement |
291 | 291 | */ |
292 | - public function addItemInToolbar($caption, $icon = NULL, $callback = NULL) { |
|
293 | - $result = $this->addInToolbar($caption, $callback); |
|
292 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
293 | + $result=$this->addInToolbar($caption, $callback); |
|
294 | 294 | if (isset($icon) && method_exists($result, "addIcon")) |
295 | 295 | $result->addIcon($icon); |
296 | 296 | return $result; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * function($element) |
304 | 304 | * @return \Ajax\common\Widget |
305 | 305 | */ |
306 | - public function addItemsInToolbar(array $items, $callback = NULL) { |
|
306 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
307 | 307 | if (JArray::isAssociative($items)) { |
308 | 308 | foreach ($items as $icon => $item) { |
309 | 309 | $this->addItemInToolbar($item, $icon, $callback); |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | * function($element) |
325 | 325 | * @return \Ajax\common\html\HtmlDoubleElement |
326 | 326 | */ |
327 | - public function addDropdownInToolbar($value, $items, $callback = NULL) { |
|
328 | - $dd = $value; |
|
327 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
328 | + $dd=$value; |
|
329 | 329 | if (\is_string($value)) { |
330 | - $dd = new HtmlDropdown("dropdown-" . $this->identifier . "-" . $value, $value, $items); |
|
330 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
331 | 331 | } |
332 | 332 | return $this->addInToolbar($dd, $callback); |
333 | 333 | } |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | * function($element) |
341 | 341 | * @return \Ajax\common\html\HtmlDoubleElement |
342 | 342 | */ |
343 | - public function addButtonInToolbar($caption, $cssStyle = null, $callback = NULL) { |
|
344 | - $bt = new HtmlButton("bt-" . $caption, $caption, $cssStyle); |
|
343 | + public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) { |
|
344 | + $bt=new HtmlButton("bt-".$caption, $caption, $cssStyle); |
|
345 | 345 | return $this->addInToolbar($bt, $callback); |
346 | 346 | } |
347 | 347 | |
@@ -353,8 +353,8 @@ discard block |
||
353 | 353 | * function($element) |
354 | 354 | * @return \Ajax\common\html\HtmlDoubleElement |
355 | 355 | */ |
356 | - public function addButtonsInToolbar(array $captions, $asIcon = false, $callback = NULL) { |
|
357 | - $bts = new HtmlButtonGroups("", $captions, $asIcon); |
|
356 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
357 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
358 | 358 | return $this->addInToolbar($bts, $callback); |
359 | 359 | } |
360 | 360 | |
@@ -366,14 +366,14 @@ discard block |
||
366 | 366 | * @param boolean $labeled |
367 | 367 | * @return \Ajax\common\html\HtmlDoubleElement |
368 | 368 | */ |
369 | - public function addLabelledIconButtonInToolbar($caption, $icon, $before = true, $labeled = false) { |
|
370 | - $bt = new HtmlButton("", $caption); |
|
369 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
370 | + $bt=new HtmlButton("", $caption); |
|
371 | 371 | $bt->addIcon($icon, $before, $labeled); |
372 | 372 | return $this->addInToolbar($bt); |
373 | 373 | } |
374 | 374 | |
375 | - public function addSubmitInToolbar($identifier, $value, $cssStyle = NULL, $url = NULL, $responseElement = NULL, $parameters = NULL) { |
|
376 | - $button = new HtmlButton($identifier, $value, $cssStyle); |
|
375 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
376 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
377 | 377 | $this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters); |
378 | 378 | return $this->addInToolbar($button); |
379 | 379 | } |
@@ -396,8 +396,8 @@ discard block |
||
396 | 396 | * @param boolean $_edition |
397 | 397 | * @return \Ajax\common\Widget |
398 | 398 | */ |
399 | - public function setEdition($_edition = true) { |
|
400 | - $this->_edition = $_edition; |
|
399 | + public function setEdition($_edition=true) { |
|
400 | + $this->_edition=$_edition; |
|
401 | 401 | return $this; |
402 | 402 | } |
403 | 403 | |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | * @param string|boolean $disable |
427 | 427 | * @return string |
428 | 428 | */ |
429 | - public function jsDisabled($disable = true) { |
|
430 | - return "$('#" . $this->identifier . " .ui.input,#" . $this->identifier . " .ui.dropdown,#" . $this->identifier . " .ui.checkbox').toggleClass('disabled'," . $disable . ");"; |
|
429 | + public function jsDisabled($disable=true) { |
|
430 | + return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | * function($element) |
438 | 438 | * @return \Ajax\common\html\HtmlDoubleElement |
439 | 439 | */ |
440 | - public function addEditButtonInToolbar($caption, $callback = NULL) { |
|
441 | - $bt = new HtmlButton($this->identifier . "-editBtn", $caption); |
|
440 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
441 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
442 | 442 | $bt->setToggle(); |
443 | 443 | $bt->setActive($this->_edition); |
444 | 444 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
@@ -446,18 +446,18 @@ discard block |
||
446 | 446 | } |
447 | 447 | |
448 | 448 | public function setToolbar(HtmlMenu $_toolbar) { |
449 | - $this->_toolbar = $_toolbar; |
|
449 | + $this->_toolbar=$_toolbar; |
|
450 | 450 | return $this; |
451 | 451 | } |
452 | 452 | |
453 | 453 | public function setToolbarPosition($_toolbarPosition) { |
454 | - $this->_toolbarPosition = $_toolbarPosition; |
|
454 | + $this->_toolbarPosition=$_toolbarPosition; |
|
455 | 455 | return $this; |
456 | 456 | } |
457 | 457 | |
458 | 458 | public function getForm() { |
459 | - if (! isset($this->_form)) { |
|
460 | - $this->_form = new HtmlForm("frm-" . $this->identifier); |
|
459 | + if (!isset($this->_form)) { |
|
460 | + $this->_form=new HtmlForm("frm-".$this->identifier); |
|
461 | 461 | $this->setEdition(true); |
462 | 462 | } |
463 | 463 | return $this->_form; |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | } |
472 | 472 | |
473 | 473 | protected function runForm(JsUtils $js) { |
474 | - $fields = $this->getContentInstances(HtmlFormField::class); |
|
474 | + $fields=$this->getContentInstances(HtmlFormField::class); |
|
475 | 475 | foreach ($fields as $field) { |
476 | 476 | $this->_form->addField($field); |
477 | 477 | } |
@@ -480,10 +480,10 @@ discard block |
||
480 | 480 | |
481 | 481 | protected function _compileForm() { |
482 | 482 | if (isset($this->_form)) { |
483 | - $noValidate = ""; |
|
484 | - if (\sizeof($this->_form->getValidationParams()) > 0) |
|
485 | - $noValidate = "novalidate"; |
|
486 | - $this->wrapContent("<form class='" . $this->_form->getProperty('class') . "' id='frm-" . $this->identifier . "' name='frm-" . $this->identifier . "' " . $noValidate . ">", "</form>"); |
|
483 | + $noValidate=""; |
|
484 | + if (\sizeof($this->_form->getValidationParams())>0) |
|
485 | + $noValidate="novalidate"; |
|
486 | + $this->wrapContent("<form class='".$this->_form->getProperty('class')."' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>"); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
@@ -505,21 +505,21 @@ discard block |
||
505 | 505 | } |
506 | 506 | |
507 | 507 | public function swapFields($index1, $index2) { |
508 | - $index1 = $this->_getIndex($index1); |
|
509 | - $index2 = $this->_getIndex($index2); |
|
508 | + $index1=$this->_getIndex($index1); |
|
509 | + $index2=$this->_getIndex($index2); |
|
510 | 510 | return $this->_instanceViewer->swapFields($index1, $index2); |
511 | 511 | } |
512 | 512 | |
513 | 513 | public function removeField($index) { |
514 | - $index = $this->_getIndex($index); |
|
515 | - if ($index !== false) { |
|
514 | + $index=$this->_getIndex($index); |
|
515 | + if ($index!==false) { |
|
516 | 516 | $this->_instanceViewer->removeField($index); |
517 | 517 | } |
518 | 518 | return $this; |
519 | 519 | } |
520 | 520 | |
521 | - public function asModal($header = null) { |
|
522 | - $modal = new HtmlModal("modal-" . $this->identifier, $header); |
|
521 | + public function asModal($header=null) { |
|
522 | + $modal=new HtmlModal("modal-".$this->identifier, $header); |
|
523 | 523 | $modal->setContent($this); |
524 | 524 | if (isset($this->_form)) { |
525 | 525 | $this->_form->onSuccess($modal->jsHide()); |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | return $modal; |
528 | 528 | } |
529 | 529 | |
530 | - public function addToProperty($name, $value, $separator = " ") { |
|
530 | + public function addToProperty($name, $value, $separator=" ") { |
|
531 | 531 | return $this->getHtmlComponent()->addToProperty($name, $value, $separator); |
532 | 532 | } |
533 | 533 |
@@ -291,8 +291,9 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function addItemInToolbar($caption, $icon = NULL, $callback = NULL) { |
293 | 293 | $result = $this->addInToolbar($caption, $callback); |
294 | - if (isset($icon) && method_exists($result, "addIcon")) |
|
295 | - $result->addIcon($icon); |
|
294 | + if (isset($icon) && method_exists($result, "addIcon")) { |
|
295 | + $result->addIcon($icon); |
|
296 | + } |
|
296 | 297 | return $result; |
297 | 298 | } |
298 | 299 | |
@@ -481,8 +482,9 @@ discard block |
||
481 | 482 | protected function _compileForm() { |
482 | 483 | if (isset($this->_form)) { |
483 | 484 | $noValidate = ""; |
484 | - if (\sizeof($this->_form->getValidationParams()) > 0) |
|
485 | - $noValidate = "novalidate"; |
|
485 | + if (\sizeof($this->_form->getValidationParams()) > 0) { |
|
486 | + $noValidate = "novalidate"; |
|
487 | + } |
|
486 | 488 | $this->wrapContent("<form class='" . $this->_form->getProperty('class') . "' id='frm-" . $this->identifier . "' name='frm-" . $this->identifier . "' " . $noValidate . ">", "</form>"); |
487 | 489 | } |
488 | 490 | } |