Passed
Push — master ( 6d276a...5c767a )
by Jean-Christophe
02:21
created

DataTable::setColAlignment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
namespace Ajax\semantic\widgets\datatable;
3
4
use Ajax\JsUtils;
5
use Ajax\common\Widget;
6
use Ajax\common\html\HtmlDoubleElement;
7
use Ajax\semantic\html\base\constants\Direction;
8
use Ajax\semantic\html\base\traits\BaseTrait;
9
use Ajax\semantic\html\collections\HtmlMessage;
10
use Ajax\semantic\html\collections\table\HtmlTable;
11
use Ajax\semantic\html\collections\table\traits\TableTrait;
12
use Ajax\semantic\html\elements\HtmlInput;
13
use Ajax\semantic\html\modules\checkbox\HtmlCheckbox;
14
use Ajax\semantic\widgets\base\InstanceViewer;
15
use Ajax\service\JArray;
16
use Ajax\service\JString;
17
use Ajax\semantic\html\base\HtmlSemDoubleElement;
18
19
/**
20
 * DataTable widget for displaying list of objects
21
 *
22
 * @version 1.1.0
23
 * @author jc
24
 * @since 2.2
25
 *
26
 */
27
class DataTable extends Widget {
28
	use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait;
29
30
	protected $_searchField;
31
32
	protected $_urls;
33
34
	protected $_pagination;
35
36
	protected $_compileParts;
37
38
	protected $_deleteBehavior;
39
40
	protected $_editBehavior;
41
42
	protected $_displayBehavior;
43
44
	protected $_visibleHover = false;
45
46
	protected $_targetSelector;
47
48
	protected $_refreshSelector;
49
50
	protected $_emptyMessage;
51
52
	protected $_json;
53
54
	protected $_rowClass = "_element";
55
56
	protected $_sortable;
57
58
	protected $_hiddenColumns;
59
60
	protected $_colWidths;
61
62
	protected $_paginationToolbar;
63
64
	public function __construct($identifier, $model, $modelInstance = NULL) {
65
		parent::__construct($identifier, $model, $modelInstance);
66
		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
67
		$this->_urls = [];
68
		$this->_emptyMessage = new HtmlMessage("", "nothing to display");
69
		$this->_emptyMessage->setIcon("info circle");
70
	}
71
72
	public function run(JsUtils $js) {
73
		if ($this->_runned !== true) {
74
			$offset = $js->scriptCount();
75
			if ($this->_hasCheckboxes && isset($js)) {
76
				$this->_runCheckboxes($js);
77
			}
78
			if ($this->_visibleHover) {
79
				$js->execOn("mouseover", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [
80
					"preventDefault" => false,
81
					"stopPropagation" => true
82
				]);
83
				$js->execOn("mouseout", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [
84
					"preventDefault" => false,
85
					"stopPropagation" => true
86
				]);
87
			}
88
			if (\is_array($this->_deleteBehavior))
89
				$this->_generateBehavior("delete", $this->_deleteBehavior, $js);
90
			if (\is_array($this->_editBehavior))
91
				$this->_generateBehavior("edit", $this->_editBehavior, $js);
92
			if (\is_array($this->_displayBehavior)) {
93
				$this->_generateBehavior("display", $this->_displayBehavior, $js);
94
			}
95
			parent::run($js);
96
			if (isset($this->_pagination))
97
				$this->_associatePaginationBehavior($js, $offset);
98
			$this->_associateSearchFieldBehavior($js, $offset);
99
			$this->_runned = true;
100
		}
101
	}
102
103
	protected function _generateBehavior($op, $params, JsUtils $js) {
104
		if (isset($this->_urls[$op])) {
105
			$params = \array_merge($params, [
106
				"attr" => "data-ajax"
107
			]);
108
			$js->ajaxOnClick("#" . $this->identifier . " ._" . $op, $this->_urls[$op], $this->getTargetSelector($op), $params);
109
		}
110
	}
111
112
	/**
113
	 *
114
	 * {@inheritdoc}
115
	 * @see TableTrait::getTable()
116
	 */
117
	protected function getTable() {
118
		return $this->content["table"];
119
	}
120
121
	public function refreshTR() {
122
		$this->getTable()->refreshTR();
123
		return $this;
124
	}
125
126
	public function refreshTD($fieldName, $jquery, $view) {
127
		$index = $this->_getIndex($fieldName);
128
		$this->compile($jquery, $view);
129
		return $this->refreshTR()
130
			->getTable()
131
			->getCell(0, $index);
132
	}
133
134
	public function compile(JsUtils $js = NULL, &$view = NULL) {
135
		if (! $this->_generated) {
136
			if (isset($this->_buttonsColumn)) {
137
				$this->_instanceViewer->sortColumnContent($this->_buttonsColumn, $this->_buttons);
138
			}
139
			$this->_instanceViewer->setInstance($this->_model);
140
			$captions = $this->_instanceViewer->getCaptions();
141
			$table = $this->content["table"];
142
			if ($this->_hasCheckboxes) {
143
				$this->_generateMainCheckbox($captions);
144
			}
145
			$table->setRowCount(0, \sizeof($captions));
146
			$this->_generateHeader($table, $captions);
147
148
			if (isset($this->_compileParts))
149
				$table->setCompileParts($this->_compileParts);
150
151
			$this->_generateContent($table);
152
153
			$this->compileExtraElements($table, $captions);
154
			$this->_compileSearchFieldBehavior($js);
155
156
			$this->content = JArray::sortAssociative($this->content, [
157
				PositionInTable::BEFORETABLE,
158
				"table",
159
				PositionInTable::AFTERTABLE
160
			]);
161
			$this->_compileForm();
162
			$this->_applyStyleAttributes($table);
163
			$this->_generated = true;
164
		}
165
		return parent::compile($js, $view);
166
	}
167
168
	protected function compileExtraElements($table, $captions) {
169
		if ($this->_hasCheckboxes && $table->hasPart("thead")) {
170
			$table->getHeader()
171
				->getCell(0, 0)
172
				->addClass("no-sort");
173
		}
174
175
		if (isset($this->_toolbar)) {
176
			$this->_setToolbarPosition($table, $captions);
177
		}
178
		if (isset($this->_pagination) && $this->_pagination->getVisible()) {
179
			$this->_generatePagination($table);
180
		}
181
	}
182
183
	protected function _applyStyleAttributes($table) {
184
		if (isset($this->_hiddenColumns))
185
			$this->_hideColumns();
186
		if (isset($this->_colWidths)) {
187
			foreach ($this->_colWidths as $colIndex => $width) {
188
				$table->setColWidth($colIndex, $width);
189
			}
190
		}
191
	}
192
193
	protected function _hideColumns() {
194
		foreach ($this->_hiddenColumns as $colIndex) {
195
			$this->_self->hideColumn($colIndex);
196
		}
197
		return $this;
198
	}
199
200
	protected function _generateHeader(HtmlTable $table, $captions) {
201
		$table->setHeaderValues($captions);
202
		if (isset($this->_sortable)) {
203
			$table->setSortable($this->_sortable);
204
		}
205
	}
206
207
	protected function _generateContent($table) {
208
		$objects = $this->_modelInstance;
209
		if (isset($this->_pagination)) {
210
			$objects = $this->_pagination->getObjects($this->_modelInstance);
211
		}
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) {
217
				return $this->_generateRow($instance, $fields, $table);
218
			});
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) {
223
				$this->_instanceViewer->setInstance($instance);
224
				foreach ($groupByFields as $index => $gbField) {
225
					$this->_generateGroupByRow($index, $gbField, $table, $fields, $activeValues, $uuids);
226
				}
227
				return $this->_generateRow($instance, $fields, $table, null, $uuids);
228
			});
