Completed
Push — master ( 18e8f7...34fb15 )
by Jean-Christophe
02:32
created
Ajax/semantic/html/content/table/HtmlTableContent.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  *
12 12
  */
13 13
 class HtmlTableContent extends HtmlSemCollection {
14
-	protected $_tdTagNames=[ "thead" => "th","tbody" => "td","tfoot" => "th" ];
14
+	protected $_tdTagNames=["thead" => "th", "tbody" => "td", "tfoot" => "th"];
15 15
 
16 16
 	/**
17 17
 	 *
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	public function setRowCount($rowCount, $colCount) {
36 36
 		$count=$this->count();
37
-		for($i=$count; $i < $rowCount; $i++) {
37
+		for ($i=$count; $i<$rowCount; $i++) {
38 38
 			$this->addItem($colCount);
39 39
 		}
40 40
 		return $this;
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		$tr=new HtmlTR("", $value);
57 57
 		$tr->setContainer($this, $count);
58 58
 		$tr->setTdTagName($this->_tdTagNames[$this->tagName]);
59
-		if (isset($value) === true) {
59
+		if (isset($value)===true) {
60 60
 			$tr->setColCount($value);
61 61
 		}
62 62
 		return $tr;
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function setCellValue($row, $col, $value="") {
116 116
 		$cell=$this->getCell($row, $col);
117
-		if (isset($cell) === true) {
117
+		if (isset($cell)===true) {
118 118
 			$cell->setValue($value);
119 119
 		}
120 120
 		return $this;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 * @param mixed $values
126 126
 	 */
127 127
 	public function setValues($values=array()) {
128
-		return $this->_addOrSetValues($values, function(HtmlTR $row,$_values){$row->setValues($_values);});
128
+		return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) {$row->setValues($_values); });
129 129
 	}
130 130
 
131 131
 	/**
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @param mixed $values
134 134
 	 */
135 135
 	public function addValues($values=array()) {
136
-		return $this->_addOrSetValues($values, function(HtmlTR $row,$_values){$row->addValues($_values);});
136
+		return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) {$row->addValues($_values); });
137 137
 	}
138 138
 
139 139
 	/**
@@ -141,21 +141,21 @@  discard block
 block discarded – undo
141 141
 	 * @param mixed $values
142 142
 	 * @param callable $callback
143 143
 	 */
