@@ -20,19 +20,19 @@ discard block |
||
20 | 20 | |
21 | 21 | public function __construct($identifier) { |
22 | 22 | parent::__construct($identifier, "tr", ""); |
23 | - $this->_states=[ State::ACTIVE,State::POSITIVE,State::NEGATIVE,State::WARNING,State::ERROR,State::DISABLED ]; |
|
23 | + $this->_states=[State::ACTIVE, State::POSITIVE, State::NEGATIVE, State::WARNING, State::ERROR, State::DISABLED]; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function setColCount($colCount) { |
27 | 27 | $count=$this->count(); |
28 | - for($i=$count; $i < $colCount; $i++) { |
|
28 | + for ($i=$count; $i<$colCount; $i++) { |
|
29 | 29 | $item=$this->addItem(NULL); |
30 | 30 | $item->setTagName($this->_tdTagName); |
31 | 31 | } |
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
35 | - public function getColCount(){ |
|
35 | + public function getColCount() { |
|
36 | 36 | return $this->count(); |
37 | 37 | } |
38 | 38 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param mixed $values |
69 | 69 | */ |
70 | 70 | public function setValues($values=array()) { |
71 | - return $this->_addOrSetValues($values, function(&$cell,$value){$cell->setValue($value);}); |
|
71 | + return $this->_addOrSetValues($values, function(&$cell, $value) {$cell->setValue($value); }); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,27 +76,27 @@ discard block |
||
76 | 76 | * @param mixed $values |
77 | 77 | */ |
78 | 78 | public function addValues($values=array()) { |
79 | - return $this->_addOrSetValues($values, function(&$cell,$value){$cell->addValue($value);}); |
|
79 | + return $this->_addOrSetValues($values, function(&$cell, $value) {$cell->addValue($value); }); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Sets or adds values to the row cols |
84 | 84 | * @param mixed $values |
85 | 85 | */ |
86 | - protected function _addOrSetValues($values,$callback) { |
|
86 | + protected function _addOrSetValues($values, $callback) { |
|
87 | 87 | $count=$this->count(); |
88 | 88 | if (!\is_array($values)) { |
89 | 89 | $values=\array_fill(0, $count, $values); |
90 | 90 | } else { |
91 | - if (JArray::isAssociative($values) === true) { |
|
91 | + if (JArray::isAssociative($values)===true) { |
|
92 | 92 | $values=\array_values($values); |
93 | 93 | } |
94 | 94 | } |
95 | 95 | $count=\min(\sizeof($values), $count); |
96 | 96 | |
97 | - for($i=0; $i < $count; $i++) { |
|
97 | + for ($i=0; $i<$count; $i++) { |
|
98 | 98 | $cell=$this->content[$i]; |
99 | - $callback($cell,$values[$i]); |
|
99 | + $callback($cell, $values[$i]); |
|
100 | 100 | } |
101 | 101 | return $this; |
102 | 102 | } |
@@ -122,20 +122,20 @@ discard block |
||
122 | 122 | public function getColPosition($colIndex) { |
123 | 123 | $pos=0; |
124 | 124 | $rows=$this->_container->getContent(); |
125 | - for($i=0; $i < $this->_row; $i++) { |
|
125 | + for ($i=0; $i<$this->_row; $i++) { |
|
126 | 126 | $max=\min($colIndex, $rows[$i]->count()); |
127 | - for($j=0; $j < $max; $j++) { |
|
127 | + for ($j=0; $j<$max; $j++) { |
|
128 | 128 | $rowspan=$rows[$i]->getItem($j)->getRowspan(); |
129 | - if ($rowspan + $i > $this->_row) |
|
129 | + if ($rowspan+$i>$this->_row) |
|
130 | 130 | $pos++; |
131 | 131 | } |
132 | 132 | } |
133 | - if ($pos > $colIndex) |
|
133 | + if ($pos>$colIndex) |
|
134 | 134 | return NULL; |
135 | 135 | $count=$this->count(); |
136 | - for($i=0; $i < $count; $i++) { |
|
136 | + for ($i=0; $i<$count; $i++) { |
|
137 | 137 | $pos+=$this->content[$i]->getColspan(); |
138 | - if ($pos >= $colIndex + 1) |
|
138 | + if ($pos>=$colIndex+1) |
|
139 | 139 | return $i; |
140 | 140 | } |
141 | 141 | return null; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | public function conditionalCellFormat($callback, $format) { |
145 | 145 | $cells=$this->content; |
146 | - foreach ( $cells as $cell ) { |
|
146 | + foreach ($cells as $cell) { |
|
147 | 147 | $cell->conditionalCellFormat($callback, $format); |
148 | 148 | } |
149 | 149 | return $this; |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | |
159 | 159 | public function containsStr($needle) { |
160 | 160 | $cells=$this->content; |
161 | - foreach ( $cells as $cell ) { |
|
162 | - if (\strpos($cell->getContent(), $needle) !== false) |
|
161 | + foreach ($cells as $cell) { |
|
162 | + if (\strpos($cell->getContent(), $needle)!==false) |
|
163 | 163 | return true; |
164 | 164 | } |
165 | 165 | return false; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | public function applyCells($callback) { |
174 | 174 | $cells=$this->content; |
175 | - foreach ( $cells as $cell ) { |
|
175 | + foreach ($cells as $cell) { |
|
176 | 176 | $cell->apply($callback); |
177 | 177 | } |
178 | 178 | return $this; |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | |
19 | 19 | protected function createItem($value) { |
20 | 20 | $count=$this->count(); |
21 | - $item=new HtmlListItem("item-" . $this->identifier . "-" . $count, $value); |
|
21 | + $item=new HtmlListItem("item-".$this->identifier."-".$count, $value); |
|
22 | 22 | return $item; |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function addHeader($niveau, $content) { |
26 | - $header=new HtmlHeader("header-" . $this->identifier, $niveau, $content, "page"); |
|
26 | + $header=new HtmlHeader("header-".$this->identifier, $niveau, $content, "page"); |
|
27 | 27 | $this->wrap($header); |
28 | 28 | return $header; |
29 | 29 | } |
30 | 30 | |
31 | - public function getItemPart($index,$partName="header"){ |
|
31 | + public function getItemPart($index, $partName="header") { |
|
32 | 32 | return $this->getItem($index)->getPart($partName); |
33 | 33 | } |
34 | 34 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | public function asLink() { |
40 | - $this->addToPropertyCtrl("class", "link", array ("link" )); |
|
40 | + $this->addToPropertyCtrl("class", "link", array("link")); |
|
41 | 41 | return $this->contentAs("a"); |
42 | 42 | } |
43 | 43 | |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | public function run(JsUtils $js) { |
63 | - if ($this->_hasCheckedList === true) { |
|
64 | - $jsCode=include dirname(__FILE__) . '/../../components/jsTemplates/tplCheckedList.php'; |
|
65 | - $jsCode=\str_replace("%identifier%", "#" . $this->identifier, $jsCode); |
|
63 | + if ($this->_hasCheckedList===true) { |
|
64 | + $jsCode=include dirname(__FILE__).'/../../components/jsTemplates/tplCheckedList.php'; |
|
65 | + $jsCode=\str_replace("%identifier%", "#".$this->identifier, $jsCode); |
|
66 | 66 | $this->executeOnRun($jsCode); |
67 | 67 | } |
68 | 68 | return parent::run($js); |
@@ -86,24 +86,24 @@ discard block |
||
86 | 86 | |
87 | 87 | public function addCheckedList($items=array(), $masterItem=NULL, $values=array()) { |
88 | 88 | $count=$this->count(); |
89 | - $identifier=$this->identifier . "-" . $count; |
|
89 | + $identifier=$this->identifier."-".$count; |
|
90 | 90 | if (isset($masterItem)) { |
91 | - $masterO=new HtmlFormCheckbox("master-" . $identifier, $masterItem); |
|
91 | + $masterO=new HtmlFormCheckbox("master-".$identifier, $masterItem); |
|
92 | 92 | $masterO->getHtmlCk()->addToProperty("class", "master"); |
93 | 93 | $masterO->setClass("item"); |
94 | 94 | $this->addItem($masterO); |
95 | 95 | } |
96 | - $fields=array (); |
|
96 | + $fields=array(); |
|
97 | 97 | $i=0; |
98 | - foreach ( $items as $val => $caption ) { |
|
99 | - $itemO=new HtmlFormCheckbox($identifier . "-" . $i++, $caption, $val, "child"); |
|
100 | - if (\array_search($val, $values) !== false) { |
|
98 | + foreach ($items as $val => $caption) { |
|
99 | + $itemO=new HtmlFormCheckbox($identifier."-".$i++, $caption, $val, "child"); |
|
100 | + if (\array_search($val, $values)!==false) { |
|
101 | 101 | $itemO->getField()->setProperty("checked", ""); |
102 | 102 | } |
103 | 103 | $itemO->setClass("item"); |
104 | 104 | $fields[]=$itemO; |
105 | 105 | } |
106 | - if (isset($masterO) === true) { |
|
106 | + if (isset($masterO)===true) { |
|
107 | 107 | $list=new HtmlList("", $fields); |
108 | 108 | $list->setClass("list"); |
109 | 109 | $masterO->addContent($list); |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | return $this; |
115 | 115 | } |
116 | 116 | |
117 | - public function setIcons($icons){ |
|
118 | - if(!\is_array($icons)){ |
|
117 | + public function setIcons($icons) { |
|
118 | + if (!\is_array($icons)) { |
|
119 | 119 | $icons=\array_fill(0, \sizeof($this->content), $icons); |
120 | 120 | } |
121 | - $max=\min(\sizeof($icons),\sizeof($this->content)); |
|
122 | - for($i=0;$i<$max;$i++){ |
|
121 | + $max=\min(\sizeof($icons), \sizeof($this->content)); |
|
122 | + for ($i=0; $i<$max; $i++) { |
|
123 | 123 | $this->content[$i]->addIcon($icons[$i]); |
124 | 124 | } |
125 | 125 | return $this; |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | |
28 | 28 | public function __construct($identifier, $rowCount, $colCount) { |
29 | 29 | parent::__construct($identifier, "table", "ui table"); |
30 | - $this->content=array (); |
|
30 | + $this->content=array(); |
|
31 | 31 | $this->setRowCount($rowCount, $colCount); |
32 | - $this->_variations=[ Variation::CELLED,Variation::PADDED,Variation::COMPACT ]; |
|
33 | - $this->_compileParts=["thead","tbody","tfoot"]; |
|
32 | + $this->_variations=[Variation::CELLED, Variation::PADDED, Variation::COMPACT]; |
|
33 | + $this->_compileParts=["thead", "tbody", "tfoot"]; |
|
34 | 34 | $this->_afterCompileEvents=[]; |
35 | 35 | } |
36 | 36 | |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | * @return HtmlTableContent |
49 | 49 | */ |
50 | 50 | public function getPart($key) { |
51 | - if (\array_key_exists($key, $this->content) === false) { |
|
51 | + if (\array_key_exists($key, $this->content)===false) { |
|
52 | 52 | $this->content[$key]=new HtmlTableContent("", $key); |
53 | - if ($key !== "tbody") { |
|
53 | + if ($key!=="tbody") { |
|
54 | 54 | $this->content[$key]->setRowCount(1, $this->_colCount); |
55 | 55 | } |
56 | 56 | } |
57 | 57 | return $this->content[$key]; |
58 | 58 | } |
59 | 59 | |
60 | - protected function _getFirstPart(){ |
|
61 | - if(isset($this->content["thead"])){ |
|
60 | + protected function _getFirstPart() { |
|
61 | + if (isset($this->content["thead"])) { |
|
62 | 62 | return $this->content["thead"]; |
63 | 63 | } |
64 | 64 | return $this->content["tbody"]; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @return boolean |
104 | 104 | */ |
105 | 105 | public function hasPart($key) { |
106 | - return \array_key_exists($key, $this->content) === true; |
|
106 | + return \array_key_exists($key, $this->content)===true; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | |
239 | 239 | private function colAlign($colIndex, $function) { |
240 | 240 | if (\is_array($colIndex)) { |
241 | - foreach ( $colIndex as $cIndex ) { |
|
241 | + foreach ($colIndex as $cIndex) { |
|
242 | 242 | $this->colAlign($cIndex, $function); |
243 | 243 | } |
244 | 244 | } else { |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @see HtmlSemDoubleElement::compile() |
300 | 300 | */ |
301 | 301 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
302 | - if(\sizeof($this->_compileParts)<3){ |
|
302 | + if (\sizeof($this->_compileParts)<3) { |
|
303 | 303 | $this->_template="%content%"; |
304 | 304 | $this->refresh(); |
305 | 305 | } |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | |
310 | 310 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
311 | 311 | if ($this->propertyContains("class", "sortable")) { |
312 | - $this->addEvent("execute", "$('#" . $this->identifier . "').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
312 | + $this->addEvent("execute", "$('#".$this->identifier."').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
313 | 313 | } |
314 | - if(isset($this->_activeRowSelector)){ |
|
314 | + if (isset($this->_activeRowSelector)) { |
|
315 | 315 | $this->_activeRowSelector->compile(); |
316 | 316 | } |
317 | 317 | } |
@@ -325,13 +325,13 @@ discard block |
||
325 | 325 | public function fromDatabaseObject($object, $function) { |
326 | 326 | $result=$function($object); |
327 | 327 | if (\is_array($result)) { |
328 | - $result= $this->addRow($function($object)); |
|
328 | + $result=$this->addRow($function($object)); |
|
329 | 329 | } else { |
330 | - $result= $this->getBody()->_addRow($result); |
|
330 | + $result=$this->getBody()->_addRow($result); |
|
331 | 331 | } |
332 | - if(isset($this->_afterCompileEvents["onNewRow"])){ |
|
333 | - if(\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
334 | - $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
332 | + if (isset($this->_afterCompileEvents["onNewRow"])) { |
|
333 | + if (\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
334 | + $this->_afterCompileEvents["onNewRow"]($result, $object); |
|
335 | 335 | } |
336 | 336 | return $result; |
337 | 337 | } |
@@ -346,14 +346,14 @@ discard block |
||
346 | 346 | return $this; |
347 | 347 | } |
348 | 348 | |
349 | - public function refresh(){ |
|
349 | + public function refresh() { |
|
350 | 350 | $this->_footer=$this->getFooter(); |
351 | 351 | $this->addEvent("execute", '$("#'.$this->identifier.' tfoot").replaceWith("'.\addslashes($this->_footer).'");'); |
352 | 352 | } |
353 | 353 | |
354 | - public function run(JsUtils $js){ |
|
355 | - $result= parent::run($js); |
|
356 | - if(isset($this->_footer)) |
|
354 | + public function run(JsUtils $js) { |
|
355 | + $result=parent::run($js); |
|
356 | + if (isset($this->_footer)) |
|
357 | 357 | $this->_footer->run($js); |
358 | 358 | return $result; |
359 | 359 | } |
@@ -376,38 +376,38 @@ discard block |
||
376 | 376 | * @param boolean $multiple |
377 | 377 | * @return HtmlTable |
378 | 378 | */ |
379 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
380 | - $this->_activeRowSelector=new ActiveRow($this,$class,$event,$multiple); |
|
379 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
380 | + $this->_activeRowSelector=new ActiveRow($this, $class, $event, $multiple); |
|
381 | 381 | return $this; |
382 | 382 | } |
383 | 383 | |
384 | - public function hideColumn($colIndex){ |
|
385 | - if(isset($this->content["thead"])){ |
|
384 | + public function hideColumn($colIndex) { |
|
385 | + if (isset($this->content["thead"])) { |
|
386 | 386 | $this->content["thead"]->hideColumn($colIndex); |
387 | 387 | } |
388 | 388 | $this->content["tbody"]->hideColumn($colIndex); |
389 | - if(isset($this->content["tfoot"])){ |
|
389 | + if (isset($this->content["tfoot"])) { |
|
390 | 390 | $this->content["tfoot"]->hideColumn($colIndex); |
391 | 391 | } |
392 | 392 | return $this; |
393 | 393 | } |
394 | 394 | |
395 | - public function setColWidth($colIndex,$width){ |
|
395 | + public function setColWidth($colIndex, $width) { |
|
396 | 396 | $part=$this->_getFirstPart(); |
397 | - if($part!==null && $part->count()>0) |
|
397 | + if ($part!==null && $part->count()>0) |
|
398 | 398 | $part->getCell(0, $colIndex)->setWidth($width); |
399 | 399 | return $this; |
400 | 400 | } |
401 | 401 | |
402 | - public function setColWidths($widths){ |
|
402 | + public function setColWidths($widths) { |
|
403 | 403 | $part=$this->_getFirstPart(); |
404 | - if($part!==null && $part->col()>0){ |
|
404 | + if ($part!==null && $part->col()>0) { |
|
405 | 405 | $count=$part->getColCount(); |
406 | - if(!\is_array($widths)){ |
|
406 | + if (!\is_array($widths)) { |
|
407 | 407 | $widths=\array_fill(0, $count, $widths); |
408 | 408 | } |
409 | - $max=\min(\sizeof($widths),$count); |
|
410 | - for($i=0;$i<$max;$i++){ |
|
409 | + $max=\min(\sizeof($widths), $count); |
|
410 | + for ($i=0; $i<$max; $i++) { |
|
411 | 411 | $part->getCell(0, $i)->setWidth($widths[$i]); |
412 | 412 | } |
413 | 413 | } |
@@ -19,56 +19,56 @@ discard block |
||
19 | 19 | protected $_colWidths; |
20 | 20 | |
21 | 21 | public function __construct($identifier, $modelInstance=NULL) { |
22 | - parent::__construct($identifier, null,$modelInstance); |
|
23 | - $this->_init(new DeInstanceViewer($identifier), "table", new HtmlTable($identifier, 0,2), false); |
|
22 | + parent::__construct($identifier, null, $modelInstance); |
|
23 | + $this->_init(new DeInstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 2), false); |
|
24 | 24 | $this->content["table"]->setDefinition(); |
25 | 25 | } |
26 | 26 | |
27 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
28 | - if(!$this->_generated){ |
|
27 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
28 | + if (!$this->_generated) { |
|
29 | 29 | $this->_instanceViewer->setInstance($this->_modelInstance); |
30 | 30 | |
31 | 31 | $table=$this->content["table"]; |
32 | 32 | $this->_generateContent($table); |
33 | 33 | |
34 | - if(isset($this->_toolbar)){ |
|
34 | + if (isset($this->_toolbar)) { |
|
35 | 35 | $this->_setToolbarPosition($table); |
36 | 36 | } |
37 | - if(isset($this->_colWidths)){ |
|
37 | + if (isset($this->_colWidths)) { |
|
38 | 38 | $this->_applyStyleAttributes($table); |
39 | 39 | } |
40 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
40 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
41 | 41 | $this->_compileForm(); |
42 | 42 | $this->_generated=true; |
43 | 43 | } |
44 | - return parent::compile($js,$view); |
|
44 | + return parent::compile($js, $view); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * @param HtmlTable $table |
49 | 49 | */ |
50 | - protected function _generateContent($table){ |
|
51 | - $values= $this->_instanceViewer->getValues(); |
|
50 | + protected function _generateContent($table) { |
|
51 | + $values=$this->_instanceViewer->getValues(); |
|
52 | 52 | $captions=$this->_instanceViewer->getCaptions(); |
53 | 53 | $count=$this->_instanceViewer->count(); |
54 | 54 | |
55 | - for($i=0;$i<$count;$i++){ |
|
56 | - $table->addRow([$captions[$i],$values[$i]]); |
|
55 | + for ($i=0; $i<$count; $i++) { |
|
56 | + $table->addRow([$captions[$i], $values[$i]]); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | - protected function _applyStyleAttributes(HtmlTable $table){ |
|
60 | + protected function _applyStyleAttributes(HtmlTable $table) { |
|
61 | 61 | $table->setColWidths($this->_colWidths); |
62 | 62 | } |
63 | - protected function _getFieldName($index){ |
|
63 | + protected function _getFieldName($index) { |
|
64 | 64 | return $this->_instanceViewer->getFieldName($index); |
65 | 65 | } |
66 | 66 | |
67 | - protected function _getFieldCaption($index){ |
|
67 | + protected function _getFieldCaption($index) { |
|
68 | 68 | return null; |
69 | 69 | } |
70 | 70 | |
71 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
71 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
72 | 72 | return $this->identifier."-{$prefix}-".$name; |
73 | 73 | } |
74 | 74 | |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | return $this; |
101 | 101 | } |
102 | 102 | |
103 | - public function asForm(){ |
|
103 | + public function asForm() { |
|
104 | 104 | return $this->getForm(); |
105 | 105 | } |
106 | 106 | |
107 | - public function setColCaptionWidth($width){ |
|
107 | + public function setColCaptionWidth($width) { |
|
108 | 108 | $this->_colWidths[0]=$width; |
109 | 109 | return $this; |
110 | 110 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | return $this; |
115 | 115 | } |
116 | 116 | |
117 | - public function setColWidths($widths){ |
|
117 | + public function setColWidths($widths) { |
|
118 | 118 | $this->_colWidths=$widths; |
119 | 119 | return $this; |
120 | 120 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | */ |
25 | 25 | class DataTable extends Widget { |
26 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait; |
|
26 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait; |
|
27 | 27 | protected $_searchField; |
28 | 28 | protected $_urls; |
29 | 29 | protected $_pagination; |
@@ -41,35 +41,35 @@ discard block |
||
41 | 41 | protected $_colWidths; |
42 | 42 | |
43 | 43 | |
44 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
45 | - parent::__construct($identifier, $model,$modelInstance); |
|
46 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
|
44 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
45 | + parent::__construct($identifier, $model, $modelInstance); |
|
46 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
|
47 | 47 | $this->_urls=[]; |
48 | - $this->_emptyMessage=new HtmlMessage("","nothing to display"); |
|
48 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
49 | 49 | $this->_emptyMessage->setIcon("info circle"); |
50 | 50 | } |
51 | 51 | |
52 | - public function run(JsUtils $js){ |
|
53 | - if($this->_hasCheckboxes && isset($js)){ |
|
52 | + public function run(JsUtils $js) { |
|
53 | + if ($this->_hasCheckboxes && isset($js)) { |
|
54 | 54 | $this->_runCheckboxes($js); |
55 | 55 | } |
56 | - if($this->_visibleHover){ |
|
57 | - $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
58 | - $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
56 | + if ($this->_visibleHover) { |
|
57 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
58 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
59 | 59 | } |
60 | - if(\is_array($this->_deleteBehavior)) |
|
61 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
62 | - if(\is_array($this->_editBehavior)) |
|
63 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
60 | + if (\is_array($this->_deleteBehavior)) |
|
61 | + $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
62 | + if (\is_array($this->_editBehavior)) |
|
63 | + $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
64 | 64 | return parent::run($js); |
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | 68 | |
69 | - protected function _generateBehavior($op,$params,JsUtils $js){ |
|
70 | - if(isset($this->_urls[$op])){ |
|
71 | - $params=\array_merge($params,["attr"=>"data-ajax"]); |
|
72 | - $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector(),$params); |
|
69 | + protected function _generateBehavior($op, $params, JsUtils $js) { |
|
70 | + if (isset($this->_urls[$op])) { |
|
71 | + $params=\array_merge($params, ["attr"=>"data-ajax"]); |
|
72 | + $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector(), $params); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -82,155 +82,155 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
86 | - if(!$this->_generated){ |
|
85 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
86 | + if (!$this->_generated) { |
|
87 | 87 | $this->_instanceViewer->setInstance($this->_model); |
88 | 88 | $captions=$this->_instanceViewer->getCaptions(); |
89 | 89 | $table=$this->content["table"]; |
90 | - if($this->_hasCheckboxes){ |
|
90 | + if ($this->_hasCheckboxes) { |
|
91 | 91 | $this->_generateMainCheckbox($captions); |
92 | 92 | } |
93 | 93 | $table->setRowCount(0, \sizeof($captions)); |
94 | - $this->_generateHeader($table,$captions); |
|
94 | + $this->_generateHeader($table, $captions); |
|
95 | 95 | |
96 | - if(isset($this->_compileParts)) |
|
96 | + if (isset($this->_compileParts)) |
|
97 | 97 | $table->setCompileParts($this->_compileParts); |
98 | 98 | |
99 | - if(isset($this->_searchField) && isset($js)){ |
|
100 | - if(isset($this->_urls["refresh"])) |
|
101 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
99 | + if (isset($this->_searchField) && isset($js)) { |
|
100 | + if (isset($this->_urls["refresh"])) |
|
101 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $this->_generateContent($table); |
105 | 105 | |
106 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
106 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
107 | 107 | $table->getHeader()->getCell(0, 0)->addClass("no-sort"); |
108 | 108 | } |
109 | 109 | |
110 | - if(isset($this->_toolbar)){ |
|
110 | + if (isset($this->_toolbar)) { |
|
111 | 111 | $this->_setToolbarPosition($table, $captions); |
112 | 112 | } |
113 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
114 | - $this->_generatePagination($table,$js); |
|
113 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
114 | + $this->_generatePagination($table, $js); |
|
115 | 115 | } |
116 | 116 | |
117 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
117 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
118 | 118 | $this->_compileForm(); |
119 | 119 | $this->_applyStyleAttributes($table); |
120 | 120 | $this->_generated=true; |
121 | 121 | } |
122 | - return parent::compile($js,$view); |
|
122 | + return parent::compile($js, $view); |
|
123 | 123 | } |
124 | 124 | |
125 | - protected function _applyStyleAttributes($table){ |
|
126 | - if(isset($this->_hiddenColumns)) |
|
125 | + protected function _applyStyleAttributes($table) { |
|
126 | + if (isset($this->_hiddenColumns)) |
|
127 | 127 | $this->_hideColumns(); |
128 | - if(isset($this->_colWidths)){ |
|
129 | - foreach ($this->_colWidths as $colIndex=>$width){ |
|
130 | - $table->setColWidth($colIndex,$width); |
|
128 | + if (isset($this->_colWidths)) { |
|
129 | + foreach ($this->_colWidths as $colIndex=>$width) { |
|
130 | + $table->setColWidth($colIndex, $width); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | - protected function _hideColumns(){ |
|
135 | + protected function _hideColumns() { |
|
136 | 136 | $table=$this->getTable(); |
137 | - foreach ($this->_hiddenColumns as $colIndex){ |
|
137 | + foreach ($this->_hiddenColumns as $colIndex) { |
|
138 | 138 | $table->hideColumn($colIndex); |
139 | 139 | } |
140 | 140 | return $this; |
141 | 141 | } |
142 | 142 | |
143 | - protected function _generateHeader(HtmlTable $table,$captions){ |
|
143 | + protected function _generateHeader(HtmlTable $table, $captions) { |
|
144 | 144 | $table->setHeaderValues($captions); |
145 | - if(isset($this->_sortable)){ |
|
145 | + if (isset($this->_sortable)) { |
|
146 | 146 | $table->setSortable($this->_sortable); |
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | |
151 | 151 | |
152 | - protected function _generateContent($table){ |
|
152 | + protected function _generateContent($table) { |
|
153 | 153 | $objects=$this->_modelInstance; |
154 | - if(isset($this->_pagination)){ |
|
154 | + if (isset($this->_pagination)) { |
|
155 | 155 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
156 | 156 | } |
157 | 157 | InstanceViewer::setIndex(0); |
158 | 158 | $table->fromDatabaseObjects($objects, function($instance) use($table){ |
159 | 159 | return $this->_generateRow($instance, $table); |
160 | 160 | }); |
161 | - if($table->getRowCount()==0){ |
|
161 | + if ($table->getRowCount()==0) { |
|
162 | 162 | $result=$table->addRow(); |
163 | 163 | $result->mergeRow(); |
164 | 164 | $result->setValues([$this->_emptyMessage]); |
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | - protected function _generateRow($instance,&$table,$checkedClass=null){ |
|
168 | + protected function _generateRow($instance, &$table, $checkedClass=null) { |
|
169 | 169 | $this->_instanceViewer->setInstance($instance); |
170 | 170 | InstanceViewer::$index++; |
171 | - $values= $this->_instanceViewer->getValues(); |
|
171 | + $values=$this->_instanceViewer->getValues(); |
|
172 | 172 | $id=$this->_instanceViewer->getIdentifier(); |
173 | - if($this->_hasCheckboxes){ |
|
174 | - $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,""); |
|
173 | + if ($this->_hasCheckboxes) { |
|
174 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
175 | 175 | $ck->setOnChange("event.stopPropagation();"); |
176 | 176 | $field=$ck->getField(); |
177 | - $field->setProperty("value",$id); |
|
177 | + $field->setProperty("value", $id); |
|
178 | 178 | $field->setProperty("name", "selection[]"); |
179 | - if(isset($checkedClass)) |
|
179 | + if (isset($checkedClass)) |
|
180 | 180 | $field->setClass($checkedClass); |
181 | 181 | \array_unshift($values, $ck); |
182 | 182 | } |
183 | 183 | $result=$table->newRow(); |
184 | 184 | $result->setIdentifier($this->identifier."-tr-".$id); |
185 | - $result->setProperty("data-ajax",$id); |
|
185 | + $result->setProperty("data-ajax", $id); |
|
186 | 186 | $result->setValues($values); |
187 | - $result->addToProperty("class",$this->_rowClass); |
|
187 | + $result->addToProperty("class", $this->_rowClass); |
|
188 | 188 | return $result; |
189 | 189 | } |
190 | 190 | |
191 | - protected function _generatePagination($table,$js=NULL){ |
|
192 | - if(isset($this->_toolbar)){ |
|
193 | - if($this->_toolbarPosition==PositionInTable::FOOTER) |
|
191 | + protected function _generatePagination($table, $js=NULL) { |
|
192 | + if (isset($this->_toolbar)) { |
|
193 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
194 | 194 | $this->_toolbar->setFloated("left"); |
195 | 195 | } |
196 | 196 | $footer=$table->getFooter(); |
197 | 197 | $footer->mergeCol(); |
198 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
198 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
199 | 199 | $menu->floatRight(); |
200 | 200 | $menu->setActiveItem($this->_pagination->getPage()-1); |
201 | 201 | $footer->addValues($menu); |
202 | - $this->_associatePaginationBehavior($menu,$js); |
|
202 | + $this->_associatePaginationBehavior($menu, $js); |
|
203 | 203 | } |
204 | 204 | |
205 | - protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){ |
|
206 | - if(isset($this->_urls["refresh"])){ |
|
207 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
205 | + protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) { |
|
206 | + if (isset($this->_urls["refresh"])) { |
|
207 | + $menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | - protected function _getFieldName($index){ |
|
211 | + protected function _getFieldName($index) { |
|
212 | 212 | $fieldName=parent::_getFieldName($index); |
213 | - if(\is_object($fieldName)) |
|
213 | + if (\is_object($fieldName)) |
|
214 | 214 | $fieldName="field-".$index; |
215 | 215 | return $fieldName."[]"; |
216 | 216 | } |
217 | 217 | |
218 | - protected function _getFieldCaption($index){ |
|
218 | + protected function _getFieldCaption($index) { |
|
219 | 219 | return null; |
220 | 220 | } |
221 | 221 | |
222 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
223 | - switch ($this->_toolbarPosition){ |
|
222 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
223 | + switch ($this->_toolbarPosition) { |
|
224 | 224 | case PositionInTable::BEFORETABLE: |
225 | 225 | case PositionInTable::AFTERTABLE: |
226 | - if(isset($this->_compileParts)===false){ |
|
226 | + if (isset($this->_compileParts)===false) { |
|
227 | 227 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
228 | 228 | } |
229 | 229 | break; |
230 | 230 | case PositionInTable::HEADER: |
231 | 231 | case PositionInTable::FOOTER: |
232 | 232 | case PositionInTable::BODY: |
233 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
233 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
234 | 234 | break; |
235 | 235 | } |
236 | 236 | } |
@@ -242,23 +242,23 @@ discard block |
||
242 | 242 | * @param callable $callback function called after the field compilation |
243 | 243 | * @return DataTable |
244 | 244 | */ |
245 | - public function afterCompile($index,$callback){ |
|
246 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
245 | + public function afterCompile($index, $callback) { |
|
246 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
247 | 247 | return $this; |
248 | 248 | } |
249 | 249 | |
250 | - private function addToolbarRow($part,$table,$captions){ |
|
250 | + private function addToolbarRow($part, $table, $captions) { |
|
251 | 251 | $hasPart=$table->hasPart($part); |
252 | - if($hasPart){ |
|
252 | + if ($hasPart) { |
|
253 | 253 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
254 | - }else{ |
|
254 | + } else { |
|
255 | 255 | $row=$table->getPart($part)->getRow(0); |
256 | 256 | } |
257 | 257 | $row->mergeCol(); |
258 | 258 | $row->setValues([$this->_toolbar]); |
259 | 259 | } |
260 | 260 | |
261 | - public function getHtmlComponent(){ |
|
261 | + public function getHtmlComponent() { |
|
262 | 262 | return $this->content["table"]; |
263 | 263 | } |
264 | 264 | |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | * @return DataTable |
273 | 273 | */ |
274 | 274 | public function setUrls($urls) { |
275 | - if(\is_array($urls)){ |
|
276 | - $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
|
277 | - $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
|
278 | - $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
|
279 | - }else{ |
|
280 | - $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
|
275 | + if (\is_array($urls)) { |
|
276 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
277 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
278 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
279 | + } else { |
|
280 | + $this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls]; |
|
281 | 281 | } |
282 | 282 | return $this; |
283 | 283 | } |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @param number $pages_visibles The number of visible pages in the Pagination component |
291 | 291 | * @return DataTable |
292 | 292 | */ |
293 | - public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){ |
|
294 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount); |
|
293 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
294 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
295 | 295 | return $this; |
296 | 296 | } |
297 | 297 | |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * @param number $pages_visibles The number of visible pages in the Pagination component |
303 | 303 | * @return DataTable |
304 | 304 | */ |
305 | - public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){ |
|
306 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page); |
|
305 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
306 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
307 | 307 | return $this; |
308 | 308 | } |
309 | 309 | |
@@ -313,20 +313,20 @@ discard block |
||
313 | 313 | * @param array $compileParts |
314 | 314 | * @return DataTable |
315 | 315 | */ |
316 | - public function refresh($compileParts=["tbody"]){ |
|
316 | + public function refresh($compileParts=["tbody"]) { |
|
317 | 317 | $this->_compileParts=$compileParts; |
318 | 318 | return $this; |
319 | 319 | } |
320 | 320 | |
321 | 321 | |
322 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
322 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
323 | 323 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
324 | 324 | } |
325 | 325 | |
326 | - public function getSearchField(){ |
|
327 | - if(isset($this->_searchField)===false){ |
|
328 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
329 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
326 | + public function getSearchField() { |
|
327 | + if (isset($this->_searchField)===false) { |
|
328 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
329 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
330 | 330 | } |
331 | 331 | return $this->_searchField; |
332 | 332 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | return $this; |
343 | 343 | } |
344 | 344 | |
345 | - public function asForm(){ |
|
345 | + public function asForm() { |
|
346 | 346 | return $this->getForm(); |
347 | 347 | } |
348 | 348 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | |
351 | 351 | protected function getTargetSelector() { |
352 | 352 | $result=$this->_targetSelector; |
353 | - if(!isset($result)) |
|
353 | + if (!isset($result)) |
|
354 | 354 | $result="#".$this->identifier; |
355 | 355 | return $result; |
356 | 356 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | } |
367 | 367 | |
368 | 368 | public function getRefreshSelector() { |
369 | - if(isset($this->_refreshSelector)) |
|
369 | + if (isset($this->_refreshSelector)) |
|
370 | 370 | return $this->_refreshSelector; |
371 | 371 | return "#".$this->identifier." tbody"; |
372 | 372 | } |
@@ -384,9 +384,9 @@ discard block |
||
384 | 384 | * {@inheritDoc} |
385 | 385 | * @see \Ajax\common\Widget::show() |
386 | 386 | */ |
387 | - public function show($modelInstance){ |
|
388 | - if(\is_array($modelInstance)){ |
|
389 | - if(\is_array(array_values($modelInstance)[0])) |
|
387 | + public function show($modelInstance) { |
|
388 | + if (\is_array($modelInstance)) { |
|
389 | + if (\is_array(array_values($modelInstance)[0])) |
|
390 | 390 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
391 | 391 | } |
392 | 392 | $this->_modelInstance=$modelInstance; |
@@ -421,24 +421,24 @@ discard block |
||
421 | 421 | return $this; |
422 | 422 | } |
423 | 423 | |
424 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
425 | - $this->getTable()->setActiveRowSelector($class,$event,$multiple); |
|
424 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
425 | + $this->getTable()->setActiveRowSelector($class, $event, $multiple); |
|
426 | 426 | return $this; |
427 | 427 | } |
428 | 428 | |
429 | - public function hideColumn($colIndex){ |
|
430 | - if(!\is_array($this->_hiddenColumns)) |
|
429 | + public function hideColumn($colIndex) { |
|
430 | + if (!\is_array($this->_hiddenColumns)) |
|
431 | 431 | $this->_hiddenColumns=[]; |
432 | 432 | $this->_hiddenColumns[]=$colIndex; |
433 | 433 | return $this; |
434 | 434 | } |
435 | 435 | |
436 | - public function setColWidth($colIndex,$width){ |
|
436 | + public function setColWidth($colIndex, $width) { |
|
437 | 437 | $this->_colWidths[$colIndex]=$width; |
438 | 438 | return $this; |
439 | 439 | } |
440 | 440 | public function setColWidths($_colWidths) { |
441 | - $this->_colWidths = $_colWidths; |
|
441 | + $this->_colWidths=$_colWidths; |
|
442 | 442 | return $this; |
443 | 443 | } |
444 | 444 | } |
445 | 445 | \ No newline at end of file |