@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | */ |
28 | 28 | class DataTable extends Widget { |
29 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait; |
|
29 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait; |
|
30 | 30 | |
31 | 31 | protected $_searchField; |
32 | 32 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | protected $_displayBehavior; |
44 | 44 | |
45 | - protected $_visibleHover = false; |
|
45 | + protected $_visibleHover=false; |
|
46 | 46 | |
47 | 47 | protected $_targetSelector; |
48 | 48 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | protected $_json; |
54 | 54 | |
55 | - protected $_rowClass = "_element"; |
|
55 | + protected $_rowClass="_element"; |
|
56 | 56 | |
57 | 57 | protected $_sortable; |
58 | 58 | |
@@ -62,26 +62,26 @@ discard block |
||
62 | 62 | |
63 | 63 | protected $_paginationToolbar; |
64 | 64 | |
65 | - public function __construct($identifier, $model, $modelInstance = NULL) { |
|
65 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
66 | 66 | parent::__construct($identifier, $model, $modelInstance); |
67 | 67 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
68 | - $this->_urls = []; |
|
69 | - $this->_emptyMessage = new HtmlMessage("", "nothing to display"); |
|
68 | + $this->_urls=[]; |
|
69 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
70 | 70 | $this->_emptyMessage->setIcon("info circle"); |
71 | 71 | } |
72 | 72 | |
73 | 73 | public function run(JsUtils $js) { |
74 | - if ($this->_runned !== true) { |
|
75 | - $offset = $js->scriptCount(); |
|
74 | + if ($this->_runned!==true) { |
|
75 | + $offset=$js->scriptCount(); |
|
76 | 76 | if ($this->_hasCheckboxes && isset($js)) { |
77 | 77 | $this->_runCheckboxes($js); |
78 | 78 | } |
79 | 79 | if ($this->_visibleHover) { |
80 | - $js->execOn("mouseover", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [ |
|
80 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [ |
|
81 | 81 | "preventDefault" => false, |
82 | 82 | "stopPropagation" => true |
83 | 83 | ]); |
84 | - $js->execOn("mouseout", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [ |
|
84 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [ |
|
85 | 85 | "preventDefault" => false, |
86 | 86 | "stopPropagation" => true |
87 | 87 | ]); |
@@ -97,16 +97,16 @@ discard block |
||
97 | 97 | if (isset($this->_pagination)) |
98 | 98 | $this->_associatePaginationBehavior($js, $offset); |
99 | 99 | $this->_associateSearchFieldBehavior($js, $offset); |
100 | - $this->_runned = true; |
|
100 | + $this->_runned=true; |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | 104 | protected function _generateBehavior($op, $params, JsUtils $js) { |
105 | 105 | if (isset($this->_urls[$op])) { |
106 | - $params = \array_merge($params, [ |
|
106 | + $params=\array_merge($params, [ |
|
107 | 107 | "attr" => "data-ajax" |
108 | 108 | ]); |
109 | - $js->ajaxOnClick("#" . $this->identifier . " ._" . $op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
109 | + $js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
@@ -125,21 +125,21 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | public function refreshTD($fieldName, $jquery, $view) { |
128 | - $index = $this->_getIndex($fieldName); |
|
128 | + $index=$this->_getIndex($fieldName); |
|
129 | 129 | $this->compile($jquery, $view); |
130 | 130 | return $this->refreshTR() |
131 | 131 | ->getTable() |
132 | 132 | ->getCell(0, $index); |
133 | 133 | } |
134 | 134 | |
135 | - public function compile(JsUtils $js = NULL, &$view = NULL) { |
|
136 | - if (! $this->_generated) { |
|
135 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
136 | + if (!$this->_generated) { |
|
137 | 137 | if (isset($this->_buttonsColumn)) { |
138 | 138 | $this->_instanceViewer->sortColumnContent($this->_buttonsColumn, $this->_buttons); |
139 | 139 | } |
140 | 140 | $this->_instanceViewer->setInstance($this->_model); |
141 | - $captions = $this->_instanceViewer->getCaptions(); |
|
142 | - $table = $this->content["table"]; |
|
141 | + $captions=$this->_instanceViewer->getCaptions(); |
|
142 | + $table=$this->content["table"]; |
|
143 | 143 | if ($this->_hasCheckboxes) { |
144 | 144 | $this->_generateMainCheckbox($captions); |
145 | 145 | } |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | $this->compileExtraElements($table, $captions); |
155 | 155 | $this->_compileSearchFieldBehavior($js); |
156 | 156 | |
157 | - $this->content = JArray::sortAssociative($this->content, [ |
|
157 | + $this->content=JArray::sortAssociative($this->content, [ |
|
158 | 158 | PositionInTable::BEFORETABLE, |
159 | 159 | "table", |
160 | 160 | PositionInTable::AFTERTABLE |
161 | 161 | ]); |
162 | 162 | $this->_compileForm(); |
163 | 163 | $this->_applyStyleAttributes($table); |
164 | - $this->_generated = true; |
|
164 | + $this->_generated=true; |
|
165 | 165 | } |
166 | 166 | return parent::compile($js, $view); |
167 | 167 | } |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | } |
200 | 200 | |
201 | 201 | protected function _generateHeader(HtmlTable $table, $captions) { |
202 | - $gbFields = $this->_instanceViewer->getGroupByFields(); |
|
202 | + $gbFields=$this->_instanceViewer->getGroupByFields(); |
|
203 | 203 | if (\is_array($gbFields)) { |
204 | - $captions = \array_values(UArray::removeByKeys($captions, $gbFields)); |
|
204 | + $captions=\array_values(UArray::removeByKeys($captions, $gbFields)); |
|
205 | 205 | } |
206 | 206 | $table->setHeaderValues($captions); |
207 | 207 | if (isset($this->_sortable)) { |
@@ -210,22 +210,22 @@ discard block |
||
210 | 210 | } |
211 | 211 | |
212 | 212 | protected function _generateContent($table) { |
213 | - $objects = $this->_modelInstance; |
|
213 | + $objects=$this->_modelInstance; |
|
214 | 214 | if (isset($this->_pagination)) { |
215 | - $objects = $this->_pagination->getObjects($this->_modelInstance); |
|
215 | + $objects=$this->_pagination->getObjects($this->_modelInstance); |
|
216 | 216 | } |
217 | 217 | InstanceViewer::setIndex(0); |
218 | - $fields = $this->_instanceViewer->getSimpleProperties(); |
|
219 | - $groupByFields = $this->_instanceViewer->getGroupByFields(); |
|
220 | - if (! is_array($groupByFields)) { |
|
221 | - $table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields) { |
|
218 | + $fields=$this->_instanceViewer->getSimpleProperties(); |
|
219 | + $groupByFields=$this->_instanceViewer->getGroupByFields(); |
|
220 | + if (!is_array($groupByFields)) { |
|
221 | + $table->fromDatabaseObjects($objects, function($instance) use ($table, $fields) { |
|
222 | 222 | return $this->_generateRow($instance, $fields, $table); |
223 | 223 | }); |
224 | 224 | } else { |
225 | - $diffFields = array_values(UArray::removeByKeys($fields, $groupByFields)); |
|
226 | - $activeValues = array_combine($groupByFields, \array_fill(0, \count($groupByFields), null)); |
|
227 | - $uuids = []; |
|
228 | - $table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids, $diffFields) { |
|
225 | + $diffFields=array_values(UArray::removeByKeys($fields, $groupByFields)); |
|
226 | + $activeValues=array_combine($groupByFields, \array_fill(0, \count($groupByFields), null)); |
|
227 | + $uuids=[]; |
|
228 | + $table->fromDatabaseObjects($objects, function($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids, $diffFields) { |
|
229 | 229 | $this->_instanceViewer->setInstance($instance); |
230 | 230 | foreach ($groupByFields as $index => $gbField) { |
231 | 231 | $this->_generateGroupByRow($index, $gbField, $table, $fields, $activeValues, $uuids); |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | return $this->_generateRow($instance, $diffFields, $table, null, $uuids); |
234 | 234 | }); |
235 | 235 | } |
236 | - if ($table->getRowCount() == 0) { |
|
237 | - $result = $table->addRow(); |
|
236 | + if ($table->getRowCount()==0) { |
|
237 | + $result=$table->addRow(); |
|
238 | 238 | $result->mergeRow(); |
239 | 239 | $result->setValues([ |
240 | 240 | $this->_emptyMessage |
@@ -243,20 +243,20 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | protected function _generateGroupByRow($index, $gbField, $table, $fields, &$activeValues, &$uuids) { |
246 | - $newValue = $this->_instanceViewer->getValue($gbField); |
|
247 | - if ($this->getElementContent($activeValues[$gbField]) !== $this->getElementContent($newValue)) { |
|
248 | - if ($index == 0) { |
|
249 | - $uuids = []; |
|
246 | + $newValue=$this->_instanceViewer->getValue($gbField); |
|
247 | + if ($this->getElementContent($activeValues[$gbField])!==$this->getElementContent($newValue)) { |
|
248 | + if ($index==0) { |
|
249 | + $uuids=[]; |
|
250 | 250 | } |
251 | - $uuid = uniqid("grp"); |
|
252 | - $uuids[$gbField] = $uuid; |
|
253 | - $id = $this->_instanceViewer->getIdentifier(); |
|
254 | - $result = $table->addMergeRow(sizeof($fields) + 1, $newValue); |
|
255 | - $result->setIdentifier($this->identifier . "-tr-gb-" . $id); |
|
251 | + $uuid=uniqid("grp"); |
|
252 | + $uuids[$gbField]=$uuid; |
|
253 | + $id=$this->_instanceViewer->getIdentifier(); |
|
254 | + $result=$table->addMergeRow(sizeof($fields)+1, $newValue); |
|
255 | + $result->setIdentifier($this->identifier."-tr-gb-".$id); |
|
256 | 256 | $result->setProperty("data-ajax", $id); |
257 | 257 | $result->setProperty("data-group", $uuid); |
258 | 258 | $result->addToProperty("class", $this->_rowClass); |
259 | - $activeValues[$gbField] = $newValue; |
|
259 | + $activeValues[$gbField]=$newValue; |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | public function getFieldValue($index) { |
271 | - $index = $this->_getIndex($index); |
|
271 | + $index=$this->_getIndex($index); |
|
272 | 272 | if (is_numeric($index)) { |
273 | - $values = $this->_instanceViewer->getValues(); |
|
273 | + $values=$this->_instanceViewer->getValues(); |
|
274 | 274 | if (isset($values[$index])) { |
275 | 275 | return $values[$index]; |
276 | 276 | } |
@@ -278,30 +278,30 @@ discard block |
||
278 | 278 | return null; |
279 | 279 | } |
280 | 280 | |
281 | - protected function _generateRow($instance, $fields, &$table, $checkedClass = null, $uuids = null) { |
|
281 | + protected function _generateRow($instance, $fields, &$table, $checkedClass=null, $uuids=null) { |
|
282 | 282 | $this->_instanceViewer->setInstance($instance); |
283 | - InstanceViewer::$index ++; |
|
284 | - $values = $this->_instanceViewer->getValues(); |
|
285 | - $id = $this->_instanceViewer->getIdentifier(); |
|
286 | - $dataAjax = $id; |
|
287 | - $id = $this->cleanIdentifier($id); |
|
283 | + InstanceViewer::$index++; |
|
284 | + $values=$this->_instanceViewer->getValues(); |
|
285 | + $id=$this->_instanceViewer->getIdentifier(); |
|
286 | + $dataAjax=$id; |
|
287 | + $id=$this->cleanIdentifier($id); |
|
288 | 288 | if ($this->_hasCheckboxes) { |
289 | - $ck = new HtmlCheckbox("ck-" . $this->identifier . "-" . $id, ""); |
|
290 | - $checked = false; |
|
289 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
290 | + $checked=false; |
|
291 | 291 | if (isset($this->_checkedCallback)) { |
292 | - $func = $this->_checkedCallback; |
|
293 | - $checked = $func($instance); |
|
292 | + $func=$this->_checkedCallback; |
|
293 | + $checked=$func($instance); |
|
294 | 294 | } |
295 | 295 | $ck->setChecked($checked); |
296 | - $field = $ck->getField(); |
|
296 | + $field=$ck->getField(); |
|
297 | 297 | $field->setProperty("value", $dataAjax); |
298 | 298 | $field->setProperty("name", "selection[]"); |
299 | 299 | if (isset($checkedClass)) |
300 | 300 | $field->setClass($checkedClass); |
301 | 301 | \array_unshift($values, $ck); |
302 | 302 | } |
303 | - $result = $table->newRow(); |
|
304 | - $result->setIdentifier($this->identifier . "-tr-" . $id); |
|
303 | + $result=$table->newRow(); |
|
304 | + $result->setIdentifier($this->identifier."-tr-".$id); |
|
305 | 305 | $result->setProperty("data-ajax", $dataAjax); |
306 | 306 | $result->setValues($values); |
307 | 307 | $result->addToProperty("class", $this->_rowClass); |
@@ -314,63 +314,63 @@ discard block |
||
314 | 314 | |
315 | 315 | protected function _generatePagination($table) { |
316 | 316 | if (isset($this->_toolbar)) { |
317 | - if ($this->_toolbarPosition == PositionInTable::FOOTER) |
|
317 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
318 | 318 | $this->_toolbar->setFloated("left"); |
319 | 319 | } |
320 | - $footer = $table->getFooter(); |
|
320 | + $footer=$table->getFooter(); |
|
321 | 321 | $footer->mergeCol(); |
322 | - $this->_paginationToolbar = $this->_pagination->generateMenu($this->identifier); |
|
322 | + $this->_paginationToolbar=$this->_pagination->generateMenu($this->identifier); |
|
323 | 323 | $footer->addValues($this->_paginationToolbar); |
324 | 324 | } |
325 | 325 | |
326 | - protected function _associatePaginationBehavior(JsUtils $js = NULL, $offset = null) { |
|
326 | + protected function _associatePaginationBehavior(JsUtils $js=NULL, $offset=null) { |
|
327 | 327 | if (isset($this->_urls["refresh"])) { |
328 | - $menu = $this->_pagination->getMenu(); |
|
328 | + $menu=$this->_pagination->getMenu(); |
|
329 | 329 | if (isset($menu) && isset($js)) { |
330 | - $js->postOnClick("#" . $menu->getIdentifier() . " .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", $this->getRefreshSelector(), [ |
|
330 | + $js->postOnClick("#".$menu->getIdentifier()." .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model)."'}", $this->getRefreshSelector(), [ |
|
331 | 331 | "preventDefault" => false, |
332 | 332 | "jqueryDone" => "replaceWith", |
333 | 333 | "hasLoader" => false, |
334 | - "jsCallback" => '$("#' . $this->identifier . '").trigger("pageChange");$("#' . $this->identifier . '").trigger("activeRowChange");' |
|
334 | + "jsCallback" => '$("#'.$this->identifier.'").trigger("pageChange");$("#'.$this->identifier.'").trigger("activeRowChange");' |
|
335 | 335 | ]); |
336 | - $page = $_POST["p"] ?? null; |
|
336 | + $page=$_POST["p"] ?? null; |
|
337 | 337 | if (isset($page)) { |
338 | - $js->execAtLast('$("#' . $this->getIdentifier() . ' .pagination").children("a.item").removeClass("active");$("#' . $this->getIdentifier() . ' .pagination").children("a.item[data-page=' . $page . ']:not(.no-active)").addClass("active");'); |
|
338 | + $js->execAtLast('$("#'.$this->getIdentifier().' .pagination").children("a.item").removeClass("active");$("#'.$this->getIdentifier().' .pagination").children("a.item[data-page='.$page.']:not(.no-active)").addClass("active");'); |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
344 | - protected function _compileSearchFieldBehavior(JsUtils $js = NULL) { |
|
344 | + protected function _compileSearchFieldBehavior(JsUtils $js=NULL) { |
|
345 | 345 | if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) { |
346 | - $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", "#" . $this->identifier . " tbody", [ |
|
346 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'".JString::doubleBackSlashes($this->_model)."'}", "#".$this->identifier." tbody", [ |
|
347 | 347 | "preventDefault" => false, |
348 | 348 | "jqueryDone" => "replaceWith", |
349 | 349 | "hasLoader" => "internal", |
350 | - "jsCallback" => '$("#' . $this->identifier . '").trigger("searchTerminate",[$(self).val()]);' |
|
350 | + "jsCallback" => '$("#'.$this->identifier.'").trigger("searchTerminate",[$(self).val()]);' |
|
351 | 351 | ]); |
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | - protected function _associateSearchFieldBehavior(JsUtils $js = NULL, $offset = null) {} |
|
355 | + protected function _associateSearchFieldBehavior(JsUtils $js=NULL, $offset=null) {} |
|
356 | 356 | |
357 | 357 | protected function _getFieldName($index) { |
358 | - $fieldName = parent::_getFieldName($index); |
|
358 | + $fieldName=parent::_getFieldName($index); |
|
359 | 359 | if (\is_object($fieldName)) |
360 | - $fieldName = "field-" . $index; |
|
361 | - return $fieldName . "[]"; |
|
360 | + $fieldName="field-".$index; |
|
361 | + return $fieldName."[]"; |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | protected function _getFieldCaption($index) { |
365 | 365 | return null; |
366 | 366 | } |
367 | 367 | |
368 | - protected function applyToolbarPosition(string $position, $table, $captions = NULL) { |
|
368 | + protected function applyToolbarPosition(string $position, $table, $captions=NULL) { |
|
369 | 369 | switch ($position) { |
370 | 370 | case PositionInTable::BEFORETABLE: |
371 | 371 | case PositionInTable::AFTERTABLE: |
372 | - if (isset($this->_compileParts) === false) { |
|
373 | - $this->content[$position] = $this->_toolbar; |
|
372 | + if (isset($this->_compileParts)===false) { |
|
373 | + $this->content[$position]=$this->_toolbar; |
|
374 | 374 | } |
375 | 375 | break; |
376 | 376 | case PositionInTable::HEADER: |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | - protected function _setToolbarPosition($table, $captions = NULL) { |
|
384 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
385 | 385 | if (\is_array($this->_toolbarPosition)) { |
386 | 386 | foreach ($this->_toolbarPosition as $tbp) { |
387 | 387 | $this->applyToolbarPosition($tbp, $table, $captions); |
@@ -407,11 +407,11 @@ discard block |
||
407 | 407 | } |
408 | 408 | |
409 | 409 | private function addToolbarRow($part, $table, $captions) { |
410 | - $hasPart = $table->hasPart($part); |
|
410 | + $hasPart=$table->hasPart($part); |
|
411 | 411 | if ($hasPart) { |
412 | - $row = $table->getPart($part)->addRow(\sizeof($captions)); |
|
412 | + $row=$table->getPart($part)->addRow(\sizeof($captions)); |
|
413 | 413 | } else { |
414 | - $row = $table->getPart($part)->getRow(0); |
|
414 | + $row=$table->getPart($part)->getRow(0); |
|
415 | 415 | } |
416 | 416 | $row->mergeCol(); |
417 | 417 | $row->setValues([ |
@@ -443,12 +443,12 @@ discard block |
||
443 | 443 | */ |
444 | 444 | public function setUrls($urls) { |
445 | 445 | if (\is_array($urls)) { |
446 | - $this->_urls["refresh"] = JArray::getValue($urls, "refresh", 0); |
|
447 | - $this->_urls["edit"] = JArray::getValue($urls, "edit", 1); |
|
448 | - $this->_urls["delete"] = JArray::getValue($urls, "delete", 2); |
|
449 | - $this->_urls["display"] = JArray::getValue($urls, "display", 3); |
|
446 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
447 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
448 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
449 | + $this->_urls["display"]=JArray::getValue($urls, "display", 3); |
|
450 | 450 | } else { |
451 | - $this->_urls = [ |
|
451 | + $this->_urls=[ |
|
452 | 452 | "refresh" => $urls, |
453 | 453 | "edit" => $urls, |
454 | 454 | "delete" => $urls, |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | * The number of visible pages in the Pagination component |
472 | 472 | * @return DataTable |
473 | 473 | */ |
474 | - public function paginate($page, $total_rowcount, $items_per_page = 10, $pages_visibles = null) { |
|
475 | - $this->_pagination = new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
474 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
475 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
476 | 476 | return $this; |
477 | 477 | } |
478 | 478 | |
@@ -487,8 +487,8 @@ discard block |
||
487 | 487 | * The number of visible pages in the Pagination component |
488 | 488 | * @return DataTable |
489 | 489 | */ |
490 | - public function autoPaginate($page = 1, $items_per_page = 10, $pages_visibles = 4) { |
|
491 | - $this->_pagination = new Pagination($items_per_page, $pages_visibles, $page); |
|
490 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
491 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
492 | 492 | return $this; |
493 | 493 | } |
494 | 494 | |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | * @param array $compileParts |
498 | 498 | * @return DataTable |
499 | 499 | */ |
500 | - public function refresh($compileParts = [ |
|
500 | + public function refresh($compileParts=[ |
|
501 | 501 | 'tbody' |
502 | 502 | ]) { |
503 | - $this->_compileParts = $compileParts; |
|
503 | + $this->_compileParts=$compileParts; |
|
504 | 504 | return $this; |
505 | 505 | } |
506 | 506 | |
@@ -510,14 +510,14 @@ discard block |
||
510 | 510 | * @param string $position |
511 | 511 | * @return \Ajax\common\html\HtmlDoubleElement |
512 | 512 | */ |
513 | - public function addSearchInToolbar($position = Direction::RIGHT) { |
|
513 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
514 | 514 | return $this->addInToolbar($this->getSearchField()) |
515 | 515 | ->setPosition($position); |
516 | 516 | } |
517 | 517 | |
518 | 518 | public function getSearchField() { |
519 | - if (isset($this->_searchField) === false) { |
|
520 | - $this->_searchField = new HtmlInput("search-" . $this->identifier, "search", "", "Search..."); |
|
519 | + if (isset($this->_searchField)===false) { |
|
520 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
521 | 521 | $this->_searchField->addIcon("search", Direction::RIGHT); |
522 | 522 | } |
523 | 523 | return $this->_searchField; |
@@ -545,9 +545,9 @@ discard block |
||
545 | 545 | } |
546 | 546 | |
547 | 547 | protected function getTargetSelector($op) { |
548 | - $result = $this->_targetSelector; |
|
549 | - if (! isset($result[$op])) |
|
550 | - $result = "#" . $this->identifier; |
|
548 | + $result=$this->_targetSelector; |
|
549 | + if (!isset($result[$op])) |
|
550 | + $result="#".$this->identifier; |
|
551 | 551 | return $result[$op]; |
552 | 552 | } |
553 | 553 | |
@@ -559,20 +559,20 @@ discard block |
||
559 | 559 | * @return DataTable |
560 | 560 | */ |
561 | 561 | public function setTargetSelector($_targetSelector) { |
562 | - if (! \is_array($_targetSelector)) { |
|
563 | - $_targetSelector = [ |
|
562 | + if (!\is_array($_targetSelector)) { |
|
563 | + $_targetSelector=[ |
|
564 | 564 | "edit" => $_targetSelector, |
565 | 565 | "delete" => $_targetSelector |
566 | 566 | ]; |
567 | 567 | } |
568 | - $this->_targetSelector = $_targetSelector; |
|
568 | + $this->_targetSelector=$_targetSelector; |
|
569 | 569 | return $this; |
570 | 570 | } |
571 | 571 | |
572 | 572 | public function getRefreshSelector() { |
573 | 573 | if (isset($this->_refreshSelector)) |
574 | 574 | return $this->_refreshSelector; |
575 | - return "#" . $this->identifier . " tbody"; |
|
575 | + return "#".$this->identifier." tbody"; |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @return DataTable |
582 | 582 | */ |
583 | 583 | public function setRefreshSelector($_refreshSelector) { |
584 | - $this->_refreshSelector = $_refreshSelector; |
|
584 | + $this->_refreshSelector=$_refreshSelector; |
|
585 | 585 | return $this; |
586 | 586 | } |
587 | 587 | |
@@ -593,9 +593,9 @@ discard block |
||
593 | 593 | public function show($modelInstance) { |
594 | 594 | if (\is_array($modelInstance)) { |
595 | 595 | if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
596 | - $modelInstance = \json_decode(\json_encode($modelInstance), FALSE); |
|
596 | + $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
597 | 597 | } |
598 | - $this->_modelInstance = $modelInstance; |
|
598 | + $this->_modelInstance=$modelInstance; |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | public function getRowClass() { |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | * @return DataTable |
610 | 610 | */ |
611 | 611 | public function setRowClass($_rowClass) { |
612 | - $this->_rowClass = $_rowClass; |
|
612 | + $this->_rowClass=$_rowClass; |
|
613 | 613 | return $this; |
614 | 614 | } |
615 | 615 | |
@@ -620,16 +620,16 @@ discard block |
||
620 | 620 | * @return DataTable |
621 | 621 | */ |
622 | 622 | public function setEmptyMessage($_emptyMessage) { |
623 | - $this->_emptyMessage = $_emptyMessage; |
|
623 | + $this->_emptyMessage=$_emptyMessage; |
|
624 | 624 | return $this; |
625 | 625 | } |
626 | 626 | |
627 | - public function setSortable($colIndex = NULL) { |
|
628 | - $this->_sortable = $colIndex; |
|
627 | + public function setSortable($colIndex=NULL) { |
|
628 | + $this->_sortable=$colIndex; |
|
629 | 629 | return $this; |
630 | 630 | } |
631 | 631 | |
632 | - public function setActiveRowSelector($class = "active", $event = "click", $multiple = false) { |
|
632 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
633 | 633 | $this->_self->setActiveRowSelector($class, $event, $multiple); |
634 | 634 | return $this; |
635 | 635 | } |
@@ -639,19 +639,19 @@ discard block |
||
639 | 639 | } |
640 | 640 | |
641 | 641 | public function hideColumn($colIndex) { |
642 | - if (! \is_array($this->_hiddenColumns)) |
|
643 | - $this->_hiddenColumns = []; |
|
644 | - $this->_hiddenColumns[] = $colIndex; |
|
642 | + if (!\is_array($this->_hiddenColumns)) |
|
643 | + $this->_hiddenColumns=[]; |
|
644 | + $this->_hiddenColumns[]=$colIndex; |
|
645 | 645 | return $this; |
646 | 646 | } |
647 | 647 | |
648 | 648 | public function setColWidth($colIndex, $width) { |
649 | - $this->_colWidths[$colIndex] = $width; |
|
649 | + $this->_colWidths[$colIndex]=$width; |
|
650 | 650 | return $this; |
651 | 651 | } |
652 | 652 | |
653 | 653 | public function setColWidths($_colWidths) { |
654 | - $this->_colWidths = $_colWidths; |
|
654 | + $this->_colWidths=$_colWidths; |
|
655 | 655 | return $this; |
656 | 656 | } |
657 | 657 | |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | return $this; |
661 | 661 | } |
662 | 662 | |
663 | - public function trigger($event, $params = "[]") { |
|
663 | + public function trigger($event, $params="[]") { |
|
664 | 664 | return $this->getHtmlComponent()->trigger($event, $params); |
665 | 665 | } |
666 | 666 | |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | * @param mixed $_displayBehavior |
699 | 699 | */ |
700 | 700 | public function setDisplayBehavior($_displayBehavior) { |
701 | - $this->_displayBehavior = $_displayBehavior; |
|
701 | + $this->_displayBehavior=$_displayBehavior; |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | /** |
@@ -718,8 +718,8 @@ discard block |
||
718 | 718 | } |
719 | 719 | |
720 | 720 | public function addGroupBy($index) { |
721 | - $index = $this->_getIndex($index); |
|
722 | - if ($index !== false) { |
|
721 | + $index=$this->_getIndex($index); |
|
722 | + if ($index!==false) { |
|
723 | 723 | $this->_instanceViewer->addGroupBy($index); |
724 | 724 | } |
725 | 725 | } |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | * @param boolean $_visibleHover |
730 | 730 | */ |
731 | 731 | public function setVisibleHover($_visibleHover) { |
732 | - $this->_visibleHover = $_visibleHover; |
|
732 | + $this->_visibleHover=$_visibleHover; |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | /** |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | return $this->_paginationToolbar; |
741 | 741 | } |
742 | 742 | |
743 | - public function setInverted($recursive = true) { |
|
743 | + public function setInverted($recursive=true) { |
|
744 | 744 | $this->getHtmlComponent()->setInverted($recursive); |
745 | 745 | if ($this->_emptyMessage instanceof HtmlSemDoubleElement) { |
746 | 746 | $this->_emptyMessage->setInverted($recursive); |
@@ -86,16 +86,19 @@ discard block |
||
86 | 86 | "stopPropagation" => true |
87 | 87 | ]); |
88 | 88 | } |
89 | - if (\is_array($this->_deleteBehavior)) |
|
90 | - $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
91 | - if (\is_array($this->_editBehavior)) |
|
92 | - $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
89 | + if (\is_array($this->_deleteBehavior)) { |
|
90 | + $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
91 | + } |
|
92 | + if (\is_array($this->_editBehavior)) { |
|
93 | + $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
94 | + } |
|
93 | 95 | if (\is_array($this->_displayBehavior)) { |
94 | 96 | $this->_generateBehavior("display", $this->_displayBehavior, $js); |
95 | 97 | } |
96 | 98 | parent::run($js); |
97 | - if (isset($this->_pagination)) |
|
98 | - $this->_associatePaginationBehavior($js, $offset); |
|
99 | + if (isset($this->_pagination)) { |
|
100 | + $this->_associatePaginationBehavior($js, $offset); |
|
101 | + } |
|
99 | 102 | $this->_associateSearchFieldBehavior($js, $offset); |
100 | 103 | $this->_runned = true; |
101 | 104 | } |
@@ -146,8 +149,9 @@ discard block |
||
146 | 149 | $table->setRowCount(0, \count($captions)); |
147 | 150 | $this->_generateHeader($table, $captions); |
148 | 151 | |
149 | - if (isset($this->_compileParts)) |
|
150 | - $table->setCompileParts($this->_compileParts); |
|
152 | + if (isset($this->_compileParts)) { |
|
153 | + $table->setCompileParts($this->_compileParts); |
|
154 | + } |
|
151 | 155 | |
152 | 156 | $this->_generateContent($table); |
153 | 157 | |
@@ -182,8 +186,9 @@ discard block |
||
182 | 186 | } |
183 | 187 | |
184 | 188 | protected function _applyStyleAttributes($table) { |
185 | - if (isset($this->_hiddenColumns)) |
|
186 | - $this->_hideColumns(); |
|
189 | + if (isset($this->_hiddenColumns)) { |
|
190 | + $this->_hideColumns(); |
|
191 | + } |
|
187 | 192 | if (isset($this->_colWidths)) { |
188 | 193 | foreach ($this->_colWidths as $colIndex => $width) { |
189 | 194 | $table->setColWidth($colIndex, $width); |
@@ -296,8 +301,9 @@ discard block |
||
296 | 301 | $field = $ck->getField(); |
297 | 302 | $field->setProperty("value", $dataAjax); |
298 | 303 | $field->setProperty("name", "selection[]"); |
299 | - if (isset($checkedClass)) |
|
300 | - $field->setClass($checkedClass); |
|
304 | + if (isset($checkedClass)) { |
|
305 | + $field->setClass($checkedClass); |
|
306 | + } |
|
301 | 307 | \array_unshift($values, $ck); |
302 | 308 | } |
303 | 309 | $result = $table->newRow(); |
@@ -314,8 +320,9 @@ discard block |
||
314 | 320 | |
315 | 321 | protected function _generatePagination($table) { |
316 | 322 | if (isset($this->_toolbar)) { |
317 | - if ($this->_toolbarPosition == PositionInTable::FOOTER) |
|
318 | - $this->_toolbar->setFloated("left"); |
|
323 | + if ($this->_toolbarPosition == PositionInTable::FOOTER) { |
|
324 | + $this->_toolbar->setFloated("left"); |
|
325 | + } |
|
319 | 326 | } |
320 | 327 | $footer = $table->getFooter(); |
321 | 328 | $footer->mergeCol(); |
@@ -356,8 +363,9 @@ discard block |
||
356 | 363 | |
357 | 364 | protected function _getFieldName($index) { |
358 | 365 | $fieldName = parent::_getFieldName($index); |
359 | - if (\is_object($fieldName)) |
|
360 | - $fieldName = "field-" . $index; |
|
366 | + if (\is_object($fieldName)) { |
|
367 | + $fieldName = "field-" . $index; |
|
368 | + } |
|
361 | 369 | return $fieldName . "[]"; |
362 | 370 | } |
363 | 371 | |
@@ -546,8 +554,9 @@ discard block |
||
546 | 554 | |
547 | 555 | protected function getTargetSelector($op) { |
548 | 556 | $result = $this->_targetSelector; |
549 | - if (! isset($result[$op])) |
|
550 | - $result = "#" . $this->identifier; |
|
557 | + if (! isset($result[$op])) { |
|
558 | + $result = "#" . $this->identifier; |
|
559 | + } |
|
551 | 560 | return $result[$op]; |
552 | 561 | } |
553 | 562 | |
@@ -570,8 +579,9 @@ discard block |
||
570 | 579 | } |
571 | 580 | |
572 | 581 | public function getRefreshSelector() { |
573 | - if (isset($this->_refreshSelector)) |
|
574 | - return $this->_refreshSelector; |
|
582 | + if (isset($this->_refreshSelector)) { |
|
583 | + return $this->_refreshSelector; |
|
584 | + } |
|
575 | 585 | return "#" . $this->identifier . " tbody"; |
576 | 586 | } |
577 | 587 | |
@@ -592,8 +602,9 @@ discard block |
||
592 | 602 | */ |
593 | 603 | public function show($modelInstance) { |
594 | 604 | if (\is_array($modelInstance)) { |
595 | - if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
|
596 | - $modelInstance = \json_decode(\json_encode($modelInstance), FALSE); |
|
605 | + if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) { |
|
606 | + $modelInstance = \json_decode(\json_encode($modelInstance), FALSE); |
|
607 | + } |
|
597 | 608 | } |
598 | 609 | $this->_modelInstance = $modelInstance; |
599 | 610 | } |
@@ -639,8 +650,9 @@ discard block |
||
639 | 650 | } |
640 | 651 | |
641 | 652 | public function hideColumn($colIndex) { |
642 | - if (! \is_array($this->_hiddenColumns)) |
|
643 | - $this->_hiddenColumns = []; |
|
653 | + if (! \is_array($this->_hiddenColumns)) { |
|
654 | + $this->_hiddenColumns = []; |
|
655 | + } |
|
644 | 656 | $this->_hiddenColumns[] = $colIndex; |
645 | 657 | return $this; |
646 | 658 | } |