@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Ajax\semantic\html\collections\table\traits; |
3 | 3 | |
4 | -trait TableTrait{ |
|
4 | +trait TableTrait { |
|
5 | 5 | /** |
6 | 6 | * @return HtmlTable |
7 | 7 | */ |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | abstract public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false); |
10 | 10 | abstract public function getOn($event, $url, $responseElement="", $parameters=array()); |
11 | 11 | |
12 | - protected function addToPropertyTable($property,$value){ |
|
12 | + protected function addToPropertyTable($property, $value) { |
|
13 | 13 | return $this->getTable()->addToProperty($property, $value); |
14 | 14 | } |
15 | 15 | |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | public function setBasic($very=false) { |
21 | 21 | $table=$this->getTable(); |
22 | 22 | if ($very) |
23 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
24 | - return $table->addToPropertyCtrl("class", "basic", array ("basic" )); |
|
23 | + $table->addToPropertyCtrl("class", "very", array("very")); |
|
24 | + return $table->addToPropertyCtrl("class", "basic", array("basic")); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function setCompact($very=false) { |
28 | 28 | $table=$this->getTable(); |
29 | 29 | if ($very) |
30 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
31 | - return $table->addToPropertyCtrl("class", "compact", array ("compact" )); |
|
30 | + $table->addToPropertyCtrl("class", "very", array("very")); |
|
31 | + return $table->addToPropertyCtrl("class", "compact", array("compact")); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | public function setCollapsing() { |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | return $this->addToPropertyTable("class", "striped"); |
68 | 68 | } |
69 | 69 | |
70 | - public function onRowClick($jsCode, $stopPropagation=false, $preventDefault=false){ |
|
71 | - $this->onRowClick($jsCode,$stopPropagation,$preventDefault); |
|
70 | + public function onRowClick($jsCode, $stopPropagation=false, $preventDefault=false) { |
|
71 | + $this->onRowClick($jsCode, $stopPropagation, $preventDefault); |
|
72 | 72 | } |
73 | 73 | |
74 | - public function onRow($event,$jsCode, $stopPropagation=false, $preventDefault=false){ |
|
75 | - $this->getTable()->addEvent($event,"{{tr}}".$jsCode,$stopPropagation,$preventDefault); |
|
74 | + public function onRow($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
|
75 | + $this->getTable()->addEvent($event, "{{tr}}".$jsCode, $stopPropagation, $preventDefault); |
|
76 | 76 | } |
77 | 77 | |
78 | - public function getOnRow($event, $url, $responseElement="", $parameters=array()){ |
|
79 | - $parameters=\array_merge($parameters,["eventItemSelector"=>"tbody tr","stopPropagation"=>false,"preventDefault"=>false]); |
|
80 | - return $this->getTable()->getOn($event, $url,$responseElement,$parameters); |
|
78 | + public function getOnRow($event, $url, $responseElement="", $parameters=array()) { |
|
79 | + $parameters=\array_merge($parameters, ["eventItemSelector"=>"tbody tr", "stopPropagation"=>false, "preventDefault"=>false]); |
|
80 | + return $this->getTable()->getOn($event, $url, $responseElement, $parameters); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | \ No newline at end of file |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | |
29 | 29 | public function __construct($identifier, $rowCount, $colCount) { |
30 | 30 | parent::__construct($identifier, "table", "ui table"); |
31 | - $this->content=array (); |
|
31 | + $this->content=array(); |
|
32 | 32 | $this->setRowCount($rowCount, $colCount); |
33 | - $this->_variations=[ Variation::CELLED,Variation::PADDED,Variation::COMPACT ]; |
|
34 | - $this->_compileParts=["thead","tbody","tfoot"]; |
|
33 | + $this->_variations=[Variation::CELLED, Variation::PADDED, Variation::COMPACT]; |
|
34 | + $this->_compileParts=["thead", "tbody", "tfoot"]; |
|
35 | 35 | $this->_afterCompileEvents=[]; |
36 | 36 | } |
37 | 37 | |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * @return HtmlTableContent |
50 | 50 | */ |
51 | 51 | public function getPart($key) { |
52 | - if (\array_key_exists($key, $this->content) === false) { |
|
52 | + if (\array_key_exists($key, $this->content)===false) { |
|
53 | 53 | $this->content[$key]=new HtmlTableContent("", $key); |
54 | - if ($key !== "tbody") { |
|
54 | + if ($key!=="tbody") { |
|
55 | 55 | $this->content[$key]->setRowCount(1, $this->_colCount); |
56 | 56 | } |
57 | 57 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @return boolean |
97 | 97 | */ |
98 | 98 | public function hasPart($key) { |
99 | - return \array_key_exists($key, $this->content) === true; |
|
99 | + return \array_key_exists($key, $this->content)===true; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | private function colAlign($colIndex, $function) { |
203 | 203 | if (\is_array($colIndex)) { |
204 | - foreach ( $colIndex as $cIndex ) { |
|
204 | + foreach ($colIndex as $cIndex) { |
|
205 | 205 | $this->colAlign($cIndex, $function); |
206 | 206 | } |
207 | 207 | } else { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile() |
241 | 241 | */ |
242 | 242 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
243 | - if(\sizeof($this->_compileParts)<3){ |
|
243 | + if (\sizeof($this->_compileParts)<3) { |
|
244 | 244 | $this->_template="%content%"; |
245 | 245 | $this->refresh(); |
246 | 246 | } |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | |
251 | 251 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
252 | 252 | if ($this->propertyContains("class", "sortable")) { |
253 | - $this->addEvent("execute", "$('#" . $this->identifier . "').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
253 | + $this->addEvent("execute", "$('#".$this->identifier."').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
254 | 254 | } |
255 | - if(isset($this->_activeClass)){ |
|
255 | + if (isset($this->_activeClass)) { |
|
256 | 256 | $this->onRow($this->_activeRowEvent, "$(this).toggleClass('".$this->_activeClass."');"); |
257 | 257 | } |
258 | 258 | } |
@@ -266,13 +266,13 @@ discard block |
||
266 | 266 | public function fromDatabaseObject($object, $function) { |
267 | 267 | $result=$function($object); |
268 | 268 | if (\is_array($result)) { |
269 | - $result= $this->addRow($function($object)); |
|
269 | + $result=$this->addRow($function($object)); |
|
270 | 270 | } else { |
271 | - $result= $this->getBody()->_addRow($result); |
|
271 | + $result=$this->getBody()->_addRow($result); |
|
272 | 272 | } |
273 | - if(isset($this->_afterCompileEvents["onNewRow"])){ |
|
274 | - if(\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
275 | - $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
273 | + if (isset($this->_afterCompileEvents["onNewRow"])) { |
|
274 | + if (\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
275 | + $this->_afterCompileEvents["onNewRow"]($result, $object); |
|
276 | 276 | } |
277 | 277 | return $result; |
278 | 278 | } |
@@ -286,14 +286,14 @@ discard block |
||
286 | 286 | return $this; |
287 | 287 | } |
288 | 288 | |
289 | - public function refresh(){ |
|
289 | + public function refresh() { |
|
290 | 290 | $this->_footer=$this->getFooter(); |
291 | 291 | $this->addEvent("execute", '$("#'.$this->identifier.' tfoot").replaceWith("'.\addslashes($this->_footer).'");'); |
292 | 292 | } |
293 | 293 | |
294 | - public function run(JsUtils $js){ |
|
295 | - $result= parent::run($js); |
|
296 | - if(isset($this->_footer)) |
|
294 | + public function run(JsUtils $js) { |
|
295 | + $result=parent::run($js); |
|
296 | + if (isset($this->_footer)) |
|
297 | 297 | $this->_footer->run($js); |
298 | 298 | return $result; |
299 | 299 | } |
@@ -271,8 +271,9 @@ discard block |
||
271 | 271 | $result= $this->getBody()->_addRow($result); |
272 | 272 | } |
273 | 273 | if(isset($this->_afterCompileEvents["onNewRow"])){ |
274 | - if(\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
275 | - $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
274 | + if(\is_callable($this->_afterCompileEvents["onNewRow"])) { |
|
275 | + $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
276 | + } |
|
276 | 277 | } |
277 | 278 | return $result; |
278 | 279 | } |
@@ -293,8 +294,9 @@ discard block |
||
293 | 294 | |
294 | 295 | public function run(JsUtils $js){ |
295 | 296 | $result= parent::run($js); |
296 | - if(isset($this->_footer)) |
|
297 | - $this->_footer->run($js); |
|
297 | + if(isset($this->_footer)) { |
|
298 | + $this->_footer->run($js); |
|
299 | + } |
|
298 | 300 | return $result; |
299 | 301 | } |
300 | 302 |