229
		}
230
		if ($table->getRowCount() == 0) {
231
			$result = $table->addRow();
232
			$result->mergeRow();
233
			$result->setValues([
234
				$this->_emptyMessage
235
			]);
236
		}
237
	}
238
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 = [];
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);
250
			$result->setProperty("data-ajax", $id);
251
			$result->setProperty("data-group", $uuid);
252
			$result->addToProperty("class", $this->_rowClass);
253
			$activeValues[$gbField] = $newValue;
254
		}
255
	}
256
257
	private function getElementContent($elm) {
258
		if ($elm instanceof HtmlDoubleElement) {
259
			return $elm->getTextContent();
260
		}
261
		return $elm;
262
	}
263
264
	public function getFieldValue($index) {
265
		$index = $this->_getIndex($index);
266
		if (is_numeric($index)) {
267
			$values = $this->_instanceViewer->getValues();
268
			if (isset($values[$index])) {
269
				return $values[$index];
270
			}
271
		}
272
		return null;
273
	}
274
275
	protected function _generateRow($instance, $fields, &$table, $checkedClass = null, $uuids = null) {
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);
282
		if ($this->_hasCheckboxes) {
283
			$ck = new HtmlCheckbox("ck-" . $this->identifier . "-" . $id, "");
284
			$checked = false;
285
			if (isset($this->_checkedCallback)) {
286
				$func = $this->_checkedCallback;
287
				$checked = $func($instance);
288
			}
289
			$ck->setChecked($checked);
290
			// $ck->setOnChange("event.stopPropagation();");
291
			$field = $ck->getField();
292
			$field->setProperty("value", $dataAjax);
293
			$field->setProperty("name", "selection[]");
294
			if (isset($checkedClass))
295
				$field->setClass($checkedClass);
296
			\array_unshift($values, $ck);
297
		}
