@@ -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 | } |
@@ -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 | |
@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | private $ajaxCall; |
| 18 | 18 | |
| 19 | - public function __construct($type, $url, $params, $jsCallback = null, $method = 'post', $parameters = [], $prompt = NULL, $value = NULL) { |
|
| 19 | + public function __construct($type, $url, $params, $jsCallback=null, $method='post', $parameters=[], $prompt=NULL, $value=NULL) { |
|
| 20 | 20 | parent::__construct($type, $prompt, $value); |
| 21 | - $parameters = \array_merge([ |
|
| 21 | + $parameters=\array_merge([ |
|
| 22 | 22 | 'async' => false, |
| 23 | 23 | 'url' => $url, |
| 24 | 24 | 'params' => $params, |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | 'preventDefault' => false, |
| 30 | 30 | 'responseElement' => null |
| 31 | 31 | ], $parameters); |
| 32 | - $this->ajaxCall = new AjaxCall($method, $parameters); |
|
| 32 | + $this->ajaxCall=new AjaxCall($method, $parameters); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function compile(JsUtils $js) { |
| 36 | - $js->exec(Rule::custom($this->getType(), "function(value,ruleValue){var result=true;" . $this->ajaxCall->compile($js) . "return result;}"), true); |
|
| 36 | + $js->exec(Rule::custom($this->getType(), "function(value,ruleValue){var result=true;".$this->ajaxCall->compile($js)."return result;}"), true); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -15,9 +15,9 @@ |
||
| 15 | 15 | |
| 16 | 16 | protected $jsFunction; |
| 17 | 17 | |
| 18 | - public function __construct($type, $jsFunction, $prompt = NULL, $value = NULL) { |
|
| 18 | + public function __construct($type, $jsFunction, $prompt=NULL, $value=NULL) { |
|
| 19 | 19 | parent::__construct($type, $prompt, $value); |
| 20 | - $this->jsFunction = $jsFunction; |
|
| 20 | + $this->jsFunction=$jsFunction; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function compile(JsUtils $js) { |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class HtmlRail extends HtmlSemDoubleElement { |
| 12 | 12 | |
| 13 | - public function __construct($identifier, $content = NULL) { |
|
| 13 | + public function __construct($identifier, $content=NULL) { |
|
| 14 | 14 | parent::__construct($identifier, 'div', 'ui rail', $content); |
| 15 | 15 | } |
| 16 | 16 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param string $onClick |
| 46 | 46 | * @return HtmlButton |
| 47 | 47 | */ |
| 48 | - public function htmlButton($identifier, $value = null, $cssStyle = null, $onClick = null) { |
|
| 48 | + public function htmlButton($identifier, $value=null, $cssStyle=null, $onClick=null) { |
|
| 49 | 49 | return $this->addHtmlComponent(new HtmlButton($identifier, $value, $cssStyle, $onClick)); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param boolean $asIcons |
| 60 | 60 | * @return HtmlButtonGroups |
| 61 | 61 | */ |
| 62 | - public function htmlButtonGroups($identifier, $elements = array(), $asIcons = false) { |
|
| 62 | + public function htmlButtonGroups($identifier, $elements=array(), $asIcons=false) { |
|
| 63 | 63 | return $this->addHtmlComponent(new HtmlButtonGroups($identifier, $elements, $asIcons)); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @param string $content |
| 73 | 73 | * @return HtmlContainer |
| 74 | 74 | */ |
| 75 | - public function htmlContainer($identifier, $content = "") { |
|
| 75 | + public function htmlContainer($identifier, $content="") { |
|
| 76 | 76 | return $this->addHtmlComponent(new HtmlContainer($identifier, $content)); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @param string $content |
| 86 | 86 | * @return HtmlDivider |
| 87 | 87 | */ |
| 88 | - public function htmlDivider($identifier, $content = "", $tagName = "div") { |
|
| 88 | + public function htmlDivider($identifier, $content="", $tagName="div") { |
|
| 89 | 89 | return $this->addHtmlComponent(new HtmlDivider($identifier, $content, $tagName)); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @param string $type |
| 101 | 101 | * @return HtmlHeader |
| 102 | 102 | */ |
| 103 | - public function htmlHeader($identifier, $niveau = 1, $content = NULL, $type = "page") { |
|
| 103 | + public function htmlHeader($identifier, $niveau=1, $content=NULL, $type="page") { |
|
| 104 | 104 | return $this->addHtmlComponent(new HtmlHeader($identifier, $niveau, $content, $type)); |
| 105 | 105 | } |
| 106 | 106 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param string $size |
| 129 | 129 | * @return HtmlImage |
| 130 | 130 | */ |
| 131 | - public function htmlImage($identifier, $src = "", $alt = "", $size = NULL) { |
|
| 131 | + public function htmlImage($identifier, $src="", $alt="", $size=NULL) { |
|
| 132 | 132 | return $this->addHtmlComponent(new HtmlImage($identifier, $src, $alt, $size)); |
| 133 | 133 | } |
| 134 | 134 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param string $size |
| 143 | 143 | * @return HtmlIconGroups |
| 144 | 144 | */ |
| 145 | - public function htmlIconGroups($identifier, $icons = array(), $size = "") { |
|
| 145 | + public function htmlIconGroups($identifier, $icons=array(), $size="") { |
|
| 146 | 146 | return $this->addHtmlComponent(new HtmlIconGroups($identifier, $icons, $size)); |
| 147 | 147 | } |
| 148 | 148 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param string $placeholder |
| 158 | 158 | * @return HtmlInput |
| 159 | 159 | */ |
| 160 | - public function htmlInput($identifier, $type = "text", $value = "", $placeholder = "") { |
|
| 160 | + public function htmlInput($identifier, $type="text", $value="", $placeholder="") { |
|
| 161 | 161 | return $this->addHtmlComponent(new HtmlInput($identifier, $type, $value, $placeholder)); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param string $tagName |
| 172 | 172 | * @return HtmlLabel |
| 173 | 173 | */ |
| 174 | - public function htmlLabel($identifier, $content = "", $icon = NULL, $tagName = "div") { |
|
| 174 | + public function htmlLabel($identifier, $content="", $icon=NULL, $tagName="div") { |
|
| 175 | 175 | return $this->addHtmlComponent(new HtmlLabel($identifier, $content, $icon, $tagName)); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param array $attributes |
| 183 | 183 | * @return HtmlLabelGroups |
| 184 | 184 | */ |
| 185 | - public function htmlLabelGroups($identifier, $labels = array(), $attributes = array()) { |
|
| 185 | + public function htmlLabelGroups($identifier, $labels=array(), $attributes=array()) { |
|
| 186 | 186 | return $this->addHtmlComponent(new HtmlLabelGroups($identifier, $labels, $attributes)); |
| 187 | 187 | } |
| 188 | 188 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @param array $items |
| 194 | 194 | * @return HtmlList |
| 195 | 195 | */ |
| 196 | - public function htmlList($identifier, $items = array()) { |
|
| 196 | + public function htmlList($identifier, $items=array()) { |
|
| 197 | 197 | return $this->addHtmlComponent(new HtmlList($identifier, $items)); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @param string $content |
| 205 | 205 | * @return HtmlSegment |
| 206 | 206 | */ |
| 207 | - public function htmlSegment($identifier, $content = "") { |
|
| 207 | + public function htmlSegment($identifier, $content="") { |
|
| 208 | 208 | return $this->addHtmlComponent(new HtmlSegment($identifier, $content)); |
| 209 | 209 | } |
| 210 | 210 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * the segments |
| 217 | 217 | * @return HtmlSegmentGroups |
| 218 | 218 | */ |
| 219 | - public function htmlSegmentGroups($identifier, $items = array()) { |
|
| 219 | + public function htmlSegmentGroups($identifier, $items=array()) { |
|
| 220 | 220 | return $this->addHtmlComponent(new HtmlSegmentGroups($identifier, $items)); |
| 221 | 221 | } |
| 222 | 222 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | * @param Direction|string $attributeType |
| 231 | 231 | * @return HtmlReveal |
| 232 | 232 | */ |
| 233 | - public function htmlReveal($identifier, $visibleContent, $hiddenContent, $type = RevealType::FADE, $attributeType = NULL) { |
|
| 233 | + public function htmlReveal($identifier, $visibleContent, $hiddenContent, $type=RevealType::FADE, $attributeType=NULL) { |
|
| 234 | 234 | return $this->addHtmlComponent(new HtmlReveal($identifier, $visibleContent, $hiddenContent, $type, $attributeType)); |
| 235 | 235 | } |
| 236 | 236 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @param array $steps |
| 242 | 242 | * @return HtmlStep |
| 243 | 243 | */ |
| 244 | - public function htmlStep($identifier, $steps = array()) { |
|
| 244 | + public function htmlStep($identifier, $steps=array()) { |
|
| 245 | 245 | return $this->addHtmlComponent(new HtmlStep($identifier, $steps)); |
| 246 | 246 | } |
| 247 | 247 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | * @param mixed $content |
| 276 | 276 | * @return HtmlRail |
| 277 | 277 | */ |
| 278 | - public function htmlRail($identifier, $content = null) { |
|
| 278 | + public function htmlRail($identifier, $content=null) { |
|
| 279 | 279 | return $this->addHtmlComponent(new HtmlRail($identifier, $content)); |
| 280 | 280 | } |
| 281 | 281 | } |
@@ -13,19 +13,19 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | protected $content; |
| 15 | 15 | |
| 16 | - protected $wrapContentBefore = ""; |
|
| 16 | + protected $wrapContentBefore=""; |
|
| 17 | 17 | |
| 18 | - protected $wrapContentAfter = ""; |
|
| 18 | + protected $wrapContentAfter=""; |
|
| 19 | 19 | |
| 20 | 20 | protected $_editableContent; |
| 21 | 21 | |
| 22 | - public function __construct($identifier, $tagName = "p") { |
|
| 22 | + public function __construct($identifier, $tagName="p") { |
|
| 23 | 23 | parent::__construct($identifier, $tagName); |
| 24 | - $this->_template = '<%tagName% id="%identifier%" %properties%>%wrapContentBefore%%content%%wrapContentAfter%</%tagName%>'; |
|
| 24 | + $this->_template='<%tagName% id="%identifier%" %properties%>%wrapContentBefore%%content%%wrapContentAfter%</%tagName%>'; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function setContent($content) { |
| 28 | - $this->content = $content; |
|
| 28 | + $this->content=$content; |
|
| 29 | 29 | return $this; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -33,19 +33,19 @@ discard block |
||
| 33 | 33 | return $this->content; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function addContent($content, $before = false) { |
|
| 37 | - if (! \is_array($this->content)) { |
|
| 36 | + public function addContent($content, $before=false) { |
|
| 37 | + if (!\is_array($this->content)) { |
|
| 38 | 38 | if (isset($this->content)) |
| 39 | - $this->content = array( |
|
| 39 | + $this->content=array( |
|
| 40 | 40 | $this->content |
| 41 | 41 | ); |
| 42 | 42 | else |
| 43 | - $this->content = array(); |
|
| 43 | + $this->content=array(); |
|
| 44 | 44 | } |
| 45 | 45 | if ($before) |
| 46 | 46 | \array_unshift($this->content, $content); |
| 47 | 47 | else |
| 48 | - $this->content[] = $content; |
|
| 48 | + $this->content[]=$content; |
|
| 49 | 49 | return $this; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | public function setValue($value) {} |
| 70 | 70 | |
| 71 | - public function wrapContent($before, $after = "") { |
|
| 72 | - $this->wrapContentBefore .= $before; |
|
| 73 | - $this->wrapContentAfter = $after . $this->wrapContentAfter; |
|
| 71 | + public function wrapContent($before, $after="") { |
|
| 72 | + $this->wrapContentBefore.=$before; |
|
| 73 | + $this->wrapContentAfter=$after.$this->wrapContentAfter; |
|
| 74 | 74 | return $this; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -89,14 +89,14 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | protected function _getContentInstances($class, $content) { |
| 92 | - $instances = []; |
|
| 92 | + $instances=[]; |
|
| 93 | 93 | if ($content instanceof $class) { |
| 94 | - $instances[] = $content; |
|
| 94 | + $instances[]=$content; |
|
| 95 | 95 | } elseif ($content instanceof HtmlDoubleElement) { |
| 96 | - $instances = \array_merge($instances, $content->getContentInstances($class)); |
|
| 96 | + $instances=\array_merge($instances, $content->getContentInstances($class)); |
|
| 97 | 97 | } elseif (\is_array($content)) { |
| 98 | 98 | foreach ($content as $element) { |
| 99 | - $instances = \array_merge($instances, $this->_getContentInstances($class, $element)); |
|
| 99 | + $instances=\array_merge($instances, $this->_getContentInstances($class, $element)); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | return $instances; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return HtmlDoubleElement |
| 109 | 109 | */ |
| 110 | - public function asLink($href = NULL, $target = NULL) { |
|
| 110 | + public function asLink($href=NULL, $target=NULL) { |
|
| 111 | 111 | if (isset($href)) |
| 112 | 112 | $this->setProperty("href", $href); |
| 113 | 113 | if (isset($target)) |
@@ -122,28 +122,28 @@ discard block |
||
| 122 | 122 | return \strip_tags($this->content); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - public function asEditable(HtmlFormField $field, $asForm = false, $setValueProperty = "val()") { |
|
| 126 | - $idF = $field->getIdentifier(); |
|
| 127 | - $idE = $idF; |
|
| 125 | + public function asEditable(HtmlFormField $field, $asForm=false, $setValueProperty="val()") { |
|
| 126 | + $idF=$field->getIdentifier(); |
|
| 127 | + $idE=$idF; |
|
| 128 | 128 | if ($asForm) { |
| 129 | - $frm = new HtmlForm("frm-" . $field->getIdentifier()); |
|
| 129 | + $frm=new HtmlForm("frm-".$field->getIdentifier()); |
|
| 130 | 130 | $frm->setProperty("onsubmit", "return false;"); |
| 131 | - $fields = $frm->addFields(); |
|
| 132 | - $idE = $frm->getIdentifier(); |
|
| 131 | + $fields=$frm->addFields(); |
|
| 132 | + $idE=$frm->getIdentifier(); |
|
| 133 | 133 | $fields->addItem($field); |
| 134 | - $fields->addButtonIcon("bt-okay", "check", "green mini", "\$('#" . $idE . "').trigger('validate',{value: $('#'+idF+' input').val()});"); |
|
| 135 | - $fields->addButtonIcon("bt-cancel", "close", "mini", "\$('#" . $idE . "').trigger('endEdit');"); |
|
| 136 | - $this->_editableContent = $frm; |
|
| 137 | - $keypress = ""; |
|
| 138 | - $focusOut = ""; |
|
| 134 | + $fields->addButtonIcon("bt-okay", "check", "green mini", "\$('#".$idE."').trigger('validate',{value: $('#'+idF+' input').val()});"); |
|
| 135 | + $fields->addButtonIcon("bt-cancel", "close", "mini", "\$('#".$idE."').trigger('endEdit');"); |
|
| 136 | + $this->_editableContent=$frm; |
|
| 137 | + $keypress=""; |
|
| 138 | + $focusOut=""; |
|
| 139 | 139 | } else { |
| 140 | - $focusOut = "if(e.relatedTarget==null)elm.trigger('endEdit');"; |
|
| 141 | - $this->_editableContent = $field; |
|
| 142 | - $keypress = "$('#" . $idF . "').keyup(function(e){if(e.which == 13) {\$('#" . $idE . "').trigger('validate',{value: $('#'+idF+' input').val()});}if(e.keyCode===27) {\$('#" . $idE . "').trigger('endEdit');}});"; |
|
| 140 | + $focusOut="if(e.relatedTarget==null)elm.trigger('endEdit');"; |
|
| 141 | + $this->_editableContent=$field; |
|
| 142 | + $keypress="$('#".$idF."').keyup(function(e){if(e.which == 13) {\$('#".$idE."').trigger('validate',{value: $('#'+idF+' input').val()});}if(e.keyCode===27) {\$('#".$idE."').trigger('endEdit');}});"; |
|
| 143 | 143 | } |
| 144 | 144 | $this->_editableContent->setProperty("style", "display:none;"); |
| 145 | - $this->onCreate("let idF='" . $idF . "';let idE='" . $idE . "';let elm=$('#'+idE);let self=$('#" . $this->getIdentifier() . "');" . $keypress . "elm.on('validate',function(){self.html($('#'+idE+' input')." . $setValueProperty . ");elm.trigger('endEdit');});elm.on('endEdit',function(){self.show();$(this).hide();});elm.focusout(function(e){" . $focusOut . "});"); |
|
| 146 | - $this->onClick("let self=$(this);self.hide();" . $field->setJsContent("self.html()") . ";$('#" . $idF . " input').trigger('change');elm.show();$('#'+idE+' input').focus();"); |
|
| 145 | + $this->onCreate("let idF='".$idF."';let idE='".$idE."';let elm=$('#'+idE);let self=$('#".$this->getIdentifier()."');".$keypress."elm.on('validate',function(){self.html($('#'+idE+' input').".$setValueProperty.");elm.trigger('endEdit');});elm.on('endEdit',function(){self.show();$(this).hide();});elm.focusout(function(e){".$focusOut."});"); |
|
| 146 | + $this->onClick("let self=$(this);self.hide();".$field->setJsContent("self.html()").";$('#".$idF." input').trigger('change');elm.show();$('#'+idE+' input').focus();"); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -151,8 +151,8 @@ discard block |
||
| 151 | 151 | * {@inheritdoc} |
| 152 | 152 | * @see \Ajax\common\html\BaseHtml::compile_once() |
| 153 | 153 | */ |
| 154 | - protected function compile_once(\Ajax\JsUtils $js = NULL, &$view = NULL) { |
|
| 155 | - if (! $this->_compiled && isset($this->_editableContent)) { |
|
| 154 | + protected function compile_once(\Ajax\JsUtils $js=NULL, &$view=NULL) { |
|
| 155 | + if (!$this->_compiled && isset($this->_editableContent)) { |
|
| 156 | 156 | $this->wrap("", $this->_editableContent); |
| 157 | 157 | } |
| 158 | 158 | parent::compile_once($js, $view); |
@@ -35,17 +35,19 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | public function addContent($content, $before = false) { |
| 37 | 37 | if (! \is_array($this->content)) { |
| 38 | - if (isset($this->content)) |
|
| 39 | - $this->content = array( |
|
| 38 | + if (isset($this->content)) { |
|
| 39 | + $this->content = array( |
|
| 40 | 40 | $this->content |
| 41 | 41 | ); |
| 42 | - else |
|
| 43 | - $this->content = array(); |
|
| 42 | + } else { |
|
| 43 | + $this->content = array(); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + if ($before) { |
|
| 47 | + \array_unshift($this->content, $content); |
|
| 48 | + } else { |
|
| 49 | + $this->content[] = $content; |
|
| 44 | 50 | } |
| 45 | - if ($before) |
|
| 46 | - \array_unshift($this->content, $content); |
|
| 47 | - else |
|
| 48 | - $this->content[] = $content; |
|
| 49 | 51 | return $this; |
| 50 | 52 | } |
| 51 | 53 | |
@@ -108,10 +110,12 @@ discard block |
||
| 108 | 110 | * @return HtmlDoubleElement |
| 109 | 111 | */ |
| 110 | 112 | public function asLink($href = NULL, $target = NULL) { |
| 111 | - if (isset($href)) |
|
| 112 | - $this->setProperty("href", $href); |
|
| 113 | - if (isset($target)) |
|
| 114 | - $this->setProperty("target", $target); |
|
| 113 | + if (isset($href)) { |
|
| 114 | + $this->setProperty("href", $href); |
|
| 115 | + } |
|
| 116 | + if (isset($target)) { |
|
| 117 | + $this->setProperty("target", $target); |
|
| 118 | + } |
|
| 115 | 119 | return $this->setTagName("a"); |
| 116 | 120 | } |
| 117 | 121 | |
@@ -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(); |
@@ -65,42 +65,42 @@ discard block |
||
| 65 | 65 | \sort($separators); |
| 66 | 66 | $size=\count($separators); |
| 67 | 67 | $nb=0; |
| 68 | - if($size===1){ |
|
| 68 | + if ($size===1) { |
|
| 69 | 69 | $i=-1; |
| 70 | - foreach ($values as $k=>$v){ |
|
| 71 | - $this->_generateFields($form, [$v], $headers, $i, $wrappers,$nb++,$names[$k]??''); |
|
| 70 | + foreach ($values as $k=>$v) { |
|
| 71 | + $this->_generateFields($form, [$v], $headers, $i, $wrappers, $nb++, $names[$k] ?? ''); |
|
| 72 | 72 | $i++; |
| 73 | 73 | } |
| 74 | - }else{ |
|
| 74 | + } else { |
|
| 75 | 75 | $separators[]=$count; |
| 76 | - for($i=0;$i<$size;$i++){ |
|
| 77 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
| 78 | - $this->_generateFields($form, $fields, $headers, $separators[$i], $wrappers,$nb++,$names[$i]??''); |
|
| 76 | + for ($i=0; $i<$size; $i++) { |
|
| 77 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
| 78 | + $this->_generateFields($form, $fields, $headers, $separators[$i], $wrappers, $nb++, $names[$i] ?? ''); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | - if($this->_hasRules && !$this->getForm()->hasValidationParams()){ |
|
| 81 | + if ($this->_hasRules && !$this->getForm()->hasValidationParams()) { |
|
| 82 | 82 | $this->setValidationParams(['inline'=>true]); |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - protected function _generateFields($form, $values, $headers, $sepFirst, $wrappers, $nb, $name){ |
|
| 86 | + protected function _generateFields($form, $values, $headers, $sepFirst, $wrappers, $nb, $name) { |
|
| 87 | 87 | $wrapper=null; |
| 88 | - if(isset($headers[$sepFirst+1])) |
|
| 89 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 90 | - if(isset($wrappers[$sepFirst+1])){ |
|
| 88 | + if (isset($headers[$sepFirst+1])) |
|
| 89 | + $form->addHeader($headers[$sepFirst+1], 4, true); |
|
| 90 | + if (isset($wrappers[$sepFirst+1])) { |
|
| 91 | 91 | $wrapper=$wrappers[$sepFirst+1]; |
| 92 | 92 | } |
| 93 | 93 | $count=\count($values); |
| 94 | - if($count===1){ |
|
| 94 | + if ($count===1) { |
|
| 95 | 95 | $added=$form->addField($values[0]); |
| 96 | - }elseif($count>1){ |
|
| 96 | + }elseif ($count>1) { |
|
| 97 | 97 | $added=$form->addFields($values); |
| 98 | - }else |
|
| 98 | + } else |
|
| 99 | 99 | return; |
| 100 | - if(isset($wrapper)){ |
|
| 101 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
| 100 | + if (isset($wrapper)) { |
|
| 101 | + $added->wrap($wrapper[0], $wrapper[1]); |
|
| 102 | 102 | } |
| 103 | - $this->execHook('onGenerateFields',$added,$nb,$name); |
|
| 103 | + $this->execHook('onGenerateFields', $added, $nb, $name); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -108,18 +108,18 @@ discard block |
||
| 108 | 108 | * the generated field is the first parameter |
| 109 | 109 | * @param callable $callback the fonction to call when a field is generated |
| 110 | 110 | */ |
| 111 | - public function onGenerateField($callback){ |
|
| 112 | - $this->addHook('onGenerateFields',$callback); |
|
| 111 | + public function onGenerateField($callback) { |
|
| 112 | + $this->addHook('onGenerateFields', $callback); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * @return HtmlForm |
| 117 | 117 | */ |
| 118 | - public function getForm(){ |
|
| 118 | + public function getForm() { |
|
| 119 | 119 | return $this->content['form']; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public function addSeparatorAfter($fieldNum){ |
|
| 122 | + public function addSeparatorAfter($fieldNum) { |
|
| 123 | 123 | $fieldNum=$this->_getIndex($fieldNum); |
| 124 | 124 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
| 125 | 125 | return $this; |
@@ -134,12 +134,12 @@ discard block |
||
| 134 | 134 | return $this; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
| 138 | - return $this->_fieldAs(function($id,$name,$value) use ($cssStyle){ |
|
| 139 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 137 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 138 | + return $this->_fieldAs(function($id, $name, $value) use ($cssStyle){ |
|
| 139 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 140 | 140 | $button->setProperty('type', 'reset'); |
| 141 | 141 | return $button; |
| 142 | - }, $index,$attributes); |
|
| 142 | + }, $index, $attributes); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -158,19 +158,19 @@ discard block |
||
| 158 | 158 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public function addDividerBefore($index,$title){ |
|
| 161 | + public function addDividerBefore($index, $title) { |
|
| 162 | 162 | $index=$this->_getIndex($index); |
| 163 | 163 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
| 164 | 164 | return $this; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - public function addWrapper($index,$contentBefore,$contentAfter=null){ |
|
| 167 | + public function addWrapper($index, $contentBefore, $contentAfter=null) { |
|
| 168 | 168 | $index=$this->_getIndex($index); |
| 169 | - $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
|
| 169 | + $this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter); |
|
| 170 | 170 | return $this; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - public function run(JsUtils $js){ |
|
| 173 | + public function run(JsUtils $js) { |
|
| 174 | 174 | parent::run($js); |
| 175 | 175 | } |
| 176 | 176 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $this->_generateFields($form, [$v], $headers, $i, $wrappers,$nb++,$names[$k]??''); |
| 72 | 72 | $i++; |
| 73 | 73 | } |
| 74 | - }else{ |
|
| 74 | + } else{ |
|
| 75 | 75 | $separators[]=$count; |
| 76 | 76 | for($i=0;$i<$size;$i++){ |
| 77 | 77 | $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
@@ -85,18 +85,20 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | protected function _generateFields($form, $values, $headers, $sepFirst, $wrappers, $nb, $name){ |
| 87 | 87 | $wrapper=null; |
| 88 | - if(isset($headers[$sepFirst+1])) |
|
| 89 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 88 | + if(isset($headers[$sepFirst+1])) { |
|
| 89 | + $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 90 | + } |
|
| 90 | 91 | if(isset($wrappers[$sepFirst+1])){ |
| 91 | 92 | $wrapper=$wrappers[$sepFirst+1]; |
| 92 | 93 | } |
| 93 | 94 | $count=\count($values); |
| 94 | 95 | if($count===1){ |
| 95 | 96 | $added=$form->addField($values[0]); |
| 96 | - }elseif($count>1){ |
|
| 97 | + } elseif($count>1){ |
|
| 97 | 98 | $added=$form->addFields($values); |
| 98 | - }else |
|
| 99 | - return; |
|
| 99 | + } else { |
|
| 100 | + return; |
|
| 101 | + } |
|
| 100 | 102 | if(isset($wrapper)){ |
| 101 | 103 | $added->wrap($wrapper[0],$wrapper[1]); |
| 102 | 104 | } |
@@ -7,20 +7,20 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
| 9 | 9 | |
| 10 | - public function __construct($identifier, $items = array(), $label = NULL, $value = "", $multiple = false, $associative = true) { |
|
| 11 | - parent::__construct("field-" . $identifier, (new HtmlDropdown("dropdown-" . $identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label); |
|
| 12 | - $this->_identifier = $identifier; |
|
| 10 | + public function __construct($identifier, $items=array(), $label=NULL, $value="", $multiple=false, $associative=true) { |
|
| 11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label); |
|
| 12 | + $this->_identifier=$identifier; |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | public function setItems($items) { |
| 16 | 16 | return $this->getField()->setItems($items); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function addItem($item, $value = NULL, $image = NULL) { |
|
| 19 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
| 20 | 20 | return $this->getField()->addItem($item, $value, $image); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public static function multipleDropdown($identifier, $items = array(), $label = NULL, $value = "", $associative = true) { |
|
| 23 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value="", $associative=true) { |
|
| 24 | 24 | return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | return $this->getField()->getInput(); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function asSelect($name = NULL, $multiple = false, $selection = true) { |
|
| 35 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
| 36 | 36 | $this->getField()->asSelect($name, $multiple, $selection); |
| 37 | 37 | return $this; |
| 38 | 38 | } |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | * @param boolean $floating |
| 43 | 43 | * @return HtmlDropdown |
| 44 | 44 | */ |
| 45 | - public function asButton($floating = false) { |
|
| 46 | - $field = $this->content["field"]; |
|
| 47 | - $label = $this->content["label"]; |
|
| 45 | + public function asButton($floating=false) { |
|
| 46 | + $field=$this->content["field"]; |
|
| 47 | + $label=$this->content["label"]; |
|
| 48 | 48 | $field->addContent($label); |
| 49 | - $this->content = [ |
|
| 49 | + $this->content=[ |
|
| 50 | 50 | "field" => $field |
| 51 | 51 | ]; |
| 52 | 52 | $this->content["field"]->asButton($floating); |
@@ -61,15 +61,15 @@ discard block |
||
| 61 | 61 | * @param boolean $labeled |
| 62 | 62 | * @return mixed|HtmlButton |
| 63 | 63 | */ |
| 64 | - public function addAction($action, $direction = Direction::RIGHT, $icon = NULL, $labeled = false) { |
|
| 64 | + public function addAction($action, $direction=Direction::RIGHT, $icon=NULL, $labeled=false) { |
|
| 65 | 65 | $this->getField()->setStyle('display:inline-block; width: auto'); |
| 66 | - $actionO = $action; |
|
| 67 | - if (\is_object($action) === false) { |
|
| 68 | - $actionO = new HtmlButton("action-" . $this->identifier, $action); |
|
| 66 | + $actionO=$action; |
|
| 67 | + if (\is_object($action)===false) { |
|
| 68 | + $actionO=new HtmlButton("action-".$this->identifier, $action); |
|
| 69 | 69 | if (isset($icon)) |
| 70 | 70 | $actionO->addIcon($icon, true, $labeled); |
| 71 | 71 | } |
| 72 | - $this->addContent($actionO, \strstr($direction, Direction::LEFT) !== false); |
|
| 72 | + $this->addContent($actionO, \strstr($direction, Direction::LEFT)!==false); |
|
| 73 | 73 | return $actionO; |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -66,8 +66,9 @@ |
||
| 66 | 66 | $actionO = $action; |
| 67 | 67 | if (\is_object($action) === false) { |
| 68 | 68 | $actionO = new HtmlButton("action-" . $this->identifier, $action); |
| 69 | - if (isset($icon)) |
|
| 70 | - $actionO->addIcon($icon, true, $labeled); |
|
| 69 | + if (isset($icon)) { |
|
| 70 | + $actionO->addIcon($icon, true, $labeled); |
|
| 71 | + } |
|
| 71 | 72 | } |
| 72 | 73 | $this->addContent($actionO, \strstr($direction, Direction::LEFT) !== false); |
| 73 | 74 | return $actionO; |
@@ -29,12 +29,12 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @var string|array |
| 31 | 31 | */ |
| 32 | - protected $_contentSeparator = ""; |
|
| 32 | + protected $_contentSeparator=""; |
|
| 33 | 33 | |
| 34 | 34 | public function __construct($identifier, $tagName, $baseClass) { |
| 35 | 35 | parent::__construct($identifier, $tagName, $baseClass); |
| 36 | - $this->root = ""; |
|
| 37 | - $this->attr = "data-ajax"; |
|
| 36 | + $this->root=""; |
|
| 37 | + $this->attr="data-ajax"; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -54,23 +54,23 @@ discard block |
||
| 54 | 54 | return JArray::implode($this->_contentSeparator, $this->content); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function setContentDivider($divider, $index = NULL) { |
|
| 58 | - $divider = "<div class='divider'> {$divider} </div>"; |
|
| 57 | + public function setContentDivider($divider, $index=NULL) { |
|
| 58 | + $divider="<div class='divider'> {$divider} </div>"; |
|
| 59 | 59 | return $this->setDivider($divider, $index); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function setIconContentDivider($iconContentDivider, $index = NULL) { |
|
| 63 | - $contentDivider = "<i class='" . $iconContentDivider . " icon divider'></i>"; |
|
| 62 | + public function setIconContentDivider($iconContentDivider, $index=NULL) { |
|
| 63 | + $contentDivider="<i class='".$iconContentDivider." icon divider'></i>"; |
|
| 64 | 64 | return $this->setDivider($contentDivider, $index); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | protected function setDivider($divider, $index) { |
| 68 | 68 | if (isset($index)) { |
| 69 | - if (! \is_array($this->_contentSeparator)) |
|
| 70 | - $this->_contentSeparator = array_fill(0, $this->count() - 1, $this->_contentSeparator); |
|
| 71 | - $this->_contentSeparator[$index] = $divider; |
|
| 69 | + if (!\is_array($this->_contentSeparator)) |
|
| 70 | + $this->_contentSeparator=array_fill(0, $this->count()-1, $this->_contentSeparator); |
|
| 71 | + $this->_contentSeparator[$index]=$divider; |
|
| 72 | 72 | } else { |
| 73 | - $this->_contentSeparator = $divider; |
|
| 73 | + $this->_contentSeparator=$divider; |
|
| 74 | 74 | } |
| 75 | 75 | return $this; |
| 76 | 76 | } |
@@ -66,8 +66,9 @@ |
||
| 66 | 66 | |
| 67 | 67 | protected function setDivider($divider, $index) { |
| 68 | 68 | if (isset($index)) { |
| 69 | - if (! \is_array($this->_contentSeparator)) |
|
| 70 | - $this->_contentSeparator = array_fill(0, $this->count() - 1, $this->_contentSeparator); |
|
| 69 | + if (! \is_array($this->_contentSeparator)) { |
|
| 70 | + $this->_contentSeparator = array_fill(0, $this->count() - 1, $this->_contentSeparator); |
|
| 71 | + } |
|
| 71 | 72 | $this->_contentSeparator[$index] = $divider; |
| 72 | 73 | } else { |
| 73 | 74 | $this->_contentSeparator = $divider; |