@@ -45,6 +45,10 @@ discard block |
||
| 45 | 45 | return parent::run($js); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | + /** |
|
| 49 | + * @param string $identifier |
|
| 50 | + * @param string $model |
|
| 51 | + */ |
|
| 48 | 52 | public function __construct($identifier,$model,$modelInstance=NULL) { |
| 49 | 53 | parent::__construct($identifier, $model,$modelInstance); |
| 50 | 54 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
@@ -171,6 +175,9 @@ discard block |
||
| 171 | 175 | return $this; |
| 172 | 176 | } |
| 173 | 177 | |
| 178 | + /** |
|
| 179 | + * @param PositionInTable $part |
|
| 180 | + */ |
|
| 174 | 181 | private function addToolbarRow($part,$table,$captions){ |
| 175 | 182 | $hasPart=$table->hasPart($part); |
| 176 | 183 | if($hasPart){ |
@@ -216,7 +223,7 @@ discard block |
||
| 216 | 223 | * @param string $caption |
| 217 | 224 | * @param callable $callback |
| 218 | 225 | * @param boolean $visibleHover |
| 219 | - * @return callable |
|
| 226 | + * @return \Closure |
|
| 220 | 227 | */ |
| 221 | 228 | private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
| 222 | 229 | return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
@@ -226,7 +233,7 @@ discard block |
||
| 226 | 233 | * @param callable $thisCallback |
| 227 | 234 | * @param array $parameters |
| 228 | 235 | * @param callable $callback |
| 229 | - * @return callable |
|
| 236 | + * @return \Closure |
|
| 230 | 237 | */ |
| 231 | 238 | private function getCallable($thisCallback,$parameters,$callback=null){ |
| 232 | 239 | $result=function($instance) use($thisCallback,$parameters,$callback){ |
@@ -295,11 +302,19 @@ discard block |
||
| 295 | 302 | return $this; |
| 296 | 303 | } |
| 297 | 304 | |
| 305 | + /** |
|
| 306 | + * @param string $icon |
|
| 307 | + * @param string $class |
|
| 308 | + */ |
|
| 298 | 309 | private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
| 299 | 310 | $this->addField($this->getCallable("getDefaultButton",[$icon,$class],$visibleHover,$callback)); |
| 300 | 311 | return $this; |
| 301 | 312 | } |
| 302 | 313 | |
| 314 | + /** |
|
| 315 | + * @param string $icon |
|
| 316 | + * @param string $class |
|
| 317 | + */ |
|
| 303 | 318 | private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
| 304 | 319 | $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
| 305 | 320 | return $this; |
@@ -371,6 +386,9 @@ discard block |
||
| 371 | 386 | }, $index,$attributes); |
| 372 | 387 | } |
| 373 | 388 | |
| 389 | + /** |
|
| 390 | + * @param HtmlButton $element |
|
| 391 | + */ |
|
| 374 | 392 | protected function _visibleOver($element){ |
| 375 | 393 | $this->_visibleHover=true; |
| 376 | 394 | return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
@@ -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 | |
@@ -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 | } |