298
		$result = $table->newRow();
299
		$result->setIdentifier($this->identifier . "-tr-" . $id);
300
		$result->setProperty("data-ajax", $dataAjax);
301
		$result->setValues($values);
302
		$result->addToProperty("class", $this->_rowClass);
303
		$result->setPropertyValues("data-field", $fields);
304
		if (isset($uuids)) {
305
			$result->setProperty("data-child", implode(" ", $uuids));
306
		}
307
		return $result;
308
	}
309
310
	protected function _generatePagination($table) {
311
		if (isset($this->_toolbar)) {
312
			if ($this->_toolbarPosition == PositionInTable::FOOTER)
313
				$this->_toolbar->setFloated("left");
314
		}
315
		$footer = $table->getFooter();
316
		$footer->mergeCol();
317
		$this->_paginationToolbar = $this->_pagination->generateMenu($this->identifier);
318
		$footer->addValues($this->_paginationToolbar);
319
	}
320
321
	protected function _associatePaginationBehavior(JsUtils $js = NULL, $offset = null) {
322
		if (isset($this->_urls["refresh"])) {
323
			$menu = $this->_pagination->getMenu();
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(), [
326
					"preventDefault" => false,
327
					"jqueryDone" => "replaceWith",
328
					"hasLoader" => false,
329
					"jsCallback" => '$("#' . $this->identifier . '").trigger("pageChange");$("#' . $this->identifier . '").trigger("activeRowChange");'
330
				]);
331
				$page = $_POST["p"] ?? null;
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");');
334
				}
335
			}
336
		}
337
	}
338
339
	protected function _compileSearchFieldBehavior(JsUtils $js = NULL) {
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", [
342
				"preventDefault" => false,
343
				"jqueryDone" => "replaceWith",
344
				"hasLoader" => "internal",
345
				"jsCallback" => '$("#' . $this->identifier . '").trigger("searchTerminate",[$(self).val()]);'
346
			]);
347
		}
348
	}
349
350
	protected function _associateSearchFieldBehavior(JsUtils $js = NULL, $offset = null) {}
351
352
	protected function _getFieldName($index) {
353
		$fieldName = parent::_getFieldName($index);
354
		if (\is_object($fieldName))
355
			$fieldName = "field-" . $index;
356
		return $fieldName . "[]";
357
	}
358
359
	protected function _getFieldCaption($index) {
360
		return null;
361
	}
