Passed
Push — master ( 99e98a...333494 )
by Jean-Christophe
02:12
created
Ajax/semantic/widgets/datatable/DataTable.php 1 patch
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  */
27 27
 class DataTable extends Widget {
28
-	use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait;
28
+	use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait;
29 29
 
30 30
 	protected $_searchField;
31 31
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
 	protected $_displayBehavior;
43 43
 
44
-	protected $_visibleHover = false;
44
+	protected $_visibleHover=false;
45 45
 
46 46
 	protected $_targetSelector;
47 47
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
 	protected $_json;
53 53
 
54
-	protected $_rowClass = "_element";
54
+	protected $_rowClass="_element";
55 55
 
56 56
 	protected $_sortable;
57 57
 
@@ -61,26 +61,26 @@  discard block
 block discarded – undo
61 61
 	
62 62
 	protected $_paginationToolbar;
63 63
 
64
-	public function __construct($identifier, $model, $modelInstance = NULL) {
64
+	public function __construct($identifier, $model, $modelInstance=NULL) {
65 65
 		parent::__construct($identifier, $model, $modelInstance);
66 66
 		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
67
-		$this->_urls = [];
68
-		$this->_emptyMessage = new HtmlMessage("", "nothing to display");
67
+		$this->_urls=[];
68
+		$this->_emptyMessage=new HtmlMessage("", "nothing to display");
69 69
 		$this->_emptyMessage->setIcon("info circle");
70 70
 	}
71 71
 
72 72
 	public function run(JsUtils $js) {
73
-		if ($this->_runned !== true) {
74
-			$offset = $js->scriptCount();
73
+		if ($this->_runned!==true) {
74
+			$offset=$js->scriptCount();
75 75
 			if ($this->_hasCheckboxes && isset($js)) {
76 76
 				$this->_runCheckboxes($js);
77 77
 			}
78 78
 			if ($this->_visibleHover) {
79
-				$js->execOn("mouseover", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [
79
+				$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [
80 80
 					"preventDefault" => false,
81 81
 					"stopPropagation" => true
82 82
 				]);
83
-				$js->execOn("mouseout", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [
83
+				$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [
84 84
 					"preventDefault" => false,
85 85
 					"stopPropagation" => true
86 86
 				]);
@@ -96,16 +96,16 @@  discard block
 block discarded – undo
96 96
 			if (isset($this->_pagination))
97 97
 				$this->_associatePaginationBehavior($js, $offset);
98 98
 			$this->_associateSearchFieldBehavior($js, $offset);
99
-			$this->_runned = true;
99
+			$this->_runned=true;
100 100
 		}
101 101
 	}
102 102
 
103 103
 	protected function _generateBehavior($op, $params, JsUtils $js) {
104 104
 		if (isset($this->_urls[$op])) {
105
-			$params = \array_merge($params, [
105
+			$params=\array_merge($params, [
106 106
 				"attr" => "data-ajax"
107 107
 			]);
108
-			$js->ajaxOnClick("#" . $this->identifier . " ._" . $op, $this->_urls[$op], $this->getTargetSelector($op), $params);
108
+			$js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params);
109 109
 		}
110 110
 	}
111 111
 
@@ -124,21 +124,21 @@  discard block
 block discarded – undo
124 124
 	}
125 125
 
126 126
 	public function refreshTD($fieldName, $jquery, $view) {
127
-		$index = $this->_getIndex($fieldName);
127
+		$index=$this->_getIndex($fieldName);
128 128
 		$this->compile($jquery, $view);
129 129
 		return $this->refreshTR()
130 130
 			->getTable()
131 131
 			->getCell(0, $index);
132 132
 	}
133 133
 
134
-	public function compile(JsUtils $js = NULL, &$view = NULL) {
135
-		if (! $this->_generated) {
134
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
135
+		if (!$this->_generated) {
136 136
 			if (isset($this->_buttonsColumn)) {
137 137
 				$this->_instanceViewer->sortColumnContent($this->_buttonsColumn, $this->_buttons);
138 138
 			}
139 139
 			$this->_instanceViewer->setInstance($this->_model);
140
-			$captions = $this->_instanceViewer->getCaptions();
141
-			$table = $this->content["table"];
140
+			$captions=$this->_instanceViewer->getCaptions();
141
+			$table=$this->content["table"];
142 142
 			if ($this->_hasCheckboxes) {
143 143
 				$this->_generateMainCheckbox($captions);
144 144
 			}
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 			$this->compileExtraElements($table, $captions);
154 154
 			$this->_compileSearchFieldBehavior($js);
155 155
 
156
-			$this->content = JArray::sortAssociative($this->content, [
156
+			$this->content=JArray::sortAssociative($this->content, [
157 157
 				PositionInTable::BEFORETABLE,
158 158
 				"table",
159 159
 				PositionInTable::AFTERTABLE
160 160
 			]);
161 161
 			$this->_compileForm();
162 162
 			$this->_applyStyleAttributes($table);
163
-			$this->_generated = true;
163
+			$this->_generated=true;
164 164
 		}
165 165
 		return parent::compile($js, $view);
166 166
 	}
@@ -205,21 +205,21 @@  discard block
 block discarded – undo
205 205
 	}
206 206
 
207 207
 	protected function _generateContent($table) {
208
-		$objects = $this->_modelInstance;
208
+		$objects=$this->_modelInstance;
209 209
 		if (isset($this->_pagination)) {
210
-			$objects = $this->_pagination->getObjects($this->_modelInstance);
210
+			$objects=$this->_pagination->getObjects($this->_modelInstance);
211 211
 		}
212 212
 		InstanceViewer::setIndex(0);
213
-		$fields = $this->_instanceViewer->getSimpleProperties();
214
-		$groupByFields = $this->_instanceViewer->getGroupByFields();
215
-		if (! is_array($groupByFields)) {
216
-			$table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields) {
213
+		$fields=$this->_instanceViewer->getSimpleProperties();
214
+		$groupByFields=$this->_instanceViewer->getGroupByFields();
215
+		if (!is_array($groupByFields)) {
216
+			$table->fromDatabaseObjects($objects, function($instance) use ($table, $fields) {
217 217
 				return $this->_generateRow($instance, $fields, $table);
218 218
 			});
219 219
 		} else {
220
-			$activeValues = array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null));
221
-			$uuids = [];
222
-			$table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids) {
220
+			$activeValues=array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null));
221
+			$uuids=[];
222
+			$table->fromDatabaseObjects($objects, function($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids) {
223 223
 				$this->_instanceViewer->setInstance($instance);
224 224
 				foreach ($groupByFields as $index => $gbField) {
225 225
 					$this->_generateGroupByRow($index, $gbField, $table, $fields, $activeValues, $uuids);
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
 				return $this->_generateRow($instance, $fields, $table, null, $uuids);
228 228
 			});
229 229
 		}
230
-		if ($table->getRowCount() == 0) {
231
-			$result = $table->addRow();
230
+		if ($table->getRowCount()==0) {
231
+			$result=$table->addRow();
232 232
 			$result->mergeRow();
233 233
 			$result->setValues([
234 234
 				$this->_emptyMessage
@@ -237,20 +237,20 @@  discard block
 block discarded – undo
237 237
 	}
238 238
 
239 239
 	protected function _generateGroupByRow($index, $gbField, $table, $fields, &$activeValues, &$uuids) {
240
-		$newValue = $this->_instanceViewer->getValue($gbField);
241
-		if ($this->getElementContent($activeValues[$gbField]) !== $this->getElementContent($newValue)) {
242
-			if ($index == 0) {
243
-				$uuids = [];
240
+		$newValue=$this->_instanceViewer->getValue($gbField);
241
+		if ($this->getElementContent($activeValues[$gbField])!==$this->getElementContent($newValue)) {
242
+			if ($index==0) {
243
+				$uuids=[];
244 244
 			}
245
-			$uuid = uniqid("grp");
246
-			$uuids[$gbField] = $uuid;
247
-			$id = $this->_instanceViewer->getIdentifier();
248
-			$result = $table->addMergeRow(sizeof($fields) + 1, $newValue);
249
-			$result->setIdentifier($this->identifier . "-tr-gb-" . $id);
245
+			$uuid=uniqid("grp");
246
+			$uuids[$gbField]=$uuid;
247
+			$id=$this->_instanceViewer->getIdentifier();
248
+			$result=$table->addMergeRow(sizeof($fields)+1, $newValue);
249
+			$result->setIdentifier($this->identifier."-tr-gb-".$id);
250 250
 			$result->setProperty("data-ajax", $id);
251 251
 			$result->setProperty("data-group", $uuid);
252 252
 			$result->addToProperty("class", $this->_rowClass);
253
-			$activeValues[$gbField] = $newValue;
253
+			$activeValues[$gbField]=$newValue;
254 254
 		}
255 255
 	}
256 256
 
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 	}
263 263
 
264 264
 	public function getFieldValue($index) {
265
-		$index = $this->_getIndex($index);
265
+		$index=$this->_getIndex($index);
266 266
 		if (is_numeric($index)) {
267
-			$values = $this->_instanceViewer->getValues();
267
+			$values=$this->_instanceViewer->getValues();
268 268
 			if (isset($values[$index])) {
269 269
 				return $values[$index];
270 270
 			}
@@ -272,31 +272,31 @@  discard block
 block discarded – undo
272 272
 		return null;
273 273
 	}
274 274
 
275
-	protected function _generateRow($instance, $fields, &$table, $checkedClass = null, $uuids = null) {
275
+	protected function _generateRow($instance, $fields, &$table, $checkedClass=null, $uuids=null) {
276 276
 		$this->_instanceViewer->setInstance($instance);
277
-		InstanceViewer::$index ++;
278
-		$values = $this->_instanceViewer->getValues();
279
-		$id = $this->_instanceViewer->getIdentifier();
280
-		$dataAjax = $id;
281
-		$id = $this->cleanIdentifier($id);
277
+		InstanceViewer::$index++;
278
+		$values=$this->_instanceViewer->getValues();
279
+		$id=$this->_instanceViewer->getIdentifier();
280
+		$dataAjax=$id;
281
+		$id=$this->cleanIdentifier($id);
282 282
 		if ($this->_hasCheckboxes) {
283
-			$ck = new HtmlCheckbox("ck-" . $this->identifier . "-" . $id, "");
284
-			$checked = false;
283
+			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, "");
284
+			$checked=false;
285 285
 			if (isset($this->_checkedCallback)) {
286
-				$func = $this->_checkedCallback;
287
-				$checked = $func($instance);
286
+				$func=$this->_checkedCallback;
287
+				$checked=$func($instance);
288 288
 			}
289 289
 			$ck->setChecked($checked);
290 290
 			// $ck->setOnChange("event.stopPropagation();");
291
-			$field = $ck->getField();
291
+			$field=$ck->getField();
292 292
 			$field->setProperty("value", $dataAjax);
293 293
 			$field->setProperty("name", "selection[]");
294 294
 			if (isset($checkedClass))
295 295
 				$field->setClass($checkedClass);
296 296
 			\array_unshift($values, $ck);
297 297
 		}
298
-		$result = $table->newRow();
299
-		$result->setIdentifier($this->identifier . "-tr-" . $id);
298
+		$result=$table->newRow();
299
+		$result->setIdentifier($this->identifier."-tr-".$id);
300 300
 		$result->setProperty("data-ajax", $dataAjax);
301 301
 		$result->setValues($values);
302 302
 		$result->addToProperty("class", $this->_rowClass);
@@ -309,63 +309,63 @@  discard block
 block discarded – undo
309 309
 
310 310
 	protected function _generatePagination($table) {
311 311
 		if (isset($this->_toolbar)) {
312
-			if ($this->_toolbarPosition == PositionInTable::FOOTER)
312
+			if ($this->_toolbarPosition==PositionInTable::FOOTER)
313 313
 				$this->_toolbar->setFloated("left");
314 314
 		}
315
-		$footer = $table->getFooter();
315
+		$footer=$table->getFooter();
316 316
 		$footer->mergeCol();
317 317
 		$this->_paginationToolbar=$this->_pagination->generateMenu($this->identifier);
318 318
 		$footer->addValues($this->_paginationToolbar);
319 319
 	}
320 320
 
321
-	protected function _associatePaginationBehavior(JsUtils $js = NULL, $offset = null) {
321
+	protected function _associatePaginationBehavior(JsUtils $js=NULL, $offset=null) {
322 322
 		if (isset($this->_urls["refresh"])) {
323
-			$menu = $this->_pagination->getMenu();
323
+			$menu=$this->_pagination->getMenu();
324 324
 			if (isset($menu) && isset($js)) {
325
-				$js->postOnClick("#" . $menu->getIdentifier() . " .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", $this->getRefreshSelector(), [
325
+				$js->postOnClick("#".$menu->getIdentifier()." .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model)."'}", $this->getRefreshSelector(), [
326 326
 					"preventDefault" => false,
327 327
 					"jqueryDone" => "replaceWith",
328 328
 					"hasLoader" => false,
329
-					"jsCallback" => '$("#' . $this->identifier . '").trigger("pageChange");$("#' . $this->identifier . '").trigger("activeRowChange");'
329
+					"jsCallback" => '$("#'.$this->identifier.'").trigger("pageChange");$("#'.$this->identifier.'").trigger("activeRowChange");'
330 330
 				]);
331
-				$page = $_POST["p"] ?? null;
331
+				$page=$_POST["p"] ?? null;
332 332
 				if (isset($page)) {
333
-					$js->execAtLast('$("#' . $this->getIdentifier() . ' .pagination").children("a.item").removeClass("active");$("#' . $this->getIdentifier() . ' .pagination").children("a.item[data-page=' . $page . ']:not(.no-active)").addClass("active");');
333
+					$js->execAtLast('$("#'.$this->getIdentifier().' .pagination").children("a.item").removeClass("active");$("#'.$this->getIdentifier().' .pagination").children("a.item[data-page='.$page.']:not(.no-active)").addClass("active");');
334 334
 				}
335 335
 			}
336 336
 		}
337 337
 	}
338 338
 
339
-	protected function _compileSearchFieldBehavior(JsUtils $js = NULL) {
339
+	protected function _compileSearchFieldBehavior(JsUtils $js=NULL) {
340 340
 		if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) {
341
-			$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", "#" . $this->identifier . " tbody", [
341
+			$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'".JString::doubleBackSlashes($this->_model)."'}", "#".$this->identifier." tbody", [
342 342
 				"preventDefault" => false,
343 343
 				"jqueryDone" => "replaceWith",
344 344
 				"hasLoader" => "internal",
345
-				"jsCallback" => '$("#' . $this->identifier . '").trigger("searchTerminate",[$(self).val()]);'
345
+				"jsCallback" => '$("#'.$this->identifier.'").trigger("searchTerminate",[$(self).val()]);'
346 346
 			]);
347 347
 		}
348 348
 	}
349 349
 
350
-	protected function _associateSearchFieldBehavior(JsUtils $js = NULL, $offset = null) {}
350
+	protected function _associateSearchFieldBehavior(JsUtils $js=NULL, $offset=null) {}
351 351
 
352 352
 	protected function _getFieldName($index) {
353
-		$fieldName = parent::_getFieldName($index);
353
+		$fieldName=parent::_getFieldName($index);
354 354
 		if (\is_object($fieldName))
355
-			$fieldName = "field-" . $index;
356
-		return $fieldName . "[]";
355
+			$fieldName="field-".$index;
356
+		return $fieldName."[]";
357 357
 	}
358 358
 
359 359
 	protected function _getFieldCaption($index) {
360 360
 		return null;
361 361
 	}
362 362
 
363
-	protected function _setToolbarPosition($table, $captions = NULL) {
363
+	protected function _setToolbarPosition($table, $captions=NULL) {
364 364
 		switch ($this->_toolbarPosition) {
365 365
 			case PositionInTable::BEFORETABLE:
366 366
 			case PositionInTable::AFTERTABLE:
367
-				if (isset($this->_compileParts) === false) {
368
-					$this->content[$this->_toolbarPosition] = $this->_toolbar;
367
+				if (isset($this->_compileParts)===false) {
368
+					$this->content[$this->_toolbarPosition]=$this->_toolbar;
369 369
 				}
370 370
 				break;
371 371
 			case PositionInTable::HEADER:
@@ -392,11 +392,11 @@  discard block
 block discarded – undo
392 392
 	}
393 393
 
394 394
 	private function addToolbarRow($part, $table, $captions) {
395
-		$hasPart = $table->hasPart($part);
395
+		$hasPart=$table->hasPart($part);
396 396
 		if ($hasPart) {
397
-			$row = $table->getPart($part)->addRow(\sizeof($captions));
397
+			$row=$table->getPart($part)->addRow(\sizeof($captions));
398 398
 		} else {
399
-			$row = $table->getPart($part)->getRow(0);
399
+			$row=$table->getPart($part)->getRow(0);
400 400
 		}
401 401
 		$row->mergeCol();
402 402
 		$row->setValues([
@@ -428,12 +428,12 @@  discard block
 block discarded – undo
428 428
 	 */
429 429
 	public function setUrls($urls) {
430 430
 		if (\is_array($urls)) {
431
-			$this->_urls["refresh"] = JArray::getValue($urls, "refresh", 0);
432
-			$this->_urls["edit"] = JArray::getValue($urls, "edit", 1);
433
-			$this->_urls["delete"] = JArray::getValue($urls, "delete", 2);
434
-			$this->_urls["display"] = JArray::getValue($urls, "display", 3);
431
+			$this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0);
432
+			$this->_urls["edit"]=JArray::getValue($urls, "edit", 1);
433
+			$this->_urls["delete"]=JArray::getValue($urls, "delete", 2);
434
+			$this->_urls["display"]=JArray::getValue($urls, "display", 3);
435 435
 		} else {
436
-			$this->_urls = [
436
+			$this->_urls=[
437 437
 				"refresh" => $urls,
438 438
 				"edit" => $urls,
439 439
 				"delete" => $urls,
@@ -456,8 +456,8 @@  discard block
 block discarded – undo
456 456
 	 *        	The number of visible pages in the Pagination component
457 457
 	 * @return DataTable
458 458
 	 */
459
-	public function paginate($page, $total_rowcount, $items_per_page = 10, $pages_visibles = null) {
460
-		$this->_pagination = new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
459
+	public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) {
460
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
461 461
 		return $this;
462 462
 	}
463 463
 
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 	 *        	The number of visible pages in the Pagination component
473 473
 	 * @return DataTable
474 474
 	 */
475
-	public function autoPaginate($page = 1, $items_per_page = 10, $pages_visibles = 4) {
476
-		$this->_pagination = new Pagination($items_per_page, $pages_visibles, $page);
475
+	public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) {
476
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page);
477 477
 		return $this;
478 478
 	}
479 479
 
@@ -482,10 +482,10 @@  discard block
 block discarded – undo
482 482
 	 * @param array $compileParts
483 483
 	 * @return DataTable
484 484
 	 */
485
-	public function refresh($compileParts = [
485
+	public function refresh($compileParts=[
486 486
 		"tbody"
487 487
 	]) {
488
-		$this->_compileParts = $compileParts;
488
+		$this->_compileParts=$compileParts;
489 489
 		return $this;
490 490
 	}
491 491
 
@@ -495,14 +495,14 @@  discard block
 block discarded – undo
495 495
 	 * @param string $position
496 496
 	 * @return \Ajax\common\html\HtmlDoubleElement
497 497
 	 */
498
-	public function addSearchInToolbar($position = Direction::RIGHT) {
498
+	public function addSearchInToolbar($position=Direction::RIGHT) {
499 499
 		return $this->addInToolbar($this->getSearchField())
500 500
 			->setPosition($position);
501 501
 	}
502 502
 
503 503
 	public function getSearchField() {
504
-		if (isset($this->_searchField) === false) {
505
-			$this->_searchField = new HtmlInput("search-" . $this->identifier, "search", "", "Search...");
504
+		if (isset($this->_searchField)===false) {
505
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
506 506
 			$this->_searchField->addIcon("search", Direction::RIGHT);
507 507
 		}
508 508
 		return $this->_searchField;
@@ -530,9 +530,9 @@  discard block
 block discarded – undo
530 530
 	}
531 531
 
532 532
 	protected function getTargetSelector($op) {
533
-		$result = $this->_targetSelector;
534
-		if (! isset($result[$op]))
535
-			$result = "#" . $this->identifier;
533
+		$result=$this->_targetSelector;
534
+		if (!isset($result[$op]))
535
+			$result="#".$this->identifier;
536 536
 		return $result[$op];
537 537
 	}
538 538
 
@@ -544,20 +544,20 @@  discard block
 block discarded – undo
544 544
 	 * @return DataTable
545 545
 	 */
546 546
 	public function setTargetSelector($_targetSelector) {
547
-		if (! \is_array($_targetSelector)) {
548
-			$_targetSelector = [
547
+		if (!\is_array($_targetSelector)) {
548
+			$_targetSelector=[
549 549
 				"edit" => $_targetSelector,
550 550
 				"delete" => $_targetSelector
551 551
 			];
552 552
 		}
553
-		$this->_targetSelector = $_targetSelector;
553
+		$this->_targetSelector=$_targetSelector;
554 554
 		return $this;
555 555
 	}
556 556
 
557 557
 	public function getRefreshSelector() {
558 558
 		if (isset($this->_refreshSelector))
559 559
 			return $this->_refreshSelector;
560
-		return "#" . $this->identifier . " tbody";
560
+		return "#".$this->identifier." tbody";
561 561
 	}
562 562
 
563 563
 	/**
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 * @return DataTable
567 567
 	 */
568 568
 	public function setRefreshSelector($_refreshSelector) {
569
-		$this->_refreshSelector = $_refreshSelector;
569
+		$this->_refreshSelector=$_refreshSelector;
570 570
 		return $this;
571 571
 	}
572 572
 
@@ -578,9 +578,9 @@  discard block
 block discarded – undo
578 578
 	public function show($modelInstance) {
579 579
 		if (\is_array($modelInstance)) {
580 580
 			if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
581
-				$modelInstance = \json_decode(\json_encode($modelInstance), FALSE);
581
+				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
582 582
 		}
583
-		$this->_modelInstance = $modelInstance;
583
+		$this->_modelInstance=$modelInstance;
584 584
 	}
585 585
 
586 586
 	public function getRowClass() {
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 	 * @return DataTable
595 595
 	 */
596 596
 	public function setRowClass($_rowClass) {
597
-		$this->_rowClass = $_rowClass;
597
+		$this->_rowClass=$_rowClass;
598 598
 		return $this;
599 599
 	}
600 600
 
@@ -605,34 +605,34 @@  discard block
 block discarded – undo
605 605
 	 * @return DataTable
606 606
 	 */
607 607
 	public function setEmptyMessage($_emptyMessage) {
608
-		$this->_emptyMessage = $_emptyMessage;
608
+		$this->_emptyMessage=$_emptyMessage;
609 609
 		return $this;
610 610
 	}
611 611
 
612
-	public function setSortable($colIndex = NULL) {
613
-		$this->_sortable = $colIndex;
612
+	public function setSortable($colIndex=NULL) {
613
+		$this->_sortable=$colIndex;
614 614
 		return $this;
615 615
 	}
616 616
 
617
-	public function setActiveRowSelector($class = "active", $event = "click", $multiple = false) {
617
+	public function setActiveRowSelector($class="active", $event="click", $multiple=false) {
618 618
 		$this->_self->setActiveRowSelector($class, $event, $multiple);
619 619
 		return $this;
620 620
 	}
621 621
 
622 622
 	public function hideColumn($colIndex) {
623
-		if (! \is_array($this->_hiddenColumns))
624
-			$this->_hiddenColumns = [];
625
-		$this->_hiddenColumns[] = $colIndex;
623
+		if (!\is_array($this->_hiddenColumns))
624
+			$this->_hiddenColumns=[];
625
+		$this->_hiddenColumns[]=$colIndex;
626 626
 		return $this;
627 627
 	}
628 628
 
629 629
 	public function setColWidth($colIndex, $width) {
630
-		$this->_colWidths[$colIndex] = $width;
630
+		$this->_colWidths[$colIndex]=$width;
631 631
 		return $this;
632 632
 	}
633 633
 
634 634
 	public function setColWidths($_colWidths) {
635
-		$this->_colWidths = $_colWidths;
635
+		$this->_colWidths=$_colWidths;
636 636
 		return $this;
637 637
 	}
638 638
 
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 		return $this;
642 642
 	}
643 643
 
644
-	public function trigger($event, $params = "[]") {
644
+	public function trigger($event, $params="[]") {
645 645
 		return $this->getHtmlComponent()->trigger($event, $params);
646 646
 	}
647 647
 
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 	 * @param mixed $_displayBehavior
680 680
 	 */
681 681
 	public function setDisplayBehavior($_displayBehavior) {
682
-		$this->_displayBehavior = $_displayBehavior;
682
+		$this->_displayBehavior=$_displayBehavior;
683 683
 	}
684 684
 
685 685
 	/**
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 	 * @param boolean $_visibleHover
704 704
 	 */
705 705
 	public function setVisibleHover($_visibleHover) {
706
-		$this->_visibleHover = $_visibleHover;
706
+		$this->_visibleHover=$_visibleHover;
707 707
 	}
708 708
 	/**
709 709
 	 * @return \Ajax\semantic\html\collections\menus\HtmlPaginationMenu
@@ -712,9 +712,9 @@  discard block
 block discarded – undo
712 712
 		return $this->_paginationToolbar;
713 713
 	}
714 714
 	
715
-	public function setInverted($recursive=true){
715
+	public function setInverted($recursive=true) {
716 716
 		$this->getHtmlComponent()->setInverted($recursive);
717
-		if($this->_emptyMessage instanceof HtmlSemDoubleElement){
717
+		if ($this->_emptyMessage instanceof HtmlSemDoubleElement) {
718 718
 			$this->_emptyMessage->setInverted($recursive);
719 719
 		}
720 720
 	}
Please login to merge, or discard this patch.
Ajax/semantic/html/modules/HtmlTab.php 2 patches
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -18,19 +18,19 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class HtmlTab extends HtmlSemCollection {
20 20
 
21
-	protected $params = [];
21
+	protected $params=[];
22 22
 
23
-	protected $_activated = false;
23
+	protected $_activated=false;
24 24
 
25
-	public function __construct($identifier, $tabs = array()) {
25
+	public function __construct($identifier, $tabs=array()) {
26 26
 		parent::__construct($identifier, "div", "");
27
-		$menu = new HtmlMenu("menu" . $this->identifier);
27
+		$menu=new HtmlMenu("menu".$this->identifier);
28 28
 		$menu->asTab(false)->setAttachment(NULL, Side::TOP);
29
-		$this->content["menu"] = $menu;
29
+		$this->content["menu"]=$menu;
30 30
 		$this->addItems($tabs);
31 31
 	}
32 32
 	
33
-	public function getMenu(){
33
+	public function getMenu() {
34 34
 		return $this->content['menu'];
35 35
 	}
36 36
 
@@ -41,18 +41,18 @@  discard block
 block discarded – undo
41 41
 	 * @return HtmlSegment
42 42
 	 */
43 43
 	protected function createItem($value) {
44
-		$count = $this->count();
45
-		$title = $value;
46
-		$content = NULL;
44
+		$count=$this->count();
45
+		$title=$value;
46
+		$content=NULL;
47 47
 		if (\is_array($value)) {
48
-			$title = @$value[0];
49
-			$content = @$value[1];
48
+			$title=@$value[0];
49
+			$content=@$value[1];
50 50
 		}
51
-		$menuItem = $this->content["menu"]->addItem($title);
51
+		$menuItem=$this->content["menu"]->addItem($title);
52 52
 		$menuItem->addToProperty("data-tab", $menuItem->getIdentifier());
53 53
 		$menuItem->removeProperty("href");
54
-		$result = $this->createSegment($count, $content, $menuItem->getIdentifier());
55
-		$result->menuTab = $menuItem;
54
+		$result=$this->createSegment($count, $content, $menuItem->getIdentifier());
55
+		$result->menuTab=$menuItem;
56 56
 		return $result;
57 57
 	}
58 58
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * @return \Ajax\semantic\html\elements\HtmlSegment
65 65
 	 */
66 66
 	private function createSegment($count, $content, $datatab) {
67
-		$segment = new HtmlSegment("item-" . $this->identifier . "-" . $count, $content);
67
+		$segment=new HtmlSegment("item-".$this->identifier."-".$count, $content);
68 68
 		$segment->setAttachment(NULL, Side::BOTTOM)
69 69
 			->addToProperty("class", "tab")
70 70
 			->addToProperty("data-tab", $datatab);
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 	 * @return \Ajax\semantic\html\modules\HtmlTab
82 82
 	 */
83 83
 	public function setTabContent($index, $content) {
84
-		$menu = $this->content["menu"];
85
-		if ($index < $menu->count()) {
86
-			if (isset($this->content[$index]) === false) {
87
-				$this->content[$index] = $this->createSegment($index, $content, $menu->getItem($index)
84
+		$menu=$this->content["menu"];
85
+		if ($index<$menu->count()) {
86
+			if (isset($this->content[$index])===false) {
87
+				$this->content[$index]=$this->createSegment($index, $content, $menu->getItem($index)
88 88
 					->getIdentifier());
89 89
 			} else
90 90
 				$this->content[$index]->setContent($content);
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 	 * @return \Ajax\semantic\html\modules\HtmlTab
100 100
 	 */
101 101
 	public function setTabsContent($contents) {
102
-		$size = \sizeof($contents);
103
-		for ($i = 0; $i < $size; $i ++) {
102
+		$size=\sizeof($contents);
103
+		for ($i=0; $i<$size; $i++) {
104 104
 			$this->setTabContent($i, $contents[$i]);
105 105
 		}
106 106
 		return $this;
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 	 * @return \Ajax\semantic\html\modules\HtmlTab
114 114
 	 */
115 115
 	public function activate($index) {
116
-		$item = $this->content["menu"]->getItem($index);
117
-		if ($item != null) {
116
+		$item=$this->content["menu"]->getItem($index);
117
+		if ($item!=null) {
118 118
 			$item->setActive(true);
119 119
 			$this->content[$index]->setActive(true);
120
-			$this->_activated = true;
120
+			$this->_activated=true;
121 121
 		}
122 122
 		return $this;
123 123
 	}
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
 	 * @param array $params
152 152
 	 * @return \Ajax\semantic\html\elements\HtmlSegment
153 153
 	 */
154
-	public function forwardTab($index, JsUtils $js, $title, $initialController, $controller, $action, $params = array()) {
154
+	public function forwardTab($index, JsUtils $js, $title, $initialController, $controller, $action, $params=array()) {
155 155
 		if (\array_key_exists($index, $this->content)) {
156
-			$this->content[$index] = $js->forward($initialController, $controller, $action, $params);
156
+			$this->content[$index]=$js->forward($initialController, $controller, $action, $params);
157 157
 			return $this->content[$index];
158 158
 		}
159 159
 
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
 	 *        	The parameters to pass to the view
175 175
 	 * @return \Ajax\semantic\html\elements\HtmlSegment
176 176
 	 */
177
-	public function renderViewTab($index, JsUtils $js, $title, $initialController, $viewName, $params = array()) {
177
+	public function renderViewTab($index, JsUtils $js, $title, $initialController, $viewName, $params=array()) {
178 178
 		if (\array_key_exists($index, $this->content)) {
179
-			$this->content[$index] = $js->renderContent($initialController, $viewName, $params);
179
+			$this->content[$index]=$js->renderContent($initialController, $viewName, $params);
180 180
 			return $this->content[$index];
181 181
 		}
182 182
 		return $this->addAndRenderViewTab($js, $title, $initialController, $viewName, $params);
@@ -196,10 +196,10 @@  discard block
 block discarded – undo
196 196
 	 * @param array $params
197 197
 	 * @return \Ajax\semantic\html\elements\HtmlSegment
198 198
 	 */
199
-	public function addAndForwardTab(JsUtils $js, $title, $initialController, $controller, $action, $params = array()) {
199
+	public function addAndForwardTab(JsUtils $js, $title, $initialController, $controller, $action, $params=array()) {
200 200
 		\ob_start();
201 201
 		$js->forward($initialController, $controller, $action, $params);
202
-		$content = \ob_get_clean();
202
+		$content=\ob_get_clean();
203 203
 		return $this->addTab($title, $content);
204 204
 	}
205 205
 
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
 	 *        	The parameters to pass to the view
216 216
 	 * @return \Ajax\semantic\html\elements\HtmlSegment
217 217
 	 */
218
-	public function addAndRenderViewTab(JsUtils $js, $title, $initialController, $viewName, $params = array()) {
218
+	public function addAndRenderViewTab(JsUtils $js, $title, $initialController, $viewName, $params=array()) {
219 219
 		return $this->addTab($title, $js->renderContent($initialController, $viewName, $params));
220 220
 	}
221 221
 
222
-	public function setPointing($value = Direction::NONE) {
222
+	public function setPointing($value=Direction::NONE) {
223 223
 		return $this->content["menu"]->setPointing($value);
224 224
 	}
225 225
 
@@ -254,25 +254,25 @@  discard block
 block discarded – undo
254 254
 	 * @return \Ajax\semantic\html\modules\HtmlTab
255 255
 	 */
256 256
 	public function setMenu($menu) {
257
-		$contentSize = \sizeof($this->content);
258
-		for ($i = 0; $i < $contentSize; $i ++) {
259
-			if ($menu->getItem($i) !== NULL) {
257
+		$contentSize=\sizeof($this->content);
258
+		for ($i=0; $i<$contentSize; $i++) {
259
+			if ($menu->getItem($i)!==NULL) {
260 260
 				if (isset($this->content[$i])) {
261 261
 					$menu->getItem($i)->addToProperty("data-tab", $this->content[$i]->getProperty("data-tab"));
262 262
 				}
263 263
 			}
264 264
 		}
265
-		$menuSize = $menu->count();
266
-		for ($i = 0; $i < $menuSize; $i ++) {
265
+		$menuSize=$menu->count();
266
+		for ($i=0; $i<$menuSize; $i++) {
267 267
 			$menu->getItem($i)->removeProperty("href");
268
-			if (isset($this->content[$i]) === false) {
269
-				$this->content[$i] = $this->createSegment($i, "New content", $menu->getItem($i)
268
+			if (isset($this->content[$i])===false) {
269
+				$this->content[$i]=$this->createSegment($i, "New content", $menu->getItem($i)
270 270
 					->getIdentifier());
271 271
 			}
272 272
 			$menu->getItem($i)->addToProperty("data-tab", $this->content[$i]->getProperty("data-tab"));
273 273
 		}
274 274
 
275
-		$this->content["menu"] = $menu;
275
+		$this->content["menu"]=$menu;
276 276
 		return $this;
277 277
 	}
278 278
 
@@ -281,19 +281,19 @@  discard block
 block discarded – undo
281 281
 	 * @see BaseHtml::run()
282 282
 	 */
283 283
 	public function run(JsUtils $js) {
284
-		if (isset($this->_bsComponent) === false)
285
-			$this->_bsComponent = $js->semantic()->tab("#" . $this->identifier . " .item", $this->params);
284
+		if (isset($this->_bsComponent)===false)
285
+			$this->_bsComponent=$js->semantic()->tab("#".$this->identifier." .item", $this->params);
286 286
 		$this->addEventsOnRun($js);
287 287
 		return $this->_bsComponent;
288 288
 	}
289 289
 
290
-	public function compile(JsUtils $js = NULL, &$view = NULL) {
291
-		if (! $this->_activated && $this->content["menu"]->count() > 0 && \sizeof($this->content) > 1)
290
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
291
+		if (!$this->_activated && $this->content["menu"]->count()>0 && \sizeof($this->content)>1)
292 292
 			$this->activate(0);
293 293
 		return parent::compile($js, $view);
294 294
 	}
295 295
 	
296
-	public function setInverted($recursive=true){
296
+	public function setInverted($recursive=true) {
297 297
 		parent::setInverted($recursive);
298 298
 		$this->content['menu']->addClass('inverted');
299 299
 	}
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -86,8 +86,9 @@  discard block
 block discarded – undo
86 86
 			if (isset($this->content[$index]) === false) {
87 87
 				$this->content[$index] = $this->createSegment($index, $content, $menu->getItem($index)
88 88
 					->getIdentifier());
89
-			} else
90
-				$this->content[$index]->setContent($content);
89
+			} else {
90
+							$this->content[$index]->setContent($content);
91
+			}
91 92
 		}
92 93
 		return $this;
93 94
 	}
@@ -281,15 +282,17 @@  discard block
 block discarded – undo
281 282
 	 * @see BaseHtml::run()
282 283
 	 */
283 284
 	public function run(JsUtils $js) {
284
-		if (isset($this->_bsComponent) === false)
285
-			$this->_bsComponent = $js->semantic()->tab("#" . $this->identifier . " .item", $this->params);
285
+		if (isset($this->_bsComponent) === false) {
286
+					$this->_bsComponent = $js->semantic()->tab("#" . $this->identifier . " .item", $this->params);
287
+		}
286 288
 		$this->addEventsOnRun($js);
287 289
 		return $this->_bsComponent;
288 290
 	}
289 291
 
290 292
 	public function compile(JsUtils $js = NULL, &$view = NULL) {
291
-		if (! $this->_activated && $this->content["menu"]->count() > 0 && \sizeof($this->content) > 1)
292
-			$this->activate(0);
293
+		if (! $this->_activated && $this->content["menu"]->count() > 0 && \sizeof($this->content) > 1) {
294
+					$this->activate(0);
295
+		}
293 296
 		return parent::compile($js, $view);
294 297
 	}
295 298
 	
Please login to merge, or discard this patch.