@@ -35,8 +35,9 @@ discard block |
||
35 | 35 | $name=$attributes["name"]; |
36 | 36 | } |
37 | 37 | $element=$elementCallback($this->_getFieldIdentifier($prefix),$name,$value,""); |
38 | - if(\is_array($attributes)) |
|
39 | - $this->_applyAttributes($element, $attributes,$index); |
|
38 | + if(\is_array($attributes)) { |
|
39 | + $this->_applyAttributes($element, $attributes,$index); |
|
40 | + } |
|
40 | 41 | return $element; |
41 | 42 | }); |
42 | 43 | return $this; |
@@ -70,8 +71,9 @@ discard block |
||
70 | 71 | public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
71 | 72 | return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
72 | 73 | $header=new HtmlHeader($id,$niveau,$value); |
73 | - if(isset($icon)) |
|
74 | - $header->asIcon($icon, $value); |
|
74 | + if(isset($icon)) { |
|
75 | + $header->asIcon($icon, $value); |
|
76 | + } |
|
75 | 77 | return $header; |
76 | 78 | }, $index,$attributes,"header"); |
77 | 79 | } |
@@ -79,7 +81,9 @@ discard block |
||
79 | 81 | |
80 | 82 | public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
81 | 83 | $this->setValueFunction($index,function($img) use($size,$circular){ |
82 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
84 | + $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) { |
|
85 | + $image->setCircular(); |
|
86 | + } |
|
83 | 87 | return $image; |
84 | 88 | }); |
85 | 89 | return $this; |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | $this->widgetIdentifier=$identifier; |
21 | 21 | $this->values=[]; |
22 | 22 | $this->afterCompile=[]; |
23 | - if(isset($instance)) |
|
24 | - $this->setInstance($instance); |
|
23 | + if(isset($instance)) { |
|
24 | + $this->setInstance($instance); |
|
25 | + } |
|
25 | 26 | $this->setCaptions($captions); |
26 | 27 | $this->captionCallback=NULL; |
27 | 28 | } |
@@ -38,8 +39,9 @@ discard block |
||
38 | 39 | |
39 | 40 | public function getIdentifier(){ |
40 | 41 | $value=self::$index; |
41 | - if(isset($this->values["identifier"])) |
|
42 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
42 | + if(isset($this->values["identifier"])) { |
|
43 | + $value=$this->values["identifier"](self::$index,$this->instance); |
|
44 | + } |
|
43 | 45 | return $value; |
44 | 46 | } |
45 | 47 | |
@@ -62,19 +64,19 @@ discard block |
||
62 | 64 | $value=$property->getValue($this->instance); |
63 | 65 | if(isset($this->values[$index])){ |
64 | 66 | $value= $this->values[$index]($value,$this->instance,$index); |
65 | - }else{ |
|
67 | + } else{ |
|
66 | 68 | $value=$this->_getDefaultValue($property->getName(),$value, $index); |
67 | 69 | } |
68 | - }else{ |
|
69 | - if(\is_callable($property)) |
|
70 | - $value=$property($this->instance); |
|
71 | - elseif(\is_array($property)){ |
|
70 | + } else{ |
|
71 | + if(\is_callable($property)) { |
|
72 | + $value=$property($this->instance); |
|
73 | + } elseif(\is_array($property)){ |
|
72 | 74 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
73 | 75 | $value=\implode("", $values); |
74 | - }else{ |
|
76 | + } else{ |
|
75 | 77 | if(isset($this->values[$index])){ |
76 | 78 | $value= $this->values[$index]($property,$this->instance,$index); |
77 | - }else{ |
|
79 | + } else{ |
|
78 | 80 | $value=$property; |
79 | 81 | } |
80 | 82 | } |
@@ -97,10 +99,10 @@ discard block |
||
97 | 99 | if(isset($vb[$index])){ |
98 | 100 | if(\is_array($vb[$index])){ |
99 | 101 | $this->visibleProperties[$index][]=$field; |
100 | - }else{ |
|
102 | + } else{ |
|
101 | 103 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
102 | 104 | } |
103 | - }else{ |
|
105 | + } else{ |
|
104 | 106 | return $this->insertField($index, $field); |
105 | 107 | } |
106 | 108 | return $this; |
@@ -136,26 +138,27 @@ discard block |
||
136 | 138 | $this->reflect=new \ReflectionClass($instance); |
137 | 139 | if(\sizeof($this->visibleProperties)===0){ |
138 | 140 | $this->properties=$this->getDefaultProperties(); |
139 | - }else{ |
|
141 | + } else{ |
|
140 | 142 | foreach ($this->visibleProperties as $property){ |
141 | 143 | if(\is_callable($property)){ |
142 | 144 | $this->properties[]=$property; |
143 | - }elseif(\is_string($property)){ |
|
145 | + } elseif(\is_string($property)){ |
|
144 | 146 | try{ |
145 | 147 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
146 | 148 | $rProperty=$this->reflect->getProperty($property); |
147 | 149 | $this->properties[]=$rProperty; |
148 | - }catch(\Exception $e){ |
|
150 | + } catch(\Exception $e){ |
|
149 | 151 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
150 | 152 | $this->properties[]=$property; |
151 | 153 | } |
152 | - }elseif(\is_int($property)){ |
|
154 | + } elseif(\is_int($property)){ |
|
153 | 155 | $props=$this->getDefaultProperties(); |
154 | - if(isset($props[$property])) |
|
155 | - $this->properties[]=$props[$property]; |
|
156 | - else |
|
157 | - $this->properties[]=$property; |
|
158 | - }else{ |
|
156 | + if(isset($props[$property])) { |
|
157 | + $this->properties[]=$props[$property]; |
|
158 | + } else { |
|
159 | + $this->properties[]=$property; |
|
160 | + } |
|
161 | + } else{ |
|
159 | 162 | $this->properties[]=$property; |
160 | 163 | } |
161 | 164 | } |
@@ -202,12 +205,13 @@ discard block |
||
202 | 205 | if(isset($this->captions[$index])){ |
203 | 206 | return $this->captions[$index]; |
204 | 207 | } |
205 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
206 | - return $this->properties[$index]->getName(); |
|
207 | - elseif(\is_callable($this->properties[$index])) |
|
208 | - return ""; |
|
209 | - else |
|
210 | - return $this->properties[$index]; |
|
208 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
209 | + return $this->properties[$index]->getName(); |
|
210 | + } elseif(\is_callable($this->properties[$index])) { |
|
211 | + return ""; |
|
212 | + } else { |
|
213 | + return $this->properties[$index]; |
|
214 | + } |
|
211 | 215 | } |
212 | 216 | |
213 | 217 | public function getCaptions(){ |
@@ -216,7 +220,7 @@ discard block |
||
216 | 220 | for($i=\sizeof($captions);$i<$this->count();$i++){ |
217 | 221 | $captions[]=""; |
218 | 222 | } |
219 | - }else{ |
|
223 | + } else{ |
|
220 | 224 | $captions=[]; |
221 | 225 | $index=0; |
222 | 226 | $count=$this->count(); |
@@ -232,8 +236,9 @@ discard block |
||
232 | 236 | } |
233 | 237 | |
234 | 238 | public function setCaption($index,$caption){ |
235 | - if(isset($this->captions)===false) |
|
236 | - $this->captions=[]; |
|
239 | + if(isset($this->captions)===false) { |
|
240 | + $this->captions=[]; |
|
241 | + } |
|
237 | 242 | $this->captions[$index]=$caption; |
238 | 243 | return $this; |
239 | 244 | } |