@@ -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 | } |
@@ -217,8 +220,9 @@ discard block |
||
217 | 220 | $count=$this->count(); |
218 | 221 | for($i=0; $i < $count; $i++) { |
219 | 222 | $index=$this->content[$i]->getColPosition($colIndex); |
220 | - if ($index !== NULL) |
|
221 | - $this->getCell($i, $index)->$function(); |
|
223 | + if ($index !== NULL) { |
|
224 | + $this->getCell($i, $index)->$function(); |
|
225 | + } |
|
222 | 226 | } |
223 | 227 | return $this; |
224 | 228 | } |
@@ -229,8 +233,9 @@ discard block |
||
229 | 233 | $maxRow=$this->content[$i]->count(); |
230 | 234 | $index=$maxRow-$colIndex-1; |
231 | 235 | if (($cell=$this->getCell($i, $index))!== NULL){ |
232 | - if($cell->getColspan()==1) |
|
233 | - $cell->$function(); |
|
236 | + if($cell->getColspan()==1) { |
|
237 | + $cell->$function(); |
|
238 | + } |
|
234 | 239 | } |
235 | 240 | } |
236 | 241 | return $this; |
@@ -274,8 +279,9 @@ discard block |
||
274 | 279 | */ |
275 | 280 | public function getColCount() { |
276 | 281 | $result=0; |
277 | - if ($this->count() > 0) |
|
278 | - $result=$this->getItem(0)->count(); |
|
282 | + if ($this->count() > 0) { |
|
283 | + $result=$this->getItem(0)->count(); |
|
284 | + } |
|
279 | 285 | return $result; |
280 | 286 | } |
281 | 287 | |
@@ -299,8 +305,9 @@ discard block |
||
299 | 305 | |
300 | 306 | public function toDelete($rowIndex, $colIndex){ |
301 | 307 | $row=$this->getItem($rowIndex); |
302 | - if (isset($row) === true) |
|
303 | - $row->toDelete($colIndex); |
|
308 | + if (isset($row) === true) { |
|
309 | + $row->toDelete($colIndex); |
|
310 | + } |
|
304 | 311 | return $this; |
305 | 312 | } |
306 | 313 | |
@@ -398,8 +405,9 @@ discard block |
||
398 | 405 | foreach ( $rows as $row ) { |
399 | 406 | $cell=$row->getItem($colIndex); |
400 | 407 | $value=$cell->getContent(); |
401 | - if($functionExists) |
|
402 | - $value=\call_user_func($function,$value); |
|
408 | + if($functionExists) { |
|
409 | + $value=\call_user_func($function,$value); |
|
410 | + } |
|
403 | 411 | if($value!==$identiqual){ |
404 | 412 | if($counter>0 && isset($cellToMerge)){ |
405 | 413 | $cellToMerge->setRowspan($counter); |
@@ -59,8 +59,9 @@ |
||
59 | 59 | $callback.=$js->trigger("#".$id." [name='selection[]']","change",false)."$('#".$id." tbody .ui.checkbox').checkbox();".$js->execOn("change", "#".$id." [name='selection[]']", $this->_getCheckedChange($js)); |
60 | 60 | $callback.=$this->_generatePaginationScript($id); |
61 | 61 | if(isset($this->_urls["refresh"])){ |
62 | - if(isset($menu)) |
|
63 | - $js->jsonArrayOn("click", "#".$menu->getIdentifier()." a","#".$this->_identifier." tr.".$this->_modelClass, $this->_urls["refresh"],"post",["params"=>"{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model)."'}","jsCallback"=>$callback]); |
|
62 | + if(isset($menu)) { |
|
63 | + $js->jsonArrayOn("click", "#".$menu->getIdentifier()." a","#".$this->_identifier." tr.".$this->_modelClass, $this->_urls["refresh"],"post",["params"=>"{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model)."'}","jsCallback"=>$callback]); |
|
64 | + } |
|
64 | 65 | } |
65 | 66 | } |
66 | 67 |
@@ -60,16 +60,19 @@ discard block |
||
60 | 60 | $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
61 | 61 | $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
62 | 62 | } |
63 | - if(\is_array($this->_deleteBehavior)) |
|
64 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
65 | - if(\is_array($this->_editBehavior)) |
|
66 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
63 | + if(\is_array($this->_deleteBehavior)) { |
|
64 | + $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
65 | + } |
|
66 | + if(\is_array($this->_editBehavior)) { |
|
67 | + $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
68 | + } |
|
67 | 69 | if(\is_array($this->_displayBehavior)){ |
68 | 70 | $this->_generateBehavior("display",$this->_displayBehavior,$js); |
69 | 71 | } |
70 | 72 | parent::run($js); |
71 | - if(isset($this->_pagination)) |
|
72 | - $this->_associatePaginationBehavior($js,$offset); |
|
73 | + if(isset($this->_pagination)) { |
|
74 | + $this->_associatePaginationBehavior($js,$offset); |
|
75 | + } |
|
73 | 76 | $this->_associateSearchFieldBehavior($js,$offset); |
74 | 77 | |
75 | 78 | } |
@@ -104,8 +107,9 @@ discard block |
||
104 | 107 | $table->setRowCount(0, \sizeof($captions)); |
105 | 108 | $this->_generateHeader($table,$captions); |
106 | 109 | |
107 | - if(isset($this->_compileParts)) |
|
108 | - $table->setCompileParts($this->_compileParts); |
|
110 | + if(isset($this->_compileParts)) { |
|
111 | + $table->setCompileParts($this->_compileParts); |
|
112 | + } |
|
109 | 113 | |
110 | 114 | $this->_generateContent($table); |
111 | 115 | |
@@ -135,8 +139,9 @@ discard block |
||
135 | 139 | } |
136 | 140 | |
137 | 141 | protected function _applyStyleAttributes($table){ |
138 | - if(isset($this->_hiddenColumns)) |
|
139 | - $this->_hideColumns(); |
|
142 | + if(isset($this->_hiddenColumns)) { |
|
143 | + $this->_hideColumns(); |
|
144 | + } |
|
140 | 145 | if(isset($this->_colWidths)){ |
141 | 146 | foreach ($this->_colWidths as $colIndex=>$width){ |
142 | 147 | $table->setColWidth($colIndex,$width); |
@@ -171,7 +176,7 @@ discard block |
||
171 | 176 | $table->fromDatabaseObjects($objects, function($instance) use($table,$fields){ |
172 | 177 | return $this->_generateRow($instance, $fields,$table); |
173 | 178 | }); |
174 | - }else{ |
|
179 | + } else{ |
|
175 | 180 | $groupByFields=$this->_instanceViewer->getGroupByFields(); |
176 | 181 | $activeValues=array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null)); |
177 | 182 | $uuids=[]; |
@@ -234,8 +239,9 @@ discard block |
||
234 | 239 | $field=$ck->getField(); |
235 | 240 | $field->setProperty("value",$dataAjax); |
236 | 241 | $field->setProperty("name", "selection[]"); |
237 | - if(isset($checkedClass)) |
|
238 | - $field->setClass($checkedClass); |
|
242 | + if(isset($checkedClass)) { |
|
243 | + $field->setClass($checkedClass); |
|
244 | + } |
|
239 | 245 | \array_unshift($values, $ck); |
240 | 246 | } |
241 | 247 | $result=$table->newRow(); |
@@ -252,8 +258,9 @@ discard block |
||
252 | 258 | |
253 | 259 | protected function _generatePagination($table){ |
254 | 260 | if(isset($this->_toolbar)){ |
255 | - if($this->_toolbarPosition==PositionInTable::FOOTER) |
|
256 | - $this->_toolbar->setFloated("left"); |
|
261 | + if($this->_toolbarPosition==PositionInTable::FOOTER) { |
|
262 | + $this->_toolbar->setFloated("left"); |
|
263 | + } |
|
257 | 264 | } |
258 | 265 | $footer=$table->getFooter(); |
259 | 266 | $footer->mergeCol(); |
@@ -277,8 +284,9 @@ discard block |
||
277 | 284 | |
278 | 285 | protected function _getFieldName($index){ |
279 | 286 | $fieldName=parent::_getFieldName($index); |
280 | - if(\is_object($fieldName)) |
|
281 | - $fieldName="field-".$index; |
|
287 | + if(\is_object($fieldName)) { |
|
288 | + $fieldName="field-".$index; |
|
289 | + } |
|
282 | 290 | return $fieldName."[]"; |
283 | 291 | } |
284 | 292 | |
@@ -318,7 +326,7 @@ discard block |
||
318 | 326 | $hasPart=$table->hasPart($part); |
319 | 327 | if($hasPart){ |
320 | 328 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
321 | - }else{ |
|
329 | + } else{ |
|
322 | 330 | $row=$table->getPart($part)->getRow(0); |
323 | 331 | } |
324 | 332 | $row->mergeCol(); |
@@ -350,7 +358,7 @@ discard block |
||
350 | 358 | $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
351 | 359 | $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
352 | 360 | $this->_urls["display"]=JArray::getValue($urls, "display",3); |
353 | - }else{ |
|
361 | + } else{ |
|
354 | 362 | $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls,"display"=>$urls]; |
355 | 363 | } |
356 | 364 | return $this; |
@@ -433,8 +441,9 @@ discard block |
||
433 | 441 | |
434 | 442 | protected function getTargetSelector($op) { |
435 | 443 | $result=$this->_targetSelector; |
436 | - if(!isset($result[$op])) |
|
437 | - $result="#".$this->identifier; |
|
444 | + if(!isset($result[$op])) { |
|
445 | + $result="#".$this->identifier; |
|
446 | + } |
|
438 | 447 | return $result[$op]; |
439 | 448 | } |
440 | 449 | |
@@ -452,8 +461,9 @@ discard block |
||
452 | 461 | } |
453 | 462 | |
454 | 463 | public function getRefreshSelector() { |
455 | - if(isset($this->_refreshSelector)) |
|
456 | - return $this->_refreshSelector; |
|
464 | + if(isset($this->_refreshSelector)) { |
|
465 | + return $this->_refreshSelector; |
|
466 | + } |
|
457 | 467 | return "#".$this->identifier." tbody"; |
458 | 468 | } |
459 | 469 | |
@@ -472,8 +482,9 @@ discard block |
||
472 | 482 | */ |
473 | 483 | public function show($modelInstance){ |
474 | 484 | if(\is_array($modelInstance)){ |
475 | - if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
|
476 | - $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
485 | + if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) { |
|
486 | + $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
487 | + } |
|
477 | 488 | } |
478 | 489 | $this->_modelInstance=$modelInstance; |
479 | 490 | } |
@@ -513,8 +524,9 @@ discard block |
||
513 | 524 | } |
514 | 525 | |
515 | 526 | public function hideColumn($colIndex){ |
516 | - if(!\is_array($this->_hiddenColumns)) |
|
517 | - $this->_hiddenColumns=[]; |
|
527 | + if(!\is_array($this->_hiddenColumns)) { |
|
528 | + $this->_hiddenColumns=[]; |
|
529 | + } |
|
518 | 530 | $this->_hiddenColumns[]=$colIndex; |
519 | 531 | return $this; |
520 | 532 | } |
@@ -24,8 +24,9 @@ discard block |
||
24 | 24 | $this->widgetIdentifier=$identifier; |
25 | 25 | $this->values=[]; |
26 | 26 | $this->afterCompile=[]; |
27 | - if(isset($instance)) |
|
28 | - $this->setInstance($instance); |
|
27 | + if(isset($instance)) { |
|
28 | + $this->setInstance($instance); |
|
29 | + } |
|
29 | 30 | $this->setCaptions($captions); |
30 | 31 | $this->captionCallback=NULL; |
31 | 32 | $this->defaultValueFunction=function($name,$value){return $value;}; |
@@ -61,7 +62,7 @@ discard block |
||
61 | 62 | while($index<$count){ |
62 | 63 | $values[]=$this->getValue($index++); |
63 | 64 | } |
64 | - }else{ |
|
65 | + } else{ |
|
65 | 66 | while($index<$count){ |
66 | 67 | if(array_search($index, $this->groupByFields)===false){ |
67 | 68 | $values[]=$this->getValue($index); |
@@ -73,14 +74,16 @@ discard block |
||
73 | 74 | } |
74 | 75 | |
75 | 76 | public function getIdentifier($index=NULL){ |
76 | - if(!isset($index)) |
|
77 | - $index=self::$index; |
|
77 | + if(!isset($index)) { |
|
78 | + $index=self::$index; |
|
79 | + } |
|
78 | 80 | $value=$index; |
79 | 81 | if(isset($this->values["identifier"])){ |
80 | - if(\is_string($this->values["identifier"])) |
|
81 | - $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
82 | - else |
|
83 | - $value=$this->values["identifier"]($index,$this->instance); |
|
82 | + if(\is_string($this->values["identifier"])) { |
|
83 | + $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
84 | + } else { |
|
85 | + $value=$this->values["identifier"]($index,$this->instance); |
|
86 | + } |
|
84 | 87 | } |
85 | 88 | return $value; |
86 | 89 | } |
@@ -110,16 +113,16 @@ discard block |
||
110 | 113 | if($property instanceof \ReflectionProperty){ |
111 | 114 | $value=$this->_getPropertyValue($property); |
112 | 115 | $propertyName=$property->getName(); |
113 | - }elseif(\is_callable($property) && array_search($property, ["system"])===false) |
|
114 | - $value=$property($this->instance); |
|
115 | - elseif(\is_array($property)){ |
|
116 | + } elseif(\is_callable($property) && array_search($property, ["system"])===false) { |
|
117 | + $value=$property($this->instance); |
|
118 | + } elseif(\is_array($property)){ |
|
116 | 119 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
117 | 120 | $value=\implode("", $values); |
118 | - }elseif(\is_string($property)){ |
|
121 | + } elseif(\is_string($property)){ |
|
119 | 122 | $value=$property; |
120 | 123 | if(isset($this->instance->{$property})){ |
121 | 124 | $value=$this->instance->{$property}; |
122 | - }elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){ |
|
125 | + } elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){ |
|
123 | 126 | $value=JReflection::callMethod($this->instance, $getter, []); |
124 | 127 | } |
125 | 128 | } |
@@ -129,7 +132,7 @@ discard block |
||
129 | 132 | protected function _postGetValue($index,$propertyName,$value){ |
130 | 133 | if(isset($this->values[$index])){ |
131 | 134 | $value= $this->values[$index]($value,$this->instance,$index,self::$index); |
132 | - }else{ |
|
135 | + } else{ |
|
133 | 136 | $value=$this->_getDefaultValue($propertyName,$value, $index); |
134 | 137 | } |
135 | 138 | if(isset($this->afterCompile[$index])){ |
@@ -143,7 +146,7 @@ discard block |
||
143 | 146 | public function insertField($index,$field,$key=null){ |
144 | 147 | if(isset($key)){ |
145 | 148 | array_splice( $this->visibleProperties, $index, 0, [$key=>$field] ); |
146 | - }else{ |
|
149 | + } else{ |
|
147 | 150 | array_splice( $this->visibleProperties, $index, 0, $field ); |
148 | 151 | } |
149 | 152 | return $this; |
@@ -164,17 +167,17 @@ discard block |
||
164 | 167 | if(isset($key)){ |
165 | 168 | if(\is_array($vb[$index])){ |
166 | 169 | $this->visibleProperties[$index][$key]=$field; |
167 | - }else{ |
|
170 | + } else{ |
|
168 | 171 | $this->visibleProperties[$index]=[$vb[$index],$key=>$field]; |
169 | 172 | } |
170 | - }else{ |
|
173 | + } else{ |
|
171 | 174 | if(\is_array($vb[$index])){ |
172 | 175 | $this->visibleProperties[$index][]=$field; |
173 | - }else{ |
|
176 | + } else{ |
|
174 | 177 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
175 | 178 | } |
176 | 179 | } |
177 | - }else{ |
|
180 | + } else{ |
|
178 | 181 | return $this->insertField($index, $field); |
179 | 182 | } |
180 | 183 | return $this; |
@@ -183,7 +186,7 @@ discard block |
||
183 | 186 | public function addField($field,$key=null){ |
184 | 187 | if(isset($key)){ |
185 | 188 | $this->visibleProperties[]=[$key=>$field]; |
186 | - }else{ |
|
189 | + } else{ |
|
187 | 190 | $this->visibleProperties[]=$field; |
188 | 191 | } |
189 | 192 | return $this; |
@@ -210,9 +213,9 @@ discard block |
||
210 | 213 | $property=$this->getProperty($index); |
211 | 214 | if($property instanceof \ReflectionProperty){ |
212 | 215 | $result=$property->getName(); |
213 | - }elseif(\is_callable($property)){ |
|
216 | + } elseif(\is_callable($property)){ |
|
214 | 217 | $result=$this->visibleProperties[$index]; |
215 | - }else{ |
|
218 | + } else{ |
|
216 | 219 | $result=$property; |
217 | 220 | } |
218 | 221 | return $result; |
@@ -232,7 +235,7 @@ discard block |
||
232 | 235 | $this->reflect=new \ReflectionClass($instance); |
233 | 236 | if(JArray::count($this->visibleProperties)===0){ |
234 | 237 | $this->properties=$this->getDefaultProperties(); |
235 | - }else{ |
|
238 | + } else{ |
|
236 | 239 | foreach ($this->visibleProperties as $property){ |
237 | 240 | $this->setInstanceProperty($property); |
238 | 241 | } |
@@ -243,22 +246,23 @@ discard block |
||
243 | 246 | private function setInstanceProperty($property){ |
244 | 247 | if(\is_callable($property)){ |
245 | 248 | $this->properties[]=$property; |
246 | - }elseif(\is_string($property)){ |
|
249 | + } elseif(\is_string($property)){ |
|
247 | 250 | try{ |
248 | 251 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
249 | 252 | $rProperty=$this->reflect->getProperty($property); |
250 | 253 | $this->properties[]=$rProperty; |
251 | - }catch(\Exception $e){ |
|
254 | + } catch(\Exception $e){ |
|
252 | 255 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
253 | 256 | $this->properties[]=$property; |
254 | 257 | } |
255 | - }elseif(\is_int($property)){ |
|
258 | + } elseif(\is_int($property)){ |
|
256 | 259 | $props=$this->getDefaultProperties(); |
257 | - if(isset($props[$property])) |
|
258 | - $this->properties[]=$props[$property]; |
|
259 | - else |
|
260 | - $this->properties[]=$property; |
|
261 | - }else{ |
|
260 | + if(isset($props[$property])) { |
|
261 | + $this->properties[]=$props[$property]; |
|
262 | + } else { |
|
263 | + $this->properties[]=$property; |
|
264 | + } |
|
265 | + } else{ |
|
262 | 266 | $this->properties[]=$property; |
263 | 267 | } |
264 | 268 | } |
@@ -302,12 +306,13 @@ discard block |
||
302 | 306 | if(isset($this->captions[$index])){ |
303 | 307 | return $this->captions[$index]; |
304 | 308 | } |
305 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
306 | - return $this->properties[$index]->getName(); |
|
307 | - elseif(\is_callable($this->properties[$index])) |
|
308 | - return ""; |
|
309 | - else |
|
310 | - return $this->properties[$index]; |
|
309 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
310 | + return $this->properties[$index]->getName(); |
|
311 | + } elseif(\is_callable($this->properties[$index])) { |
|
312 | + return ""; |
|
313 | + } else { |
|
314 | + return $this->properties[$index]; |
|
315 | + } |
|
311 | 316 | } |
312 | 317 | |
313 | 318 | public function getCaptions(){ |
@@ -319,14 +324,14 @@ discard block |
||
319 | 324 | for($i=$captionsSize;$i<$count;$i++){ |
320 | 325 | $captions[]=""; |
321 | 326 | } |
322 | - }else{ |
|
327 | + } else{ |
|
323 | 328 | $captions=[]; |
324 | 329 | $index=0; |
325 | 330 | if(!$hasGroupby){ |
326 | 331 | while($index<$count){ |
327 | 332 | $captions[]=$this->getCaption($index++); |
328 | 333 | } |
329 | - }else{ |
|
334 | + } else{ |
|
330 | 335 | while($index<$count){ |
331 | 336 | if($hasGroupby && array_search($index, $this->groupByFields)===false){ |
332 | 337 | $captions[]=$this->getCaption($index); |
@@ -343,8 +348,9 @@ discard block |
||
343 | 348 | } |
344 | 349 | |
345 | 350 | public function setCaption($index,$caption){ |
346 | - if(isset($this->captions)===false) |
|
347 | - $this->captions=[]; |
|
351 | + if(isset($this->captions)===false) { |
|
352 | + $this->captions=[]; |
|
353 | + } |
|
348 | 354 | $this->captions[$index]=$caption; |
349 | 355 | return $this; |
350 | 356 | } |
@@ -29,15 +29,17 @@ discard block |
||
29 | 29 | |
30 | 30 | public function addContent($content,$before=false) { |
31 | 31 | if (!\is_array($this->content)) { |
32 | - if(isset($this->content)) |
|
33 | - $this->content=array ($this->content); |
|
34 | - else |
|
35 | - $this->content=array(); |
|
32 | + if(isset($this->content)) { |
|
33 | + $this->content=array ($this->content); |
|
34 | + } else { |
|
35 | + $this->content=array(); |
|
36 | + } |
|
37 | + } |
|
38 | + if($before) { |
|
39 | + array_unshift($this->content,$content); |
|
40 | + } else { |
|
41 | + $this->content []=$content; |
|
36 | 42 | } |
37 | - if($before) |
|
38 | - array_unshift($this->content,$content); |
|
39 | - else |
|
40 | - $this->content []=$content; |
|
41 | 43 | return $this; |
42 | 44 | } |
43 | 45 | |
@@ -75,9 +77,9 @@ discard block |
||
75 | 77 | $instances=[]; |
76 | 78 | if($content instanceof $class){ |
77 | 79 | $instances[]=$content; |
78 | - }elseif($content instanceof HtmlDoubleElement){ |
|
80 | + } elseif($content instanceof HtmlDoubleElement){ |
|
79 | 81 | $instances=\array_merge($instances,$content->getContentInstances($class)); |
80 | - }elseif (\is_array($content)){ |
|
82 | + } elseif (\is_array($content)){ |
|
81 | 83 | foreach ($content as $element){ |
82 | 84 | $instances=\array_merge($instances,$this->_getContentInstances($class, $element)); |
83 | 85 | } |
@@ -90,10 +92,12 @@ discard block |
||
90 | 92 | * @return HtmlDoubleElement |
91 | 93 | */ |
92 | 94 | public function asLink($href=NULL,$target=NULL) { |
93 | - if (isset($href)) |
|
94 | - $this->setProperty("href", $href); |
|
95 | - if(isset($target)) |
|
96 | - $this->setProperty("target", $target); |
|
95 | + if (isset($href)) { |
|
96 | + $this->setProperty("href", $href); |
|
97 | + } |
|
98 | + if(isset($target)) { |
|
99 | + $this->setProperty("target", $target); |
|
100 | + } |
|
97 | 101 | return $this->setTagName("a"); |
98 | 102 | } |
99 | 103 |