362
363
	protected function applyToolbarPosition(string $position, $table, $captions = NULL) {
364
		switch ($position) {
365
			case PositionInTable::BEFORETABLE:
366
			case PositionInTable::AFTERTABLE:
367
				if (isset($this->_compileParts) === false) {
368
					$this->content[$position] = $this->_toolbar;
369
				}
370
				break;
371
			case PositionInTable::HEADER:
372
			case PositionInTable::FOOTER:
373
			case PositionInTable::BODY:
374
				$this->addToolbarRow($position, $table, $captions);
375
				break;
376
		}
377
	}
378
379
	protected function _setToolbarPosition($table, $captions = NULL) {
380
		if (\is_array($this->_toolbarPosition)) {
0 ignored issues
show
introduced by
The condition is_array($this->_toolbarPosition) is always false.
Loading history...
381
			foreach ($this->_toolbarPosition as $tbp) {
382
				$this->applyToolbarPosition($tbp, $table, $captions);
383
			}
384
		} else {
385
			$this->applyToolbarPosition($this->_toolbarPosition, $table, $captions);
386
		}
387
	}
388
389
	/**
390
	 * Associates a $callback function after the compilation of the field at $index position
391
	 * The $callback function can take the following arguments : $field=>the compiled field, $instance : the active instance of the object, $index: the field position
392
	 *
393
	 * @param int $index
394
	 *        	postion of the compiled field
395
	 * @param callable $callback
396
	 *        	function called after the field compilation
397
	 * @return DataTable
398
	 */
399
	public function afterCompile($index, $callback) {
400
		$this->_instanceViewer->afterCompile($index, $callback);
401
		return $this;
402
	}
403
404
	private function addToolbarRow($part, $table, $captions) {
405
		$hasPart = $table->hasPart($part);
406
		if ($hasPart) {
407
			$row = $table->getPart($part)->addRow(\sizeof($captions));
408
		} else {
409
			$row = $table->getPart($part)->getRow(0);
410
		}
411
		$row->mergeCol();
412
		$row->setValues([
413
			$this->_toolbar
414
		]);
415
	}
416
417
	/**
418
	 *
419
	 * {@inheritdoc}
420
	 * @see Widget::getHtmlComponent()
421
	 * @return HtmlTable
422
	 */
423
	public function getHtmlComponent() {
424
		return $this->content["table"];
425
	}
426
427
	public function getUrls() {
428
		return $this->_urls;
429
	}
430
431
	/**
432
	 * Sets the associative array of urls for refreshing, updating or deleting
433
	 * think of defining the update zone with the setTargetSelector method
434
	 *
435
	 * @param string|array $urls
436
	 *        	associative array with keys refresh: for refreshing with search field or pagination, edit : for updating a row, delete: for deleting a row
437
	 * @return DataTable
438
	 */
439
	public function setUrls($urls) {
440
		if (\is_array($urls)) {
441
			$this->_urls["refresh"] = JArray::getValue($urls, "refresh", 0);
442
			$this->_urls["edit"] = JArray::getValue($urls, "edit", 1);
443
			$this->_urls["delete"] = JArray::getValue($urls, "delete", 2);
444
			$this->_urls["display"] = JArray::getValue($urls, "display", 3);
445
		} else {
446
			$this->_urls = [
447
				"refresh" => $urls,
448
				"edit" => $urls,
449
				"delete" => $urls,
450
				"display" => $urls
451
			];
452
		}
453
		return $this;
454
	}
455
456
	/**
457
	 * Paginates the DataTable element with a Semantic HtmlPaginationMenu component
458
	 *
459
	 * @param number $page
460
	 *        	the active page number
461
	 * @param number $total_rowcount
462
	 *        	the total number of items
463
	 * @param number $items_per_page
464
	 *        	The number of items per page
465
	 * @param number $pages_visibles
466
	 *        	The number of visible pages in the Pagination component
467
	 * @return DataTable
468
	 */
469
	public function paginate($page, $total_rowcount, $items_per_page = 10, $pages_visibles = null) {
470
		$this->_pagination = new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
471
		return $this;
472
	}
