@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | parent::__construct($identifier, "div","field"); |
17 | 17 | $this->content=array(); |
18 | 18 | $this->_states=[State::ERROR,State::DISABLED]; |
19 | - if(isset($label)===true) |
|
20 | - $this->setLabel($label); |
|
19 | + if(isset($label)===true) { |
|
20 | + $this->setLabel($label); |
|
21 | + } |
|
21 | 22 | $this->setField($field); |
22 | 23 | $this->_validation=NULL; |
23 | 24 | } |
@@ -48,8 +49,9 @@ discard block |
||
48 | 49 | * @return mixed |
49 | 50 | */ |
50 | 51 | public function getLabel(){ |
51 | - if(\array_key_exists("label", $this->content)) |
|
52 | - return $this->content["label"]; |
|
52 | + if(\array_key_exists("label", $this->content)) { |
|
53 | + return $this->content["label"]; |
|
54 | + } |
|
53 | 55 | } |
54 | 56 | |
55 | 57 | /** |
@@ -29,12 +29,14 @@ discard block |
||
29 | 29 | if (\is_string($end)) { |
30 | 30 | $label=$end; |
31 | 31 | \array_pop($fields); |
32 | - } else |
|
33 | - $label=NULL; |
|
32 | + } else { |
|
33 | + $label=NULL; |
|
34 | + } |
|
34 | 35 | } |
35 | 36 | } |
36 | - if (isset($label)) |
|
37 | - $this->setLabel($label); |
|
37 | + if (isset($label)) { |
|
38 | + $this->setLabel($label); |
|
39 | + } |
|
38 | 40 | foreach ( $fields as $field ) { |
39 | 41 | $this->addItem($field); |
40 | 42 | } |
@@ -57,8 +59,9 @@ discard block |
||
57 | 59 | |
58 | 60 | public function addItem($item) { |
59 | 61 | $item=parent::addItem($item); |
60 | - if($item instanceof HtmlFormField) |
|
61 | - $item->setContainer($this); |
|
62 | + if($item instanceof HtmlFormField) { |
|
63 | + $item->setContainer($this); |
|
64 | + } |
|
62 | 65 | return $item; |
63 | 66 | } |
64 | 67 | |
@@ -66,8 +69,9 @@ discard block |
||
66 | 69 | if ($this->_equalWidth) { |
67 | 70 | $count=$this->count(); |
68 | 71 | $this->addToProperty("class", Wide::getConstants()["W".$count]." fields"); |
69 | - } else |
|
70 | - $this->addToProperty("class", "fields"); |
|
72 | + } else { |
|
73 | + $this->addToProperty("class", "fields"); |
|
74 | + } |
|
71 | 75 | return parent::compile($js, $view); |
72 | 76 | } |
73 | 77 | |
@@ -108,8 +112,9 @@ discard block |
||
108 | 112 | $fields[]=$itemO; |
109 | 113 | } |
110 | 114 | $radios=new HtmlFormFields("fields-".$name, $fields); |
111 | - if (isset($label)) |
|
112 | - $radios->setLabel($label)->setProperty("for", $name); |
|
115 | + if (isset($label)) { |
|
116 | + $radios->setLabel($label)->setProperty("for", $name); |
|
117 | + } |
|
113 | 118 | return $radios; |
114 | 119 | } |
115 | 120 | |
@@ -124,8 +129,9 @@ discard block |
||
124 | 129 | $fields[]=$itemO; |
125 | 130 | } |
126 | 131 | $radios=new HtmlFormFields("fields-".$name, $fields); |
127 | - if (isset($label)) |
|
128 | - $radios->setLabel($label)->setProperty("for", $name); |
|
132 | + if (isset($label)) { |
|
133 | + $radios->setLabel($label)->setProperty("for", $name); |
|
134 | + } |
|
129 | 135 | return $radios; |
130 | 136 | } |
131 | 137 |
@@ -49,8 +49,9 @@ |
||
49 | 49 | $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
50 | 50 | if(\sizeof($fields)===1){ |
51 | 51 | $form->addField($fields[0]); |
52 | - }else |
|
53 | - $form->addFields($fields); |
|
52 | + } else { |
|
53 | + $form->addFields($fields); |
|
54 | + } |
|
54 | 55 | } |
55 | 56 | } |
56 | 57 |
@@ -31,10 +31,11 @@ discard block |
||
31 | 31 | protected function _applyAttributes($element,&$attributes,$index){ |
32 | 32 | if(isset($attributes["rules"])){ |
33 | 33 | $rules=$attributes["rules"]; |
34 | - if(\is_array($rules)) |
|
35 | - $element->addRules($rules); |
|
36 | - else |
|
37 | - $element->addRule($rules); |
|
34 | + if(\is_array($rules)) { |
|
35 | + $element->addRules($rules); |
|
36 | + } else { |
|
37 | + $element->addRule($rules); |
|
38 | + } |
|
38 | 39 | unset($attributes["rules"]); |
39 | 40 | } |
40 | 41 | if(isset($attributes["callback"])){ |
@@ -52,8 +53,9 @@ discard block |
||
52 | 53 | $caption=$this->_instanceViewer->getCaption($index); |
53 | 54 | $name=$this->_instanceViewer->getFieldName($index); |
54 | 55 | $element=$elementCallback($name,$caption,$value); |
55 | - if(\is_array($attributes)) |
|
56 | - $this->_applyAttributes($element, $attributes,$index); |
|
56 | + if(\is_array($attributes)) { |
|
57 | + $this->_applyAttributes($element, $attributes,$index); |
|
58 | + } |
|
57 | 59 | return $element; |
58 | 60 | }); |
59 | 61 | return $this; |
@@ -34,17 +34,18 @@ |
||
34 | 34 | $property=$this->getProperty($index); |
35 | 35 | if($property instanceof \ReflectionProperty){ |
36 | 36 | $result=$property->getName(); |
37 | - }elseif(\is_callable($property)){ |
|
37 | + } elseif(\is_callable($property)){ |
|
38 | 38 | $result=$this->visibleProperties[$index]; |
39 | - }else{ |
|
39 | + } else{ |
|
40 | 40 | $result=\strtolower($this->getCaption($index)); |
41 | 41 | } |
42 | 42 | return $result; |
43 | 43 | } |
44 | 44 | |
45 | 45 | public function addSeparatorAfter($fieldNum){ |
46 | - if(\array_search($fieldNum, $this->separators)===false) |
|
47 | - $this->separators[]=$fieldNum; |
|
46 | + if(\array_search($fieldNum, $this->separators)===false) { |
|
47 | + $this->separators[]=$fieldNum; |
|
48 | + } |
|
48 | 49 | return $this; |
49 | 50 | } |
50 | 51 |
@@ -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,17 +60,18 @@ 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 |
|
71 | - $value=$property; |
|
72 | + } else { |
|
73 | + $value=$property; |
|
74 | + } |
|
72 | 75 | } |
73 | 76 | if(isset($this->afterCompile[$index])){ |
74 | 77 | if(\is_callable($this->afterCompile[$index])){ |
@@ -88,10 +91,10 @@ discard block |
||
88 | 91 | if(isset($vb[$index])){ |
89 | 92 | if(\is_array($vb[$index])){ |
90 | 93 | $this->visibleProperties[$index][]=$field; |
91 | - }else{ |
|
94 | + } else{ |
|
92 | 95 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
93 | 96 | } |
94 | - }else{ |
|
97 | + } else{ |
|
95 | 98 | return $this->insertField($index, $field); |
96 | 99 | } |
97 | 100 | return $this; |
@@ -127,26 +130,27 @@ discard block |
||
127 | 130 | $this->reflect=new \ReflectionClass($instance); |
128 | 131 | if(\sizeof($this->visibleProperties)===0){ |
129 | 132 | $this->properties=$this->getDefaultProperties(); |
130 | - }else{ |
|
133 | + } else{ |
|
131 | 134 | foreach ($this->visibleProperties as $property){ |
132 | 135 | if(\is_callable($property)){ |
133 | 136 | $this->properties[]=$property; |
134 | - }elseif(\is_string($property)){ |
|
137 | + } elseif(\is_string($property)){ |
|
135 | 138 | try{ |
136 | 139 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
137 | 140 | $rProperty=$this->reflect->getProperty($property); |
138 | 141 | $this->properties[]=$rProperty; |
139 | - }catch(\Exception $e){ |
|
142 | + } catch(\Exception $e){ |
|
140 | 143 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
141 | 144 | $this->properties[]=$property; |
142 | 145 | } |
143 | - }elseif(\is_int($property)){ |
|
146 | + } elseif(\is_int($property)){ |
|
144 | 147 | $props=$this->getDefaultProperties(); |
145 | - if(isset($props[$property])) |
|
146 | - $this->properties[]=$props[$property]; |
|
147 | - else |
|
148 | - $this->properties[]=$property; |
|
149 | - }else{ |
|
148 | + if(isset($props[$property])) { |
|
149 | + $this->properties[]=$props[$property]; |
|
150 | + } else { |
|
151 | + $this->properties[]=$property; |
|
152 | + } |
|
153 | + } else{ |
|
150 | 154 | $this->properties[]=$property; |
151 | 155 | } |
152 | 156 | } |
@@ -190,12 +194,13 @@ discard block |
||
190 | 194 | } |
191 | 195 | |
192 | 196 | public function getCaption($index){ |
193 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
194 | - return $this->properties[$index]->getName(); |
|
195 | - elseif(\is_callable($this->properties[$index])) |
|
196 | - return ""; |
|
197 | - else |
|
198 | - return $this->properties[$index]; |
|
197 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
198 | + return $this->properties[$index]->getName(); |
|
199 | + } elseif(\is_callable($this->properties[$index])) { |
|
200 | + return ""; |
|
201 | + } else { |
|
202 | + return $this->properties[$index]; |
|
203 | + } |
|
199 | 204 | } |
200 | 205 | |
201 | 206 | public function getCaptions(){ |