@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | trait JsUtilsActionsTrait { |
| 13 | 13 | |
| 14 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 14 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 15 | 15 | /** |
| 16 | 16 | * show or hide with effect |
| 17 | 17 | * |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @param boolean $immediatly defers the execution if set to false |
| 23 | 23 | * @return string |
| 24 | 24 | */ |
| 25 | - protected function _showHideWithEffect($action,$element='this', $speed='', $callback='', $immediatly=false) { |
|
| 25 | + protected function _showHideWithEffect($action, $element='this', $speed='', $callback='', $immediatly=false) { |
|
| 26 | 26 | $element=Javascript::prep_element($element); |
| 27 | 27 | $speed=$this->_validate_speed($speed); |
| 28 | 28 | if ($callback!='') { |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | * @return string |
| 40 | 40 | */ |
| 41 | 41 | private function _validate_speed($speed) { |
| 42 | - if (in_array($speed, array ( |
|
| 43 | - 'slow','normal','fast' |
|
| 42 | + if (in_array($speed, array( |
|
| 43 | + 'slow', 'normal', 'fast' |
|
| 44 | 44 | ))) { |
| 45 | 45 | $speed='"'.$speed.'"'; |
| 46 | 46 | } elseif (preg_match("/[^0-9]/", $speed)) { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param string $param |
| 58 | 58 | * @param boolean $immediatly delayed if false |
| 59 | 59 | */ |
| 60 | - public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) { |
|
| 60 | + public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) { |
|
| 61 | 61 | $element=Javascript::prep_element($element); |
| 62 | 62 | if (isset($param)) { |
| 63 | 63 | $param=Javascript::prep_value($param); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @param boolean $immediatly delayed if false |
| 78 | 78 | * @return string |
| 79 | 79 | */ |
| 80 | - public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) { |
|
| 80 | + public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) { |
|
| 81 | 81 | $to=Javascript::prep_element($to); |
| 82 | 82 | $element=Javascript::prep_element($element); |
| 83 | 83 | $str="$({$to}).{$jQueryCall}({$element});"; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @return string |
| 95 | 95 | */ |
| 96 | 96 | public function addClass($element='this', $class='', $immediatly=false) { |
| 97 | - return $this->_genericCallValue('addClass',$element, $class, $immediatly); |
|
| 97 | + return $this->_genericCallValue('addClass', $element, $class, $immediatly); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | * @param boolean $immediatly defers the execution if set to false |
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | - public function after($to, $element, $immediatly=false){ |
|
| 108 | - return $this->_genericCallElement('after',$to, $element, $immediatly); |
|
| 107 | + public function after($to, $element, $immediatly=false) { |
|
| 108 | + return $this->_genericCallElement('after', $to, $element, $immediatly); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | * @param boolean $immediatly defers the execution if set to false |
| 116 | 116 | * @return string |
| 117 | 117 | */ |
| 118 | - public function before($to, $element, $immediatly=false){ |
|
| 119 | - return $this->_genericCallElement('before',$to, $element, $immediatly); |
|
| 118 | + public function before($to, $element, $immediatly=false) { |
|
| 119 | + return $this->_genericCallElement('before', $to, $element, $immediatly); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | * @param string $value |
| 145 | 145 | * @param boolean $immediatly defers the execution if set to false |
| 146 | 146 | */ |
| 147 | - public function val($element='this',$value='',$immediatly=false){ |
|
| 148 | - return $this->_genericCallValue('val',$element,$value,$immediatly); |
|
| 147 | + public function val($element='this', $value='', $immediatly=false) { |
|
| 148 | + return $this->_genericCallValue('val', $element, $value, $immediatly); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @param boolean $immediatly defers the execution if set to false |
| 156 | 156 | */ |
| 157 | 157 | public function html($element='this', $value='', $immediatly=false) { |
| 158 | - return $this->_genericCallValue('html',$element, $value, $immediatly); |
|
| 158 | + return $this->_genericCallValue('html', $element, $value, $immediatly); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | $animations="\t\t\t"; |
| 176 | 176 | if (\is_array($params)) { |
| 177 | - foreach ( $params as $param => $value ) { |
|
| 177 | + foreach ($params as $param => $value) { |
|
| 178 | 178 | $animations.=$param.': \''.$value.'\', '; |
| 179 | 179 | } |
| 180 | 180 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @return string |
| 204 | 204 | */ |
| 205 | 205 | public function append($to, $element, $immediatly=false) { |
| 206 | - return $this->_genericCallElement('append',$to, $element, $immediatly); |
|
| 206 | + return $this->_genericCallElement('append', $to, $element, $immediatly); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @return string |
| 215 | 215 | */ |
| 216 | 216 | public function prepend($to, $element, $immediatly=false) { |
| 217 | - return $this->_genericCallElement('prepend',$to, $element, $immediatly); |
|
| 217 | + return $this->_genericCallElement('prepend', $to, $element, $immediatly); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * @return string |
| 228 | 228 | */ |
| 229 | 229 | public function fadeIn($element='this', $speed='', $callback='', $immediatly=false) { |
| 230 | - return $this->_showHideWithEffect("fadeIn",$element,$speed,$callback,$immediatly); |
|
| 230 | + return $this->_showHideWithEffect("fadeIn", $element, $speed, $callback, $immediatly); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * @return string |
| 241 | 241 | */ |
| 242 | 242 | public function fadeOut($element='this', $speed='', $callback='', $immediatly=false) { |
| 243 | - return $this->_showHideWithEffect("fadeOut",$element,$speed,$callback,$immediatly); |
|
| 243 | + return $this->_showHideWithEffect("fadeOut", $element, $speed, $callback, $immediatly); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * @return string |
| 254 | 254 | */ |
| 255 | 255 | public function slideUp($element='this', $speed='', $callback='', $immediatly=false) { |
| 256 | - return $this->_showHideWithEffect("slideUp",$element,$speed,$callback,$immediatly); |
|
| 256 | + return $this->_showHideWithEffect("slideUp", $element, $speed, $callback, $immediatly); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * @return string |
| 266 | 266 | */ |
| 267 | 267 | public function removeClass($element='this', $class='', $immediatly=false) { |
| 268 | - return $this->_genericCallValue('removeClass',$element, $class, $immediatly); |
|
| 268 | + return $this->_genericCallValue('removeClass', $element, $class, $immediatly); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * @return string |
| 279 | 279 | */ |
| 280 | 280 | public function slideDown($element='this', $speed='', $callback='', $immediatly=false) { |
| 281 | - return $this->_showHideWithEffect("slideDown",$element,$speed,$callback,$immediatly); |
|
| 281 | + return $this->_showHideWithEffect("slideDown", $element, $speed, $callback, $immediatly); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | * @return string |
| 292 | 292 | */ |
| 293 | 293 | public function slideToggle($element='this', $speed='', $callback='', $immediatly=false) { |
| 294 | - return $this->_showHideWithEffect("slideToggle",$element,$speed,$callback,$immediatly); |
|
| 294 | + return $this->_showHideWithEffect("slideToggle", $element, $speed, $callback, $immediatly); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | * @return string |
| 305 | 305 | */ |
| 306 | 306 | public function hide($element='this', $speed='', $callback='', $immediatly=false) { |
| 307 | - return $this->_showHideWithEffect("hide",$element,$speed,$callback,$immediatly); |
|
| 307 | + return $this->_showHideWithEffect("hide", $element, $speed, $callback, $immediatly); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * @return string |
| 318 | 318 | */ |
| 319 | 319 | public function toggle($element='this', $speed='', $callback='', $immediatly=false) { |
| 320 | - return $this->_showHideWithEffect("toggle",$element,$speed,$callback,$immediatly); |
|
| 320 | + return $this->_showHideWithEffect("toggle", $element, $speed, $callback, $immediatly); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * @return string |
| 330 | 330 | */ |
| 331 | 331 | public function toggleClass($element='this', $class='', $immediatly=false) { |
| 332 | - return $this->_genericCallValue('toggleClass',$element, $class, $immediatly); |
|
| 332 | + return $this->_genericCallValue('toggleClass', $element, $class, $immediatly); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | * @return string |
| 358 | 358 | */ |
| 359 | 359 | public function show($element='this', $speed='', $callback='', $immediatly=false) { |
| 360 | - return $this->_showHideWithEffect("show",$element,$speed,$callback,$immediatly); |
|
| 360 | + return $this->_showHideWithEffect("show", $element, $speed, $callback, $immediatly); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -369,8 +369,8 @@ discard block |
||
| 369 | 369 | */ |
| 370 | 370 | public function sortable($element, $options=array()) { |
| 371 | 371 | if (count($options)>0) { |
| 372 | - $sort_options=array (); |
|
| 373 | - foreach ( $options as $k => $v ) { |
|
| 372 | + $sort_options=array(); |
|
| 373 | + foreach ($options as $k => $v) { |
|
| 374 | 374 | $sort_options[]="\n\t\t".$k.': '.$v.""; |
| 375 | 375 | } |
| 376 | 376 | $sort_options=implode(",", $sort_options); |
@@ -467,8 +467,8 @@ discard block |
||
| 467 | 467 | * @param boolean $immediatly |
| 468 | 468 | * @return string |
| 469 | 469 | */ |
| 470 | - private function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="",$immediatly=true) { |
|
| 471 | - return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 470 | + private function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="", $immediatly=true) { |
|
| 471 | + return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | $preventDefault=false; |
| 487 | 487 | $immediatly=true; |
| 488 | 488 | extract($parameters); |
| 489 | - return $this->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback,$immediatly); |
|
| 489 | + return $this->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback, $immediatly); |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | /** |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | $preventDefault=false; |
| 528 | 528 | $immediatly=true; |
| 529 | 529 | extract($parameters); |
| 530 | - $script=$this->_add_event($element, $this->exec($js), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 530 | + $script=$this->_add_event($element, $this->exec($js), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 531 | 531 | return $script; |
| 532 | 532 | } |
| 533 | 533 | |
@@ -536,10 +536,10 @@ discard block |
||
| 536 | 536 | * @param string $element The element selector |
| 537 | 537 | * @param array $parameters default : array("attr"=>"id","preventDefault"=>false,"stopPropagation"=>false,"immediatly"=>true) |
| 538 | 538 | */ |
| 539 | - public function setDraggable($element,$parameters=[]){ |
|
| 539 | + public function setDraggable($element, $parameters=[]) { |
|
| 540 | 540 | $attr="id"; |
| 541 | 541 | extract($parameters); |
| 542 | - $script=$this->_add_event($element, Javascript::draggable($attr), "dragstart",$parameters); |
|
| 542 | + $script=$this->_add_event($element, Javascript::draggable($attr), "dragstart", $parameters); |
|
| 543 | 543 | return $script; |
| 544 | 544 | } |
| 545 | 545 | |
@@ -549,13 +549,13 @@ discard block |
||
| 549 | 549 | * @param array $parameters default : array("attr"=>"id","stopPropagation"=>false,"immediatly"=>true,"jqueryDone"=>"append") |
| 550 | 550 | * @param string $jsCallback the js script to call when element is dropped |
| 551 | 551 | */ |
| 552 | - public function asDropZone($element,$jsCallback="",$parameters=[]){ |
|
| 552 | + public function asDropZone($element, $jsCallback="", $parameters=[]) { |
|
| 553 | 553 | $stopPropagation=false; |
| 554 | 554 | $immediatly=true; |
| 555 | 555 | $jqueryDone="append"; |
| 556 | - $script=$this->_add_event($element, '', "dragover",true,$stopPropagation,$immediatly); |
|
| 556 | + $script=$this->_add_event($element, '', "dragover", true, $stopPropagation, $immediatly); |
|
| 557 | 557 | extract($parameters); |
| 558 | - $script.=$this->_add_event($element, Javascript::dropZone($jqueryDone,$jsCallback), "drop",true,$stopPropagation,$immediatly); |
|
| 558 | + $script.=$this->_add_event($element, Javascript::dropZone($jqueryDone, $jsCallback), "drop", true, $stopPropagation, $immediatly); |
|
| 559 | 559 | return $script; |
| 560 | 560 | } |
| 561 | 561 | } |
@@ -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 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * @return HtmlTD |
| 54 | 54 | */ |
| 55 | - public function getItem($index){ |
|
| 55 | + public function getItem($index) { |
|
| 56 | 56 | return parent::getItem($index); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @param mixed $values |
| 76 | 76 | */ |
| 77 | 77 | public function setValues($values=array()) { |
| 78 | - return $this->_addOrSetValues($values, function(HtmlTD &$cell,$value){$cell->setValue($value);}); |
|
| 78 | + return $this->_addOrSetValues($values, function(HtmlTD &$cell, $value) {$cell->setValue($value); }); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -83,27 +83,27 @@ discard block |
||
| 83 | 83 | * @param mixed $values |
| 84 | 84 | */ |
| 85 | 85 | public function addValues($values=array()) { |
| 86 | - return $this->_addOrSetValues($values, function(HtmlTD &$cell,$value){$cell->addValue($value);}); |
|
| 86 | + return $this->_addOrSetValues($values, function(HtmlTD &$cell, $value) {$cell->addValue($value); }); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * Sets or adds values to the row cols |
| 91 | 91 | * @param mixed $values |
| 92 | 92 | */ |
| 93 | - protected function _addOrSetValues($values,$callback) { |
|
| 93 | + protected function _addOrSetValues($values, $callback) { |
|
| 94 | 94 | $count=$this->count(); |
| 95 | 95 | if (!\is_array($values)) { |
| 96 | 96 | $values=\array_fill(0, $count, $values); |
| 97 | 97 | } else { |
| 98 | - if (JArray::isAssociative($values) === true) { |
|
| 98 | + if (JArray::isAssociative($values)===true) { |
|
| 99 | 99 | $values=\array_values($values); |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | $count=\min(\sizeof($values), $count); |
| 103 | 103 | |
| 104 | - for($i=0; $i < $count; $i++) { |
|
| 104 | + for ($i=0; $i<$count; $i++) { |
|
| 105 | 105 | $cell=$this->content[$i]; |
| 106 | - $callback($cell,$values[$i]); |
|
| 106 | + $callback($cell, $values[$i]); |
|
| 107 | 107 | } |
| 108 | 108 | return $this; |
| 109 | 109 | } |
@@ -127,24 +127,24 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | public function getColPosition($colIndex) { |
| 130 | - if($this->_container->_isMerged()!==true) |
|
| 130 | + if ($this->_container->_isMerged()!==true) |
|
| 131 | 131 | return $colIndex; |
| 132 | 132 | $pos=0; |
| 133 | 133 | $rows=$this->_container->getContent(); |
| 134 | - for($i=0; $i < $this->_row; $i++) { |
|
| 134 | + for ($i=0; $i<$this->_row; $i++) { |
|
| 135 | 135 | $max=\min($colIndex, $rows[$i]->count()); |
| 136 | - for($j=0; $j < $max; $j++) { |
|
| 136 | + for ($j=0; $j<$max; $j++) { |
|
| 137 | 137 | $rowspan=$rows[$i]->getItem($j)->getRowspan(); |
| 138 | - if ($rowspan + $i > $this->_row) |
|
| 138 | + if ($rowspan+$i>$this->_row) |
|
| 139 | 139 | $pos++; |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | - if ($pos > $colIndex) |
|
| 142 | + if ($pos>$colIndex) |
|
| 143 | 143 | return NULL; |
| 144 | 144 | $count=$this->count(); |
| 145 | - for($i=0; $i < $count; $i++) { |
|
| 145 | + for ($i=0; $i<$count; $i++) { |
|
| 146 | 146 | $pos+=$this->content[$i]->getColspan(); |
| 147 | - if ($pos >= $colIndex + 1) |
|
| 147 | + if ($pos>=$colIndex+1) |
|
| 148 | 148 | return $i; |
| 149 | 149 | } |
| 150 | 150 | return null; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | public function conditionalCellFormat($callback, $format) { |
| 154 | 154 | $cells=$this->content; |
| 155 | - foreach ( $cells as $cell ) { |
|
| 155 | + foreach ($cells as $cell) { |
|
| 156 | 156 | $cell->conditionalCellFormat($callback, $format); |
| 157 | 157 | } |
| 158 | 158 | return $this; |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | public function containsStr($needle) { |
| 169 | 169 | $cells=$this->content; |
| 170 | - foreach ( $cells as $cell ) { |
|
| 171 | - if (\strpos($cell->getContent(), $needle) !== false) |
|
| 170 | + foreach ($cells as $cell) { |
|
| 171 | + if (\strpos($cell->getContent(), $needle)!==false) |
|
| 172 | 172 | return true; |
| 173 | 173 | } |
| 174 | 174 | return false; |
@@ -181,13 +181,13 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | public function applyCells($callback) { |
| 183 | 183 | $cells=$this->content; |
| 184 | - foreach ( $cells as $cell ) { |
|
| 184 | + foreach ($cells as $cell) { |
|
| 185 | 185 | $cell->apply($callback); |
| 186 | 186 | } |
| 187 | 187 | return $this; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - public function toDelete($colIndex){ |
|
| 190 | + public function toDelete($colIndex) { |
|
| 191 | 191 | $this->getItem($colIndex)->toDelete(); |
| 192 | 192 | return $this; |
| 193 | 193 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * |
| 14 | 14 | */ |
| 15 | 15 | class HtmlTableContent extends HtmlSemCollection { |
| 16 | - protected $_tdTagNames=[ "thead" => "th","tbody" => "td","tfoot" => "th" ]; |
|
| 16 | + protected $_tdTagNames=["thead" => "th", "tbody" => "td", "tfoot" => "th"]; |
|
| 17 | 17 | protected $_merged=false; |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function setRowCount($rowCount, $colCount) { |
| 39 | 39 | $count=$this->count(); |
| 40 | - for($i=$count; $i < $rowCount; $i++) { |
|
| 40 | + for ($i=$count; $i<$rowCount; $i++) { |
|
| 41 | 41 | $this->addItem($colCount); |
| 42 | 42 | } |
| 43 | 43 | return $this; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $tr=new HtmlTR(""); |
| 60 | 60 | $tr->setContainer($this, $count); |
| 61 | 61 | $tr->setTdTagName($this->_tdTagNames[$this->tagName]); |
| 62 | - if (isset($value) === true) { |
|
| 62 | + if (isset($value)===true) { |
|
| 63 | 63 | $tr->setColCount($value); |
| 64 | 64 | } |
| 65 | 65 | return $tr; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | /** |
| 89 | 89 | * @return HtmlTR |
| 90 | 90 | */ |
| 91 | - public function getItem($index){ |
|
| 91 | + public function getItem($index) { |
|
| 92 | 92 | return parent::getItem($index); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $row=$this->getItem($row); |
| 103 | 103 | if (isset($row) && $row instanceof HtmlCollection) { |
| 104 | 104 | $col=$row->getItem($col); |
| 105 | - }else{ |
|
| 105 | + } else { |
|
| 106 | 106 | $col=$row; |
| 107 | 107 | } |
| 108 | 108 | return $col; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function setCellValue($row, $col, $value="") { |
| 128 | 128 | $cell=$this->getCell($row, $col); |
| 129 | - if (isset($cell) === true) { |
|
| 129 | + if (isset($cell)===true) { |
|
| 130 | 130 | $cell->setValue($value); |
| 131 | 131 | } |
| 132 | 132 | return $this; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param mixed $values |
| 138 | 138 | */ |
| 139 | 139 | public function setValues($values=array()) { |
| 140 | - return $this->_addOrSetValues($values, function(HtmlTR $row,$_values){$row->setValues($_values);}); |
|
| 140 | + return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) {$row->setValues($_values); }); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param mixed $values |
| 146 | 146 | */ |
| 147 | 147 | public function addValues($values=array()) { |
| 148 | - return $this->_addOrSetValues($values, function(HtmlTR $row,$_values){$row->addValues($_values);}); |
|
| 148 | + return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) {$row->addValues($_values); }); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -153,21 +153,21 @@ discard block |
||
| 153 | 153 | * @param mixed $values |
| 154 | 154 | * @param callable $callback |
| 155 | 155 | */ |
| 156 | - protected function _addOrSetValues($values,$callback) { |
|
| 156 | + protected function _addOrSetValues($values, $callback) { |
|
| 157 | 157 | $count=$this->count(); |
| 158 | 158 | $isArray=true; |
| 159 | 159 | if (!\is_array($values)) { |
| 160 | 160 | $values=\array_fill(0, $count, $values); |
| 161 | 161 | $isArray=false; |
| 162 | 162 | } |
| 163 | - if (JArray::dimension($values) == 1 && $isArray) |
|
| 164 | - $values=[ $values ]; |
|
| 163 | + if (JArray::dimension($values)==1 && $isArray) |
|
| 164 | + $values=[$values]; |
|
| 165 | 165 | |
| 166 | 166 | $count=\min(\sizeof($values), $count); |
| 167 | 167 | |
| 168 | - for($i=0; $i < $count; $i++) { |
|
| 168 | + for ($i=0; $i<$count; $i++) { |
|
| 169 | 169 | $row=$this->content[$i]; |
| 170 | - $callback($row,$values[$i]); |
|
| 170 | + $callback($row, $values[$i]); |
|
| 171 | 171 | } |
| 172 | 172 | return $this; |
| 173 | 173 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $values=\array_fill(0, $count, $values); |
| 179 | 179 | } |
| 180 | 180 | $count=\min(\sizeof($values), $count); |
| 181 | - for($i=0; $i < $count; $i++) { |
|
| 181 | + for ($i=0; $i<$count; $i++) { |
|
| 182 | 182 | $this->getCell($i, $colIndex)->setValue($values[$i]); |
| 183 | 183 | } |
| 184 | 184 | return $this; |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | public function addColVariations($colIndex, $variations=array()) { |
| 188 | 188 | $count=$this->count(); |
| 189 | - for($i=0; $i < $count; $i++) { |
|
| 189 | + for ($i=0; $i<$count; $i++) { |
|
| 190 | 190 | $this->getCell($i, $colIndex)->addVariations($variations); |
| 191 | 191 | } |
| 192 | 192 | return $this; |
@@ -203,9 +203,9 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | private function colAlign($colIndex, $function) { |
| 205 | 205 | $count=$this->count(); |
| 206 | - for($i=0; $i < $count; $i++) { |
|
| 206 | + for ($i=0; $i<$count; $i++) { |
|
| 207 | 207 | $index=$this->content[$i]->getColPosition($colIndex); |
| 208 | - if ($index !== NULL) |
|
| 208 | + if ($index!==NULL) |
|
| 209 | 209 | $this->getCell($i, $index)->$function(); |
| 210 | 210 | } |
| 211 | 211 | return $this; |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function getColCount() { |
| 239 | 239 | $result=0; |
| 240 | - if ($this->count() > 0) |
|
| 240 | + if ($this->count()>0) |
|
| 241 | 241 | $result=$this->getItem(0)->count(); |
| 242 | 242 | return $result; |
| 243 | 243 | } |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | public function delete($rowIndex, $colIndex=NULL) { |
| 252 | 252 | if (isset($colIndex)) { |
| 253 | 253 | $row=$this->getItem($rowIndex); |
| 254 | - if (isset($row) === true) { |
|
| 254 | + if (isset($row)===true) { |
|
| 255 | 255 | $row->delete($colIndex); |
| 256 | 256 | } |
| 257 | 257 | } else { |
@@ -260,9 +260,9 @@ discard block |
||
| 260 | 260 | return $this; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - public function toDelete($rowIndex, $colIndex){ |
|
| 263 | + public function toDelete($rowIndex, $colIndex) { |
|
| 264 | 264 | $row=$this->getItem($rowIndex); |
| 265 | - if (isset($row) === true) |
|
| 265 | + if (isset($row)===true) |
|
| 266 | 266 | $row->toDelete($colIndex); |
| 267 | 267 | return $this; |
| 268 | 268 | } |
@@ -291,17 +291,17 @@ discard block |
||
| 291 | 291 | */ |
| 292 | 292 | public function conditionalCellFormat($callback, $format) { |
| 293 | 293 | $rows=$this->content; |
| 294 | - foreach ( $rows as $row ) { |
|
| 294 | + foreach ($rows as $row) { |
|
| 295 | 295 | $row->conditionalCellFormat($callback, $format); |
| 296 | 296 | } |
| 297 | 297 | return $this; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - public function conditionalColFormat($colIndex,$callback,$format){ |
|
| 300 | + public function conditionalColFormat($colIndex, $callback, $format) { |
|
| 301 | 301 | $rows=$this->content; |
| 302 | - foreach ( $rows as $row ) { |
|
| 302 | + foreach ($rows as $row) { |
|
| 303 | 303 | $cell=$row->getItem($colIndex); |
| 304 | - $cell->conditionnalCellFormat($callback,$format); |
|
| 304 | + $cell->conditionnalCellFormat($callback, $format); |
|
| 305 | 305 | } |
| 306 | 306 | return $this; |
| 307 | 307 | } |
@@ -313,17 +313,17 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | public function conditionalRowFormat($callback, $format) { |
| 315 | 315 | $rows=$this->content; |
| 316 | - foreach ( $rows as $row ) { |
|
| 316 | + foreach ($rows as $row) { |
|
| 317 | 317 | $row->conditionalRowFormat($callback, $format); |
| 318 | 318 | } |
| 319 | 319 | return $this; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - public function hideColumn($colIndex){ |
|
| 322 | + public function hideColumn($colIndex) { |
|
| 323 | 323 | $rows=$this->content; |
| 324 | - foreach ( $rows as $row ) { |
|
| 324 | + foreach ($rows as $row) { |
|
| 325 | 325 | $cell=$row->getItem($colIndex); |
| 326 | - $cell->addToProperty("style","display:none;"); |
|
| 326 | + $cell->addToProperty("style", "display:none;"); |
|
| 327 | 327 | } |
| 328 | 328 | return $this; |
| 329 | 329 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | */ |
| 335 | 335 | public function applyCells($callback) { |
| 336 | 336 | $rows=$this->content; |
| 337 | - foreach ( $rows as $row ) { |
|
| 337 | + foreach ($rows as $row) { |
|
| 338 | 338 | $row->applyCells($callback); |
| 339 | 339 | } |
| 340 | 340 | return $this; |
@@ -346,25 +346,25 @@ discard block |
||
| 346 | 346 | */ |
| 347 | 347 | public function applyRows($callback) { |
| 348 | 348 | $rows=$this->content; |
| 349 | - foreach ( $rows as $row ) { |
|
| 349 | + foreach ($rows as $row) { |
|
| 350 | 350 | $row->apply($callback); |
| 351 | 351 | } |
| 352 | 352 | return $this; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - public function mergeIdentiqualValues($colIndex,$function="strip_tags"){ |
|
| 355 | + public function mergeIdentiqualValues($colIndex, $function="strip_tags") { |
|
| 356 | 356 | $rows=$this->content; |
| 357 | 357 | $identiqual=null; |
| 358 | 358 | $counter=0; |
| 359 | 359 | $cellToMerge=null; |
| 360 | 360 | $functionExists=\function_exists($function); |
| 361 | - foreach ( $rows as $row ) { |
|
| 361 | + foreach ($rows as $row) { |
|
| 362 | 362 | $cell=$row->getItem($colIndex); |
| 363 | 363 | $value=$cell->getContent(); |
| 364 | - if($functionExists) |
|
| 365 | - $value=\call_user_func($function,$value); |
|
| 366 | - if($value!==$identiqual){ |
|
| 367 | - if($counter>0 && isset($cellToMerge)){ |
|
| 364 | + if ($functionExists) |
|
| 365 | + $value=\call_user_func($function, $value); |
|
| 366 | + if ($value!==$identiqual) { |
|
| 367 | + if ($counter>0 && isset($cellToMerge)) { |
|
| 368 | 368 | $cellToMerge->setRowspan($counter); |
| 369 | 369 | } |
| 370 | 370 | $counter=0; |
@@ -373,17 +373,17 @@ discard block |
||
| 373 | 373 | } |
| 374 | 374 | $counter++; |
| 375 | 375 | } |
| 376 | - if($counter>0 && isset($cellToMerge)){ |
|
| 376 | + if ($counter>0 && isset($cellToMerge)) { |
|
| 377 | 377 | $cellToMerge->setRowspan($counter); |
| 378 | 378 | } |
| 379 | 379 | return $this; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - public function _isMerged(){ |
|
| 382 | + public function _isMerged() { |
|
| 383 | 383 | return $this->_merged; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - public function _setMerged($value){ |
|
| 386 | + public function _setMerged($value) { |
|
| 387 | 387 | $this->_merged=$value; |
| 388 | 388 | return $this; |
| 389 | 389 | } |