@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | use Ajax\semantic\html\base\constants\Wide; |
12 | 12 | |
13 | 13 | class HtmlTD extends HtmlSemDoubleElement { |
14 | - use TextAlignmentTrait,TableElementTrait; |
|
14 | + use TextAlignmentTrait, TableElementTrait; |
|
15 | 15 | private $_container; |
16 | 16 | private $_row; |
17 | 17 | private $_col; |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function __construct($identifier, $content=NULL, $tagName="td") { |
28 | 28 | parent::__construct($identifier, $tagName, "", $content); |
29 | - $this->_variations=[ Variation::COLLAPSING ]; |
|
30 | - $this->_states=[ State::ACTIVE,State::POSITIVE,State::NEGATIVE,State::WARNING,State::ERROR,State::DISABLED ]; |
|
29 | + $this->_variations=[Variation::COLLAPSING]; |
|
30 | + $this->_states=[State::ACTIVE, State::POSITIVE, State::NEGATIVE, State::WARNING, State::ERROR, State::DISABLED]; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function setContainer($container, $row, $col) { |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | public function setRowspan($rowspan) { |
50 | - $to=min($this->_container->count(), $this->_row + $rowspan - 1); |
|
51 | - for($i=$to; $i > $this->_row; $i--) { |
|
50 | + $to=min($this->_container->count(), $this->_row+$rowspan-1); |
|
51 | + for ($i=$to; $i>$this->_row; $i--) { |
|
52 | 52 | $this->_container->delete($i, $this->_col); |
53 | 53 | } |
54 | 54 | $this->setProperty("rowspan", $rowspan); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | public function mergeRow() { |
59 | - if(!$this->_rowMerged){ |
|
59 | + if (!$this->_rowMerged) { |
|
60 | 60 | $this->_rowMerged=true; |
61 | 61 | return $this->setRowspan($this->_container->count()); |
62 | 62 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | public function mergeCol() { |
67 | - if(!$this->_colMerged){ |
|
67 | + if (!$this->_colMerged) { |
|
68 | 68 | $this->_colMerged=true; |
69 | 69 | return $this->setColspan($this->_container->getRow($this->_row)->count()); |
70 | 70 | } |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | public function setColspan($colspan) { |
75 | - $to=min($this->_container->getRow($this->_row)->count(), $this->_col + $colspan - 1); |
|
76 | - for($i=$to; $i > $this->_col; $i--) { |
|
77 | - $this->_container->delete($this->_row, $this->_col + 1); |
|
75 | + $to=min($this->_container->getRow($this->_row)->count(), $this->_col+$colspan-1); |
|
76 | + for ($i=$to; $i>$this->_col; $i--) { |
|
77 | + $this->_container->delete($this->_row, $this->_col+1); |
|
78 | 78 | } |
79 | 79 | $this->setProperty("colspan", $colspan); |
80 | 80 | return $this->_container; |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | return $this->addToProperty("class", "selectable"); |
114 | 114 | } |
115 | 115 | |
116 | - public function setWidth($width){ |
|
116 | + public function setWidth($width) { |
|
117 | 117 | if (\is_int($width)) { |
118 | - $width=Wide::getConstants()["W" . $width]; |
|
118 | + $width=Wide::getConstants()["W".$width]; |
|
119 | 119 | } |
120 | 120 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
121 | - return $this->addToPropertyCtrl("class", "wide", array ("wide" )); |
|
121 | + return $this->addToPropertyCtrl("class", "wide", array("wide")); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | \ No newline at end of file |
@@ -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,9 +48,9 @@ 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 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return boolean |
96 | 96 | */ |
97 | 97 | public function hasPart($key) { |
98 | - return \array_key_exists($key, $this->content) === true; |
|
98 | + return \array_key_exists($key, $this->content)===true; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | private function colAlign($colIndex, $function) { |
232 | 232 | if (\is_array($colIndex)) { |
233 | - foreach ( $colIndex as $cIndex ) { |
|
233 | + foreach ($colIndex as $cIndex) { |
|
234 | 234 | $this->colAlign($cIndex, $function); |
235 | 235 | } |
236 | 236 | } else { |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @see HtmlSemDoubleElement::compile() |
292 | 292 | */ |
293 | 293 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
294 | - if(\sizeof($this->_compileParts)<3){ |
|
294 | + if (\sizeof($this->_compileParts)<3) { |
|
295 | 295 | $this->_template="%content%"; |
296 | 296 | $this->refresh(); |
297 | 297 | } |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | |
302 | 302 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
303 | 303 | if ($this->propertyContains("class", "sortable")) { |
304 | - $this->addEvent("execute", "$('#" . $this->identifier . "').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
304 | + $this->addEvent("execute", "$('#".$this->identifier."').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
305 | 305 | } |
306 | - if(isset($this->_activeRowSelector)){ |
|
306 | + if (isset($this->_activeRowSelector)) { |
|
307 | 307 | $this->_activeRowSelector->compile(); |
308 | 308 | } |
309 | 309 | } |
@@ -317,13 +317,13 @@ discard block |
||
317 | 317 | public function fromDatabaseObject($object, $function) { |
318 | 318 | $result=$function($object); |
319 | 319 | if (\is_array($result)) { |
320 | - $result= $this->addRow($function($object)); |
|
320 | + $result=$this->addRow($function($object)); |
|
321 | 321 | } else { |
322 | - $result= $this->getBody()->_addRow($result); |
|
322 | + $result=$this->getBody()->_addRow($result); |
|
323 | 323 | } |
324 | - if(isset($this->_afterCompileEvents["onNewRow"])){ |
|
325 | - if(\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
326 | - $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
324 | + if (isset($this->_afterCompileEvents["onNewRow"])) { |
|
325 | + if (\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
326 | + $this->_afterCompileEvents["onNewRow"]($result, $object); |
|
327 | 327 | } |
328 | 328 | return $result; |
329 | 329 | } |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | return $this; |
339 | 339 | } |
340 | 340 | |
341 | - public function refresh(){ |
|
341 | + public function refresh() { |
|
342 | 342 | $this->_footer=$this->getFooter(); |
343 | 343 | $this->addEvent("execute", '$("#'.$this->identifier.' tfoot").replaceWith("'.\addslashes($this->_footer).'");'); |
344 | 344 | } |
345 | 345 | |
346 | - public function run(JsUtils $js){ |
|
347 | - $result= parent::run($js); |
|
348 | - if(isset($this->_footer)) |
|
346 | + public function run(JsUtils $js) { |
|
347 | + $result=parent::run($js); |
|
348 | + if (isset($this->_footer)) |
|
349 | 349 | $this->_footer->run($js); |
350 | 350 | return $result; |
351 | 351 | } |
@@ -368,27 +368,27 @@ discard block |
||
368 | 368 | * @param boolean $multiple |
369 | 369 | * @return HtmlTable |
370 | 370 | */ |
371 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
372 | - $this->_activeRowSelector=new ActiveRow($this,$class,$event,$multiple); |
|
371 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
372 | + $this->_activeRowSelector=new ActiveRow($this, $class, $event, $multiple); |
|
373 | 373 | return $this; |
374 | 374 | } |
375 | 375 | |
376 | - public function hideColumn($colIndex){ |
|
377 | - if($this->hasPart("thead")){ |
|
376 | + public function hideColumn($colIndex) { |
|
377 | + if ($this->hasPart("thead")) { |
|
378 | 378 | $this->getHeader()->hideColumn($colIndex); |
379 | 379 | } |
380 | 380 | $this->getBody()->hideColumn($colIndex); |
381 | - if($this->hasPart("tfoot")){ |
|
381 | + if ($this->hasPart("tfoot")) { |
|
382 | 382 | $this->getFooter()->hideColumn($colIndex); |
383 | 383 | } |
384 | 384 | return $this; |
385 | 385 | } |
386 | 386 | |
387 | - public function setColWidth($colIndex,$width){ |
|
388 | - if($this->hasPart("thead")){ |
|
387 | + public function setColWidth($colIndex, $width) { |
|
388 | + if ($this->hasPart("thead")) { |
|
389 | 389 | $this->getHeader()->getCell(0, $colIndex)->setWidth($width); |
390 | - }else{ |
|
391 | - if($this->getBody()->count()>0) |
|
390 | + } else { |
|
391 | + if ($this->getBody()->count()>0) |
|
392 | 392 | $this->getBody()->getCell(0, $colIndex)->setWidth($width); |
393 | 393 | } |
394 | 394 | return $this; |
@@ -322,8 +322,9 @@ discard block |
||
322 | 322 | $result= $this->getBody()->_addRow($result); |
323 | 323 | } |
324 | 324 | if(isset($this->_afterCompileEvents["onNewRow"])){ |
325 | - if(\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
326 | - $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
325 | + if(\is_callable($this->_afterCompileEvents["onNewRow"])) { |
|
326 | + $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
327 | + } |
|
327 | 328 | } |
328 | 329 | return $result; |
329 | 330 | } |
@@ -345,8 +346,9 @@ discard block |
||
345 | 346 | |
346 | 347 | public function run(JsUtils $js){ |
347 | 348 | $result= parent::run($js); |
348 | - if(isset($this->_footer)) |
|
349 | - $this->_footer->run($js); |
|
349 | + if(isset($this->_footer)) { |
|
350 | + $this->_footer->run($js); |
|
351 | + } |
|
350 | 352 | return $result; |
351 | 353 | } |
352 | 354 | |
@@ -387,9 +389,10 @@ discard block |
||
387 | 389 | public function setColWidth($colIndex,$width){ |
388 | 390 | if($this->hasPart("thead")){ |
389 | 391 | $this->getHeader()->getCell(0, $colIndex)->setWidth($width); |
390 | - }else{ |
|
391 | - if($this->getBody()->count()>0) |
|
392 | - $this->getBody()->getCell(0, $colIndex)->setWidth($width); |
|
392 | + } else{ |
|
393 | + if($this->getBody()->count()>0) { |
|
394 | + $this->getBody()->getCell(0, $colIndex)->setWidth($width); |
|
395 | + } |
|
393 | 396 | } |
394 | 397 | return $this; |
395 | 398 | } |
@@ -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 | |
90 | 90 | $table=$this->content["table"]; |
91 | 91 | |
92 | - if($this->_hasCheckboxes){ |
|
92 | + if ($this->_hasCheckboxes) { |
|
93 | 93 | $this->_generateMainCheckbox($captions); |
94 | 94 | } |
95 | 95 | |
96 | 96 | $table->setRowCount(0, \sizeof($captions)); |
97 | - $this->_generateHeader($table,$captions); |
|
97 | + $this->_generateHeader($table, $captions); |
|
98 | 98 | |
99 | - if(isset($this->_compileParts)) |
|
99 | + if (isset($this->_compileParts)) |
|
100 | 100 | $table->setCompileParts($this->_compileParts); |
101 | 101 | |
102 | - if(isset($this->_searchField) && isset($js)){ |
|
103 | - if(isset($this->_urls["refresh"])) |
|
104 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
102 | + if (isset($this->_searchField) && isset($js)) { |
|
103 | + if (isset($this->_urls["refresh"])) |
|
104 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | $this->_generateContent($table); |
108 | 108 | |
109 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
109 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
110 | 110 | $table->getHeader()->getCell(0, 0)->addClass("no-sort"); |
111 | 111 | } |
112 | 112 | |
113 | - if(isset($this->_toolbar)){ |
|
113 | + if (isset($this->_toolbar)) { |
|
114 | 114 | $this->_setToolbarPosition($table, $captions); |
115 | 115 | } |
116 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
117 | - $this->_generatePagination($table,$js); |
|
116 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
117 | + $this->_generatePagination($table, $js); |
|
118 | 118 | } |
119 | 119 | |
120 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
120 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
121 | 121 | $this->_compileForm(); |
122 | - if(isset($this->_hiddenColumns)) |
|
122 | + if (isset($this->_hiddenColumns)) |
|
123 | 123 | $this->_hideColumns(); |
124 | - if(isset($this->_colWidths)){ |
|
125 | - foreach ($this->_colWidths as $colIndex=>$width){ |
|
126 | - $table->setColWidth($colIndex,$width); |
|
124 | + if (isset($this->_colWidths)) { |
|
125 | + foreach ($this->_colWidths as $colIndex=>$width) { |
|
126 | + $table->setColWidth($colIndex, $width); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | 130 | $this->_generated=true; |
131 | 131 | } |
132 | - return parent::compile($js,$view); |
|
132 | + return parent::compile($js, $view); |
|
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 |
@@ -57,10 +57,12 @@ discard block |
||
57 | 57 | $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
58 | 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 | + } |
|
63 | + if(\is_array($this->_editBehavior)) { |
|
64 | + $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
65 | + } |
|
64 | 66 | return parent::run($js); |
65 | 67 | } |
66 | 68 | |
@@ -96,12 +98,14 @@ discard block |
||
96 | 98 | $table->setRowCount(0, \sizeof($captions)); |
97 | 99 | $this->_generateHeader($table,$captions); |
98 | 100 | |
99 | - if(isset($this->_compileParts)) |
|
100 | - $table->setCompileParts($this->_compileParts); |
|
101 | + if(isset($this->_compileParts)) { |
|
102 | + $table->setCompileParts($this->_compileParts); |
|
103 | + } |
|
101 | 104 | |
102 | 105 | if(isset($this->_searchField) && isset($js)){ |
103 | - if(isset($this->_urls["refresh"])) |
|
104 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
106 | + if(isset($this->_urls["refresh"])) { |
|
107 | + $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
108 | + } |
|
105 | 109 | } |
106 | 110 | |
107 | 111 | $this->_generateContent($table); |
@@ -119,8 +123,9 @@ discard block |
||
119 | 123 | |
120 | 124 | $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
121 | 125 | $this->_compileForm(); |
122 | - if(isset($this->_hiddenColumns)) |
|
123 | - $this->_hideColumns(); |
|
126 | + if(isset($this->_hiddenColumns)) { |
|
127 | + $this->_hideColumns(); |
|
128 | + } |
|
124 | 129 | if(isset($this->_colWidths)){ |
125 | 130 | foreach ($this->_colWidths as $colIndex=>$width){ |
126 | 131 | $table->setColWidth($colIndex,$width); |
@@ -176,8 +181,9 @@ discard block |
||
176 | 181 | $field=$ck->getField(); |
177 | 182 | $field->setProperty("value",$id); |
178 | 183 | $field->setProperty("name", "selection[]"); |
179 | - if(isset($checkedClass)) |
|
180 | - $field->setClass($checkedClass); |
|
184 | + if(isset($checkedClass)) { |
|
185 | + $field->setClass($checkedClass); |
|
186 | + } |
|
181 | 187 | \array_unshift($values, $ck); |
182 | 188 | } |
183 | 189 | $result=$table->newRow(); |
@@ -190,8 +196,9 @@ discard block |
||
190 | 196 | |
191 | 197 | protected function _generatePagination($table,$js=NULL){ |
192 | 198 | if(isset($this->_toolbar)){ |
193 | - if($this->_toolbarPosition==PositionInTable::FOOTER) |
|
194 | - $this->_toolbar->setFloated("left"); |
|
199 | + if($this->_toolbarPosition==PositionInTable::FOOTER) { |
|
200 | + $this->_toolbar->setFloated("left"); |
|
201 | + } |
|
195 | 202 | } |
196 | 203 | $footer=$table->getFooter(); |
197 | 204 | $footer->mergeCol(); |
@@ -210,8 +217,9 @@ discard block |
||
210 | 217 | |
211 | 218 | protected function _getFieldName($index){ |
212 | 219 | $fieldName=parent::_getFieldName($index); |
213 | - if(\is_object($fieldName)) |
|
214 | - $fieldName="field-".$index; |
|
220 | + if(\is_object($fieldName)) { |
|
221 | + $fieldName="field-".$index; |
|
222 | + } |
|
215 | 223 | return $fieldName."[]"; |
216 | 224 | } |
217 | 225 | |
@@ -251,7 +259,7 @@ discard block |
||
251 | 259 | $hasPart=$table->hasPart($part); |
252 | 260 | if($hasPart){ |
253 | 261 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
254 | - }else{ |
|
262 | + } else{ |
|
255 | 263 | $row=$table->getPart($part)->getRow(0); |
256 | 264 | } |
257 | 265 | $row->mergeCol(); |
@@ -276,7 +284,7 @@ discard block |
||
276 | 284 | $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
277 | 285 | $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
278 | 286 | $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
279 | - }else{ |
|
287 | + } else{ |
|
280 | 288 | $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
281 | 289 | } |
282 | 290 | return $this; |
@@ -350,8 +358,9 @@ discard block |
||
350 | 358 | |
351 | 359 | protected function getTargetSelector() { |
352 | 360 | $result=$this->_targetSelector; |
353 | - if(!isset($result)) |
|
354 | - $result="#".$this->identifier; |
|
361 | + if(!isset($result)) { |
|
362 | + $result="#".$this->identifier; |
|
363 | + } |
|
355 | 364 | return $result; |
356 | 365 | } |
357 | 366 | |
@@ -366,8 +375,9 @@ discard block |
||
366 | 375 | } |
367 | 376 | |
368 | 377 | public function getRefreshSelector() { |
369 | - if(isset($this->_refreshSelector)) |
|
370 | - return $this->_refreshSelector; |
|
378 | + if(isset($this->_refreshSelector)) { |
|
379 | + return $this->_refreshSelector; |
|
380 | + } |
|
371 | 381 | return "#".$this->identifier." tbody"; |
372 | 382 | } |
373 | 383 | |
@@ -386,8 +396,9 @@ discard block |
||
386 | 396 | */ |
387 | 397 | public function show($modelInstance){ |
388 | 398 | if(\is_array($modelInstance)){ |
389 | - if(\is_array(array_values($modelInstance)[0])) |
|
390 | - $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
399 | + if(\is_array(array_values($modelInstance)[0])) { |
|
400 | + $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
401 | + } |
|
391 | 402 | } |
392 | 403 | $this->_modelInstance=$modelInstance; |
393 | 404 | } |
@@ -427,8 +438,9 @@ discard block |
||
427 | 438 | } |
428 | 439 | |
429 | 440 | public function hideColumn($colIndex){ |
430 | - if(!\is_array($this->_hiddenColumns)) |
|
431 | - $this->_hiddenColumns=[]; |
|
441 | + if(!\is_array($this->_hiddenColumns)) { |
|
442 | + $this->_hiddenColumns=[]; |
|
443 | + } |
|
432 | 444 | $this->_hiddenColumns[]=$colIndex; |
433 | 445 | return $this; |
434 | 446 | } |