Passed
Push — master ( e370f7...d93737 )
by Jean-Christophe
03:07
created
Ajax/common/Widget.php 2 patches
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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='ui form' 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='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>");
484 484
 		}
485 485
 	}
486 486
 
@@ -502,21 +502,21 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -288,8 +288,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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='ui form' id='frm-" . $this->identifier . "' name='frm-" . $this->identifier . "' " . $noValidate . ">", "</form>");
484 486
 		}
485 487
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 2 patches
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *
25 25
  */
26 26
 class DataTable extends Widget {
27
-	use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait;
27
+	use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait;
28 28
 
29 29
 	protected $_searchField;
30 30
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
 	protected $_displayBehavior;
42 42
 
43
-	protected $_visibleHover = false;
43
+	protected $_visibleHover=false;
44 44
 
45 45
 	protected $_targetSelector;
46 46
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
 	protected $_json;
52 52
 
53
-	protected $_rowClass = "_element";
53
+	protected $_rowClass="_element";
54 54
 
55 55
 	protected $_sortable;
56 56
 
@@ -58,26 +58,26 @@  discard block
 block discarded – undo
58 58
 
59 59
 	protected $_colWidths;
60 60
 
61
-	public function __construct($identifier, $model, $modelInstance = NULL) {
61
+	public function __construct($identifier, $model, $modelInstance=NULL) {
62 62
 		parent::__construct($identifier, $model, $modelInstance);
63 63
 		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
64
-		$this->_urls = [];
65
-		$this->_emptyMessage = new HtmlMessage("", "nothing to display");
64
+		$this->_urls=[];
65
+		$this->_emptyMessage=new HtmlMessage("", "nothing to display");
66 66
 		$this->_emptyMessage->setIcon("info circle");
67 67
 	}
68 68
 
69 69
 	public function run(JsUtils $js) {
70
-		if ($this->_runned !== true) {
71
-			$offset = $js->scriptCount();
70
+		if ($this->_runned!==true) {
71
+			$offset=$js->scriptCount();
72 72
 			if ($this->_hasCheckboxes && isset($js)) {
73 73
 				$this->_runCheckboxes($js);
74 74
 			}
75 75
 			if ($this->_visibleHover) {
76
-				$js->execOn("mouseover", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [
76
+				$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [
77 77
 					"preventDefault" => false,
78 78
 					"stopPropagation" => true
79 79
 				]);
80
-				$js->execOn("mouseout", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [
80
+				$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [
81 81
 					"preventDefault" => false,
82 82
 					"stopPropagation" => true
83 83
 				]);
@@ -93,16 +93,16 @@  discard block
 block discarded – undo
93 93
 			if (isset($this->_pagination))
94 94
 				$this->_associatePaginationBehavior($js, $offset);
95 95
 			$this->_associateSearchFieldBehavior($js, $offset);
96
-			$this->_runned = true;
96
+			$this->_runned=true;
97 97
 		}
98 98
 	}
99 99
 
100 100
 	protected function _generateBehavior($op, $params, JsUtils $js) {
101 101
 		if (isset($this->_urls[$op])) {
102
-			$params = \array_merge($params, [
102
+			$params=\array_merge($params, [
103 103
 				"attr" => "data-ajax"
104 104
 			]);
105
-			$js->ajaxOnClick("#" . $this->identifier . " ._" . $op, $this->_urls[$op], $this->getTargetSelector($op), $params);
105
+			$js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params);
106 106
 		}
107 107
 	}
108 108
 
@@ -121,21 +121,21 @@  discard block
 block discarded – undo
121 121
 	}
122 122
 
123 123
 	public function refreshTD($fieldName, $jquery, $view) {
124
-		$index = $this->_getIndex($fieldName);
124
+		$index=$this->_getIndex($fieldName);
125 125
 		$this->compile($jquery, $view);
126 126
 		return $this->refreshTR()
127 127
 			->getTable()
128 128
 			->getCell(0, $index);
129 129
 	}
130 130
 
131
-	public function compile(JsUtils $js = NULL, &$view = NULL) {
132
-		if (! $this->_generated) {
131
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
132
+		if (!$this->_generated) {
133 133
 			if (isset($this->_buttonsColumn)) {
134 134
 				$this->_instanceViewer->sortColumnContent($this->_buttonsColumn, $this->_buttons);
135 135
 			}
136 136
 			$this->_instanceViewer->setInstance($this->_model);
137
-			$captions = $this->_instanceViewer->getCaptions();
138
-			$table = $this->content["table"];
137
+			$captions=$this->_instanceViewer->getCaptions();
138
+			$table=$this->content["table"];
139 139
 			if ($this->_hasCheckboxes) {
140 140
 				$this->_generateMainCheckbox($captions);
141 141
 			}
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
 			$this->compileExtraElements($table, $captions);
151 151
 			$this->_compileSearchFieldBehavior($js);
152 152
 
153
-			$this->content = JArray::sortAssociative($this->content, [
153
+			$this->content=JArray::sortAssociative($this->content, [
154 154
 				PositionInTable::BEFORETABLE,
155 155
 				"table",
156 156
 				PositionInTable::AFTERTABLE
157 157
 			]);
158 158
 			$this->_compileForm();
159 159
 			$this->_applyStyleAttributes($table);
160
-			$this->_generated = true;
160
+			$this->_generated=true;
161 161
 		}
162 162
 		return parent::compile($js, $view);
163 163
 	}
@@ -202,21 +202,21 @@  discard block
 block discarded – undo
202 202
 	}
203 203
 
204 204
 	protected function _generateContent($table) {
205
-		$objects = $this->_modelInstance;
205
+		$objects=$this->_modelInstance;
206 206
 		if (isset($this->_pagination)) {
207
-			$objects = $this->_pagination->getObjects($this->_modelInstance);
207
+			$objects=$this->_pagination->getObjects($this->_modelInstance);
208 208
 		}
209 209
 		InstanceViewer::setIndex(0);
210
-		$fields = $this->_instanceViewer->getSimpleProperties();
211
-		$groupByFields = $this->_instanceViewer->getGroupByFields();
212
-		if (! is_array($groupByFields)) {
213
-			$table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields) {
210
+		$fields=$this->_instanceViewer->getSimpleProperties();
211
+		$groupByFields=$this->_instanceViewer->getGroupByFields();
212
+		if (!is_array($groupByFields)) {
213
+			$table->fromDatabaseObjects($objects, function($instance) use ($table, $fields) {
214 214
 				return $this->_generateRow($instance, $fields, $table);
215 215
 			});
216 216
 		} else {
217
-			$activeValues = array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null));
218
-			$uuids = [];
219
-			$table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids) {
217
+			$activeValues=array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null));
218
+			$uuids=[];
219
+			$table->fromDatabaseObjects($objects, function($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids) {
220 220
 				$this->_instanceViewer->setInstance($instance);
221 221
 				foreach ($groupByFields as $index => $gbField) {
222 222
 					$this->_generateGroupByRow($index, $gbField, $table, $fields, $activeValues, $uuids);
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 				return $this->_generateRow($instance, $fields, $table, null, $uuids);
225 225
 			});
226 226
 		}
227
-		if ($table->getRowCount() == 0) {
228
-			$result = $table->addRow();
227
+		if ($table->getRowCount()==0) {
228
+			$result=$table->addRow();
229 229
 			$result->mergeRow();
230 230
 			$result->setValues([
231 231
 				$this->_emptyMessage
@@ -234,20 +234,20 @@  discard block
 block discarded – undo
234 234
 	}
235 235
 
236 236
 	protected function _generateGroupByRow($index, $gbField, $table, $fields, &$activeValues, &$uuids) {
237
-		$newValue = $this->_instanceViewer->getValue($gbField);
238
-		if ($this->getElementContent($activeValues[$gbField]) !== $this->getElementContent($newValue)) {
239
-			if ($index == 0) {
240
-				$uuids = [];
237
+		$newValue=$this->_instanceViewer->getValue($gbField);
238
+		if ($this->getElementContent($activeValues[$gbField])!==$this->getElementContent($newValue)) {
239
+			if ($index==0) {
240
+				$uuids=[];
241 241
 			}
242
-			$uuid = uniqid("grp");
243
-			$uuids[$gbField] = $uuid;
244
-			$id = $this->_instanceViewer->getIdentifier();
245
-			$result = $table->addMergeRow(sizeof($fields) + 1, $newValue);
246
-			$result->setIdentifier($this->identifier . "-tr-gb-" . $id);
242
+			$uuid=uniqid("grp");
243
+			$uuids[$gbField]=$uuid;
244
+			$id=$this->_instanceViewer->getIdentifier();
245
+			$result=$table->addMergeRow(sizeof($fields)+1, $newValue);
246
+			$result->setIdentifier($this->identifier."-tr-gb-".$id);
247 247
 			$result->setProperty("data-ajax", $id);
248 248
 			$result->setProperty("data-group", $uuid);
249 249
 			$result->addToProperty("class", $this->_rowClass);
250
-			$activeValues[$gbField] = $newValue;
250
+			$activeValues[$gbField]=$newValue;
251 251
 		}
252 252
 	}
253 253
 
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
 	}
260 260
 
261 261
 	public function getFieldValue($index) {
262
-		$index = $this->_getIndex($index);
262
+		$index=$this->_getIndex($index);
263 263
 		if (is_numeric($index)) {
264
-			$values = $this->_instanceViewer->getValues();
264
+			$values=$this->_instanceViewer->getValues();
265 265
 			if (isset($values[$index])) {
266 266
 				return $values[$index];
267 267
 			}
@@ -269,31 +269,31 @@  discard block
 block discarded – undo
269 269
 		return null;
270 270
 	}
271 271
 
272
-	protected function _generateRow($instance, $fields, &$table, $checkedClass = null, $uuids = null) {
272
+	protected function _generateRow($instance, $fields, &$table, $checkedClass=null, $uuids=null) {
273 273
 		$this->_instanceViewer->setInstance($instance);
274
-		InstanceViewer::$index ++;
275
-		$values = $this->_instanceViewer->getValues();
276
-		$id = $this->_instanceViewer->getIdentifier();
277
-		$dataAjax = $id;
278
-		$id = $this->cleanIdentifier($id);
274
+		InstanceViewer::$index++;
275
+		$values=$this->_instanceViewer->getValues();
276
+		$id=$this->_instanceViewer->getIdentifier();
277
+		$dataAjax=$id;
278
+		$id=$this->cleanIdentifier($id);
279 279
 		if ($this->_hasCheckboxes) {
280
-			$ck = new HtmlCheckbox("ck-" . $this->identifier . "-" . $id, "");
281
-			$checked = false;
280
+			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, "");
281
+			$checked=false;
282 282
 			if (isset($this->_checkedCallback)) {
283
-				$func = $this->_checkedCallback;
284
-				$checked = $func($instance);
283
+				$func=$this->_checkedCallback;
284
+				$checked=$func($instance);
285 285
 			}
286 286
 			$ck->setChecked($checked);
287 287
 			// $ck->setOnChange("event.stopPropagation();");
288
-			$field = $ck->getField();
288
+			$field=$ck->getField();
289 289
 			$field->setProperty("value", $dataAjax);
290 290
 			$field->setProperty("name", "selection[]");
291 291
 			if (isset($checkedClass))
292 292
 				$field->setClass($checkedClass);
293 293
 			\array_unshift($values, $ck);
294 294
 		}
295
-		$result = $table->newRow();
296
-		$result->setIdentifier($this->identifier . "-tr-" . $id);
295
+		$result=$table->newRow();
296
+		$result->setIdentifier($this->identifier."-tr-".$id);
297 297
 		$result->setProperty("data-ajax", $dataAjax);
298 298
 		$result->setValues($values);
299 299
 		$result->addToProperty("class", $this->_rowClass);
@@ -306,62 +306,62 @@  discard block
 block discarded – undo
306 306
 
307 307
 	protected function _generatePagination($table) {
308 308
 		if (isset($this->_toolbar)) {
309
-			if ($this->_toolbarPosition == PositionInTable::FOOTER)
309
+			if ($this->_toolbarPosition==PositionInTable::FOOTER)
310 310
 				$this->_toolbar->setFloated("left");
311 311
 		}
312
-		$footer = $table->getFooter();
312
+		$footer=$table->getFooter();
313 313
 		$footer->mergeCol();
314 314
 		$footer->addValues($this->_pagination->generateMenu($this->identifier));
315 315
 	}
316 316
 
317
-	protected function _associatePaginationBehavior(JsUtils $js = NULL, $offset = null) {
317
+	protected function _associatePaginationBehavior(JsUtils $js=NULL, $offset=null) {
318 318
 		if (isset($this->_urls["refresh"])) {
319
-			$menu = $this->_pagination->getMenu();
319
+			$menu=$this->_pagination->getMenu();
320 320
 			if (isset($menu) && isset($js)) {
321
-				$js->postOnClick("#" . $menu->getIdentifier() . " .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", $this->getRefreshSelector(), [
321
+				$js->postOnClick("#".$menu->getIdentifier()." .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model)."'}", $this->getRefreshSelector(), [
322 322
 					"preventDefault" => false,
323 323
 					"jqueryDone" => "replaceWith",
324 324
 					"hasLoader" => false,
325
-					"jsCallback" => '$("#' . $this->identifier . '").trigger("pageChange");$("#' . $this->identifier . '").trigger("activeRowChange");'
325
+					"jsCallback" => '$("#'.$this->identifier.'").trigger("pageChange");$("#'.$this->identifier.'").trigger("activeRowChange");'
326 326
 				]);
327
-				$page = $_POST["p"] ?? null;
327
+				$page=$_POST["p"] ?? null;
328 328
 				if (isset($page)) {
329
-					$js->execAtLast('$("#' . $this->getIdentifier() . ' .pagination").children("a.item").removeClass("active");$("#' . $this->getIdentifier() . ' .pagination").children("a.item[data-page=' . $page . ']:not(.no-active)").addClass("active");');
329
+					$js->execAtLast('$("#'.$this->getIdentifier().' .pagination").children("a.item").removeClass("active");$("#'.$this->getIdentifier().' .pagination").children("a.item[data-page='.$page.']:not(.no-active)").addClass("active");');
330 330
 				}
331 331
 			}
332 332
 		}
333 333
 	}
334 334
 
335
-	protected function _compileSearchFieldBehavior(JsUtils $js = NULL) {
335
+	protected function _compileSearchFieldBehavior(JsUtils $js=NULL) {
336 336
 		if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) {
337
-			$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", "#" . $this->identifier . " tbody", [
337
+			$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'".JString::doubleBackSlashes($this->_model)."'}", "#".$this->identifier." tbody", [
338 338
 				"preventDefault" => false,
339 339
 				"jqueryDone" => "replaceWith",
340 340
 				"hasLoader" => "internal",
341
-				"jsCallback" => '$("#' . $this->identifier . '").trigger("searchTerminate",[$(self).val()]);'
341
+				"jsCallback" => '$("#'.$this->identifier.'").trigger("searchTerminate",[$(self).val()]);'
342 342
 			]);
343 343
 		}
344 344
 	}
345 345
 
346
-	protected function _associateSearchFieldBehavior(JsUtils $js = NULL, $offset = null) {}
346
+	protected function _associateSearchFieldBehavior(JsUtils $js=NULL, $offset=null) {}
347 347
 
348 348
 	protected function _getFieldName($index) {
349
-		$fieldName = parent::_getFieldName($index);
349
+		$fieldName=parent::_getFieldName($index);
350 350
 		if (\is_object($fieldName))
351
-			$fieldName = "field-" . $index;
352
-		return $fieldName . "[]";
351
+			$fieldName="field-".$index;
352
+		return $fieldName."[]";
353 353
 	}
354 354
 
355 355
 	protected function _getFieldCaption($index) {
356 356
 		return null;
357 357
 	}
358 358
 
359
-	protected function _setToolbarPosition($table, $captions = NULL) {
359
+	protected function _setToolbarPosition($table, $captions=NULL) {
360 360
 		switch ($this->_toolbarPosition) {
361 361
 			case PositionInTable::BEFORETABLE:
362 362
 			case PositionInTable::AFTERTABLE:
363
-				if (isset($this->_compileParts) === false) {
364
-					$this->content[$this->_toolbarPosition] = $this->_toolbar;
363
+				if (isset($this->_compileParts)===false) {
364
+					$this->content[$this->_toolbarPosition]=$this->_toolbar;
365 365
 				}
366 366
 				break;
367 367
 			case PositionInTable::HEADER:
@@ -388,11 +388,11 @@  discard block
 block discarded – undo
388 388
 	}
389 389
 
390 390
 	private function addToolbarRow($part, $table, $captions) {
391
-		$hasPart = $table->hasPart($part);
391
+		$hasPart=$table->hasPart($part);
392 392
 		if ($hasPart) {
393
-			$row = $table->getPart($part)->addRow(\sizeof($captions));
393
+			$row=$table->getPart($part)->addRow(\sizeof($captions));
394 394
 		} else {
395
-			$row = $table->getPart($part)->getRow(0);
395
+			$row=$table->getPart($part)->getRow(0);
396 396
 		}
397 397
 		$row->mergeCol();
398 398
 		$row->setValues([
@@ -424,12 +424,12 @@  discard block
 block discarded – undo
424 424
 	 */
425 425
 	public function setUrls($urls) {
426 426
 		if (\is_array($urls)) {
427
-			$this->_urls["refresh"] = JArray::getValue($urls, "refresh", 0);
428
-			$this->_urls["edit"] = JArray::getValue($urls, "edit", 1);
429
-			$this->_urls["delete"] = JArray::getValue($urls, "delete", 2);
430
-			$this->_urls["display"] = JArray::getValue($urls, "display", 3);
427
+			$this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0);
428
+			$this->_urls["edit"]=JArray::getValue($urls, "edit", 1);
429
+			$this->_urls["delete"]=JArray::getValue($urls, "delete", 2);
430
+			$this->_urls["display"]=JArray::getValue($urls, "display", 3);
431 431
 		} else {
432
-			$this->_urls = [
432
+			$this->_urls=[
433 433
 				"refresh" => $urls,
434 434
 				"edit" => $urls,
435 435
 				"delete" => $urls,
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
 	 *        	The number of visible pages in the Pagination component
453 453
 	 * @return DataTable
454 454
 	 */
455
-	public function paginate($page, $total_rowcount, $items_per_page = 10, $pages_visibles = null) {
456
-		$this->_pagination = new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
455
+	public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) {
456
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
457 457
 		return $this;
458 458
 	}
459 459
 
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
 	 *        	The number of visible pages in the Pagination component
469 469
 	 * @return DataTable
470 470
 	 */
471
-	public function autoPaginate($page = 1, $items_per_page = 10, $pages_visibles = 4) {
472
-		$this->_pagination = new Pagination($items_per_page, $pages_visibles, $page);
471
+	public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) {
472
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page);
473 473
 		return $this;
474 474
 	}
475 475
 
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
 	 * @param array $compileParts
479 479
 	 * @return DataTable
480 480
 	 */
481
-	public function refresh($compileParts = [
481
+	public function refresh($compileParts=[
482 482
 		"tbody"
483 483
 	]) {
484
-		$this->_compileParts = $compileParts;
484
+		$this->_compileParts=$compileParts;
485 485
 		return $this;
486 486
 	}
487 487
 
@@ -491,14 +491,14 @@  discard block
 block discarded – undo
491 491
 	 * @param string $position
492 492
 	 * @return \Ajax\common\html\HtmlDoubleElement
493 493
 	 */
494
-	public function addSearchInToolbar($position = Direction::RIGHT) {
494
+	public function addSearchInToolbar($position=Direction::RIGHT) {
495 495
 		return $this->addInToolbar($this->getSearchField())
496 496
 			->setPosition($position);
497 497
 	}
498 498
 
499 499
 	public function getSearchField() {
500
-		if (isset($this->_searchField) === false) {
501
-			$this->_searchField = new HtmlInput("search-" . $this->identifier, "search", "", "Search...");
500
+		if (isset($this->_searchField)===false) {
501
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
502 502
 			$this->_searchField->addIcon("search", Direction::RIGHT);
503 503
 		}
504 504
 		return $this->_searchField;
@@ -526,9 +526,9 @@  discard block
 block discarded – undo
526 526
 	}
527 527
 
528 528
 	protected function getTargetSelector($op) {
529
-		$result = $this->_targetSelector;
530
-		if (! isset($result[$op]))
531
-			$result = "#" . $this->identifier;
529
+		$result=$this->_targetSelector;
530
+		if (!isset($result[$op]))
531
+			$result="#".$this->identifier;
532 532
 		return $result[$op];
533 533
 	}
534 534
 
@@ -540,20 +540,20 @@  discard block
 block discarded – undo
540 540
 	 * @return DataTable
541 541
 	 */
542 542
 	public function setTargetSelector($_targetSelector) {
543
-		if (! \is_array($_targetSelector)) {
544
-			$_targetSelector = [
543
+		if (!\is_array($_targetSelector)) {
544
+			$_targetSelector=[
545 545
 				"edit" => $_targetSelector,
546 546
 				"delete" => $_targetSelector
547 547
 			];
548 548
 		}
549
-		$this->_targetSelector = $_targetSelector;
549
+		$this->_targetSelector=$_targetSelector;
550 550
 		return $this;
551 551
 	}
552 552
 
553 553
 	public function getRefreshSelector() {
554 554
 		if (isset($this->_refreshSelector))
555 555
 			return $this->_refreshSelector;
556
-		return "#" . $this->identifier . " tbody";
556
+		return "#".$this->identifier." tbody";
557 557
 	}
558 558
 
559 559
 	/**
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 	 * @return DataTable
563 563
 	 */
564 564
 	public function setRefreshSelector($_refreshSelector) {
565
-		$this->_refreshSelector = $_refreshSelector;
565
+		$this->_refreshSelector=$_refreshSelector;
566 566
 		return $this;
567 567
 	}
568 568
 
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
 	public function show($modelInstance) {
575 575
 		if (\is_array($modelInstance)) {
576 576
 			if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
577
-				$modelInstance = \json_decode(\json_encode($modelInstance), FALSE);
577
+				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
578 578
 		}
579
-		$this->_modelInstance = $modelInstance;
579
+		$this->_modelInstance=$modelInstance;
580 580
 	}
581 581
 
582 582
 	public function getRowClass() {
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 	 * @return DataTable
591 591
 	 */
592 592
 	public function setRowClass($_rowClass) {
593
-		$this->_rowClass = $_rowClass;
593
+		$this->_rowClass=$_rowClass;
594 594
 		return $this;
595 595
 	}
596 596
 
@@ -601,34 +601,34 @@  discard block
 block discarded – undo
601 601
 	 * @return DataTable
602 602
 	 */
603 603
 	public function setEmptyMessage($_emptyMessage) {
604
-		$this->_emptyMessage = $_emptyMessage;
604
+		$this->_emptyMessage=$_emptyMessage;
605 605
 		return $this;
606 606
 	}
607 607
 
608
-	public function setSortable($colIndex = NULL) {
609
-		$this->_sortable = $colIndex;
608
+	public function setSortable($colIndex=NULL) {
609
+		$this->_sortable=$colIndex;
610 610
 		return $this;
611 611
 	}
612 612
 
613
-	public function setActiveRowSelector($class = "active", $event = "click", $multiple = false) {
613
+	public function setActiveRowSelector($class="active", $event="click", $multiple=false) {
614 614
 		$this->_self->setActiveRowSelector($class, $event, $multiple);
615 615
 		return $this;
616 616
 	}
617 617
 
618 618
 	public function hideColumn($colIndex) {
619
-		if (! \is_array($this->_hiddenColumns))
620
-			$this->_hiddenColumns = [];
621
-		$this->_hiddenColumns[] = $colIndex;
619
+		if (!\is_array($this->_hiddenColumns))
620
+			$this->_hiddenColumns=[];
621
+		$this->_hiddenColumns[]=$colIndex;
622 622
 		return $this;
623 623
 	}
624 624
 
625 625
 	public function setColWidth($colIndex, $width) {
626
-		$this->_colWidths[$colIndex] = $width;
626
+		$this->_colWidths[$colIndex]=$width;
627 627
 		return $this;
628 628
 	}
629 629
 
630 630
 	public function setColWidths($_colWidths) {
631
-		$this->_colWidths = $_colWidths;
631
+		$this->_colWidths=$_colWidths;
632 632
 		return $this;
633 633
 	}
634 634
 
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 		return $this;
638 638
 	}
639 639
 
640
-	public function trigger($event, $params = "[]") {
640
+	public function trigger($event, $params="[]") {
641 641
 		return $this->getHtmlComponent()->trigger($event, $params);
642 642
 	}
643 643
 
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 	 * @param mixed $_displayBehavior
676 676
 	 */
677 677
 	public function setDisplayBehavior($_displayBehavior) {
678
-		$this->_displayBehavior = $_displayBehavior;
678
+		$this->_displayBehavior=$_displayBehavior;
679 679
 	}
680 680
 
681 681
 	/**
@@ -699,6 +699,6 @@  discard block
 block discarded – undo
699 699
 	 * @param boolean $_visibleHover
700 700
 	 */
701 701
 	public function setVisibleHover($_visibleHover) {
702
-		$this->_visibleHover = $_visibleHover;
702
+		$this->_visibleHover=$_visibleHover;
703 703
 	}
704 704
 }
Please login to merge, or discard this patch.
Braces   +36 added lines, -24 removed lines patch added patch discarded remove patch
@@ -82,16 +82,19 @@  discard block
 block discarded – undo
82 82
 					"stopPropagation" => true
83 83
 				]);
84 84
 			}
85
-			if (\is_array($this->_deleteBehavior))
86
-				$this->_generateBehavior("delete", $this->_deleteBehavior, $js);
87
-			if (\is_array($this->_editBehavior))
88
-				$this->_generateBehavior("edit", $this->_editBehavior, $js);
85
+			if (\is_array($this->_deleteBehavior)) {
86
+							$this->_generateBehavior("delete", $this->_deleteBehavior, $js);
87
+			}
88
+			if (\is_array($this->_editBehavior)) {
89
+							$this->_generateBehavior("edit", $this->_editBehavior, $js);
90
+			}
89 91
 			if (\is_array($this->_displayBehavior)) {
90 92
 				$this->_generateBehavior("display", $this->_displayBehavior, $js);
91 93
 			}
92 94
 			parent::run($js);
93
-			if (isset($this->_pagination))
94
-				$this->_associatePaginationBehavior($js, $offset);
95
+			if (isset($this->_pagination)) {
96
+							$this->_associatePaginationBehavior($js, $offset);
97
+			}
95 98
 			$this->_associateSearchFieldBehavior($js, $offset);
96 99
 			$this->_runned = true;
97 100
 		}
@@ -142,8 +145,9 @@  discard block
 block discarded – undo
142 145
 			$table->setRowCount(0, \sizeof($captions));
143 146
 			$this->_generateHeader($table, $captions);
144 147
 
145
-			if (isset($this->_compileParts))
146
-				$table->setCompileParts($this->_compileParts);
148
+			if (isset($this->_compileParts)) {
149
+							$table->setCompileParts($this->_compileParts);
150
+			}
147 151
 
148 152
 			$this->_generateContent($table);
149 153
 
@@ -178,8 +182,9 @@  discard block
 block discarded – undo
178 182
 	}
179 183
 
180 184
 	protected function _applyStyleAttributes($table) {
181
-		if (isset($this->_hiddenColumns))
182
-			$this->_hideColumns();
185
+		if (isset($this->_hiddenColumns)) {
186
+					$this->_hideColumns();
187
+		}
183 188
 		if (isset($this->_colWidths)) {
184 189
 			foreach ($this->_colWidths as $colIndex => $width) {
185 190
 				$table->setColWidth($colIndex, $width);
@@ -288,8 +293,9 @@  discard block
 block discarded – undo
288 293
 			$field = $ck->getField();
289 294
 			$field->setProperty("value", $dataAjax);
290 295
 			$field->setProperty("name", "selection[]");
291
-			if (isset($checkedClass))
292
-				$field->setClass($checkedClass);
296
+			if (isset($checkedClass)) {
297
+							$field->setClass($checkedClass);
298
+			}
293 299
 			\array_unshift($values, $ck);
294 300
 		}
295 301
 		$result = $table->newRow();
@@ -306,8 +312,9 @@  discard block
 block discarded – undo
306 312
 
307 313
 	protected function _generatePagination($table) {
308 314
 		if (isset($this->_toolbar)) {
309
-			if ($this->_toolbarPosition == PositionInTable::FOOTER)
310
-				$this->_toolbar->setFloated("left");
315
+			if ($this->_toolbarPosition == PositionInTable::FOOTER) {
316
+							$this->_toolbar->setFloated("left");
317
+			}
311 318
 		}
312 319
 		$footer = $table->getFooter();
313 320
 		$footer->mergeCol();
@@ -347,8 +354,9 @@  discard block
 block discarded – undo
347 354
 
348 355
 	protected function _getFieldName($index) {
349 356
 		$fieldName = parent::_getFieldName($index);
350
-		if (\is_object($fieldName))
351
-			$fieldName = "field-" . $index;
357
+		if (\is_object($fieldName)) {
358
+					$fieldName = "field-" . $index;
359
+		}
352 360
 		return $fieldName . "[]";
353 361
 	}
354 362
 
@@ -527,8 +535,9 @@  discard block
 block discarded – undo
527 535
 
528 536
 	protected function getTargetSelector($op) {
529 537
 		$result = $this->_targetSelector;
530
-		if (! isset($result[$op]))
531
-			$result = "#" . $this->identifier;
538
+		if (! isset($result[$op])) {
539
+					$result = "#" . $this->identifier;
540
+		}
532 541
 		return $result[$op];
533 542
 	}
534 543
 
@@ -551,8 +560,9 @@  discard block
 block discarded – undo
551 560
 	}
552 561
 
553 562
 	public function getRefreshSelector() {
554
-		if (isset($this->_refreshSelector))
555
-			return $this->_refreshSelector;
563
+		if (isset($this->_refreshSelector)) {
564
+					return $this->_refreshSelector;
565
+		}
556 566
 		return "#" . $this->identifier . " tbody";
557 567
 	}
558 568
 
@@ -573,8 +583,9 @@  discard block
 block discarded – undo
573 583
 	 */
574 584
 	public function show($modelInstance) {
575 585
 		if (\is_array($modelInstance)) {
576
-			if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
577
-				$modelInstance = \json_decode(\json_encode($modelInstance), FALSE);
586
+			if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) {
587
+							$modelInstance = \json_decode(\json_encode($modelInstance), FALSE);
588
+			}
578 589
 		}
579 590
 		$this->_modelInstance = $modelInstance;
580 591
 	}
@@ -616,8 +627,9 @@  discard block
 block discarded – undo
616 627
 	}
617 628
 
618 629
 	public function hideColumn($colIndex) {
619
-		if (! \is_array($this->_hiddenColumns))
620
-			$this->_hiddenColumns = [];
630
+		if (! \is_array($this->_hiddenColumns)) {
631
+					$this->_hiddenColumns = [];
632
+		}
621 633
 		$this->_hiddenColumns[] = $colIndex;
622 634
 		return $this;
623 635
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/FieldAsTrait.php 2 patches
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  */
37 37
 trait FieldAsTrait {
38 38
 
39
-	abstract protected function _getFieldIdentifier($prefix, $name = "");
39
+	abstract protected function _getFieldIdentifier($prefix, $name="");
40 40
 
41 41
 	abstract public function setValueFunction($index, $callback);
42 42
 
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 
45 45
 	abstract protected function _getFieldCaption($index);
46 46
 
47
-	abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement = NULL, $parameters = NULL);
47
+	abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement=NULL, $parameters=NULL);
48 48
 
49 49
 	/**
50 50
 	 *
51 51
 	 * @param HtmlFormField $element
52 52
 	 * @param array $attributes
53 53
 	 */
54
-	protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance = null) {
54
+	protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance=null) {
55 55
 		if (isset($attributes["jsCallback"])) {
56
-			$callback = $attributes["jsCallback"];
56
+			$callback=$attributes["jsCallback"];
57 57
 			if (\is_callable($callback)) {
58 58
 				$callback($element, $instance, $index, InstanceViewer::$index);
59 59
 			}
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
 		$element->fromArray($attributes);
65 65
 	}
66 66
 
67
-	private function _getLabelField($caption, $icon = NULL) {
68
-		$label = new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
67
+	private function _getLabelField($caption, $icon=NULL) {
68
+		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
69 69
 		return $label;
70 70
 	}
71 71
 
72 72
 	protected function _addRules(HtmlFormField $element, &$attributes) {
73 73
 		if (isset($attributes["rules"])) {
74
-			$this->_hasRules = true;
75
-			$rules = $attributes["rules"];
74
+			$this->_hasRules=true;
75
+			$rules=$attributes["rules"];
76 76
 			if (\is_array($rules)) {
77 77
 				$element->addRules($rules);
78 78
 			} else {
@@ -88,62 +88,62 @@  discard block
 block discarded – undo
88 88
 		return $field;
89 89
 	}
90 90
 
91
-	protected function _fieldAs($elementCallback, &$index, $attributes = NULL, $prefix = null) {
92
-		$this->setValueFunction($index, function ($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix) {
93
-			$caption = $this->_getFieldCaption($index);
94
-			$name = $this->_getFieldName($index);
95
-			$id = $this->_getFieldIdentifier($prefix, $name);
91
+	protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) {
92
+		$this->setValueFunction($index, function($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix) {
93
+			$caption=$this->_getFieldCaption($index);
94
+			$name=$this->_getFieldName($index);
95
+			$id=$this->_getFieldIdentifier($prefix, $name);
96 96
 			if (isset($attributes["name"])) {
97
-				$name = $attributes["name"];
97
+				$name=$attributes["name"];
98 98
 				unset($attributes["name"]);
99 99
 			}
100
-			$element = $elementCallback($id, $name, $value, $caption);
100
+			$element=$elementCallback($id, $name, $value, $caption);
101 101
 			if (\is_array($attributes)) {
102 102
 				$this->_applyAttributes($element, $attributes, $index, $instance);
103 103
 			}
104
-			$element->setDisabled(! $this->_edition);
104
+			$element->setDisabled(!$this->_edition);
105 105
 			return $element;
106 106
 		});
107 107
 		return $this;
108 108
 	}
109 109
 
110
-	public function fieldAsProgress($index, $label = NULL, $attributes = array()) {
111
-		$this->setValueFunction($index, function ($value) use ($label, $attributes) {
112
-			$pb = new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes);
110
+	public function fieldAsProgress($index, $label=NULL, $attributes=array()) {
111
+		$this->setValueFunction($index, function($value) use ($label, $attributes) {
112
+			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes);
113 113
 			return $pb;
114 114
 		});
115 115
 		return $this;
116 116
 	}
117 117
 
118
-	public function fieldAsRating($index, $max = 5, $icon = "") {
119
-		$this->setValueFunction($index, function ($value) use ($max, $icon) {
120
-			$rating = new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon);
118
+	public function fieldAsRating($index, $max=5, $icon="") {
119
+		$this->setValueFunction($index, function($value) use ($max, $icon) {
120
+			$rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon);
121 121
 			return $rating;
122 122
 		});
123 123
 		return $this;
124 124
 	}
125 125
 
126
-	public function fieldAsLabel($index, $icon = NULL, $attributes = NULL) {
127
-		return $this->_fieldAs(function ($id, $name, $value) use ($icon) {
128
-			$lbl = new HtmlLabel($id, $value);
126
+	public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) {
127
+		return $this->_fieldAs(function($id, $name, $value) use ($icon) {
128
+			$lbl=new HtmlLabel($id, $value);
129 129
 			if (isset($icon))
130 130
 				$lbl->addIcon($icon);
131 131
 			return $lbl;
132 132
 		}, $index, $attributes, "label");
133 133
 	}
134 134
 
135
-	public function fieldAsHeader($index, $niveau = 1, $icon = NULL, $attributes = NULL) {
136
-		return $this->_fieldAs(function ($id, $name, $value) use ($niveau, $icon) {
137
-			$header = new HtmlHeader($id, $niveau, $value);
135
+	public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) {
136
+		return $this->_fieldAs(function($id, $name, $value) use ($niveau, $icon) {
137
+			$header=new HtmlHeader($id, $niveau, $value);
138 138
 			if (isset($icon))
139 139
 				$header->asIcon($icon, $value);
140 140
 			return $header;
141 141
 		}, $index, $attributes, "header");
142 142
 	}
143 143
 
144
-	public function fieldAsImage($index, $size = Size::MINI, $circular = false) {
145
-		$this->setValueFunction($index, function ($img) use ($size, $circular) {
146
-			$image = new HtmlImage($this->_getFieldIdentifier("image"), $img);
144
+	public function fieldAsImage($index, $size=Size::MINI, $circular=false) {
145
+		$this->setValueFunction($index, function($img) use ($size, $circular) {
146
+			$image=new HtmlImage($this->_getFieldIdentifier("image"), $img);
147 147
 			$image->setSize($size);
148 148
 			if ($circular)
149 149
 				$image->setCircular();
@@ -153,131 +153,131 @@  discard block
 block discarded – undo
153 153
 	}
154 154
 
155 155
 	public function fieldAsFlag($index) {
156
-		$this->setValueFunction($index, function ($flag) {
157
-			$flag = new HtmlFlag($this->_getFieldIdentifier("flag"), $flag);
156
+		$this->setValueFunction($index, function($flag) {
157
+			$flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag);
158 158
 			return $flag;
159 159
 		});
160 160
 		return $this;
161 161
 	}
162 162
 
163 163
 	public function fieldAsIcon($index) {
164
-		$this->setValueFunction($index, function ($icon) {
165
-			$icon = new HtmlIcon($this->_getFieldIdentifier("icon"), $icon);
164
+		$this->setValueFunction($index, function($icon) {
165
+			$icon=new HtmlIcon($this->_getFieldIdentifier("icon"), $icon);
166 166
 			return $icon;
167 167
 		});
168 168
 		return $this;
169 169
 	}
170 170
 
171
-	public function fieldAsAvatar($index, $attributes = NULL) {
172
-		return $this->_fieldAs(function ($id, $name, $value) {
173
-			$img = new HtmlImage($id, $value);
171
+	public function fieldAsAvatar($index, $attributes=NULL) {
172
+		return $this->_fieldAs(function($id, $name, $value) {
173
+			$img=new HtmlImage($id, $value);
174 174
 			$img->asAvatar();
175 175
 			return $img;
176 176
 		}, $index, $attributes, "avatar");
177 177
 	}
178 178
 
179
-	public function fieldAsRadio($index, $attributes = NULL) {
180
-		return $this->_fieldAs(function ($id, $name, $value) use ($attributes) {
181
-			$input = new HtmlFormRadio($id, $name, $value, $value);
179
+	public function fieldAsRadio($index, $attributes=NULL) {
180
+		return $this->_fieldAs(function($id, $name, $value) use ($attributes) {
181
+			$input=new HtmlFormRadio($id, $name, $value, $value);
182 182
 			return $this->_prepareFormFields($input, $name, $attributes);
183 183
 		}, $index, $attributes, "radio");
184 184
 	}
185 185
 
186
-	public function fieldAsRadios($index, $elements = [], $attributes = NULL) {
187
-		return $this->_fieldAs(function ($id, $name, $value, $caption) use ($elements) {
186
+	public function fieldAsRadios($index, $elements=[], $attributes=NULL) {
187
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements) {
188 188
 			return HtmlFormFields::radios($name, $elements, $caption, $value);
189 189
 		}, $index, $attributes, "radios");
190 190
 	}
191 191
 
192
-	public function fieldAsList($index, $classNames = "", $attributes = NULL) {
193
-		return $this->_fieldAs(function ($id, $name, $value, $caption) use ($classNames) {
194
-			$result = new HtmlList($name, $value);
192
+	public function fieldAsList($index, $classNames="", $attributes=NULL) {
193
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($classNames) {
194
+			$result=new HtmlList($name, $value);
195 195
 			$result->addClass($classNames);
196 196
 			return $result;
197 197
 		}, $index, $attributes, "list");
198 198
 	}
199 199
 
200
-	public function fieldAsInput($index, $attributes = NULL) {
201
-		return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) {
202
-			$input = new HtmlFormInput($id, $caption, "text", $value);
200
+	public function fieldAsInput($index, $attributes=NULL) {
201
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) {
202
+			$input=new HtmlFormInput($id, $caption, "text", $value);
203 203
 			return $this->_prepareFormFields($input, $name, $attributes);
204 204
 		}, $index, $attributes, "input");
205 205
 	}
206 206
 
207
-	public function fieldAsDataList($index, ?array $items = [], $attributes = NULL) {
208
-		return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes, $items) {
209
-			$input = new HtmlFormInput($id, $caption, "text", $value);
207
+	public function fieldAsDataList($index, ?array $items=[], $attributes=NULL) {
208
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $items) {
209
+			$input=new HtmlFormInput($id, $caption, "text", $value);
210 210
 			$input->getField()
211 211
 				->addDataList($items);
212 212
 			return $this->_prepareFormFields($input, $name, $attributes);
213 213
 		}, $index, $attributes, "input");
214 214
 	}
215 215
 
216
-	public function fieldAsFile($index, $attributes = NULL) {
216
+	public function fieldAsFile($index, $attributes=NULL) {
217 217
 		if (isset($this->_form)) {
218 218
 			$this->_form->setProperty('enctype', 'multipart/form-data');
219 219
 		}
220
-		return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) {
221
-			$input = new HtmlFormInput($id, $caption);
220
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) {
221
+			$input=new HtmlFormInput($id, $caption);
222 222
 			$input->asFile();
223 223
 			return $this->_prepareFormFields($input, $name, $attributes);
224 224
 		}, $index, $attributes, "input");
225 225
 	}
226 226
 
227
-	public function fieldAsTextarea($index, $attributes = NULL) {
228
-		return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) {
229
-			$textarea = new HtmlFormTextarea($id, $caption, $value);
227
+	public function fieldAsTextarea($index, $attributes=NULL) {
228
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) {
229
+			$textarea=new HtmlFormTextarea($id, $caption, $value);
230 230
 			return $this->_prepareFormFields($textarea, $name, $attributes);
231 231
 		}, $index, $attributes, "textarea");
232 232
 	}
233 233
 
234
-	public function fieldAsElement($index, $tagName = "div", $baseClass = "", $attributes = NULL) {
235
-		return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass) {
236
-			$div = new HtmlSemDoubleElement($id, $tagName, $baseClass);
234
+	public function fieldAsElement($index, $tagName="div", $baseClass="", $attributes=NULL) {
235
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass) {
236
+			$div=new HtmlSemDoubleElement($id, $tagName, $baseClass);
237 237
 			$div->setContent(\htmlentities($value));
238
-			$textarea = new HtmlFormField("field-" . $id, $div, $caption);
238
+			$textarea=new HtmlFormField("field-".$id, $div, $caption);
239 239
 			return $this->_prepareFormFields($textarea, $name, $attributes);
240 240
 		}, $index, $attributes, "element");
241 241
 	}
242 242
 
243
-	public function fieldAsHidden($index, $attributes = NULL) {
244
-		if (! \is_array($attributes)) {
245
-			$attributes = [];
243
+	public function fieldAsHidden($index, $attributes=NULL) {
244
+		if (!\is_array($attributes)) {
245
+			$attributes=[];
246 246
 		}
247
-		$attributes["inputType"] = "hidden";
248
-		$attributes["style"] = "display:none;";
247
+		$attributes["inputType"]="hidden";
248
+		$attributes["style"]="display:none;";
249 249
 		return $this->fieldAsInput($index, $attributes);
250 250
 	}
251 251
 
252
-	public function fieldAsCheckbox($index, $attributes = NULL) {
253
-		return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) {
254
-			if ($caption === null || $caption === "")
255
-				$caption = "";
256
-			$input = new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier());
252
+	public function fieldAsCheckbox($index, $attributes=NULL) {
253
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) {
254
+			if ($caption===null || $caption==="")
255
+				$caption="";
256
+			$input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier());
257 257
 			$input->setChecked(JString::isBooleanTrue($value));
258 258
 			return $this->_prepareFormFields($input, $name, $attributes);
259 259
 		}, $index, $attributes, "ck");
260 260
 	}
261 261
 
262
-	public function fieldAsDropDown($index, $elements = [], $multiple = false, $attributes = NULL) {
263
-		return $this->_fieldAs(function ($id, $name, $value, $caption) use ($elements, $multiple, $attributes) {
264
-			$dd = new HtmlFormDropdown($id, $elements, $caption, $value);
262
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) {
263
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements, $multiple, $attributes) {
264
+			$dd=new HtmlFormDropdown($id, $elements, $caption, $value);
265 265
 			$dd->asSelect($name, $multiple);
266 266
 			return $this->_prepareFormFields($dd, $name, $attributes);
267 267
 		}, $index, $attributes, "dd");
268 268
 	}
269 269
 
270
-	public function fieldAsMessage($index, $attributes = NULL) {
271
-		return $this->_fieldAs(function ($id, $name, $value, $caption) {
272
-			$mess = new HtmlMessage("message-" . $id, $caption);
270
+	public function fieldAsMessage($index, $attributes=NULL) {
271
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
272
+			$mess=new HtmlMessage("message-".$id, $caption);
273 273
 			$mess->addHeader($value);
274 274
 			return $mess;
275 275
 		}, $index, $attributes, "message");
276 276
 	}
277 277
 
278
-	public function fieldAsLink($index, $attributes = NULL) {
279
-		return $this->_fieldAs(function ($id, $name, $value, $caption) {
280
-			$lnk = new HtmlLink("message-" . $id, "#", $caption);
278
+	public function fieldAsLink($index, $attributes=NULL) {
279
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
280
+			$lnk=new HtmlLink("message-".$id, "#", $caption);
281 281
 			return $lnk;
282 282
 		}, $index, $attributes, "link");
283 283
 	}
@@ -289,28 +289,28 @@  discard block
 block discarded – undo
289 289
 	 *        	an array or associative array $type=>$attributes
290 290
 	 */
291 291
 	public function fieldsAs(array $types) {
292
-		$i = 0;
292
+		$i=0;
293 293
 		if (JArray::isAssociative($types)) {
294 294
 			foreach ($types as $type => $attributes) {
295 295
 				if (\is_int($type))
296
-					$this->fieldAs($i ++, $attributes, []);
296
+					$this->fieldAs($i++, $attributes, []);
297 297
 				else {
298
-					$type = preg_replace('/\d/', '', $type);
299
-					$this->fieldAs($i ++, $type, $attributes);
298
+					$type=preg_replace('/\d/', '', $type);
299
+					$this->fieldAs($i++, $type, $attributes);
300 300
 				}
301 301
 			}
302 302
 		} else {
303 303
 			foreach ($types as $type) {
304
-				$this->fieldAs($i ++, $type);
304
+				$this->fieldAs($i++, $type);
305 305
 			}
306 306
 		}
307 307
 	}
308 308
 
309
-	public function fieldAs($index, $type, $attributes = NULL) {
310
-		$method = "fieldAs" . \ucfirst($type);
309
+	public function fieldAs($index, $type, $attributes=NULL) {
310
+		$method="fieldAs".\ucfirst($type);
311 311
 		if (\method_exists($this, $method)) {
312
-			if (! \is_array($attributes)) {
313
-				$attributes = [
312
+			if (!\is_array($attributes)) {
313
+				$attributes=[
314 314
 					$index
315 315
 				];
316 316
 			} else {
@@ -323,17 +323,17 @@  discard block
 block discarded – undo
323 323
 		}
324 324
 	}
325 325
 
326
-	public function fieldAsSubmit($index, $cssStyle = NULL, $url = NULL, $responseElement = NULL, $attributes = NULL) {
327
-		return $this->_fieldAs(function ($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes) {
328
-			$button = new HtmlButton($id, $caption, $cssStyle);
326
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
327
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes) {
328
+			$button=new HtmlButton($id, $caption, $cssStyle);
329 329
 			$this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]);
330 330
 			return $button;
331 331
 		}, $index, $attributes, "submit");
332 332
 	}
333 333
 
334
-	public function fieldAsButton($index, $cssStyle = NULL, $attributes = NULL) {
335
-		return $this->_fieldAs(function ($id, $name, $value, $caption) use ($cssStyle) {
336
-			$button = new HtmlButton($id, $value, $cssStyle);
334
+	public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) {
335
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle) {
336
+			$button=new HtmlButton($id, $value, $cssStyle);
337 337
 			return $button;
338 338
 		}, $index, $attributes, "button");
339 339
 	}
Please login to merge, or discard this patch.
Braces   +15 added lines, -11 removed lines patch added patch discarded remove patch
@@ -126,8 +126,9 @@  discard block
 block discarded – undo
126 126
 	public function fieldAsLabel($index, $icon = NULL, $attributes = NULL) {
127 127
 		return $this->_fieldAs(function ($id, $name, $value) use ($icon) {
128 128
 			$lbl = new HtmlLabel($id, $value);
129
-			if (isset($icon))
130
-				$lbl->addIcon($icon);
129
+			if (isset($icon)) {
130
+							$lbl->addIcon($icon);
131
+			}
131 132
 			return $lbl;
132 133
 		}, $index, $attributes, "label");
133 134
 	}
@@ -135,8 +136,9 @@  discard block
 block discarded – undo
135 136
 	public function fieldAsHeader($index, $niveau = 1, $icon = NULL, $attributes = NULL) {
136 137
 		return $this->_fieldAs(function ($id, $name, $value) use ($niveau, $icon) {
137 138
 			$header = new HtmlHeader($id, $niveau, $value);
138
-			if (isset($icon))
139
-				$header->asIcon($icon, $value);
139
+			if (isset($icon)) {
140
+							$header->asIcon($icon, $value);
141
+			}
140 142
 			return $header;
141 143
 		}, $index, $attributes, "header");
142 144
 	}
@@ -145,8 +147,9 @@  discard block
 block discarded – undo
145 147
 		$this->setValueFunction($index, function ($img) use ($size, $circular) {
146 148
 			$image = new HtmlImage($this->_getFieldIdentifier("image"), $img);
147 149
 			$image->setSize($size);
148
-			if ($circular)
149
-				$image->setCircular();
150
+			if ($circular) {
151
+							$image->setCircular();
152
+			}
150 153
 			return $image;
151 154
 		});
152 155
 		return $this;
@@ -251,8 +254,9 @@  discard block
 block discarded – undo
251 254
 
252 255
 	public function fieldAsCheckbox($index, $attributes = NULL) {
253 256
 		return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) {
254
-			if ($caption === null || $caption === "")
255
-				$caption = "";
257
+			if ($caption === null || $caption === "") {
258
+							$caption = "";
259
+			}
256 260
 			$input = new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier());
257 261
 			$input->setChecked(JString::isBooleanTrue($value));
258 262
 			return $this->_prepareFormFields($input, $name, $attributes);
@@ -292,9 +296,9 @@  discard block
 block discarded – undo
292 296
 		$i = 0;
293 297
 		if (JArray::isAssociative($types)) {
294 298
 			foreach ($types as $type => $attributes) {
295
-				if (\is_int($type))
296
-					$this->fieldAs($i ++, $attributes, []);
297
-				else {
299
+				if (\is_int($type)) {
300
+									$this->fieldAs($i ++, $attributes, []);
301
+				} else {
298 302
 					$type = preg_replace('/\d/', '', $type);
299 303
 					$this->fieldAs($i ++, $type, $attributes);
300 304
 				}
Please login to merge, or discard this patch.