@@ -10,7 +10,6 @@ |
||
| 10 | 10 | use Ajax\semantic\html\elements\HtmlLabel; |
| 11 | 11 | use Ajax\semantic\html\modules\HtmlProgress; |
| 12 | 12 | use Ajax\semantic\html\modules\HtmlRating; |
| 13 | -use Ajax\semantic\html\collections\HtmlMessage; |
|
| 14 | 13 | /** |
| 15 | 14 | * @author jc |
| 16 | 15 | * @property InstanceViewer $_instanceViewer |
@@ -9,16 +9,18 @@ |
||
| 9 | 9 | use TextFieldsTrait; |
| 10 | 10 | |
| 11 | 11 | public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
| 12 | - if(!isset($placeholder) && $type==="text") |
|
| 13 | - $placeholder=$label; |
|
| 12 | + if(!isset($placeholder) && $type==="text") { |
|
| 13 | + $placeholder=$label; |
|
| 14 | + } |
|
| 14 | 15 | parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
| 15 | 16 | } |
| 16 | 17 | |
| 17 | 18 | public function getDataField(){ |
| 18 | 19 | $field= $this->getField(); |
| 19 | 20 | //TODO check getField |
| 20 | - if($field instanceof HtmlInput) |
|
| 21 | - $field=$field->getDataField(); |
|
| 21 | + if($field instanceof HtmlInput) { |
|
| 22 | + $field=$field->getDataField(); |
|
| 23 | + } |
|
| 22 | 24 | return $field; |
| 23 | 25 | } |
| 24 | 26 | } |
| 25 | 27 | \ No newline at end of file |
@@ -17,8 +17,9 @@ |
||
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | public function setInputType($type){ |
| 20 | - if($type==="hidden") |
|
| 21 | - $this->addToProperty("style","display:none;"); |
|
| 20 | + if($type==="hidden") { |
|
| 21 | + $this->addToProperty("style","display:none;"); |
|
| 22 | + } |
|
| 22 | 23 | $this->getDataField()->setInputType($type); |
| 23 | 24 | return $this; |
| 24 | 25 | } |
@@ -62,10 +62,11 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public function setDismissable($dismiss=true){ |
| 65 | - if($dismiss===true) |
|
| 66 | - $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
|
| 67 | - else |
|
| 68 | - $this->close=NULL; |
|
| 65 | + if($dismiss===true) { |
|
| 66 | + $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
|
| 67 | + } else { |
|
| 68 | + $this->close=NULL; |
|
| 69 | + } |
|
| 69 | 70 | return $this; |
| 70 | 71 | } |
| 71 | 72 | |
@@ -100,7 +101,8 @@ discard block |
||
| 100 | 101 | public function setMessage($message){ |
| 101 | 102 | if(\is_array($this->content)){ |
| 102 | 103 | $this->content[\sizeof($this->content)-1]=$message; |
| 103 | - }else |
|
| 104 | - $this->setContent($message); |
|
| 104 | + } else { |
|
| 105 | + $this->setContent($message); |
|
| 106 | + } |
|
| 105 | 107 | } |
| 106 | 108 | } |
| 107 | 109 | \ No newline at end of file |
@@ -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 | } |