@@ -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 | |
@@ -66,7 +69,7 @@ discard block |
||
| 66 | 69 | $value=$property->getValue($this->instance); |
| 67 | 70 | if(isset($this->values[$index])){ |
| 68 | 71 | $value= $this->values[$index]($value,$this->instance,$index); |
| 69 | - }else{ |
|
| 72 | + } else{ |
|
| 70 | 73 | $value=$this->_getDefaultValue($property->getName(),$value, $index); |
| 71 | 74 | } |
| 72 | 75 | return $value; |
@@ -76,16 +79,16 @@ discard block |
||
| 76 | 79 | $value=null; |
| 77 | 80 | if($property instanceof \ReflectionProperty){ |
| 78 | 81 | $value=$this->_getPropertyValue($property, $index); |
| 79 | - }else{ |
|
| 80 | - if(\is_callable($property)) |
|
| 81 | - $value=$property($this->instance); |
|
| 82 | - elseif(\is_array($property)){ |
|
| 82 | + } else{ |
|
| 83 | + if(\is_callable($property)) { |
|
| 84 | + $value=$property($this->instance); |
|
| 85 | + } elseif(\is_array($property)){ |
|
| 83 | 86 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
| 84 | 87 | $value=\implode("", $values); |
| 85 | - }else{ |
|
| 88 | + } else{ |
|
| 86 | 89 | if(isset($this->values[$index])){ |
| 87 | 90 | $value= $this->values[$index]($property,$this->instance,$index); |
| 88 | - }elseif(isset($this->instance->{$property})){ |
|
| 91 | + } elseif(isset($this->instance->{$property})){ |
|
| 89 | 92 | $value=$this->instance->{$property}; |
| 90 | 93 | } |
| 91 | 94 | } |
@@ -108,10 +111,10 @@ discard block |
||
| 108 | 111 | if(isset($vb[$index])){ |
| 109 | 112 | if(\is_array($vb[$index])){ |
| 110 | 113 | $this->visibleProperties[$index][]=$field; |
| 111 | - }else{ |
|
| 114 | + } else{ |
|
| 112 | 115 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
| 113 | 116 | } |
| 114 | - }else{ |
|
| 117 | + } else{ |
|
| 115 | 118 | return $this->insertField($index, $field); |
| 116 | 119 | } |
| 117 | 120 | return $this; |
@@ -138,9 +141,9 @@ discard block |
||
| 138 | 141 | $property=$this->getProperty($index); |
| 139 | 142 | if($property instanceof \ReflectionProperty){ |
| 140 | 143 | $result=$property->getName(); |
| 141 | - }elseif(\is_callable($property)){ |
|
| 144 | + } elseif(\is_callable($property)){ |
|
| 142 | 145 | $result=$this->visibleProperties[$index]; |
| 143 | - }else{ |
|
| 146 | + } else{ |
|
| 144 | 147 | $result=$property; |
| 145 | 148 | } |
| 146 | 149 | return $result; |
@@ -160,7 +163,7 @@ discard block |
||
| 160 | 163 | $this->reflect=new \ReflectionClass($instance); |
| 161 | 164 | if(\sizeof($this->visibleProperties)===0){ |
| 162 | 165 | $this->properties=$this->getDefaultProperties(); |
| 163 | - }else{ |
|
| 166 | + } else{ |
|
| 164 | 167 | foreach ($this->visibleProperties as $property){ |
| 165 | 168 | $this->setInstanceProperty($property); |
| 166 | 169 | } |
@@ -171,22 +174,23 @@ discard block |
||
| 171 | 174 | private function setInstanceProperty($property){ |
| 172 | 175 | if(\is_callable($property)){ |
| 173 | 176 | $this->properties[]=$property; |
| 174 | - }elseif(\is_string($property)){ |
|
| 177 | + } elseif(\is_string($property)){ |
|
| 175 | 178 | try{ |
| 176 | 179 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 177 | 180 | $rProperty=$this->reflect->getProperty($property); |
| 178 | 181 | $this->properties[]=$rProperty; |
| 179 | - }catch(\Exception $e){ |
|
| 182 | + } catch(\Exception $e){ |
|
| 180 | 183 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 181 | 184 | $this->properties[]=$property; |
| 182 | 185 | } |
| 183 | - }elseif(\is_int($property)){ |
|
| 186 | + } elseif(\is_int($property)){ |
|
| 184 | 187 | $props=$this->getDefaultProperties(); |
| 185 | - if(isset($props[$property])) |
|
| 186 | - $this->properties[]=$props[$property]; |
|
| 187 | - else |
|
| 188 | - $this->properties[]=$property; |
|
| 189 | - }else{ |
|
| 188 | + if(isset($props[$property])) { |
|
| 189 | + $this->properties[]=$props[$property]; |
|
| 190 | + } else { |
|
| 191 | + $this->properties[]=$property; |
|
| 192 | + } |
|
| 193 | + } else{ |
|
| 190 | 194 | $this->properties[]=$property; |
| 191 | 195 | } |
| 192 | 196 | } |
@@ -230,12 +234,13 @@ discard block |
||
| 230 | 234 | if(isset($this->captions[$index])){ |
| 231 | 235 | return $this->captions[$index]; |
| 232 | 236 | } |
| 233 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 234 | - return $this->properties[$index]->getName(); |
|
| 235 | - elseif(\is_callable($this->properties[$index])) |
|
| 236 | - return ""; |
|
| 237 | - else |
|
| 238 | - return $this->properties[$index]; |
|
| 237 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
| 238 | + return $this->properties[$index]->getName(); |
|
| 239 | + } elseif(\is_callable($this->properties[$index])) { |
|
| 240 | + return ""; |
|
| 241 | + } else { |
|
| 242 | + return $this->properties[$index]; |
|
| 243 | + } |
|
| 239 | 244 | } |
| 240 | 245 | |
| 241 | 246 | public function getCaptions(){ |
@@ -244,7 +249,7 @@ discard block |
||
| 244 | 249 | for($i=\sizeof($captions);$i<$this->count();$i++){ |
| 245 | 250 | $captions[]=""; |
| 246 | 251 | } |
| 247 | - }else{ |
|
| 252 | + } else{ |
|
| 248 | 253 | $captions=[]; |
| 249 | 254 | $index=0; |
| 250 | 255 | $count=$this->count(); |
@@ -260,8 +265,9 @@ discard block |
||
| 260 | 265 | } |
| 261 | 266 | |
| 262 | 267 | public function setCaption($index,$caption){ |
| 263 | - if(isset($this->captions)===false) |
|
| 264 | - $this->captions=[]; |
|
| 268 | + if(isset($this->captions)===false) { |
|
| 269 | + $this->captions=[]; |
|
| 270 | + } |
|
| 265 | 271 | $this->captions[$index]=$caption; |
| 266 | 272 | return $this; |
| 267 | 273 | } |