@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * |
15 | 15 | */ |
16 | 16 | class HtmlTableContent extends HtmlSemCollection { |
17 | - protected $_tdTagNames=[ "thead" => "th","tbody" => "td","tfoot" => "th" ]; |
|
17 | + protected $_tdTagNames=["thead" => "th", "tbody" => "td", "tfoot" => "th"]; |
|
18 | 18 | protected $_merged=false; |
19 | 19 | |
20 | 20 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function setRowCount($rowCount, $colCount) { |
40 | 40 | $count=$this->count(); |
41 | - for($i=$count; $i < $rowCount; $i++) { |
|
41 | + for ($i=$count; $i<$rowCount; $i++) { |
|
42 | 42 | $this->addItem($colCount); |
43 | 43 | } |
44 | 44 | return $this; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $tr=new HtmlTR(""); |
61 | 61 | $tr->setContainer($this, $count); |
62 | 62 | $tr->setTdTagName($this->_tdTagNames[$this->tagName]); |
63 | - if (isset($value) === true) { |
|
63 | + if (isset($value)===true) { |
|
64 | 64 | $tr->setColCount($value); |
65 | 65 | } |
66 | 66 | return $tr; |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | return $this->addItem($row); |
87 | 87 | } |
88 | 88 | |
89 | - public function addMergeRow($colCount,$value=null){ |
|
89 | + public function addMergeRow($colCount, $value=null) { |
|
90 | 90 | $row=$this->addRow($colCount); |
91 | 91 | $row->mergeCol(); |
92 | - if(isset($value)){ |
|
92 | + if (isset($value)) { |
|
93 | 93 | $row->setValues([$value]); |
94 | 94 | } |
95 | 95 | return $row; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * @return HtmlTR |
100 | 100 | */ |
101 | - public function getItem($index){ |
|
101 | + public function getItem($index) { |
|
102 | 102 | return parent::getItem($index); |
103 | 103 | } |
104 | 104 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $row=$this->getItem($row); |
113 | 113 | if (isset($row) && $row instanceof HtmlCollection) { |
114 | 114 | $col=$row->getItem($col); |
115 | - }else{ |
|
115 | + } else { |
|
116 | 116 | $col=$row; |
117 | 117 | } |
118 | 118 | return $col; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function setCellValue($row, $col, $value="") { |
138 | 138 | $cell=$this->getCell($row, $col); |
139 | - if (isset($cell) === true) { |
|
139 | + if (isset($cell)===true) { |
|
140 | 140 | $cell->setValue($value); |
141 | 141 | } |
142 | 142 | return $this; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param mixed $values |
148 | 148 | */ |
149 | 149 | public function setValues($values=array()) { |
150 | - return $this->_addOrSetValues($values, function(HtmlTR $row,$_values){$row->setValues($_values);}); |
|
150 | + return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) {$row->setValues($_values); }); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param mixed $values |
156 | 156 | */ |
157 | 157 | public function addValues($values=array()) { |
158 | - return $this->_addOrSetValues($values, function(HtmlTR $row,$_values){$row->addValues($_values);}); |
|
158 | + return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) {$row->addValues($_values); }); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -163,21 +163,21 @@ discard block |
||
163 | 163 | * @param mixed $values |
164 | 164 | * @param callable $callback |
165 | 165 | */ |
166 | - protected function _addOrSetValues($values,$callback) { |
|
166 | + protected function _addOrSetValues($values, $callback) { |
|
167 | 167 | $count=$this->count(); |
168 | 168 | $isArray=true; |
169 | 169 | if (!\is_array($values)) { |
170 | 170 | $values=\array_fill(0, $count, $values); |
171 | 171 | $isArray=false; |
172 | 172 | } |
173 | - if (JArray::dimension($values) == 1 && $isArray) |
|
174 | - $values=[ $values ]; |
|
173 | + if (JArray::dimension($values)==1 && $isArray) |
|
174 | + $values=[$values]; |
|
175 | 175 | |
176 | 176 | $count=\min(\sizeof($values), $count); |
177 | 177 | |
178 | - for($i=0; $i < $count; $i++) { |
|
178 | + for ($i=0; $i<$count; $i++) { |
|
179 | 179 | $row=$this->content[$i]; |
180 | - $callback($row,$values[$i]); |
|
180 | + $callback($row, $values[$i]); |
|
181 | 181 | } |
182 | 182 | return $this; |
183 | 183 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $values=\array_fill(0, $count, $values); |
189 | 189 | } |
190 | 190 | $count=\min(\sizeof($values), $count); |
191 | - for($i=0; $i < $count; $i++) { |
|
191 | + for ($i=0; $i<$count; $i++) { |
|
192 | 192 | $this->getCell($i, $colIndex)->setValue($values[$i]); |
193 | 193 | } |
194 | 194 | return $this; |
@@ -196,20 +196,20 @@ discard block |
||
196 | 196 | |
197 | 197 | public function addColVariations($colIndex, $variations=array()) { |
198 | 198 | $count=$this->count(); |
199 | - for($i=0; $i < $count; $i++) { |
|
199 | + for ($i=0; $i<$count; $i++) { |
|
200 | 200 | $cell=$this->getCell($i, $colIndex); |
201 | - if($cell instanceof BaseTrait) |
|
201 | + if ($cell instanceof BaseTrait) |
|
202 | 202 | $cell->addVariations($variations); |
203 | 203 | } |
204 | 204 | return $this; |
205 | 205 | } |
206 | 206 | |
207 | - public function addPropertyCol($colIndex, $name,$value) { |
|
207 | + public function addPropertyCol($colIndex, $name, $value) { |
|
208 | 208 | $count=$this->count(); |
209 | - for($i=0; $i < $count; $i++) { |
|
209 | + for ($i=0; $i<$count; $i++) { |
|
210 | 210 | $cell=$this->getCell($i, $colIndex); |
211 | - if(isset($cell)) |
|
212 | - $cell->addToProperty($name,$value); |
|
211 | + if (isset($cell)) |
|
212 | + $cell->addToProperty($name, $value); |
|
213 | 213 | } |
214 | 214 | return $this; |
215 | 215 | } |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | |
226 | 226 | private function colAlign($colIndex, $function) { |
227 | 227 | $count=$this->count(); |
228 | - for($i=0; $i < $count; $i++) { |
|
228 | + for ($i=0; $i<$count; $i++) { |
|
229 | 229 | $index=$this->content[$i]->getColPosition($colIndex); |
230 | - if ($index !== NULL) |
|
230 | + if ($index!==NULL) |
|
231 | 231 | $this->getCell($i, $index)->$function(); |
232 | 232 | } |
233 | 233 | return $this; |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | |
236 | 236 | private function colAlignFromRight($colIndex, $function) { |
237 | 237 | $count=$this->count(); |
238 | - for($i=0; $i < $count; $i++) { |
|
238 | + for ($i=0; $i<$count; $i++) { |
|
239 | 239 | $maxRow=$this->content[$i]->count(); |
240 | 240 | $index=$maxRow-$colIndex-1; |
241 | - if (($cell=$this->getCell($i, $index))!== NULL){ |
|
242 | - if($cell->getColspan()==1) |
|
241 | + if (($cell=$this->getCell($i, $index))!==NULL) { |
|
242 | + if ($cell->getColspan()==1) |
|
243 | 243 | $cell->$function(); |
244 | 244 | } |
245 | 245 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | */ |
285 | 285 | public function getColCount() { |
286 | 286 | $result=0; |
287 | - if ($this->count() > 0) |
|
287 | + if ($this->count()>0) |
|
288 | 288 | $result=$this->getItem(0)->count(); |
289 | 289 | return $result; |
290 | 290 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | public function delete($rowIndex, $colIndex=NULL) { |
299 | 299 | if (isset($colIndex)) { |
300 | 300 | $row=$this->getItem($rowIndex); |
301 | - if (isset($row) === true) { |
|
301 | + if (isset($row)===true) { |
|
302 | 302 | $row->delete($colIndex); |
303 | 303 | } |
304 | 304 | } else { |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | return $this; |
308 | 308 | } |
309 | 309 | |
310 | - public function toDelete($rowIndex, $colIndex){ |
|
310 | + public function toDelete($rowIndex, $colIndex) { |
|
311 | 311 | $row=$this->getItem($rowIndex); |
312 | - if (isset($row) === true) |
|
312 | + if (isset($row)===true) |
|
313 | 313 | $row->toDelete($colIndex); |
314 | 314 | return $this; |
315 | 315 | } |
@@ -338,17 +338,17 @@ discard block |
||
338 | 338 | */ |
339 | 339 | public function conditionalCellFormat($callback, $format) { |
340 | 340 | $rows=$this->content; |
341 | - foreach ( $rows as $row ) { |
|
341 | + foreach ($rows as $row) { |
|
342 | 342 | $row->conditionalCellFormat($callback, $format); |
343 | 343 | } |
344 | 344 | return $this; |
345 | 345 | } |
346 | 346 | |
347 | - public function conditionalColFormat($colIndex,$callback,$format){ |
|
347 | + public function conditionalColFormat($colIndex, $callback, $format) { |
|
348 | 348 | $rows=$this->content; |
349 | - foreach ( $rows as $row ) { |
|
349 | + foreach ($rows as $row) { |
|
350 | 350 | $cell=$row->getItem($colIndex); |
351 | - $cell->conditionnalCellFormat($callback,$format); |
|
351 | + $cell->conditionnalCellFormat($callback, $format); |
|
352 | 352 | } |
353 | 353 | return $this; |
354 | 354 | } |
@@ -360,17 +360,17 @@ discard block |
||
360 | 360 | */ |
361 | 361 | public function conditionalRowFormat($callback, $format) { |
362 | 362 | $rows=$this->content; |
363 | - foreach ( $rows as $row ) { |
|
363 | + foreach ($rows as $row) { |
|
364 | 364 | $row->conditionalRowFormat($callback, $format); |
365 | 365 | } |
366 | 366 | return $this; |
367 | 367 | } |
368 | 368 | |
369 | - public function hideColumn($colIndex){ |
|
369 | + public function hideColumn($colIndex) { |
|
370 | 370 | $rows=$this->content; |
371 | - foreach ( $rows as $row ) { |
|
371 | + foreach ($rows as $row) { |
|
372 | 372 | $cell=$row->getItem($colIndex); |
373 | - $cell->addToProperty("style","display:none;"); |
|
373 | + $cell->addToProperty("style", "display:none;"); |
|
374 | 374 | } |
375 | 375 | return $this; |
376 | 376 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | */ |
382 | 382 | public function applyCells($callback) { |
383 | 383 | $rows=$this->content; |
384 | - foreach ( $rows as $row ) { |
|
384 | + foreach ($rows as $row) { |
|
385 | 385 | $row->applyCells($callback); |
386 | 386 | } |
387 | 387 | return $this; |
@@ -393,25 +393,25 @@ discard block |
||
393 | 393 | */ |
394 | 394 | public function applyRows($callback) { |
395 | 395 | $rows=$this->content; |
396 | - foreach ( $rows as $row ) { |
|
396 | + foreach ($rows as $row) { |
|
397 | 397 | $row->apply($callback); |
398 | 398 | } |
399 | 399 | return $this; |
400 | 400 | } |
401 | 401 | |
402 | - public function mergeIdentiqualValues($colIndex,$function="strip_tags"){ |
|
402 | + public function mergeIdentiqualValues($colIndex, $function="strip_tags") { |
|
403 | 403 | $rows=$this->content; |
404 | 404 | $identiqual=null; |
405 | 405 | $counter=0; |
406 | 406 | $cellToMerge=null; |
407 | 407 | $functionExists=\function_exists($function); |
408 | - foreach ( $rows as $row ) { |
|
408 | + foreach ($rows as $row) { |
|
409 | 409 | $cell=$row->getItem($colIndex); |
410 | 410 | $value=$cell->getContent(); |
411 | - if($functionExists) |
|
412 | - $value=\call_user_func($function,$value); |
|
413 | - if($value!==$identiqual){ |
|
414 | - if($counter>0 && isset($cellToMerge)){ |
|
411 | + if ($functionExists) |
|
412 | + $value=\call_user_func($function, $value); |
|
413 | + if ($value!==$identiqual) { |
|
414 | + if ($counter>0 && isset($cellToMerge)) { |
|
415 | 415 | $cellToMerge->setRowspan($counter); |
416 | 416 | } |
417 | 417 | $counter=0; |
@@ -420,17 +420,17 @@ discard block |
||
420 | 420 | } |
421 | 421 | $counter++; |
422 | 422 | } |
423 | - if($counter>0 && isset($cellToMerge)){ |
|
423 | + if ($counter>0 && isset($cellToMerge)) { |
|
424 | 424 | $cellToMerge->setRowspan($counter); |
425 | 425 | } |
426 | 426 | return $this; |
427 | 427 | } |
428 | 428 | |
429 | - public function _isMerged(){ |
|
429 | + public function _isMerged() { |
|
430 | 430 | return $this->_merged; |
431 | 431 | } |
432 | 432 | |
433 | - public function _setMerged($value){ |
|
433 | + public function _setMerged($value) { |
|
434 | 434 | $this->_merged=$value; |
435 | 435 | return $this; |
436 | 436 | } |
@@ -26,8 +26,9 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function __construct($identifier, $tagName="tbody", $rowCount=NULL, $colCount=NULL) { |
28 | 28 | parent::__construct($identifier, $tagName, ""); |
29 | - if (isset($rowCount) && isset($colCount)) |
|
30 | - $this->setRowCount($rowCount, $colCount); |
|
29 | + if (isset($rowCount) && isset($colCount)) { |
|
30 | + $this->setRowCount($rowCount, $colCount); |
|
31 | + } |
|
31 | 32 | } |
32 | 33 | |
33 | 34 | /** |
@@ -112,7 +113,7 @@ discard block |
||
112 | 113 | $row=$this->getItem($row); |
113 | 114 | if (isset($row) && $row instanceof HtmlCollection) { |
114 | 115 | $col=$row->getItem($col); |
115 | - }else{ |
|
116 | + } else{ |
|
116 | 117 | $col=$row; |
117 | 118 | } |
118 | 119 | return $col; |
@@ -170,8 +171,9 @@ discard block |
||
170 | 171 | $values=\array_fill(0, $count, $values); |
171 | 172 | $isArray=false; |
172 | 173 | } |
173 | - if (JArray::dimension($values) == 1 && $isArray) |
|
174 | - $values=[ $values ]; |
|
174 | + if (JArray::dimension($values) == 1 && $isArray) { |
|
175 | + $values=[ $values ]; |
|
176 | + } |
|
175 | 177 | |
176 | 178 | $count=\min(\sizeof($values), $count); |
177 | 179 | |
@@ -198,8 +200,9 @@ discard block |
||
198 | 200 | $count=$this->count(); |
199 | 201 | for($i=0; $i < $count; $i++) { |
200 | 202 | $cell=$this->getCell($i, $colIndex); |
201 | - if($cell instanceof BaseTrait) |
|
202 | - $cell->addVariations($variations); |
|
203 | + if($cell instanceof BaseTrait) { |
|
204 | + $cell->addVariations($variations); |
|
205 | + } |
|
203 | 206 | } |
204 | 207 | return $this; |
205 | 208 | } |
@@ -208,8 +211,9 @@ discard block |
||
208 | 211 | $count=$this->count(); |
209 | 212 | for($i=0; $i < $count; $i++) { |
210 | 213 | $cell=$this->getCell($i, $colIndex); |
211 | - if(isset($cell)) |
|
212 | - $cell->addToProperty($name,$value); |
|
214 | + if(isset($cell)) { |
|
215 | + $cell->addToProperty($name,$value); |
|
216 | + } |
|
213 | 217 | } |
214 | 218 | return $this; |
215 | 219 | } |
@@ -227,8 +231,9 @@ discard block |
||
227 | 231 | $count=$this->count(); |
228 | 232 | for($i=0; $i < $count; $i++) { |
229 | 233 | $index=$this->content[$i]->getColPosition($colIndex); |
230 | - if ($index !== NULL) |
|
231 | - $this->getCell($i, $index)->$function(); |
|
234 | + if ($index !== NULL) { |
|
235 | + $this->getCell($i, $index)->$function(); |
|
236 | + } |
|
232 | 237 | } |
233 | 238 | return $this; |
234 | 239 | } |
@@ -239,8 +244,9 @@ discard block |
||
239 | 244 | $maxRow=$this->content[$i]->count(); |
240 | 245 | $index=$maxRow-$colIndex-1; |
241 | 246 | if (($cell=$this->getCell($i, $index))!== NULL){ |
242 | - if($cell->getColspan()==1) |
|
243 | - $cell->$function(); |
|
247 | + if($cell->getColspan()==1) { |
|
248 | + $cell->$function(); |
|
249 | + } |
|
244 | 250 | } |
245 | 251 | } |
246 | 252 | return $this; |
@@ -284,8 +290,9 @@ discard block |
||
284 | 290 | */ |
285 | 291 | public function getColCount() { |
286 | 292 | $result=0; |
287 | - if ($this->count() > 0) |
|
288 | - $result=$this->getItem(0)->count(); |
|
293 | + if ($this->count() > 0) { |
|
294 | + $result=$this->getItem(0)->count(); |
|
295 | + } |
|
289 | 296 | return $result; |
290 | 297 | } |
291 | 298 | |
@@ -309,8 +316,9 @@ discard block |
||
309 | 316 | |
310 | 317 | public function toDelete($rowIndex, $colIndex){ |
311 | 318 | $row=$this->getItem($rowIndex); |
312 | - if (isset($row) === true) |
|
313 | - $row->toDelete($colIndex); |
|
319 | + if (isset($row) === true) { |
|
320 | + $row->toDelete($colIndex); |
|
321 | + } |
|
314 | 322 | return $this; |
315 | 323 | } |
316 | 324 | |
@@ -408,8 +416,9 @@ discard block |
||
408 | 416 | foreach ( $rows as $row ) { |
409 | 417 | $cell=$row->getItem($colIndex); |
410 | 418 | $value=$cell->getContent(); |
411 | - if($functionExists) |
|
412 | - $value=\call_user_func($function,$value); |
|
419 | + if($functionExists) { |
|
420 | + $value=\call_user_func($function,$value); |
|
421 | + } |
|
413 | 422 | if($value!==$identiqual){ |
414 | 423 | if($counter>0 && isset($cellToMerge)){ |
415 | 424 | $cellToMerge->setRowspan($counter); |