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