473
474
	/**
475
	 * Auto Paginates the DataTable element with a Semantic HtmlPaginationMenu component
476
	 *
477
	 * @param number $page
478
	 *        	the active page number
479
	 * @param number $items_per_page
480
	 *        	The number of items per page
481
	 * @param number $pages_visibles
482
	 *        	The number of visible pages in the Pagination component
483
	 * @return DataTable
484
	 */
485
	public function autoPaginate($page = 1, $items_per_page = 10, $pages_visibles = 4) {
486
		$this->_pagination = new Pagination($items_per_page, $pages_visibles, $page);
487
		return $this;
488
	}
489
490
	/**
491
	 *
492
	 * @param array $compileParts
493
	 * @return DataTable
494
	 */
495
	public function refresh($compileParts = [
496
		'tbody'
497
	]) {
498
		$this->_compileParts = $compileParts;
499
		return $this;
500
	}
501
502
	/**
503
	 * Adds a search input in toolbar
504
	 *
505
	 * @param string $position
506
	 * @return \Ajax\common\html\HtmlDoubleElement
507
	 */
508
	public function addSearchInToolbar($position = Direction::RIGHT) {
509
		return $this->addInToolbar($this->getSearchField())
510
			->setPosition($position);
511
	}
512
513
	public function getSearchField() {
514
		if (isset($this->_searchField) === false) {
515
			$this->_searchField = new HtmlInput("search-" . $this->identifier, "search", "", "Search...");
516
			$this->_searchField->addIcon("search", Direction::RIGHT);
517
		}
518
		return $this->_searchField;
519
	}
520
521
	/**
522
	 * The callback function called after the insertion of each row when fromDatabaseObjects is called
523
	 * callback function takes the parameters $row : the row inserted and $object: the instance of model used
524
	 *
525
	 * @param callable $callback
526
	 * @return DataTable
527
	 */
528
	public function onNewRow($callback) {
529
		$this->content["table"]->onNewRow($callback);
530
		return $this;
531
	}
532
533
	/**
534
	 * Returns a form corresponding to the Datatable
535
	 *
536
	 * @return \Ajax\semantic\html\collections\form\HtmlForm
537
	 */
538
	public function asForm() {
539
		return $this->getForm();
540
	}
541
542
	protected function getTargetSelector($op) {
543
		$result = $this->_targetSelector;
544
		if (! isset($result[$op]))
545
			$result = "#" . $this->identifier;
546
		return $result[$op];
547
	}
548
549
	/**
550
	 * Sets the response element selector for Edit and Delete request with ajax
551
	 *
552
	 * @param string|array $_targetSelector
553
	 *        	string or associative array ["edit"=>"edit_selector","delete"=>"delete_selector"]
554
	 * @return DataTable
555
	 */
556
	public function setTargetSelector($_targetSelector) {
557
		if (! \is_array($_targetSelector)) {
558
			$_targetSelector = [
559
				"edit" => $_targetSelector,
560
				"delete" => $_targetSelector
561
			];
562
		}
563
		$this->_targetSelector = $_targetSelector;
564
		return $this;
565
	}
566
567
	public function getRefreshSelector() {
568
		if (isset($this->_refreshSelector))
569
			return $this->_refreshSelector;
570
		return "#" . $this->identifier . " tbody";
571
	}
572
573
	/**
574
	 *
575
	 * @param string $_refreshSelector
576
	 * @return DataTable
577
	 */
578
	public function setRefreshSelector($_refreshSelector) {
579
		$this->_refreshSelector = $_refreshSelector;
580
		return $this;
581
	}
582
583
	/**
584
	 *
585
	 * {@inheritdoc}
586
	 * @see \Ajax\common\Widget::show()
587
	 */
588
	public function show($modelInstance) {
589
		if (\is_array($modelInstance)) {
590
			if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
591
				$modelInstance = \json_decode(\json_encode($modelInstance), FALSE);
592
		}
593
		$this->_modelInstance = $modelInstance;
594
	}
595
596
	public function getRowClass() {
597
		return $this->_rowClass;
598
	}
599
600
	/**
601
	 * Sets the default row class (tr class)
602
	 *
603
	 * @param string $_rowClass
604
	 * @return DataTable
605
	 */
