@@ -41,6 +41,10 @@ discard block |
||
| 41 | 41 | parent::run($js); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | + /** |
|
| 45 | + * @param string $identifier |
|
| 46 | + * @param string $model |
|
| 47 | + */ |
|
| 44 | 48 | public function __construct($identifier,$model,$modelInstance=NULL) { |
| 45 | 49 | parent::__construct($identifier, $model,$modelInstance); |
| 46 | 50 | $this->_instanceViewer=new InstanceViewerCaption(); |
@@ -143,6 +147,9 @@ discard block |
||
| 143 | 147 | return $this; |
| 144 | 148 | } |
| 145 | 149 | |
| 150 | + /** |
|
| 151 | + * @param PositionInTable $part |
|
| 152 | + */ |
|
| 146 | 153 | private function addToolbarRow($part,$table,$captions){ |
| 147 | 154 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 148 | 155 | $row->mergeCol(); |
@@ -168,16 +175,26 @@ discard block |
||
| 168 | 175 | return $this; |
| 169 | 176 | } |
| 170 | 177 | |
| 178 | + /** |
|
| 179 | + * @param \Closure $field |
|
| 180 | + */ |
|
| 171 | 181 | public function addField($field){ |
| 172 | 182 | $this->_instanceViewer->addField($field); |
| 173 | 183 | return $this; |
| 174 | 184 | } |
| 175 | 185 | |
| 186 | + /** |
|
| 187 | + * @param integer $index |
|
| 188 | + * @param \Closure $field |
|
| 189 | + */ |
|
| 176 | 190 | public function insertField($index,$field){ |
| 177 | 191 | $this->_instanceViewer->insertField($index, $field); |
| 178 | 192 | return $this; |
| 179 | 193 | } |
| 180 | 194 | |
| 195 | + /** |
|
| 196 | + * @param \Closure $field |
|
| 197 | + */ |
|
| 181 | 198 | public function insertInField($index,$field){ |
| 182 | 199 | $this->_instanceViewer->insertInField($index, $field); |
| 183 | 200 | return $this; |
@@ -226,16 +243,17 @@ discard block |
||
| 226 | 243 | /** |
| 227 | 244 | * @param string $caption |
| 228 | 245 | * @param callable $callback |
| 229 | - * @return callable |
|
| 246 | + * @return \Closure |
|
| 230 | 247 | */ |
| 231 | 248 | private function getFieldButtonCallable($caption,$callback=null){ |
| 232 | 249 | return $this->getCallable("getFieldButton",[$caption],$callback); |
| 233 | 250 | } |
| 234 | 251 | |
| 235 | 252 | /** |
| 236 | - * @param mixed $object |
|
| 237 | 253 | * @param callable $callback |
| 238 | - * @return callable |
|
| 254 | + * @param string $thisCallback |
|
| 255 | + * @param string[] $parameters |
|
| 256 | + * @return \Closure |
|
| 239 | 257 | */ |
| 240 | 258 | private function getCallable($thisCallback,$parameters,$callback=null){ |
| 241 | 259 | $result=function($instance) use($thisCallback,$parameters,$callback){ |
@@ -296,11 +314,19 @@ discard block |
||
| 296 | 314 | return $this; |
| 297 | 315 | } |
| 298 | 316 | |
| 317 | + /** |
|
| 318 | + * @param string $icon |
|
| 319 | + * @param string $class |
|
| 320 | + */ |
|
| 299 | 321 | private function addDefaultButton($icon,$class=null,$callback=null){ |
| 300 | 322 | $this->addField($this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
| 301 | 323 | return $this; |
| 302 | 324 | } |
| 303 | 325 | |
| 326 | + /** |
|
| 327 | + * @param string $icon |
|
| 328 | + * @param string $class |
|
| 329 | + */ |
|
| 304 | 330 | private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){ |
| 305 | 331 | $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
| 306 | 332 | return $this; |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | public function __construct($instance=NULL){ |
| 15 | 15 | $this->values=[]; |
| 16 | 16 | $this->afterCompile=[]; |
| 17 | - if(isset($instance)) |
|
| 18 | - $this->setInstance($instance); |
|
| 17 | + if(isset($instance)) { |
|
| 18 | + $this->setInstance($instance); |
|
| 19 | + } |
|
| 19 | 20 | } |
| 20 | 21 | |
| 21 | 22 | public function getValues(){ |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | |
| 31 | 32 | public function getIdentifier(){ |
| 32 | 33 | $value=self::$index; |
| 33 | - if(isset($this->values["identifier"])) |
|
| 34 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 34 | + if(isset($this->values["identifier"])) { |
|
| 35 | + $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 36 | + } |
|
| 35 | 37 | return $value; |
| 36 | 38 | } |
| 37 | 39 | |
@@ -47,14 +49,15 @@ discard block |
||
| 47 | 49 | if(isset($this->values[$index])){ |
| 48 | 50 | $value= $this->values[$index]($value); |
| 49 | 51 | } |
| 50 | - }else{ |
|
| 51 | - if(\is_callable($property)) |
|
| 52 | - $value=$property($this->instance); |
|
| 53 | - elseif(\is_array($property)){ |
|
| 52 | + } else{ |
|
| 53 | + if(\is_callable($property)) { |
|
| 54 | + $value=$property($this->instance); |
|
| 55 | + } elseif(\is_array($property)){ |
|
| 54 | 56 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
| 55 | 57 | $value=\implode("", $values); |
| 56 | - }else |
|
| 57 | - $value=$property; |
|
| 58 | + } else { |
|
| 59 | + $value=$property; |
|
| 60 | + } |
|
| 58 | 61 | } |
| 59 | 62 | if(isset($this->afterCompile[$index])){ |
| 60 | 63 | if(\is_callable($this->afterCompile[$index])){ |
@@ -74,10 +77,10 @@ discard block |
||
| 74 | 77 | if(isset($vb[$index])){ |
| 75 | 78 | if(\is_array($vb[$index])){ |
| 76 | 79 | $this->visibleProperties[$index][]=$field; |
| 77 | - }else{ |
|
| 80 | + } else{ |
|
| 78 | 81 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
| 79 | 82 | } |
| 80 | - }else{ |
|
| 83 | + } else{ |
|
| 81 | 84 | return $this->insertField($index, $field); |
| 82 | 85 | } |
| 83 | 86 | return $this; |
@@ -109,24 +112,25 @@ discard block |
||
| 109 | 112 | $this->reflect=new \ReflectionClass($instance); |
| 110 | 113 | if(\sizeof($this->visibleProperties)===0){ |
| 111 | 114 | $this->properties=$this->getDefaultProperties(); |
| 112 | - }else{ |
|
| 115 | + } else{ |
|
| 113 | 116 | foreach ($this->visibleProperties as $property){ |
| 114 | 117 | if(\is_callable($property)){ |
| 115 | 118 | $this->properties[]=$property; |
| 116 | - }elseif(\is_string($property)){ |
|
| 119 | + } elseif(\is_string($property)){ |
|
| 117 | 120 | try{ |
| 118 | 121 | $rProperty=$this->reflect->getProperty($property); |
| 119 | 122 | $this->properties[]=$rProperty; |
| 120 | - }catch(\Exception $e){ |
|
| 123 | + } catch(\Exception $e){ |
|
| 121 | 124 | $this->properties[]=$property; |
| 122 | 125 | } |
| 123 | - }elseif(\is_int($property)){ |
|
| 126 | + } elseif(\is_int($property)){ |
|
| 124 | 127 | $props=$this->getDefaultProperties(); |
| 125 | - if(isset($props[$property])) |
|
| 126 | - $this->properties[]=$props[$property]; |
|
| 127 | - else |
|
| 128 | - $this->properties[]=$property; |
|
| 129 | - }else{ |
|
| 128 | + if(isset($props[$property])) { |
|
| 129 | + $this->properties[]=$props[$property]; |
|
| 130 | + } else { |
|
| 131 | + $this->properties[]=$property; |
|
| 132 | + } |
|
| 133 | + } else{ |
|
| 130 | 134 | $this->properties[]=$property; |
| 131 | 135 | } |
| 132 | 136 | } |
@@ -11,12 +11,13 @@ |
||
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | public function getCaption($index){ |
| 14 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 15 | - return $this->properties[$index]->getName(); |
|
| 16 | - elseif(\is_callable($this->properties[$index])) |
|
| 17 | - return ""; |
|
| 18 | - else |
|
| 19 | - return $this->properties[$index]; |
|
| 14 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
| 15 | + return $this->properties[$index]->getName(); |
|
| 16 | + } elseif(\is_callable($this->properties[$index])) { |
|
| 17 | + return ""; |
|
| 18 | + } else { |
|
| 19 | + return $this->properties[$index]; |
|
| 20 | + } |
|
| 20 | 21 | } |
| 21 | 22 | |
| 22 | 23 | public function getCaptions(){ |