@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | |
32 | 32 | public function __construct($identifier, $rowCount, $colCount) { |
33 | 33 | parent::__construct($identifier, "table", "ui table"); |
34 | - $this->content=array (); |
|
34 | + $this->content=array(); |
|
35 | 35 | $this->setRowCount($rowCount, $colCount); |
36 | - $this->_variations=[ Variation::CELLED,Variation::PADDED,Variation::COMPACT ]; |
|
37 | - $this->_compileParts=["thead","tbody","tfoot"]; |
|
36 | + $this->_variations=[Variation::CELLED, Variation::PADDED, Variation::COMPACT]; |
|
37 | + $this->_compileParts=["thead", "tbody", "tfoot"]; |
|
38 | 38 | $this->_afterCompileEvents=[]; |
39 | 39 | } |
40 | 40 | |
@@ -44,17 +44,17 @@ discard block |
||
44 | 44 | * @return HtmlTableContent |
45 | 45 | */ |
46 | 46 | public function getPart($key) { |
47 | - if (\array_key_exists($key, $this->content) === false) { |
|
47 | + if (\array_key_exists($key, $this->content)===false) { |
|
48 | 48 | $this->content[$key]=new HtmlTableContent("", $key); |
49 | - if ($key !== "tbody") { |
|
49 | + if ($key!=="tbody") { |
|
50 | 50 | $this->content[$key]->setRowCount(1, $this->_colCount); |
51 | 51 | } |
52 | 52 | } |
53 | 53 | return $this->content[$key]; |
54 | 54 | } |
55 | 55 | |
56 | - protected function _getFirstPart(){ |
|
57 | - if(isset($this->content["thead"])){ |
|
56 | + protected function _getFirstPart() { |
|
57 | + if (isset($this->content["thead"])) { |
|
58 | 58 | return $this->content["thead"]; |
59 | 59 | } |
60 | 60 | return $this->content["tbody"]; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return boolean |
100 | 100 | */ |
101 | 101 | public function hasPart($key) { |
102 | - return \array_key_exists($key, $this->content) === true; |
|
102 | + return \array_key_exists($key, $this->content)===true; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -259,8 +259,8 @@ discard block |
||
259 | 259 | return $this->colAlign($colIndex, "colLeftFromRight"); |
260 | 260 | } |
261 | 261 | |
262 | - public function setColAlignment($colIndex,$alignment){ |
|
263 | - switch ($alignment){ |
|
262 | + public function setColAlignment($colIndex, $alignment) { |
|
263 | + switch ($alignment) { |
|
264 | 264 | case TextAlignment::LEFT: |
265 | 265 | $function="colLeft"; |
266 | 266 | break; |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | return $this; |
281 | 281 | } |
282 | 282 | |
283 | - public function setColAlignmentFromRight($colIndex,$alignment){ |
|
284 | - switch ($alignment){ |
|
283 | + public function setColAlignmentFromRight($colIndex, $alignment) { |
|
284 | + switch ($alignment) { |
|
285 | 285 | case TextAlignment::LEFT: |
286 | 286 | $function="colLeftFromRight"; |
287 | 287 | break; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | |
304 | 304 | private function colAlign($colIndex, $function) { |
305 | 305 | if (\is_array($colIndex)) { |
306 | - foreach ( $colIndex as $cIndex ) { |
|
306 | + foreach ($colIndex as $cIndex) { |
|
307 | 307 | $this->colAlign($cIndex, $function); |
308 | 308 | } |
309 | 309 | } else { |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * @see HtmlSemDoubleElement::compile() |
365 | 365 | */ |
366 | 366 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
367 | - if(\sizeof($this->_compileParts)<3){ |
|
367 | + if (\sizeof($this->_compileParts)<3) { |
|
368 | 368 | $this->_template="%content%"; |
369 | 369 | $this->refresh($js); |
370 | 370 | } |
@@ -373,9 +373,9 @@ discard block |
||
373 | 373 | } |
374 | 374 | |
375 | 375 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
376 | - parent::compile_once($js,$view); |
|
376 | + parent::compile_once($js, $view); |
|
377 | 377 | if ($this->propertyContains("class", "sortable")) { |
378 | - $this->addEvent("execute", "$('#" . $this->identifier . "').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
378 | + $this->addEvent("execute", "$('#".$this->identifier."').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
@@ -388,13 +388,13 @@ discard block |
||
388 | 388 | public function fromDatabaseObject($object, $function) { |
389 | 389 | $result=$function($object); |
390 | 390 | if (\is_array($result)) { |
391 | - $result= $this->addRow($function($object)); |
|
391 | + $result=$this->addRow($function($object)); |
|
392 | 392 | } else { |
393 | - $result= $this->getBody()->_addRow($result); |
|
393 | + $result=$this->getBody()->_addRow($result); |
|
394 | 394 | } |
395 | - if(isset($this->_afterCompileEvents["onNewRow"])){ |
|
396 | - if(\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
397 | - $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
395 | + if (isset($this->_afterCompileEvents["onNewRow"])) { |
|
396 | + if (\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
397 | + $this->_afterCompileEvents["onNewRow"]($result, $object); |
|
398 | 398 | } |
399 | 399 | return $result; |
400 | 400 | } |
@@ -409,26 +409,26 @@ discard block |
||
409 | 409 | return $this; |
410 | 410 | } |
411 | 411 | |
412 | - public function refreshTR(){ |
|
412 | + public function refreshTR() { |
|
413 | 413 | $this->setCompileParts(); |
414 | 414 | $this->getPart("tbody")->refreshTR(); |
415 | 415 | } |
416 | 416 | |
417 | - public function refresh($js){ |
|
417 | + public function refresh($js) { |
|
418 | 418 | $this->_footer=$this->getFooter(); |
419 | - if(isset($js)){ |
|
420 | - $js->exec('$("#'.$this->identifier.' tfoot").replaceWith("'.\addslashes($this->_footer).'");',true); |
|
419 | + if (isset($js)) { |
|
420 | + $js->exec('$("#'.$this->identifier.' tfoot").replaceWith("'.\addslashes($this->_footer).'");', true); |
|
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
424 | - public function run(JsUtils $js){ |
|
425 | - if(!$this->_runned){ |
|
426 | - if(isset($this->_activeRowSelector)){ |
|
424 | + public function run(JsUtils $js) { |
|
425 | + if (!$this->_runned) { |
|
426 | + if (isset($this->_activeRowSelector)) { |
|
427 | 427 | $this->_activeRowSelector->run(); |
428 | 428 | } |
429 | 429 | } |
430 | - $result= parent::run($js); |
|
431 | - if(isset($this->_footer)) |
|
430 | + $result=parent::run($js); |
|
431 | + if (isset($this->_footer)) |
|
432 | 432 | $this->_footer->run($js); |
433 | 433 | $this->_runned=true; |
434 | 434 | return $result; |
@@ -452,51 +452,51 @@ discard block |
||
452 | 452 | * @param boolean $multiple |
453 | 453 | * @return HtmlTable |
454 | 454 | */ |
455 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
456 | - $this->_activeRowSelector=new ActiveRow($this,$class,$event,$multiple); |
|
455 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
456 | + $this->_activeRowSelector=new ActiveRow($this, $class, $event, $multiple); |
|
457 | 457 | return $this; |
458 | 458 | } |
459 | 459 | |
460 | - public function hasActiveRowSelector(){ |
|
460 | + public function hasActiveRowSelector() { |
|
461 | 461 | return isset($this->_activeRowSelector); |
462 | 462 | } |
463 | 463 | |
464 | - public function hideColumn($colIndex){ |
|
465 | - if(isset($this->content["thead"])){ |
|
464 | + public function hideColumn($colIndex) { |
|
465 | + if (isset($this->content["thead"])) { |
|
466 | 466 | $this->content["thead"]->hideColumn($colIndex); |
467 | 467 | } |
468 | 468 | $this->content["tbody"]->hideColumn($colIndex); |
469 | - if(isset($this->content["tfoot"])){ |
|
469 | + if (isset($this->content["tfoot"])) { |
|
470 | 470 | $this->content["tfoot"]->hideColumn($colIndex); |
471 | 471 | } |
472 | 472 | return $this; |
473 | 473 | } |
474 | 474 | |
475 | - public function setColWidth($colIndex,$width){ |
|
475 | + public function setColWidth($colIndex, $width) { |
|
476 | 476 | $part=$this->_getFirstPart(); |
477 | - if($part!==null && $part->count()>0) |
|
477 | + if ($part!==null && $part->count()>0) |
|
478 | 478 | $part->getCell(0, $colIndex)->setWidth($width); |
479 | 479 | return $this; |
480 | 480 | } |
481 | 481 | |
482 | - public function setColWidths($widths){ |
|
482 | + public function setColWidths($widths) { |
|
483 | 483 | $part=$this->_getFirstPart(); |
484 | - if($part!==null && $part->count()>0){ |
|
484 | + if ($part!==null && $part->count()>0) { |
|
485 | 485 | $count=$part->getColCount(); |
486 | - if(!\is_array($widths)){ |
|
486 | + if (!\is_array($widths)) { |
|
487 | 487 | $widths=\array_fill(0, $count, $widths); |
488 | 488 | } |
489 | - $max=\min(\sizeof($widths),$count); |
|
490 | - for($i=0;$i<$max;$i++){ |
|
489 | + $max=\min(\sizeof($widths), $count); |
|
490 | + for ($i=0; $i<$max; $i++) { |
|
491 | 491 | $part->getCell(0, $i)->setWidth($widths[$i]); |
492 | 492 | } |
493 | 493 | } |
494 | 494 | return $this; |
495 | 495 | } |
496 | 496 | |
497 | - public function mergeIdentiqualValues($colIndex,$function="strip_tags"){ |
|
497 | + public function mergeIdentiqualValues($colIndex, $function="strip_tags") { |
|
498 | 498 | $body=$this->getBody(); |
499 | - $body->mergeIdentiqualValues($colIndex,$function); |
|
499 | + $body->mergeIdentiqualValues($colIndex, $function); |
|
500 | 500 | return $this; |
501 | 501 | } |
502 | 502 | /** |
@@ -510,16 +510,16 @@ discard block |
||
510 | 510 | * @param mixed $_innerScript |
511 | 511 | */ |
512 | 512 | public function setInnerScript($_innerScript) { |
513 | - $this->_innerScript = $_innerScript; |
|
513 | + $this->_innerScript=$_innerScript; |
|
514 | 514 | } |
515 | 515 | |
516 | - public function onActiveRowChange($jsCode){ |
|
517 | - $this->on("activeRowChange",$jsCode); |
|
516 | + public function onActiveRowChange($jsCode) { |
|
517 | + $this->on("activeRowChange", $jsCode); |
|
518 | 518 | return $this; |
519 | 519 | } |
520 | 520 | |
521 | - public function addMergeRow($colCount,$value=null){ |
|
522 | - return $this->getBody()->addMergeRow($colCount,$value); |
|
521 | + public function addMergeRow($colCount, $value=null) { |
|
522 | + return $this->getBody()->addMergeRow($colCount, $value); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | } |
@@ -25,7 +25,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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,8 +482,8 @@ discard block |
||
482 | 482 | * @param array $compileParts |
483 | 483 | * @return DataTable |
484 | 484 | */ |
485 | - public function refresh($compileParts = ['tbody']) { |
|
486 | - $this->_compileParts = $compileParts; |
|
485 | + public function refresh($compileParts=['tbody']) { |
|
486 | + $this->_compileParts=$compileParts; |
|
487 | 487 | return $this; |
488 | 488 | } |
489 | 489 | |
@@ -493,14 +493,14 @@ discard block |
||
493 | 493 | * @param string $position |
494 | 494 | * @return \Ajax\common\html\HtmlDoubleElement |
495 | 495 | */ |
496 | - public function addSearchInToolbar($position = Direction::RIGHT) { |
|
496 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
497 | 497 | return $this->addInToolbar($this->getSearchField()) |
498 | 498 | ->setPosition($position); |
499 | 499 | } |
500 | 500 | |
501 | 501 | public function getSearchField() { |
502 | - if (isset($this->_searchField) === false) { |
|
503 | - $this->_searchField = new HtmlInput("search-" . $this->identifier, "search", "", "Search..."); |
|
502 | + if (isset($this->_searchField)===false) { |
|
503 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
504 | 504 | $this->_searchField->addIcon("search", Direction::RIGHT); |
505 | 505 | } |
506 | 506 | return $this->_searchField; |
@@ -528,9 +528,9 @@ discard block |
||
528 | 528 | } |
529 | 529 | |
530 | 530 | protected function getTargetSelector($op) { |
531 | - $result = $this->_targetSelector; |
|
532 | - if (! isset($result[$op])) |
|
533 | - $result = "#" . $this->identifier; |
|
531 | + $result=$this->_targetSelector; |
|
532 | + if (!isset($result[$op])) |
|
533 | + $result="#".$this->identifier; |
|
534 | 534 | return $result[$op]; |
535 | 535 | } |
536 | 536 | |
@@ -542,20 +542,20 @@ discard block |
||
542 | 542 | * @return DataTable |
543 | 543 | */ |
544 | 544 | public function setTargetSelector($_targetSelector) { |
545 | - if (! \is_array($_targetSelector)) { |
|
546 | - $_targetSelector = [ |
|
545 | + if (!\is_array($_targetSelector)) { |
|
546 | + $_targetSelector=[ |
|
547 | 547 | "edit" => $_targetSelector, |
548 | 548 | "delete" => $_targetSelector |
549 | 549 | ]; |
550 | 550 | } |
551 | - $this->_targetSelector = $_targetSelector; |
|
551 | + $this->_targetSelector=$_targetSelector; |
|
552 | 552 | return $this; |
553 | 553 | } |
554 | 554 | |
555 | 555 | public function getRefreshSelector() { |
556 | 556 | if (isset($this->_refreshSelector)) |
557 | 557 | return $this->_refreshSelector; |
558 | - return "#" . $this->identifier . " tbody"; |
|
558 | + return "#".$this->identifier." tbody"; |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | /** |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | * @return DataTable |
565 | 565 | */ |
566 | 566 | public function setRefreshSelector($_refreshSelector) { |
567 | - $this->_refreshSelector = $_refreshSelector; |
|
567 | + $this->_refreshSelector=$_refreshSelector; |
|
568 | 568 | return $this; |
569 | 569 | } |
570 | 570 | |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | public function show($modelInstance) { |
577 | 577 | if (\is_array($modelInstance)) { |
578 | 578 | if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
579 | - $modelInstance = \json_decode(\json_encode($modelInstance), FALSE); |
|
579 | + $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
580 | 580 | } |
581 | - $this->_modelInstance = $modelInstance; |
|
581 | + $this->_modelInstance=$modelInstance; |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | public function getRowClass() { |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | * @return DataTable |
593 | 593 | */ |
594 | 594 | public function setRowClass($_rowClass) { |
595 | - $this->_rowClass = $_rowClass; |
|
595 | + $this->_rowClass=$_rowClass; |
|
596 | 596 | return $this; |
597 | 597 | } |
598 | 598 | |
@@ -603,38 +603,38 @@ discard block |
||
603 | 603 | * @return DataTable |
604 | 604 | */ |
605 | 605 | public function setEmptyMessage($_emptyMessage) { |
606 | - $this->_emptyMessage = $_emptyMessage; |
|
606 | + $this->_emptyMessage=$_emptyMessage; |
|
607 | 607 | return $this; |
608 | 608 | } |
609 | 609 | |
610 | - public function setSortable($colIndex = NULL) { |
|
611 | - $this->_sortable = $colIndex; |
|
610 | + public function setSortable($colIndex=NULL) { |
|
611 | + $this->_sortable=$colIndex; |
|
612 | 612 | return $this; |
613 | 613 | } |
614 | 614 | |
615 | - public function setActiveRowSelector($class = "active", $event = "click", $multiple = false) { |
|
615 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
616 | 616 | $this->_self->setActiveRowSelector($class, $event, $multiple); |
617 | 617 | return $this; |
618 | 618 | } |
619 | 619 | |
620 | - public function hasActiveRowSelector(){ |
|
620 | + public function hasActiveRowSelector() { |
|
621 | 621 | return $this->_self->hasActiveRowSelector(); |
622 | 622 | } |
623 | 623 | |
624 | 624 | public function hideColumn($colIndex) { |
625 | - if (! \is_array($this->_hiddenColumns)) |
|
626 | - $this->_hiddenColumns = []; |
|
627 | - $this->_hiddenColumns[] = $colIndex; |
|
625 | + if (!\is_array($this->_hiddenColumns)) |
|
626 | + $this->_hiddenColumns=[]; |
|
627 | + $this->_hiddenColumns[]=$colIndex; |
|
628 | 628 | return $this; |
629 | 629 | } |
630 | 630 | |
631 | 631 | public function setColWidth($colIndex, $width) { |
632 | - $this->_colWidths[$colIndex] = $width; |
|
632 | + $this->_colWidths[$colIndex]=$width; |
|
633 | 633 | return $this; |
634 | 634 | } |
635 | 635 | |
636 | 636 | public function setColWidths($_colWidths) { |
637 | - $this->_colWidths = $_colWidths; |
|
637 | + $this->_colWidths=$_colWidths; |
|
638 | 638 | return $this; |
639 | 639 | } |
640 | 640 | |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | return $this; |
644 | 644 | } |
645 | 645 | |
646 | - public function trigger($event, $params = "[]") { |
|
646 | + public function trigger($event, $params="[]") { |
|
647 | 647 | return $this->getHtmlComponent()->trigger($event, $params); |
648 | 648 | } |
649 | 649 | |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | * @param mixed $_displayBehavior |
682 | 682 | */ |
683 | 683 | public function setDisplayBehavior($_displayBehavior) { |
684 | - $this->_displayBehavior = $_displayBehavior; |
|
684 | + $this->_displayBehavior=$_displayBehavior; |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | /** |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | * @param boolean $_visibleHover |
706 | 706 | */ |
707 | 707 | public function setVisibleHover($_visibleHover) { |
708 | - $this->_visibleHover = $_visibleHover; |
|
708 | + $this->_visibleHover=$_visibleHover; |
|
709 | 709 | } |
710 | 710 | /** |
711 | 711 | * @return \Ajax\semantic\html\collections\menus\HtmlPaginationMenu |
@@ -714,9 +714,9 @@ discard block |
||
714 | 714 | return $this->_paginationToolbar; |
715 | 715 | } |
716 | 716 | |
717 | - public function setInverted($recursive=true){ |
|
717 | + public function setInverted($recursive=true) { |
|
718 | 718 | $this->getHtmlComponent()->setInverted($recursive); |
719 | - if($this->_emptyMessage instanceof HtmlSemDoubleElement){ |
|
719 | + if ($this->_emptyMessage instanceof HtmlSemDoubleElement) { |
|
720 | 720 | $this->_emptyMessage->setInverted($recursive); |
721 | 721 | } |
722 | 722 | } |