@@ -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 |
@@ -288,8 +288,9 @@ discard block |
||
288 | 288 | */ |
289 | 289 | public function addItemInToolbar($caption, $icon = NULL, $callback = NULL) { |
290 | 290 | $result = $this->addInToolbar($caption, $callback); |
291 | - if (isset($icon) && method_exists($result, "addIcon")) |
|
292 | - $result->addIcon($icon); |
|
291 | + if (isset($icon) && method_exists($result, "addIcon")) { |
|
292 | + $result->addIcon($icon); |
|
293 | + } |
|
293 | 294 | return $result; |
294 | 295 | } |
295 | 296 | |
@@ -478,8 +479,9 @@ discard block |
||
478 | 479 | protected function _compileForm() { |
479 | 480 | if (isset($this->_form)) { |
480 | 481 | $noValidate = ""; |
481 | - if (\sizeof($this->_form->getValidationParams()) > 0) |
|
482 | - $noValidate = "novalidate"; |
|
482 | + if (\sizeof($this->_form->getValidationParams()) > 0) { |
|
483 | + $noValidate = "novalidate"; |
|
484 | + } |
|
483 | 485 | $this->wrapContent("<form class='".$this->_form->getProperty('class')."' id='frm-" . $this->identifier . "' name='frm-" . $this->identifier . "' " . $noValidate . ">", "</form>"); |
484 | 486 | } |
485 | 487 | } |