@@ -21,8 +21,9 @@ discard block |
||
21 | 21 | $this->widgetIdentifier=$identifier; |
22 | 22 | $this->values=[]; |
23 | 23 | $this->afterCompile=[]; |
24 | - if(isset($instance)) |
|
25 | - $this->setInstance($instance); |
|
24 | + if(isset($instance)) { |
|
25 | + $this->setInstance($instance); |
|
26 | + } |
|
26 | 27 | $this->setCaptions($captions); |
27 | 28 | $this->captionCallback=NULL; |
28 | 29 | $this->defaultValueFunction=function($name,$value){return $value;}; |
@@ -39,11 +40,13 @@ discard block |
||
39 | 40 | } |
40 | 41 | |
41 | 42 | public function getIdentifier($index=NULL){ |
42 | - if(!isset($index)) |
|
43 | - $index=self::$index; |
|
43 | + if(!isset($index)) { |
|
44 | + $index=self::$index; |
|
45 | + } |
|
44 | 46 | $value=$index; |
45 | - if(isset($this->values["identifier"])) |
|
46 | - $value=$this->values["identifier"]($index,$this->instance); |
|
47 | + if(isset($this->values["identifier"])) { |
|
48 | + $value=$this->values["identifier"]($index,$this->instance); |
|
49 | + } |
|
47 | 50 | return $value; |
48 | 51 | } |
49 | 52 | |
@@ -67,19 +70,19 @@ discard block |
||
67 | 70 | $value=$property->getValue($this->instance); |
68 | 71 | if(isset($this->values[$index])){ |
69 | 72 | $value= $this->values[$index]($value,$this->instance,$index); |
70 | - }else{ |
|
73 | + } else{ |
|
71 | 74 | $value=$this->_getDefaultValue($property->getName(),$value, $index); |
72 | 75 | } |
73 | - }else{ |
|
74 | - if(\is_callable($property)) |
|
75 | - $value=$property($this->instance); |
|
76 | - elseif(\is_array($property)){ |
|
76 | + } else{ |
|
77 | + if(\is_callable($property)) { |
|
78 | + $value=$property($this->instance); |
|
79 | + } elseif(\is_array($property)){ |
|
77 | 80 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
78 | 81 | $value=\implode("", $values); |
79 | - }else{ |
|
82 | + } else{ |
|
80 | 83 | if(isset($this->values[$index])){ |
81 | 84 | $value= $this->values[$index]($property,$this->instance,$index); |
82 | - }else{ |
|
85 | + } else{ |
|
83 | 86 | $value=$property; |
84 | 87 | } |
85 | 88 | } |
@@ -102,10 +105,10 @@ discard block |
||
102 | 105 | if(isset($vb[$index])){ |
103 | 106 | if(\is_array($vb[$index])){ |
104 | 107 | $this->visibleProperties[$index][]=$field; |
105 | - }else{ |
|
108 | + } else{ |
|
106 | 109 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
107 | 110 | } |
108 | - }else{ |
|
111 | + } else{ |
|
109 | 112 | return $this->insertField($index, $field); |
110 | 113 | } |
111 | 114 | return $this; |
@@ -132,9 +135,9 @@ discard block |
||
132 | 135 | $property=$this->getProperty($index); |
133 | 136 | if($property instanceof \ReflectionProperty){ |
134 | 137 | $result=$property->getName(); |
135 | - }elseif(\is_callable($property)){ |
|
138 | + } elseif(\is_callable($property)){ |
|
136 | 139 | $result=$this->visibleProperties[$index]; |
137 | - }else{ |
|
140 | + } else{ |
|
138 | 141 | $result=$property; |
139 | 142 | } |
140 | 143 | return $result; |
@@ -154,7 +157,7 @@ discard block |
||
154 | 157 | $this->reflect=new \ReflectionClass($instance); |
155 | 158 | if(\sizeof($this->visibleProperties)===0){ |
156 | 159 | $this->properties=$this->getDefaultProperties(); |
157 | - }else{ |
|
160 | + } else{ |
|
158 | 161 | foreach ($this->visibleProperties as $property){ |
159 | 162 | $this->setInstanceProperty($property); |
160 | 163 | } |
@@ -165,22 +168,23 @@ discard block |
||
165 | 168 | private function setInstanceProperty($property){ |
166 | 169 | if(\is_callable($property)){ |
167 | 170 | $this->properties[]=$property; |
168 | - }elseif(\is_string($property)){ |
|
171 | + } elseif(\is_string($property)){ |
|
169 | 172 | try{ |
170 | 173 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
171 | 174 | $rProperty=$this->reflect->getProperty($property); |
172 | 175 | $this->properties[]=$rProperty; |
173 | - }catch(\Exception $e){ |
|
176 | + } catch(\Exception $e){ |
|
174 | 177 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
175 | 178 | $this->properties[]=$property; |
176 | 179 | } |
177 | - }elseif(\is_int($property)){ |
|
180 | + } elseif(\is_int($property)){ |
|
178 | 181 | $props=$this->getDefaultProperties(); |
179 | - if(isset($props[$property])) |
|
180 | - $this->properties[]=$props[$property]; |
|
181 | - else |
|
182 | - $this->properties[]=$property; |
|
183 | - }else{ |
|
182 | + if(isset($props[$property])) { |
|
183 | + $this->properties[]=$props[$property]; |
|
184 | + } else { |
|
185 | + $this->properties[]=$property; |
|
186 | + } |
|
187 | + } else{ |
|
184 | 188 | $this->properties[]=$property; |
185 | 189 | } |
186 | 190 | } |
@@ -224,12 +228,13 @@ discard block |
||
224 | 228 | if(isset($this->captions[$index])){ |
225 | 229 | return $this->captions[$index]; |
226 | 230 | } |
227 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
228 | - return $this->properties[$index]->getName(); |
|
229 | - elseif(\is_callable($this->properties[$index])) |
|
230 | - return ""; |
|
231 | - else |
|
232 | - return $this->properties[$index]; |
|
231 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
232 | + return $this->properties[$index]->getName(); |
|
233 | + } elseif(\is_callable($this->properties[$index])) { |
|
234 | + return ""; |
|
235 | + } else { |
|
236 | + return $this->properties[$index]; |
|
237 | + } |
|
233 | 238 | } |
234 | 239 | |
235 | 240 | public function getCaptions(){ |
@@ -238,7 +243,7 @@ discard block |
||
238 | 243 | for($i=\sizeof($captions);$i<$this->count();$i++){ |
239 | 244 | $captions[]=""; |
240 | 245 | } |
241 | - }else{ |
|
246 | + } else{ |
|
242 | 247 | $captions=[]; |
243 | 248 | $index=0; |
244 | 249 | $count=$this->count(); |
@@ -254,8 +259,9 @@ discard block |
||
254 | 259 | } |
255 | 260 | |
256 | 261 | public function setCaption($index,$caption){ |
257 | - if(isset($this->captions)===false) |
|
258 | - $this->captions=[]; |
|
262 | + if(isset($this->captions)===false) { |
|
263 | + $this->captions=[]; |
|
264 | + } |
|
259 | 265 | $this->captions[$index]=$caption; |
260 | 266 | return $this; |
261 | 267 | } |
@@ -71,8 +71,9 @@ discard block |
||
71 | 71 | |
72 | 72 | $table->setRowCount(0, \sizeof($captions)); |
73 | 73 | $table->setHeaderValues($captions); |
74 | - if(isset($this->_compileParts)) |
|
75 | - $table->setCompileParts($this->_compileParts); |
|
74 | + if(isset($this->_compileParts)) { |
|
75 | + $table->setCompileParts($this->_compileParts); |
|
76 | + } |
|
76 | 77 | if(isset($this->_searchField) && isset($js)){ |
77 | 78 | $this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
78 | 79 | } |
@@ -175,7 +176,7 @@ discard block |
||
175 | 176 | $hasPart=$table->hasPart($part); |
176 | 177 | if($hasPart){ |
177 | 178 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
178 | - }else{ |
|
179 | + } else{ |
|
179 | 180 | $row=$table->getPart($part)->getRow(0); |
180 | 181 | } |
181 | 182 | $row->mergeCol(); |
@@ -254,8 +255,9 @@ discard block |
||
254 | 255 | */ |
255 | 256 | private function getFieldButton($caption,$visibleHover=true){ |
256 | 257 | $bt= new HtmlButton("",$caption); |
257 | - if($visibleHover) |
|
258 | - $this->_visibleOver($bt); |
|
258 | + if($visibleHover) { |
|
259 | + $this->_visibleOver($bt); |
|
260 | + } |
|
259 | 261 | return $bt; |
260 | 262 | } |
261 | 263 | |
@@ -308,8 +310,9 @@ discard block |
||
308 | 310 | private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
309 | 311 | $bt=$this->getFieldButton("",$visibleHover); |
310 | 312 | $bt->asIcon($icon); |
311 | - if(isset($class)) |
|
312 | - $bt->addToProperty("class", $class); |
|
313 | + if(isset($class)) { |
|
314 | + $bt->addToProperty("class", $class); |
|
315 | + } |
|
313 | 316 | return $bt; |
314 | 317 | } |
315 | 318 |