144
-	protected function _addOrSetValues($values,$callback) {
144
+	protected function _addOrSetValues($values, $callback) {
145 145
 		$count=$this->count();
146 146
 		$isArray=true;
147 147
 		if (!\is_array($values)) {
148 148
 			$values=\array_fill(0, $count, $values);
149 149
 			$isArray=false;
150 150
 		}
151
-		if (JArray::dimension($values) == 1 && $isArray)
152
-			$values=[ $values ];
151
+		if (JArray::dimension($values)==1 && $isArray)
152
+			$values=[$values];
153 153
 
154 154
 		$count=\min(\sizeof($values), $count);
155 155
 
156
-		for($i=0; $i < $count; $i++) {
156
+		for ($i=0; $i<$count; $i++) {
157 157
 			$row=$this->content[$i];
158
-			$callback($row,$values[$i]);
158
+			$callback($row, $values[$i]);
159 159
 		}
160 160
 		return $this;
161 161
 	}
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 			$values=\array_fill(0, $count, $values);
167 167
 		}
168 168
 		$count=\min(\sizeof($values), $count);
169
-		for($i=0; $i < $count; $i++) {
169
+		for ($i=0; $i<$count; $i++) {
170 170
 			$this->getCell($i, $colIndex)->setValue($values[$i]);
171 171
 		}
172 172
 		return $this;
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
 	public function addColVariations($colIndex, $variations=array()) {
176 176
 		$count=$this->count();
177
-		for($i=0; $i < $count; $i++) {
177
+		for ($i=0; $i<$count; $i++) {
178 178
 			$this->getCell($i, $colIndex)->addVariations($variations);
179 179
 		}
180 180
 		return $this;
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
 
192 192
 	private function colAlign($colIndex, $function) {
193 193
 		$count=$this->count();
194
-		for($i=0; $i < $count; $i++) {
194
+		for ($i=0; $i<$count; $i++) {
195 195
 			$index=$this->content[$i]->getColPosition($colIndex);
196
-			if ($index !== NULL)
196
+			if ($index!==NULL)
197 197
 				$this->getCell($i, $index)->$function();
198 198
 		}
199 199
 		return $this;
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 */
226 226
 	public function getColCount() {
227 227
 		$result=0;
228
-		if ($this->count() > 0)
228
+		if ($this->count()>0)
229 229
 			$result=$this->getItem(0)->count();
230 230
 		return $result;
231 231
 	}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	public function delete($rowIndex, $colIndex=NULL) {
240 240
 		if (isset($colIndex)) {
241 241
 			$row=$this->getItem($rowIndex);
242
-			if (isset($row) === true) {
242
+			if (isset($row)===true) {
243 243
 				$row->delete($colIndex);
244 244
 			}
245 245
 		} else {
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 		return $this;
249 249
 	}
250 250
 
251
-	public function toDelete($rowIndex, $colIndex){
251
+	public function toDelete($rowIndex, $colIndex) {
252 252
 		$row=$this->getItem($rowIndex);
253
-		if (isset($row) === true)
253
+		if (isset($row)===true)
254 254
 			$row->toDelete($colIndex);
255 255
 		return $this;
256 256
 	}
@@ -279,17 +279,17 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	public function conditionalCellFormat($callback, $format) {
281 281
 		$rows=$this->content;
282
-		foreach ( $rows as $row ) {
282
+		foreach ($rows as $row) {
283 283
 			$row->conditionalCellFormat($callback, $format);
284 284
 		}
285 285
 		return $this;
286 286
 	}
287 287
 
288
-	public function conditionalColFormat($colIndex,$callback,$format){
288
+	public function conditionalColFormat($colIndex, $callback, $format) {
289 289
 		$rows=$this->content;
290
-		foreach ( $rows as $row ) {
290
+		foreach ($rows as $row) {
291 291
 			$cell=$row->getItem($colIndex);
292
-			$cell->conditionnalCellFormat($callback,$format);
292
+			$cell->conditionnalCellFormat($callback, $format);
293 293
 		}
294 294
 		return $this;
295 295
 	}
@@ -301,17 +301,17 @@  discard block
 block discarded – undo
301 301
 	 */
302 302
 	public function conditionalRowFormat($callback, $format) {
303 303
 		$rows=$this->content;
304
-		foreach ( $rows as $row ) {
304
+		foreach ($rows as $row) {
305 305
 			$row->conditionalRowFormat($callback, $format);
306 306
 		}
307 307
 		return $this;
308 308
 	}
309 309
 
310
-	public function hideColumn($colIndex){
310
+	public function hideColumn($colIndex) {
311 311
 		$rows=$this->content;
312
-		foreach ( $rows as $row ) {
312
+		foreach ($rows as $row) {
313 313
 			$cell=$row->getItem($colIndex);
314
-			$cell->addToProperty("style","display:none;");
314
+			$cell->addToProperty("style", "display:none;");
315 315
 		}
316 316
 		return $this;
317 317
 	}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 */
323 323
 	public function applyCells($callback) {
324 324
 		$rows=$this->content;
325
-		foreach ( $rows as $row ) {
325
+		foreach ($rows as $row) {
326 326
 			$row->applyCells($callback);
327 327
 		}
328 328
 		return $this;
@@ -334,25 +334,25 @@  discard block
 block discarded – undo
334 334
 	 */
335 335
 	public function applyRows($callback) {
336 336
 		$rows=$this->content;
337
-		foreach ( $rows as $row ) {
337
+		foreach ($rows as $row) {
338 338
 			$row->apply($callback);
339 339
 		}
340 340
 		return $this;
341 341
 	}
342 342
 
343
-	public function mergeIdentiqualValues($colIndex,$function="strip_tags"){
343
+	public function mergeIdentiqualValues($colIndex, $function="strip_tags") {
344 344
 		$rows=$this->content;
345 345
 		$identiqual=null;
346 346
 		$counter=0;
347 347
 		$cellToMerge=null;
348 348
 		$functionExists=\function_exists($function);
349
-		foreach ( $rows as $row ) {
349
+		foreach ($rows as $row) {
350 350
 			$cell=$row->getItem($colIndex);
351 351
 			$value=$cell->getContent();
352
-			if($functionExists)
353
-				$value=\call_user_func($function,$value);
354
-			if($value!==$identiqual){
355
-				if($counter>0 && isset($cellToMerge)){
352
+			if ($functionExists)
353
+				$value=\call_user_func($function, $value);
354
+			if ($value!==$identiqual) {
355
+				if ($counter>0 && isset($cellToMerge)) {
356 356
 					$cellToMerge->setRowspan($counter);
357 357
 				}
358 358
 				$counter=0;
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 			}
362 362
 			$counter++;
363 363
 		}
364
-		if($counter>0 && isset($cellToMerge)){
364
+		if ($counter>0 && isset($cellToMerge)) {
365 365
 			$cellToMerge->setRowspan($counter);
366 366
 		}
367 367
 		return $this;
Please login to merge, or discard this patch.