606
	public function setRowClass($_rowClass) {
607
		$this->_rowClass = $_rowClass;
608
		return $this;
609
	}
610
611
	/**
612
	 * Sets the message displayed when there is no record
613
	 *
614
	 * @param mixed $_emptyMessage
615
	 * @return DataTable
616
	 */
617
	public function setEmptyMessage($_emptyMessage) {
618
		$this->_emptyMessage = $_emptyMessage;
619
		return $this;
620
	}
621
622
	public function setSortable($colIndex = NULL) {
623
		$this->_sortable = $colIndex;
624
		return $this;
625
	}
626
627
	public function setActiveRowSelector($class = "active", $event = "click", $multiple = false) {
628
		$this->_self->setActiveRowSelector($class, $event, $multiple);
629
		return $this;
630
	}
631
632
	public function hasActiveRowSelector() {
633
		return $this->_self->hasActiveRowSelector();
634
	}
635
636
	public function hideColumn($colIndex) {
637
		if (! \is_array($this->_hiddenColumns))
638
			$this->_hiddenColumns = [];
639
		$this->_hiddenColumns[] = $colIndex;
640
		return $this;
641
	}
642
643
	public function setColWidth($colIndex, $width) {
644
		$this->_colWidths[$colIndex] = $width;
645
		return $this;
646
	}
647
648
	public function setColWidths($_colWidths) {
649
		$this->_colWidths = $_colWidths;
650
		return $this;
651
	}
652
653
	public function setColAlignment($colIndex, $alignment) {
654
		$this->content["table"]->setColAlignment($colIndex, $alignment);
655
		return $this;
656
	}
657
658
	public function trigger($event, $params = "[]") {
659
		return $this->getHtmlComponent()->trigger($event, $params);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->getHtmlComponent(...rigger($event, $params) targeting Ajax\common\html\BaseHtml::trigger() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
660
	}
661
662
	public function onActiveRowChange($jsCode) {
663
		$this->getHtmlComponent()->onActiveRowChange($jsCode);
664
		return $this;
665
	}
666
667
	/**
668
	 *
669
	 * @return mixed
670
	 */
671
	public function getDeleteBehavior() {
672
		return $this->_deleteBehavior;
673
	}
674
675
	/**
676
	 *
677
	 * @return mixed
678
	 */
679
	public function getEditBehavior() {
680
		return $this->_editBehavior;
681
	}
682
683
	/**
684
	 *
685
	 * @return mixed
686
	 */
687
	public function getDisplayBehavior() {
688
		return $this->_displayBehavior;
689
	}
690
691
	/**
692
	 *
693
	 * @param mixed $_displayBehavior
694
	 */
695
	public function setDisplayBehavior($_displayBehavior) {
696
		$this->_displayBehavior = $_displayBehavior;
697
	}
698
699
	/**
700
	 *
701
	 * @return mixed
702
	 */
703
	public function getGroupByFields() {
704
		return $this->_instanceViewer->getGroupByFields();
705
	}
706
707
	/**
708
	 *
709
	 * @param mixed $_groupByFields
710
	 */
711
	public function setGroupByFields($_groupByFields) {
712
		$this->_instanceViewer->setGroupByFields($_groupByFields);
713
	}
714
715
	/**
716
	 *
717
	 * @param boolean $_visibleHover
718
	 */
719
	public function setVisibleHover($_visibleHover) {
720
		$this->_visibleHover = $_visibleHover;
721
	}
722
723
	/**
724
	 *
725
	 * @return \Ajax\semantic\html\collections\menus\HtmlPaginationMenu
726
	 */
727
	public function getPaginationToolbar() {
728
		return $this->_paginationToolbar;
729
	}
730
731
	public function setInverted($recursive = true) {
732
		$this->getHtmlComponent()->setInverted($recursive);
733
		if ($this->_emptyMessage instanceof HtmlSemDoubleElement) {
734
			$this->_emptyMessage->setInverted($recursive);
735
		}
736
	}
737
}
738