@@ -62,8 +62,7 @@ discard block |
||
62 | 62 | $rules=$attributes["rules"]; |
63 | 63 | if(\is_array($rules)){ |
64 | 64 | $element->addRules($rules); |
65 | - } |
|
66 | - else{ |
|
65 | + } else{ |
|
67 | 66 | $element->addRule($rules); |
68 | 67 | } |
69 | 68 | unset($attributes["rules"]); |
@@ -123,8 +122,9 @@ discard block |
||
123 | 122 | public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
124 | 123 | return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
125 | 124 | $header=new HtmlHeader($id,$niveau,$value); |
126 | - if(isset($icon)) |
|
127 | - $header->asIcon($icon, $value); |
|
125 | + if(isset($icon)) { |
|
126 | + $header->asIcon($icon, $value); |
|
127 | + } |
|
128 | 128 | return $header; |
129 | 129 | }, $index,$attributes,"header"); |
130 | 130 | } |
@@ -132,7 +132,9 @@ discard block |
||
132 | 132 | |
133 | 133 | public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
134 | 134 | $this->setValueFunction($index,function($img) use($size,$circular){ |
135 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
135 | + $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) { |
|
136 | + $image->setCircular(); |
|
137 | + } |
|
136 | 138 | return $image; |
137 | 139 | }); |
138 | 140 | return $this; |
@@ -221,14 +223,14 @@ discard block |
||
221 | 223 | $i=0; |
222 | 224 | if(JArray::isAssociative($types)){ |
223 | 225 | foreach ($types as $type=>$attributes){ |
224 | - if(\is_int($type)) |
|
225 | - $this->fieldAs($i++,$attributes,[]); |
|
226 | - else{ |
|
226 | + if(\is_int($type)) { |
|
227 | + $this->fieldAs($i++,$attributes,[]); |
|
228 | + } else{ |
|
227 | 229 | $type=preg_replace('/\d/', '', $type ); |
228 | 230 | $this->fieldAs($i++,$type,$attributes); |
229 | 231 | } |
230 | 232 | } |
231 | - }else{ |
|
233 | + } else{ |
|
232 | 234 | foreach ($types as $type){ |
233 | 235 | $this->fieldAs($i++,$type); |
234 | 236 | } |
@@ -240,7 +242,7 @@ discard block |
||
240 | 242 | if(\method_exists($this, $method)){ |
241 | 243 | if(!\is_array($attributes)){ |
242 | 244 | $attributes=[$index]; |
243 | - }else{ |
|
245 | + } else{ |
|
244 | 246 | \array_unshift($attributes, $index); |
245 | 247 | } |
246 | 248 | \call_user_func_array([$this,$method], $attributes); |
@@ -29,9 +29,17 @@ discard block |
||
29 | 29 | trait FieldAsTrait{ |
30 | 30 | |
31 | 31 | abstract protected function _getFieldIdentifier($prefix,$name=""); |
32 | + |
|
33 | + /** |
|
34 | + * @param \Closure $callback |
|
35 | + */ |
|
32 | 36 | abstract public function setValueFunction($index,$callback); |
33 | 37 | abstract protected function _getFieldName($index); |
34 | 38 | abstract protected function _getFieldCaption($index); |
39 | + |
|
40 | + /** |
|
41 | + * @param string $event |
|
42 | + */ |
|
35 | 43 | abstract protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
36 | 44 | |
37 | 45 | /** |
@@ -242,6 +250,9 @@ discard block |
||
242 | 250 | } |
243 | 251 | } |
244 | 252 | |
253 | + /** |
|
254 | + * @param integer $index |
|
255 | + */ |
|
245 | 256 | public function fieldAs($index,$type,$attributes=NULL){ |
246 | 257 | $method="fieldAs".\ucfirst($type); |
247 | 258 | if(\method_exists($this, $method)){ |
@@ -26,23 +26,23 @@ discard block |
||
26 | 26 | * @property boolean $_edition |
27 | 27 | * @property mixed _modelInstance |
28 | 28 | */ |
29 | -trait FieldAsTrait{ |
|
29 | +trait FieldAsTrait { |
|
30 | 30 | |
31 | - abstract protected function _getFieldIdentifier($prefix,$name=""); |
|
32 | - abstract public function setValueFunction($index,$callback); |
|
31 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
32 | + abstract public function setValueFunction($index, $callback); |
|
33 | 33 | abstract protected function _getFieldName($index); |
34 | 34 | abstract protected function _getFieldCaption($index); |
35 | - abstract protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
|
35 | + abstract protected function _buttonAsSubmit(HtmlButton&$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @param HtmlFormField $element |
39 | 39 | * @param array $attributes |
40 | 40 | */ |
41 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
42 | - if(isset($attributes["jsCallback"])){ |
|
41 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
42 | + if (isset($attributes["jsCallback"])) { |
|
43 | 43 | $callback=$attributes["jsCallback"]; |
44 | - if(\is_callable($callback)){ |
|
45 | - $callback($element,$this->_modelInstance,$index); |
|
44 | + if (\is_callable($callback)) { |
|
45 | + $callback($element, $this->_modelInstance, $index); |
|
46 | 46 | unset($attributes["jsCallback"]); |
47 | 47 | } |
48 | 48 | } |
@@ -52,43 +52,43 @@ discard block |
||
52 | 52 | $element->fromArray($attributes); |
53 | 53 | } |
54 | 54 | |
55 | - private function _getLabelField($caption,$icon=NULL){ |
|
56 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
55 | + private function _getLabelField($caption, $icon=NULL) { |
|
56 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
57 | 57 | return $label; |
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | - protected function _addRules($element,&$attributes){ |
|
62 | - if(isset($attributes["rules"])){ |
|
61 | + protected function _addRules($element, &$attributes) { |
|
62 | + if (isset($attributes["rules"])) { |
|
63 | 63 | $rules=$attributes["rules"]; |
64 | - if(\is_array($rules)){ |
|
64 | + if (\is_array($rules)) { |
|
65 | 65 | $element->addRules($rules); |
66 | 66 | } |
67 | - else{ |
|
67 | + else { |
|
68 | 68 | $element->addRule($rules); |
69 | 69 | } |
70 | 70 | unset($attributes["rules"]); |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - protected function _prepareFormFields(&$field,$name,&$attributes){ |
|
74 | + protected function _prepareFormFields(&$field, $name, &$attributes) { |
|
75 | 75 | $field->setName($name); |
76 | 76 | $this->_addRules($field, $attributes); |
77 | 77 | return $field; |
78 | 78 | } |
79 | 79 | |
80 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
81 | - $this->setValueFunction($index,function($value,$instance,$index) use (&$attributes,$elementCallback,$prefix){ |
|
80 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
81 | + $this->setValueFunction($index, function($value, $instance, $index) use (&$attributes, $elementCallback, $prefix){ |
|
82 | 82 | $caption=$this->_getFieldCaption($index); |
83 | 83 | $name=$this->_getFieldName($index); |
84 | - $id=$this->_getFieldIdentifier($prefix,$name); |
|
85 | - if(isset($attributes["name"])){ |
|
84 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
85 | + if (isset($attributes["name"])) { |
|
86 | 86 | $name=$attributes["name"]; |
87 | 87 | unset($attributes["name"]); |
88 | 88 | } |
89 | - $element=$elementCallback($id,$name,$value,$caption); |
|
90 | - if(\is_array($attributes)){ |
|
91 | - $this->_applyAttributes($element, $attributes,$index); |
|
89 | + $element=$elementCallback($id, $name, $value, $caption); |
|
90 | + if (\is_array($attributes)) { |
|
91 | + $this->_applyAttributes($element, $attributes, $index); |
|
92 | 92 | } |
93 | 93 | $element->setDisabled(!$this->_edition); |
94 | 94 | return $element; |
@@ -97,175 +97,175 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | |
100 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
101 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
102 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
100 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
101 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
102 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
103 | 103 | return $pb; |
104 | 104 | }); |
105 | 105 | return $this; |
106 | 106 | } |
107 | 107 | |
108 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
109 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
110 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
108 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
109 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
110 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
111 | 111 | return $rating; |
112 | 112 | }); |
113 | 113 | return $this; |
114 | 114 | } |
115 | 115 | |
116 | - public function fieldAsLabel($index,$icon=NULL){ |
|
117 | - $this->setValueFunction($index,function($caption) use($icon){ |
|
118 | - $lbl=$this->_getLabelField($caption,$icon); |
|
116 | + public function fieldAsLabel($index, $icon=NULL) { |
|
117 | + $this->setValueFunction($index, function($caption) use($icon){ |
|
118 | + $lbl=$this->_getLabelField($caption, $icon); |
|
119 | 119 | return $lbl; |
120 | 120 | }); |
121 | 121 | return $this; |
122 | 122 | } |
123 | 123 | |
124 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
125 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
126 | - $header=new HtmlHeader($id,$niveau,$value); |
|
127 | - if(isset($icon)) |
|
124 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
125 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
126 | + $header=new HtmlHeader($id, $niveau, $value); |
|
127 | + if (isset($icon)) |
|
128 | 128 | $header->asIcon($icon, $value); |
129 | 129 | return $header; |
130 | - }, $index,$attributes,"header"); |
|
130 | + }, $index, $attributes, "header"); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
134 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
135 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
136 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
134 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
135 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
136 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
137 | 137 | return $image; |
138 | 138 | }); |
139 | 139 | return $this; |
140 | 140 | } |
141 | 141 | |
142 | - public function fieldAsFlag($index){ |
|
143 | - $this->setValueFunction($index,function($flag){ |
|
144 | - $flag=new HtmlFlag($this->_getFieldIdentifier("flag"),$flag); |
|
142 | + public function fieldAsFlag($index) { |
|
143 | + $this->setValueFunction($index, function($flag) { |
|
144 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
145 | 145 | return $flag; |
146 | 146 | }); |
147 | 147 | return $this; |
148 | 148 | } |
149 | 149 | |
150 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
151 | - return $this->_fieldAs(function($id,$name,$value){ |
|
152 | - $img=new HtmlImage($id,$value); |
|
150 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
151 | + return $this->_fieldAs(function($id, $name, $value) { |
|
152 | + $img=new HtmlImage($id, $value); |
|
153 | 153 | $img->asAvatar(); |
154 | 154 | return $img; |
155 | - }, $index,$attributes,"avatar"); |
|
155 | + }, $index, $attributes, "avatar"); |
|
156 | 156 | } |
157 | 157 | |
158 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
159 | - return $this->_fieldAs(function($id,$name,$value) use($attributes){ |
|
160 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
158 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
159 | + return $this->_fieldAs(function($id, $name, $value) use($attributes){ |
|
160 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
161 | 161 | return $this->_prepareFormFields($input, $name, $attributes); |
162 | - }, $index,$attributes,"radio"); |
|
162 | + }, $index, $attributes, "radio"); |
|
163 | 163 | } |
164 | 164 | |
165 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
166 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
167 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
168 | - }, $index,$attributes,"radios"); |
|
165 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
166 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
167 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
168 | + }, $index, $attributes, "radios"); |
|
169 | 169 | } |
170 | 170 | |
171 | - public function fieldAsInput($index,$attributes=NULL){ |
|
172 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
173 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
171 | + public function fieldAsInput($index, $attributes=NULL) { |
|
172 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
173 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
174 | 174 | return $this->_prepareFormFields($input, $name, $attributes); |
175 | - }, $index,$attributes,"input"); |
|
175 | + }, $index, $attributes, "input"); |
|
176 | 176 | } |
177 | 177 | |
178 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
179 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
180 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
178 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
179 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
180 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
181 | 181 | return $this->_prepareFormFields($textarea, $name, $attributes); |
182 | - }, $index,$attributes,"textarea"); |
|
182 | + }, $index, $attributes, "textarea"); |
|
183 | 183 | } |
184 | 184 | |
185 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
186 | - if(!\is_array($attributes)){ |
|
185 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
186 | + if (!\is_array($attributes)) { |
|
187 | 187 | $attributes=[]; |
188 | 188 | } |
189 | 189 | $attributes["imputType"]="hidden"; |
190 | - return $this->fieldAsInput($index,$attributes); |
|
190 | + return $this->fieldAsInput($index, $attributes); |
|
191 | 191 | } |
192 | 192 | |
193 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
194 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($attributes){ |
|
195 | - $input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier()); |
|
193 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
194 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($attributes){ |
|
195 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
196 | 196 | $input->setChecked(JString::isBooleanTrue($value)); |
197 | 197 | return $this->_prepareFormFields($input, $name, $attributes); |
198 | - }, $index,$attributes,"ck"); |
|
198 | + }, $index, $attributes, "ck"); |
|
199 | 199 | } |
200 | 200 | |
201 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
202 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple,$attributes){ |
|
203 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value); |
|
204 | - $dd->asSelect($name,$multiple); |
|
201 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
202 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple, $attributes){ |
|
203 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value); |
|
204 | + $dd->asSelect($name, $multiple); |
|
205 | 205 | return $this->_prepareFormFields($dd, $name, $attributes); |
206 | - }, $index,$attributes,"dd"); |
|
206 | + }, $index, $attributes, "dd"); |
|
207 | 207 | } |
208 | 208 | |
209 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
210 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
211 | - $mess= new HtmlMessage("message-".$id,$caption); |
|
209 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
210 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
211 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
212 | 212 | $mess->addHeader($value); |
213 | 213 | return $mess; |
214 | - }, $index,$attributes,"message"); |
|
214 | + }, $index, $attributes, "message"); |
|
215 | 215 | } |
216 | 216 | |
217 | - public function fieldAsLink($index,$attributes=NULL){ |
|
218 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
219 | - $lnk= new HtmlLink("message-".$id,"#",$caption); |
|
217 | + public function fieldAsLink($index, $attributes=NULL) { |
|
218 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
219 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
220 | 220 | return $lnk; |
221 | - }, $index,$attributes,"link"); |
|
221 | + }, $index, $attributes, "link"); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /**Change fields type |
225 | 225 | * @param array $types an array or associative array $type=>$attributes |
226 | 226 | */ |
227 | - public function fieldsAs(array $types){ |
|
227 | + public function fieldsAs(array $types) { |
|
228 | 228 | $i=0; |
229 | - if(JArray::isAssociative($types)){ |
|
230 | - foreach ($types as $type=>$attributes){ |
|
231 | - if(\is_int($type)) |
|
232 | - $this->fieldAs($i++,$attributes,[]); |
|
233 | - else{ |
|
234 | - $type=preg_replace('/\d/', '', $type ); |
|
235 | - $this->fieldAs($i++,$type,$attributes); |
|
229 | + if (JArray::isAssociative($types)) { |
|
230 | + foreach ($types as $type=>$attributes) { |
|
231 | + if (\is_int($type)) |
|
232 | + $this->fieldAs($i++, $attributes, []); |
|
233 | + else { |
|
234 | + $type=preg_replace('/\d/', '', $type); |
|
235 | + $this->fieldAs($i++, $type, $attributes); |
|
236 | 236 | } |
237 | 237 | } |
238 | - }else{ |
|
239 | - foreach ($types as $type){ |
|
240 | - $this->fieldAs($i++,$type); |
|
238 | + } else { |
|
239 | + foreach ($types as $type) { |
|
240 | + $this->fieldAs($i++, $type); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
245 | - public function fieldAs($index,$type,$attributes=NULL){ |
|
245 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
246 | 246 | $method="fieldAs".\ucfirst($type); |
247 | - if(\method_exists($this, $method)){ |
|
248 | - if(!\is_array($attributes)){ |
|
247 | + if (\method_exists($this, $method)) { |
|
248 | + if (!\is_array($attributes)) { |
|
249 | 249 | $attributes=[$index]; |
250 | - }else{ |
|
250 | + } else { |
|
251 | 251 | \array_unshift($attributes, $index); |
252 | 252 | } |
253 | - \call_user_func_array([$this,$method], $attributes); |
|
253 | + \call_user_func_array([$this, $method], $attributes); |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
257 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
258 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
259 | - $button=new HtmlButton($id,$caption,$cssStyle); |
|
260 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]); |
|
257 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
258 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
259 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
260 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
|
261 | 261 | return $button; |
262 | - }, $index,$attributes,"submit"); |
|
262 | + }, $index, $attributes, "submit"); |
|
263 | 263 | } |
264 | 264 | |
265 | - public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){ |
|
266 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
267 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
265 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
266 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
267 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
268 | 268 | return $button; |
269 | - }, $index,$attributes,"button"); |
|
269 | + }, $index, $attributes, "button"); |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | \ No newline at end of file |
@@ -10,50 +10,50 @@ |
||
10 | 10 | * @param string $identifier |
11 | 11 | * @param object $modelInstance |
12 | 12 | */ |
13 | - public function __construct($identifier,$modelInstance=null,$fieldsOrder=[],$fieldsDefinition=[],$fields=[],$captions=[],$separators=[]) { |
|
14 | - parent::__construct($identifier,$modelInstance,$fieldsOrder,$fieldsDefinition,$fields,$captions,$separators); |
|
13 | + public function __construct($identifier, $modelInstance=null, $fieldsOrder=[], $fieldsDefinition=[], $fields=[], $captions=[], $separators=[]) { |
|
14 | + parent::__construct($identifier, $modelInstance, $fieldsOrder, $fieldsDefinition, $fields, $captions, $separators); |
|
15 | 15 | } |
16 | 16 | |
17 | - protected function getDefaultModelInstance(){ |
|
17 | + protected function getDefaultModelInstance() { |
|
18 | 18 | return new UserModel(); |
19 | 19 | } |
20 | 20 | |
21 | - public static function regular($identifier,$modelInstance=null){ |
|
22 | - return new FormLogin($identifier,$modelInstance, |
|
23 | - ["message","login","password","remember","forget","submit","error"], |
|
24 | - ["message"=>[["icon"=>"sign in"]],"input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"checkbox","link","submit"=>["green fluid"],"message2"=>[["error"=>true]]], |
|
25 | - ["Connection","login","password","remember","forget","submit","error"], |
|
26 | - ["Please enter login and password to connect","Login","Password","Remember me.","Forgot your password?","Connection"], |
|
27 | - [0,2,4,5,6]); |
|
21 | + public static function regular($identifier, $modelInstance=null) { |
|
22 | + return new FormLogin($identifier, $modelInstance, |
|
23 | + ["message", "login", "password", "remember", "forget", "submit", "error"], |
|
24 | + ["message"=>[["icon"=>"sign in"]], "input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "checkbox", "link", "submit"=>["green fluid"], "message2"=>[["error"=>true]]], |
|
25 | + ["Connection", "login", "password", "remember", "forget", "submit", "error"], |
|
26 | + ["Please enter login and password to connect", "Login", "Password", "Remember me.", "Forgot your password?", "Connection"], |
|
27 | + [0, 2, 4, 5, 6]); |
|
28 | 28 | } |
29 | 29 | |
30 | - public static function smallInline($identifier,$modelInstance=null){ |
|
31 | - $result=new FormLogin($identifier,$modelInstance, |
|
32 | - ["login","password","submit"], |
|
33 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
34 | - ["login","password","submit"], |
|
35 | - ["","","Connection"], |
|
30 | + public static function smallInline($identifier, $modelInstance=null) { |
|
31 | + $result=new FormLogin($identifier, $modelInstance, |
|
32 | + ["login", "password", "submit"], |
|
33 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
34 | + ["login", "password", "submit"], |
|
35 | + ["", "", "Connection"], |
|
36 | 36 | [2]); |
37 | 37 | $result->addDividerBefore(0, "Connection"); |
38 | 38 | return $result; |
39 | 39 | } |
40 | 40 | |
41 | - public static function small($identifier,$modelInstance=null){ |
|
42 | - $result=new FormLogin($identifier,$modelInstance, |
|
43 | - ["login","password","submit"], |
|
44 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
45 | - ["login","password","submit"], |
|
46 | - ["Login","Password","Connection"], |
|
47 | - [1,2]); |
|
41 | + public static function small($identifier, $modelInstance=null) { |
|
42 | + $result=new FormLogin($identifier, $modelInstance, |
|
43 | + ["login", "password", "submit"], |
|
44 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
45 | + ["login", "password", "submit"], |
|
46 | + ["Login", "Password", "Connection"], |
|
47 | + [1, 2]); |
|
48 | 48 | $result->addDividerBefore(0, "Connection"); |
49 | 49 | return $result; |
50 | 50 | } |
51 | 51 | |
52 | - public static function attachedSegment($identifier,$modelInstance=null){ |
|
53 | - $result=self::regular($identifier,$modelInstance); |
|
54 | - $result->fieldAsMessage("message",["icon"=>"sign in","attached"=>true]); |
|
55 | - $result->addWrapper("message",null,"<div class='ui attached segment'>"); |
|
56 | - $result->addWrapper("error", null,"</div>"); |
|
52 | + public static function attachedSegment($identifier, $modelInstance=null) { |
|
53 | + $result=self::regular($identifier, $modelInstance); |
|
54 | + $result->fieldAsMessage("message", ["icon"=>"sign in", "attached"=>true]); |
|
55 | + $result->addWrapper("message", null, "<div class='ui attached segment'>"); |
|
56 | + $result->addWrapper("error", null, "</div>"); |
|
57 | 57 | return $result; |
58 | 58 | } |
59 | 59 | } |
60 | 60 | \ No newline at end of file |
@@ -15,7 +15,7 @@ |
||
15 | 15 | class HtmlFormCheckbox extends HtmlFormField { |
16 | 16 | use CheckboxTrait; |
17 | 17 | public function __construct($identifier, $label=NULL, $value=NULL, $type=NULL) { |
18 | - parent::__construct("field-".$identifier, new HtmlCheckbox($identifier,$label,$value,$type)); |
|
18 | + parent::__construct("field-".$identifier, new HtmlCheckbox($identifier, $label, $value, $type)); |
|
19 | 19 | $this->_identifier=$identifier; |
20 | 20 | } |
21 | 21 |
@@ -8,17 +8,17 @@ |
||
8 | 8 | class HtmlFormInput extends HtmlFormField { |
9 | 9 | use TextFieldsTrait; |
10 | 10 | |
11 | - public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
|
12 | - if(!isset($placeholder) && $type==="text") |
|
11 | + public function __construct($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
12 | + if (!isset($placeholder) && $type==="text") |
|
13 | 13 | $placeholder=$label; |
14 | - parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
|
14 | + parent::__construct("field-".$identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label); |
|
15 | 15 | $this->_identifier=$identifier; |
16 | 16 | } |
17 | 17 | |
18 | - public function getDataField(){ |
|
19 | - $field= $this->getField(); |
|
18 | + public function getDataField() { |
|
19 | + $field=$this->getField(); |
|
20 | 20 | //TODO check getField |
21 | - if($field instanceof HtmlInput) |
|
21 | + if ($field instanceof HtmlInput) |
|
22 | 22 | $field=$field->getDataField(); |
23 | 23 | return $field; |
24 | 24 | } |
@@ -9,8 +9,9 @@ discard block |
||
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 | $this->_identifier=$identifier; |
16 | 17 | } |
@@ -18,8 +19,9 @@ discard block |
||
18 | 19 | public function getDataField(){ |
19 | 20 | $field= $this->getField(); |
20 | 21 | //TODO check getField |
21 | - if($field instanceof HtmlInput) |
|
22 | - $field=$field->getDataField(); |
|
22 | + if($field instanceof HtmlInput) { |
|
23 | + $field=$field->getDataField(); |
|
24 | + } |
|
23 | 25 | return $field; |
24 | 26 | } |
25 | 27 | } |
26 | 28 | \ No newline at end of file |
@@ -9,10 +9,10 @@ discard block |
||
9 | 9 | class HtmlFormTextarea extends HtmlFormField { |
10 | 10 | use TextFieldsTrait; |
11 | 11 | |
12 | - public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) { |
|
13 | - if(!isset($placeholder)) |
|
12 | + public function __construct($identifier, $label=NULL, $value=NULL, $placeholder=NULL, $rows=NULL) { |
|
13 | + if (!isset($placeholder)) |
|
14 | 14 | $placeholder=$label; |
15 | - parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label); |
|
15 | + parent::__construct("field-".$identifier, new HtmlTextarea($identifier, $value, $placeholder, $rows), $label); |
|
16 | 16 | $this->_identifier=$identifier; |
17 | 17 | } |
18 | 18 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * Defines the textarea row count |
21 | 21 | * @param int $count |
22 | 22 | */ |
23 | - public function setRows($count){ |
|
23 | + public function setRows($count) { |
|
24 | 24 | $this->getField()->setRows($count); |
25 | 25 | } |
26 | 26 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | return $this->content["field"]; |
29 | 29 | } |
30 | 30 | |
31 | - public function setName($name){ |
|
32 | - $this->getDataField()->setProperty("name",$name); |
|
31 | + public function setName($name) { |
|
32 | + $this->getDataField()->setProperty("name", $name); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | \ No newline at end of file |
@@ -10,8 +10,9 @@ |
||
10 | 10 | use TextFieldsTrait; |
11 | 11 | |
12 | 12 | public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) { |
13 | - if(!isset($placeholder)) |
|
14 | - $placeholder=$label; |
|
13 | + if(!isset($placeholder)) { |
|
14 | + $placeholder=$label; |
|
15 | + } |
|
15 | 16 | parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label); |
16 | 17 | $this->_identifier=$identifier; |
17 | 18 | } |
@@ -7,26 +7,26 @@ |
||
7 | 7 | |
8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
9 | 9 | |
10 | - public function __construct($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false,$associative=true) { |
|
11 | - parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label); |
|
10 | + public function __construct($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false, $associative=true) { |
|
11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label); |
|
12 | 12 | $this->_identifier=$identifier; |
13 | 13 | } |
14 | 14 | |
15 | - public function setItems($items){ |
|
15 | + public function setItems($items) { |
|
16 | 16 | return $this->getField()->setItems($items); |
17 | 17 | } |
18 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
19 | - return $this->getField()->addItem($item,$value,$image); |
|
18 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
19 | + return $this->getField()->addItem($item, $value, $image); |
|
20 | 20 | } |
21 | - public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$associative=true){ |
|
22 | - return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative); |
|
21 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $associative=true) { |
|
22 | + return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative); |
|
23 | 23 | } |
24 | 24 | |
25 | - public function getDataField(){ |
|
25 | + public function getDataField() { |
|
26 | 26 | return $this->getField()->getInput(); |
27 | 27 | } |
28 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
29 | - $this->getField()->asSelect($name,$multiple,$selection); |
|
28 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
29 | + $this->getField()->asSelect($name, $multiple, $selection); |
|
30 | 30 | return $this; |
31 | 31 | } |
32 | 32 | } |
33 | 33 | \ No newline at end of file |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | use Ajax\JsUtils; |
11 | 11 | |
12 | 12 | class HtmlInput extends HtmlSemDoubleElement { |
13 | - use IconTrait,TextFieldsTrait,FieldTrait; |
|
13 | + use IconTrait, TextFieldsTrait, FieldTrait; |
|
14 | 14 | |
15 | 15 | public function __construct($identifier, $type="text", $value="", $placeholder="") { |
16 | - parent::__construct("div-" . $identifier, "div", "ui input"); |
|
16 | + parent::__construct("div-".$identifier, "div", "ui input"); |
|
17 | 17 | $this->_identifier=$identifier; |
18 | - $this->content=[ "field" => new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder) ]; |
|
19 | - $this->_states=[ State::DISABLED,State::FOCUS,State::ERROR ]; |
|
20 | - $this->_variations=[ Variation::TRANSPARENT ]; |
|
18 | + $this->content=["field" => new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder)]; |
|
19 | + $this->_states=[State::DISABLED, State::FOCUS, State::ERROR]; |
|
20 | + $this->_variations=[Variation::TRANSPARENT]; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function getField() { |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | |
38 | 38 | public function run(JsUtils $js) { |
39 | 39 | $result=parent::run($js); |
40 | - $result->attach("#" . $this->getDataField()->getIdentifier()); |
|
40 | + $result->attach("#".$this->getDataField()->getIdentifier()); |
|
41 | 41 | return $result; |
42 | 42 | } |
43 | 43 | |
44 | - public function setTransparent(){ |
|
44 | + public function setTransparent() { |
|
45 | 45 | return $this->addToProperty("class", "transparent"); |
46 | 46 | } |
47 | 47 | } |
48 | 48 | \ No newline at end of file |
@@ -7,22 +7,22 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // Get the input |
10 | -$source = file_get_contents($argv[1]); |
|
10 | +$source=file_get_contents($argv[1]); |
|
11 | 11 | |
12 | 12 | // make traits to classes |
13 | -$regexp = '#trait([\s]+[\S]+[\s]*){#'; |
|
14 | -$replace = 'class$1{'; |
|
15 | -$source = preg_replace($regexp, $replace, $source); |
|
13 | +$regexp='#trait([\s]+[\S]+[\s]*){#'; |
|
14 | +$replace='class$1{'; |
|
15 | +$source=preg_replace($regexp, $replace, $source); |
|
16 | 16 | |
17 | 17 | // use traits by extending them (classes that not extending a class) |
18 | -$regexp = '#class([\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
19 | -$replace = 'class$1 extends $3 $2 {'; |
|
20 | -$source = preg_replace($regexp, $replace, $source); |
|
18 | +$regexp='#class([\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
19 | +$replace='class$1 extends $3 $2 {'; |
|
20 | +$source=preg_replace($regexp, $replace, $source); |
|
21 | 21 | |
22 | 22 | // use traits by extending them (classes that already extending a class) |
23 | -$regexp = '#class([\s]+[\S]+[\s]+extends[\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
24 | -$replace = 'class$1, $3 $2{'; |
|
25 | -$source = preg_replace($regexp, $replace, $source); |
|
23 | +$regexp='#class([\s]+[\S]+[\s]+extends[\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
24 | +$replace='class$1, $3 $2{'; |
|
25 | +$source=preg_replace($regexp, $replace, $source); |
|
26 | 26 | |
27 | 27 | // Output |
28 | 28 | echo $source; |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | * @property string $identifier |
15 | 15 | */ |
16 | 16 | trait BaseTrait { |
17 | - protected $_variations=[ ]; |
|
18 | - protected $_states=[ ]; |
|
17 | + protected $_variations=[]; |
|
18 | + protected $_states=[]; |
|
19 | 19 | protected $_baseClass; |
20 | 20 | |
21 | 21 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | abstract public function setProperty($name, $value); |
30 | 30 | |
31 | - abstract public function addContent($content,$before=false); |
|
31 | + abstract public function addContent($content, $before=false); |
|
32 | 32 | |
33 | 33 | abstract public function onCreate($jsCode); |
34 | 34 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $this->setProperty("class", $this->_baseClass); |
50 | 50 | if (\is_string($variations)) |
51 | 51 | $variations=\explode(" ", $variations); |
52 | - foreach ( $variations as $variation ) { |
|
52 | + foreach ($variations as $variation) { |
|
53 | 53 | $this->addVariation($variation); |
54 | 54 | } |
55 | 55 | return $this; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | public function addVariations($variations=array()) { |
64 | 64 | if (\is_string($variations)) |
65 | 65 | $variations=\explode(" ", $variations); |
66 | - foreach ( $variations as $variation ) { |
|
66 | + foreach ($variations as $variation) { |
|
67 | 67 | $this->addVariation($variation); |
68 | 68 | } |
69 | 69 | return $this; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | public function addStates($states=array()) { |
73 | 73 | if (\is_string($states)) |
74 | 74 | $states=\explode(" ", $states); |
75 | - foreach ( $states as $state ) { |
|
75 | + foreach ($states as $state) { |
|
76 | 76 | $this->addState($state); |
77 | 77 | } |
78 | 78 | return $this; |
@@ -82,17 +82,17 @@ discard block |
||
82 | 82 | $this->setProperty("class", $this->_baseClass); |
83 | 83 | if (\is_string($states)) |
84 | 84 | $states=\explode(" ", $states); |
85 | - foreach ( $states as $state ) { |
|
85 | + foreach ($states as $state) { |
|
86 | 86 | $this->addState($state); |
87 | 87 | } |
88 | 88 | return $this; |
89 | 89 | } |
90 | 90 | |
91 | 91 | public function addIcon($icon, $before=true) { |
92 | - return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
92 | + return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before); |
|
93 | 93 | } |
94 | 94 | |
95 | - public function addSticky($context="body"){ |
|
95 | + public function addSticky($context="body") { |
|
96 | 96 | $this->onCreate("$('#".$this->identifier."').sticky({ context: '".$context."'});"); |
97 | 97 | return $this; |
98 | 98 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @return HtmlSemDoubleElement |
114 | 114 | */ |
115 | 115 | public function setDisabled($disable=true) { |
116 | - if($disable) |
|
116 | + if ($disable) |
|
117 | 117 | $this->addToProperty("class", "disabled"); |
118 | 118 | return $this; |
119 | 119 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return HtmlSemDoubleElement |
141 | 141 | */ |
142 | - public function asHeader(){ |
|
142 | + public function asHeader() { |
|
143 | 143 | return $this->addToProperty("class", "header"); |
144 | 144 | } |
145 | 145 | |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | * show it is currently the active user selection |
148 | 148 | * @return HtmlSemDoubleElement |
149 | 149 | */ |
150 | - public function setActive($value=true){ |
|
151 | - if($value) |
|
150 | + public function setActive($value=true) { |
|
151 | + if ($value) |
|
152 | 152 | $this->addToProperty("class", "active"); |
153 | 153 | return $this; |
154 | 154 | } |
155 | 155 | |
156 | - public function setAttached($value=true){ |
|
157 | - if($value) |
|
158 | - $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
156 | + public function setAttached($value=true) { |
|
157 | + if ($value) |
|
158 | + $this->addToPropertyCtrl("class", "attached", array("attached")); |
|
159 | 159 | return $this; |
160 | 160 | } |
161 | 161 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | public function setFloated($direction="right") { |
174 | - return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
174 | + return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | public function floatRight() { |
@@ -186,14 +186,14 @@ discard block |
||
186 | 186 | return $this->_baseClass; |
187 | 187 | } |
188 | 188 | |
189 | - protected function addBehavior(&$array,$key,$value,$before="",$after=""){ |
|
190 | - if(\is_string($value)){ |
|
191 | - if(isset($array[$key])){ |
|
189 | + protected function addBehavior(&$array, $key, $value, $before="", $after="") { |
|
190 | + if (\is_string($value)) { |
|
191 | + if (isset($array[$key])) { |
|
192 | 192 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
193 | 193 | $array[$key]=$before.$p.$value.$after; |
194 | - }else |
|
194 | + } else |
|
195 | 195 | $array[$key]=$before.$value.$after; |
196 | - }else |
|
196 | + } else |
|
197 | 197 | $array[$key]=$value; |
198 | 198 | return $this; |
199 | 199 | } |
@@ -47,8 +47,9 @@ discard block |
||
47 | 47 | |
48 | 48 | public function setVariations($variations) { |
49 | 49 | $this->setProperty("class", $this->_baseClass); |
50 | - if (\is_string($variations)) |
|
51 | - $variations=\explode(" ", $variations); |
|
50 | + if (\is_string($variations)) { |
|
51 | + $variations=\explode(" ", $variations); |
|
52 | + } |
|
52 | 53 | foreach ( $variations as $variation ) { |
53 | 54 | $this->addVariation($variation); |
54 | 55 | } |
@@ -61,8 +62,9 @@ discard block |
||
61 | 62 | } |
62 | 63 | |
63 | 64 | public function addVariations($variations=array()) { |
64 | - if (\is_string($variations)) |
|
65 | - $variations=\explode(" ", $variations); |
|
65 | + if (\is_string($variations)) { |
|
66 | + $variations=\explode(" ", $variations); |
|
67 | + } |
|
66 | 68 | foreach ( $variations as $variation ) { |
67 | 69 | $this->addVariation($variation); |
68 | 70 | } |
@@ -70,8 +72,9 @@ discard block |
||
70 | 72 | } |
71 | 73 | |
72 | 74 | public function addStates($states=array()) { |
73 | - if (\is_string($states)) |
|
74 | - $states=\explode(" ", $states); |
|
75 | + if (\is_string($states)) { |
|
76 | + $states=\explode(" ", $states); |
|
77 | + } |
|
75 | 78 | foreach ( $states as $state ) { |
76 | 79 | $this->addState($state); |
77 | 80 | } |
@@ -80,8 +83,9 @@ discard block |
||
80 | 83 | |
81 | 84 | public function setStates($states) { |
82 | 85 | $this->setProperty("class", $this->_baseClass); |
83 | - if (\is_string($states)) |
|
84 | - $states=\explode(" ", $states); |
|
86 | + if (\is_string($states)) { |
|
87 | + $states=\explode(" ", $states); |
|
88 | + } |
|
85 | 89 | foreach ( $states as $state ) { |
86 | 90 | $this->addState($state); |
87 | 91 | } |
@@ -113,8 +117,9 @@ discard block |
||
113 | 117 | * @return HtmlSemDoubleElement |
114 | 118 | */ |
115 | 119 | public function setDisabled($disable=true) { |
116 | - if($disable) |
|
117 | - $this->addToProperty("class", "disabled"); |
|
120 | + if($disable) { |
|
121 | + $this->addToProperty("class", "disabled"); |
|
122 | + } |
|
118 | 123 | return $this; |
119 | 124 | } |
120 | 125 | |
@@ -148,14 +153,16 @@ discard block |
||
148 | 153 | * @return HtmlSemDoubleElement |
149 | 154 | */ |
150 | 155 | public function setActive($value=true){ |
151 | - if($value) |
|
152 | - $this->addToProperty("class", "active"); |
|
156 | + if($value) { |
|
157 | + $this->addToProperty("class", "active"); |
|
158 | + } |
|
153 | 159 | return $this; |
154 | 160 | } |
155 | 161 | |
156 | 162 | public function setAttached($value=true){ |
157 | - if($value) |
|
158 | - $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
163 | + if($value) { |
|
164 | + $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
165 | + } |
|
159 | 166 | return $this; |
160 | 167 | } |
161 | 168 | |
@@ -191,10 +198,12 @@ discard block |
||
191 | 198 | if(isset($array[$key])){ |
192 | 199 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
193 | 200 | $array[$key]=$before.$p.$value.$after; |
194 | - }else |
|
195 | - $array[$key]=$before.$value.$after; |
|
196 | - }else |
|
197 | - $array[$key]=$value; |
|
201 | + } else { |
|
202 | + $array[$key]=$before.$value.$after; |
|
203 | + } |
|
204 | + } else { |
|
205 | + $array[$key]=$value; |
|
206 | + } |
|
198 | 207 | return $this; |
199 | 208 | } |
200 | 209 | } |
201 | 210 | \ No newline at end of file |