@@ -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 | } |
@@ -52,8 +52,9 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function addHeader($title, $niveau=1, $dividing=true) { |
| 54 | 54 | $header=new HtmlHeader("", $niveau, $title); |
| 55 | - if ($dividing) |
|
| 56 | - $header->setDividing(); |
|
| 55 | + if ($dividing) { |
|
| 56 | + $header->setDividing(); |
|
| 57 | + } |
|
| 57 | 58 | return $this->addItem($header); |
| 58 | 59 | } |
| 59 | 60 | |
@@ -74,14 +75,16 @@ discard block |
||
| 74 | 75 | if (\is_string($end)) { |
| 75 | 76 | $label=$end; |
| 76 | 77 | \array_pop($fields); |
| 77 | - } else |
|
| 78 | - $label=NULL; |
|
| 78 | + } else { |
|
| 79 | + $label=NULL; |
|
| 80 | + } |
|
| 79 | 81 | } |
| 80 | 82 | $this->_fields=\array_merge($this->_fields, $fields); |
| 81 | 83 | $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
| 82 | 84 | } |
| 83 | - if (isset($label)) |
|
| 84 | - $fields=new HtmlFormField("", $fields, $label); |
|
| 85 | + if (isset($label)) { |
|
| 86 | + $fields=new HtmlFormField("", $fields, $label); |
|
| 87 | + } |
|
| 85 | 88 | } else { |
| 86 | 89 | $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
| 87 | 90 | } |
@@ -134,12 +137,15 @@ discard block |
||
| 134 | 137 | */ |
| 135 | 138 | public function addMessage($identifier, $content, $header=NULL, $icon=NULL, $type=NULL) { |
| 136 | 139 | $message=new HtmlMessage($identifier, $content); |
| 137 | - if (isset($header)) |
|
| 138 | - $message->addHeader($header); |
|
| 139 | - if (isset($icon)) |
|
| 140 | - $message->setIcon($icon); |
|
| 141 | - if (isset($type)) |
|
| 142 | - $message->setStyle($type); |
|
| 140 | + if (isset($header)) { |
|
| 141 | + $message->addHeader($header); |
|
| 142 | + } |
|
| 143 | + if (isset($icon)) { |
|
| 144 | + $message->setIcon($icon); |
|
| 145 | + } |
|
| 146 | + if (isset($type)) { |
|
| 147 | + $message->setStyle($type); |
|
| 148 | + } |
|
| 143 | 149 | return $this->addItem($message); |
| 144 | 150 | } |
| 145 | 151 | |
@@ -156,23 +162,26 @@ discard block |
||
| 156 | 162 | } |
| 157 | 163 | |
| 158 | 164 | public function compile(JsUtils $js=NULL,&$view=NULL){ |
| 159 | - if(\sizeof($this->_validationParams)>0) |
|
| 160 | - $this->setProperty("novalidate", ""); |
|
| 165 | + if(\sizeof($this->_validationParams)>0) { |
|
| 166 | + $this->setProperty("novalidate", ""); |
|
| 167 | + } |
|
| 161 | 168 | return parent::compile($js,$view); |
| 162 | 169 | } |
| 163 | 170 | |
| 164 | 171 | public function run(JsUtils $js) { |
| 165 | 172 | $compo=NULL; |
| 166 | 173 | foreach ($this->_fields as $field){ |
| 167 | - if($field instanceof HtmlFormField) |
|
| 168 | - $compo=$this->addCompoValidation($js, $compo, $field); |
|
| 174 | + if($field instanceof HtmlFormField) { |
|
| 175 | + $compo=$this->addCompoValidation($js, $compo, $field); |
|
| 176 | + } |
|
| 169 | 177 | } |
| 170 | 178 | foreach ($this->content as $field){ |
| 171 | 179 | if($field instanceof HtmlFormFields){ |
| 172 | 180 | $items=$field->getItems(); |
| 173 | 181 | foreach ($items as $_field){ |
| 174 | - if($_field instanceof HtmlFormField) |
|
| 175 | - $compo=$this->addCompoValidation($js, $compo, $_field); |
|
| 182 | + if($_field instanceof HtmlFormField) { |
|
| 183 | + $compo=$this->addCompoValidation($js, $compo, $_field); |
|
| 184 | + } |
|
| 176 | 185 | } |
| 177 | 186 | } |
| 178 | 187 | } |
@@ -47,9 +47,9 @@ |
||
| 47 | 47 | $rules=$attributes["rules"]; |
| 48 | 48 | if(\is_array($rules)){ |
| 49 | 49 | $element->addRules($rules); |
| 50 | + } else { |
|
| 51 | + $element->addRule($rules); |
|
| 50 | 52 | } |
| 51 | - else |
|
| 52 | - $element->addRule($rules); |
|
| 53 | 53 | unset($attributes["rules"]); |
| 54 | 54 | } |
| 55 | 55 | } |