@@ -17,48 +17,48 @@ discard block |
||
| 17 | 17 | * @since 2.2 |
| 18 | 18 | */ |
| 19 | 19 | class DataForm extends Widget { |
| 20 | - use FormFieldAsTrait,FormTrait; |
|
| 20 | + use FormFieldAsTrait, FormTrait; |
|
| 21 | 21 | |
| 22 | 22 | public function __construct($identifier, $modelInstance=NULL) { |
| 23 | - parent::__construct($identifier, null,$modelInstance); |
|
| 23 | + parent::__construct($identifier, null, $modelInstance); |
|
| 24 | 24 | $this->_instanceViewer=new FormInstanceViewer(); |
| 25 | 25 | $this->content=["form"=>new HtmlForm($identifier)]; |
| 26 | 26 | $this->_toolbarPosition=PositionInTable::BEFORETABLE; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 29 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 30 | 30 | $this->_instanceViewer->setInstance($this->_modelInstance); |
| 31 | 31 | |
| 32 | 32 | $form=$this->content["form"]; |
| 33 | 33 | $this->_generateContent($form); |
| 34 | 34 | |
| 35 | - if(isset($this->_toolbar)){ |
|
| 35 | + if (isset($this->_toolbar)) { |
|
| 36 | 36 | $this->_setToolbarPosition($form); |
| 37 | 37 | } |
| 38 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
| 39 | - return parent::compile($js,$view); |
|
| 38 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
| 39 | + return parent::compile($js, $view); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @param HtmlForm $form |
| 44 | 44 | */ |
| 45 | - protected function _generateContent($form){ |
|
| 46 | - $values= $this->_instanceViewer->getValues(); |
|
| 45 | + protected function _generateContent($form) { |
|
| 46 | + $values=$this->_instanceViewer->getValues(); |
|
| 47 | 47 | $count=$this->_instanceViewer->count(); |
| 48 | 48 | |
| 49 | 49 | $separators=$this->_instanceViewer->getSeparators(); |
| 50 | 50 | $size=\sizeof($separators); |
| 51 | - if($size===1){ |
|
| 52 | - foreach ($values as $v){ |
|
| 51 | + if ($size===1) { |
|
| 52 | + foreach ($values as $v) { |
|
| 53 | 53 | $form->addField($v); |
| 54 | 54 | } |
| 55 | - }else{ |
|
| 55 | + } else { |
|
| 56 | 56 | $separators[]=$count; |
| 57 | - for($i=0;$i<$size;$i++){ |
|
| 58 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
| 59 | - if(\sizeof($fields)===1){ |
|
| 57 | + for ($i=0; $i<$size; $i++) { |
|
| 58 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
| 59 | + if (\sizeof($fields)===1) { |
|
| 60 | 60 | $form->addField($fields[0]); |
| 61 | - }else |
|
| 61 | + } else |
|
| 62 | 62 | $form->addFields($fields); |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | /** |
| 68 | 68 | * @return HtmlForm |
| 69 | 69 | */ |
| 70 | - protected function getForm(){ |
|
| 70 | + protected function getForm() { |
|
| 71 | 71 | return $this->content["form"]; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function addSeparatorAfter($fieldNum){ |
|
| 74 | + public function addSeparatorAfter($fieldNum) { |
|
| 75 | 75 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
| 76 | 76 | return $this; |
| 77 | 77 | } |
@@ -85,26 +85,26 @@ discard block |
||
| 85 | 85 | return $this; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){ |
|
| 89 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
| 90 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement); |
|
| 88 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) { |
|
| 89 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
| 90 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement); |
|
| 91 | 91 | return $this->addInToolbar($button); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
| 95 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle){ |
|
| 96 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 97 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement); |
|
| 94 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
| 95 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle){ |
|
| 96 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 97 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement); |
|
| 98 | 98 | return $button; |
| 99 | - }, $index,$attributes); |
|
| 99 | + }, $index, $attributes); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
| 103 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
| 104 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 102 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 103 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
| 104 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 105 | 105 | $button->setProperty("type", "reset"); |
| 106 | 106 | return $button; |
| 107 | - }, $index,$attributes); |
|
| 107 | + }, $index, $attributes); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -14,144 +14,144 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | public static $index=0; |
| 16 | 16 | |
| 17 | - public function __construct($instance=NULL,$captions=NULL){ |
|
| 17 | + public function __construct($instance=NULL, $captions=NULL) { |
|
| 18 | 18 | $this->values=[]; |
| 19 | 19 | $this->afterCompile=[]; |
| 20 | - if(isset($instance)) |
|
| 20 | + if (isset($instance)) |
|
| 21 | 21 | $this->setInstance($instance); |
| 22 | 22 | $this->setCaptions($captions); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function getValues(){ |
|
| 25 | + public function getValues() { |
|
| 26 | 26 | $values=[]; |
| 27 | 27 | $index=0; |
| 28 | 28 | $count=$this->count(); |
| 29 | - while($index<$count){ |
|
| 29 | + while ($index<$count) { |
|
| 30 | 30 | $values[]=$this->getValue($index++); |
| 31 | 31 | } |
| 32 | 32 | return $values; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function getIdentifier(){ |
|
| 35 | + public function getIdentifier() { |
|
| 36 | 36 | $value=self::$index; |
| 37 | - if(isset($this->values["identifier"])) |
|
| 38 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 37 | + if (isset($this->values["identifier"])) |
|
| 38 | + $value=$this->values["identifier"](self::$index, $this->instance); |
|
| 39 | 39 | return $value; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function getValue($index){ |
|
| 42 | + public function getValue($index) { |
|
| 43 | 43 | $property=$this->properties[$index]; |
| 44 | 44 | return $this->_getValue($property, $index); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - protected function _beforeAddProperty($index,&$field){ |
|
| 47 | + protected function _beforeAddProperty($index, &$field) { |
|
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - protected function _getDefaultValue($name,$value,$index){ |
|
| 51 | + protected function _getDefaultValue($name, $value, $index) { |
|
| 52 | 52 | return $value; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - protected function _getValue($property,$index){ |
|
| 56 | - if($property instanceof \ReflectionProperty){ |
|
| 55 | + protected function _getValue($property, $index) { |
|
| 56 | + if ($property instanceof \ReflectionProperty) { |
|
| 57 | 57 | $property->setAccessible(true); |
| 58 | 58 | $value=$property->getValue($this->instance); |
| 59 | - if(isset($this->values[$index])){ |
|
| 60 | - $value= $this->values[$index]($value,$this->instance,$index); |
|
| 61 | - }else{ |
|
| 62 | - $value=$this->_getDefaultValue($property->getName(),$value, $index); |
|
| 59 | + if (isset($this->values[$index])) { |
|
| 60 | + $value=$this->values[$index]($value, $this->instance, $index); |
|
| 61 | + } else { |
|
| 62 | + $value=$this->_getDefaultValue($property->getName(), $value, $index); |
|
| 63 | 63 | } |
| 64 | - }else{ |
|
| 65 | - if(\is_callable($property)) |
|
| 64 | + } else { |
|
| 65 | + if (\is_callable($property)) |
|
| 66 | 66 | $value=$property($this->instance); |
| 67 | - elseif(\is_array($property)){ |
|
| 68 | - $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
|
| 67 | + elseif (\is_array($property)) { |
|
| 68 | + $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property); |
|
| 69 | 69 | $value=\implode("", $values); |
| 70 | - }else{ |
|
| 71 | - if(isset($this->values[$index])){ |
|
| 72 | - $value= $this->values[$index]($property,$this->instance,$index); |
|
| 73 | - }else{ |
|
| 70 | + } else { |
|
| 71 | + if (isset($this->values[$index])) { |
|
| 72 | + $value=$this->values[$index]($property, $this->instance, $index); |
|
| 73 | + } else { |
|
| 74 | 74 | $value=$property; |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | - if(isset($this->afterCompile[$index])){ |
|
| 79 | - if(\is_callable($this->afterCompile[$index])){ |
|
| 80 | - $this->afterCompile[$index]($value,$this->instance,$index); |
|
| 78 | + if (isset($this->afterCompile[$index])) { |
|
| 79 | + if (\is_callable($this->afterCompile[$index])) { |
|
| 80 | + $this->afterCompile[$index]($value, $this->instance, $index); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | return $value; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function insertField($index,$field){ |
|
| 87 | - array_splice( $this->visibleProperties, $index, 0, $field ); |
|
| 86 | + public function insertField($index, $field) { |
|
| 87 | + array_splice($this->visibleProperties, $index, 0, $field); |
|
| 88 | 88 | return $this; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - public function insertInField($index,$field){ |
|
| 91 | + public function insertInField($index, $field) { |
|
| 92 | 92 | $vb=$this->visibleProperties; |
| 93 | - if(isset($vb[$index])){ |
|
| 94 | - if(\is_array($vb[$index])){ |
|
| 93 | + if (isset($vb[$index])) { |
|
| 94 | + if (\is_array($vb[$index])) { |
|
| 95 | 95 | $this->visibleProperties[$index][]=$field; |
| 96 | - }else{ |
|
| 97 | - $this->visibleProperties[$index]=[$vb[$index],$field]; |
|
| 96 | + } else { |
|
| 97 | + $this->visibleProperties[$index]=[$vb[$index], $field]; |
|
| 98 | 98 | } |
| 99 | - }else{ |
|
| 99 | + } else { |
|
| 100 | 100 | return $this->insertField($index, $field); |
| 101 | 101 | } |
| 102 | 102 | return $this; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - public function addField($field){ |
|
| 105 | + public function addField($field) { |
|
| 106 | 106 | $this->visibleProperties[]=$field; |
| 107 | 107 | return $this; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public function count(){ |
|
| 110 | + public function count() { |
|
| 111 | 111 | return \sizeof($this->properties); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - public function visiblePropertiesCount(){ |
|
| 114 | + public function visiblePropertiesCount() { |
|
| 115 | 115 | return \sizeof($this->visibleProperties); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - public function getProperty($index){ |
|
| 118 | + public function getProperty($index) { |
|
| 119 | 119 | return $this->properties[$index]; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - protected function showableProperty(\ReflectionProperty $rProperty){ |
|
| 123 | - return JString::startswith($rProperty->getName(),"_")===false; |
|
| 122 | + protected function showableProperty(\ReflectionProperty $rProperty) { |
|
| 123 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | public function setInstance($instance) { |
| 127 | - if(\is_string($instance)){ |
|
| 127 | + if (\is_string($instance)) { |
|
| 128 | 128 | $instance=new $instance(); |
| 129 | 129 | } |
| 130 | 130 | $this->instance=$instance; |
| 131 | 131 | $this->properties=[]; |
| 132 | 132 | $this->reflect=new \ReflectionClass($instance); |
| 133 | - if(\sizeof($this->visibleProperties)===0){ |
|
| 133 | + if (\sizeof($this->visibleProperties)===0) { |
|
| 134 | 134 | $this->properties=$this->getDefaultProperties(); |
| 135 | - }else{ |
|
| 136 | - foreach ($this->visibleProperties as $property){ |
|
| 137 | - if(\is_callable($property)){ |
|
| 135 | + } else { |
|
| 136 | + foreach ($this->visibleProperties as $property) { |
|
| 137 | + if (\is_callable($property)) { |
|
| 138 | 138 | $this->properties[]=$property; |
| 139 | - }elseif(\is_string($property)){ |
|
| 140 | - try{ |
|
| 139 | + }elseif (\is_string($property)) { |
|
| 140 | + try { |
|
| 141 | 141 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 142 | 142 | $rProperty=$this->reflect->getProperty($property); |
| 143 | 143 | $this->properties[]=$rProperty; |
| 144 | - }catch(\Exception $e){ |
|
| 144 | + }catch (\Exception $e) { |
|
| 145 | 145 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 146 | 146 | $this->properties[]=$property; |
| 147 | 147 | } |
| 148 | - }elseif(\is_int($property)){ |
|
| 148 | + }elseif (\is_int($property)) { |
|
| 149 | 149 | $props=$this->getDefaultProperties(); |
| 150 | - if(isset($props[$property])) |
|
| 150 | + if (isset($props[$property])) |
|
| 151 | 151 | $this->properties[]=$props[$property]; |
| 152 | 152 | else |
| 153 | 153 | $this->properties[]=$property; |
| 154 | - }else{ |
|
| 154 | + } else { |
|
| 155 | 155 | $this->properties[]=$property; |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -159,12 +159,12 @@ discard block |
||
| 159 | 159 | return $this; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - protected function getDefaultProperties(){ |
|
| 162 | + protected function getDefaultProperties() { |
|
| 163 | 163 | $result=[]; |
| 164 | 164 | $properties=$this->reflect->getProperties(); |
| 165 | - foreach ($properties as $property){ |
|
| 165 | + foreach ($properties as $property) { |
|
| 166 | 166 | $showable=$this->showableProperty($property); |
| 167 | - if($showable!==false){ |
|
| 167 | + if ($showable!==false) { |
|
| 168 | 168 | $result[]=$property; |
| 169 | 169 | } |
| 170 | 170 | } |
@@ -176,12 +176,12 @@ discard block |
||
| 176 | 176 | return $this; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - public function setValueFunction($index,$callback){ |
|
| 179 | + public function setValueFunction($index, $callback) { |
|
| 180 | 180 | $this->values[$index]=$callback; |
| 181 | 181 | return $this; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - public function setIdentifierFunction($callback){ |
|
| 184 | + public function setIdentifierFunction($callback) { |
|
| 185 | 185 | $this->values["identifier"]=$callback; |
| 186 | 186 | return $this; |
| 187 | 187 | } |
@@ -194,22 +194,22 @@ discard block |
||
| 194 | 194 | return $this->properties; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - public function getCaption($index){ |
|
| 198 | - if(isset($this->captions[$index])){ |
|
| 197 | + public function getCaption($index) { |
|
| 198 | + if (isset($this->captions[$index])) { |
|
| 199 | 199 | return $this->captions[$index]; |
| 200 | 200 | } |
| 201 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 201 | + if ($this->properties[$index] instanceof \ReflectionProperty) |
|
| 202 | 202 | return $this->properties[$index]->getName(); |
| 203 | - elseif(\is_callable($this->properties[$index])) |
|
| 203 | + elseif (\is_callable($this->properties[$index])) |
|
| 204 | 204 | return ""; |
| 205 | 205 | else |
| 206 | 206 | return $this->properties[$index]; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - public function getCaptions(){ |
|
| 210 | - if(isset($this->captions)){ |
|
| 211 | - $result= $this->captions; |
|
| 212 | - for($i=\sizeof($result);$i<$this->count();$i++){ |
|
| 209 | + public function getCaptions() { |
|
| 210 | + if (isset($this->captions)) { |
|
| 211 | + $result=$this->captions; |
|
| 212 | + for ($i=\sizeof($result); $i<$this->count(); $i++) { |
|
| 213 | 213 | $result[]=""; |
| 214 | 214 | } |
| 215 | 215 | return $result; |
@@ -217,14 +217,14 @@ discard block |
||
| 217 | 217 | $captions=[]; |
| 218 | 218 | $index=0; |
| 219 | 219 | $count=$this->count(); |
| 220 | - while($index<$count){ |
|
| 220 | + while ($index<$count) { |
|
| 221 | 221 | $captions[]=$this->getCaption($index++); |
| 222 | 222 | } |
| 223 | 223 | return $captions; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - public function setCaption($index,$caption){ |
|
| 227 | - if(isset($this->captions)===false) |
|
| 226 | + public function setCaption($index, $caption) { |
|
| 227 | + if (isset($this->captions)===false) |
|
| 228 | 228 | $this->captions=[]; |
| 229 | 229 | $this->captions[$index]=$caption; |
| 230 | 230 | return $this; |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * @param callable $callback function called after the field compilation |
| 243 | 243 | * @return \Ajax\semantic\widgets\datatable\InstanceViewer |
| 244 | 244 | */ |
| 245 | - public function afterCompile($index,$callback){ |
|
| 245 | + public function afterCompile($index, $callback) { |
|
| 246 | 246 | $this->afterCompile[$index]=$callback; |
| 247 | 247 | return $this; |
| 248 | 248 | } |
@@ -17,8 +17,9 @@ discard block |
||
| 17 | 17 | public function __construct($instance=NULL,$captions=NULL){ |
| 18 | 18 | $this->values=[]; |
| 19 | 19 | $this->afterCompile=[]; |
| 20 | - if(isset($instance)) |
|
| 21 | - $this->setInstance($instance); |
|
| 20 | + if(isset($instance)) { |
|
| 21 | + $this->setInstance($instance); |
|
| 22 | + } |
|
| 22 | 23 | $this->setCaptions($captions); |
| 23 | 24 | } |
| 24 | 25 | |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | public function getIdentifier(){ |
| 36 | 37 | $value=self::$index; |
| 37 | - if(isset($this->values["identifier"])) |
|
| 38 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 38 | + if(isset($this->values["identifier"])) { |
|
| 39 | + $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 40 | + } |
|
| 39 | 41 | return $value; |
| 40 | 42 | } |
| 41 | 43 | |
@@ -58,19 +60,19 @@ discard block |
||
| 58 | 60 | $value=$property->getValue($this->instance); |
| 59 | 61 | if(isset($this->values[$index])){ |
| 60 | 62 | $value= $this->values[$index]($value,$this->instance,$index); |
| 61 | - }else{ |
|
| 63 | + } else{ |
|
| 62 | 64 | $value=$this->_getDefaultValue($property->getName(),$value, $index); |
| 63 | 65 | } |
| 64 | - }else{ |
|
| 65 | - if(\is_callable($property)) |
|
| 66 | - $value=$property($this->instance); |
|
| 67 | - elseif(\is_array($property)){ |
|
| 66 | + } else{ |
|
| 67 | + if(\is_callable($property)) { |
|
| 68 | + $value=$property($this->instance); |
|
| 69 | + } elseif(\is_array($property)){ |
|
| 68 | 70 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
| 69 | 71 | $value=\implode("", $values); |
| 70 | - }else{ |
|
| 72 | + } else{ |
|
| 71 | 73 | if(isset($this->values[$index])){ |
| 72 | 74 | $value= $this->values[$index]($property,$this->instance,$index); |
| 73 | - }else{ |
|
| 75 | + } else{ |
|
| 74 | 76 | $value=$property; |
| 75 | 77 | } |
| 76 | 78 | } |
@@ -93,10 +95,10 @@ discard block |
||
| 93 | 95 | if(isset($vb[$index])){ |
| 94 | 96 | if(\is_array($vb[$index])){ |
| 95 | 97 | $this->visibleProperties[$index][]=$field; |
| 96 | - }else{ |
|
| 98 | + } else{ |
|
| 97 | 99 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
| 98 | 100 | } |
| 99 | - }else{ |
|
| 101 | + } else{ |
|
| 100 | 102 | return $this->insertField($index, $field); |
| 101 | 103 | } |
| 102 | 104 | return $this; |
@@ -132,26 +134,27 @@ discard block |
||
| 132 | 134 | $this->reflect=new \ReflectionClass($instance); |
| 133 | 135 | if(\sizeof($this->visibleProperties)===0){ |
| 134 | 136 | $this->properties=$this->getDefaultProperties(); |
| 135 | - }else{ |
|
| 137 | + } else{ |
|
| 136 | 138 | foreach ($this->visibleProperties as $property){ |
| 137 | 139 | if(\is_callable($property)){ |
| 138 | 140 | $this->properties[]=$property; |
| 139 | - }elseif(\is_string($property)){ |
|
| 141 | + } elseif(\is_string($property)){ |
|
| 140 | 142 | try{ |
| 141 | 143 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 142 | 144 | $rProperty=$this->reflect->getProperty($property); |
| 143 | 145 | $this->properties[]=$rProperty; |
| 144 | - }catch(\Exception $e){ |
|
| 146 | + } catch(\Exception $e){ |
|
| 145 | 147 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 146 | 148 | $this->properties[]=$property; |
| 147 | 149 | } |
| 148 | - }elseif(\is_int($property)){ |
|
| 150 | + } elseif(\is_int($property)){ |
|
| 149 | 151 | $props=$this->getDefaultProperties(); |
| 150 | - if(isset($props[$property])) |
|
| 151 | - $this->properties[]=$props[$property]; |
|
| 152 | - else |
|
| 153 | - $this->properties[]=$property; |
|
| 154 | - }else{ |
|
| 152 | + if(isset($props[$property])) { |
|
| 153 | + $this->properties[]=$props[$property]; |
|
| 154 | + } else { |
|
| 155 | + $this->properties[]=$property; |
|
| 156 | + } |
|
| 157 | + } else{ |
|
| 155 | 158 | $this->properties[]=$property; |
| 156 | 159 | } |
| 157 | 160 | } |
@@ -198,12 +201,13 @@ discard block |
||
| 198 | 201 | if(isset($this->captions[$index])){ |
| 199 | 202 | return $this->captions[$index]; |
| 200 | 203 | } |
| 201 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 202 | - return $this->properties[$index]->getName(); |
|
| 203 | - elseif(\is_callable($this->properties[$index])) |
|
| 204 | - return ""; |
|
| 205 | - else |
|
| 206 | - return $this->properties[$index]; |
|
| 204 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
| 205 | + return $this->properties[$index]->getName(); |
|
| 206 | + } elseif(\is_callable($this->properties[$index])) { |
|
| 207 | + return ""; |
|
| 208 | + } else { |
|
| 209 | + return $this->properties[$index]; |
|
| 210 | + } |
|
| 207 | 211 | } |
| 208 | 212 | |
| 209 | 213 | public function getCaptions(){ |
@@ -224,8 +228,9 @@ discard block |
||
| 224 | 228 | } |
| 225 | 229 | |
| 226 | 230 | public function setCaption($index,$caption){ |
| 227 | - if(isset($this->captions)===false) |
|
| 228 | - $this->captions=[]; |
|
| 231 | + if(isset($this->captions)===false) { |
|
| 232 | + $this->captions=[]; |
|
| 233 | + } |
|
| 229 | 234 | $this->captions[$index]=$caption; |
| 230 | 235 | return $this; |
| 231 | 236 | } |