@@ -17,6 +17,6 @@ |
||
17 | 17 | if (isset($toElement) && \method_exists($toElement, "setAttached")) { |
18 | 18 | $toElement->setAttached(true); |
19 | 19 | } |
20 | - return $this->addToPropertyCtrl("class", $side . " attached", Side::getConstantValues("attached")); |
|
20 | + return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached")); |
|
21 | 21 | } |
22 | 22 | } |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | $output=$input; |
13 | 13 | } |
14 | 14 | if (\is_array($input)) { |
15 | - if (sizeof($input) > 0) { |
|
16 | - if (self::containsElement($input) === false) { |
|
15 | + if (sizeof($input)>0) { |
|
16 | + if (self::containsElement($input)===false) { |
|
17 | 17 | $output=self::wrapStrings($input, $separator=' ', $valueQuote='"'); |
18 | 18 | } else { |
19 | 19 | $output=self::wrapObjects($input, $js, $separator, $valueQuote); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | private static function containsElement($input) { |
27 | - foreach ( $input as $v ) { |
|
27 | + foreach ($input as $v) { |
|
28 | 28 | if (\is_object($v) || \is_array($v)) |
29 | 29 | return true; |
30 | 30 | } |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | public static function wrapStrings($input, $separator=' ', $valueQuote='"') { |
35 | - if (JArray::isAssociative($input) === true) { |
|
36 | - $result=implode($separator, array_map(function ($v, $k) use($valueQuote) { |
|
37 | - return $k . '=' . $valueQuote . $v . $valueQuote; |
|
35 | + if (JArray::isAssociative($input)===true) { |
|
36 | + $result=implode($separator, array_map(function($v, $k) use($valueQuote) { |
|
37 | + return $k.'='.$valueQuote.$v.$valueQuote; |
|
38 | 38 | }, $input, array_keys($input))); |
39 | 39 | } else { |
40 | 40 | $result=implode($separator, array_values($input)); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | public static function wrapObjects($input, $js=NULL, $separator=' ', $valueQuote='"') { |
46 | - return implode($separator, array_map(function ($v) use($js, $separator, $valueQuote) { |
|
46 | + return implode($separator, array_map(function($v) use($js, $separator, $valueQuote) { |
|
47 | 47 | if (is_object($v)) |
48 | 48 | return $v->compile($js); |
49 | 49 | elseif (\is_array($v)) { |
@@ -29,23 +29,23 @@ discard block |
||
29 | 29 | * @property boolean $_edition |
30 | 30 | * @property mixed _modelInstance |
31 | 31 | */ |
32 | -trait FieldAsTrait{ |
|
32 | +trait FieldAsTrait { |
|
33 | 33 | |
34 | - abstract protected function _getFieldIdentifier($prefix,$name=""); |
|
35 | - abstract public function setValueFunction($index,$callback); |
|
34 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
35 | + abstract public function setValueFunction($index, $callback); |
|
36 | 36 | abstract protected function _getFieldName($index); |
37 | 37 | abstract protected function _getFieldCaption($index); |
38 | - abstract protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
|
38 | + abstract protected function _buttonAsSubmit(BaseHtml&$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @param HtmlFormField $element |
42 | 42 | * @param array $attributes |
43 | 43 | */ |
44 | - protected function _applyAttributes(BaseHtml $element,&$attributes,$index){ |
|
45 | - if(isset($attributes["jsCallback"])){ |
|
44 | + protected function _applyAttributes(BaseHtml $element, &$attributes, $index) { |
|
45 | + if (isset($attributes["jsCallback"])) { |
|
46 | 46 | $callback=$attributes["jsCallback"]; |
47 | - if(\is_callable($callback)){ |
|
48 | - $callback($element,$this->_modelInstance,$index); |
|
47 | + if (\is_callable($callback)) { |
|
48 | + $callback($element, $this->_modelInstance, $index); |
|
49 | 49 | unset($attributes["jsCallback"]); |
50 | 50 | } |
51 | 51 | } |
@@ -55,43 +55,43 @@ discard block |
||
55 | 55 | $element->fromArray($attributes); |
56 | 56 | } |
57 | 57 | |
58 | - private function _getLabelField($caption,$icon=NULL){ |
|
59 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
58 | + private function _getLabelField($caption, $icon=NULL) { |
|
59 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
60 | 60 | return $label; |
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | - protected function _addRules(HtmlFormField $element,&$attributes){ |
|
65 | - if(isset($attributes["rules"])){ |
|
64 | + protected function _addRules(HtmlFormField $element, &$attributes) { |
|
65 | + if (isset($attributes["rules"])) { |
|
66 | 66 | $rules=$attributes["rules"]; |
67 | - if(\is_array($rules)){ |
|
67 | + if (\is_array($rules)) { |
|
68 | 68 | $element->addRules($rules); |
69 | 69 | } |
70 | - else{ |
|
70 | + else { |
|
71 | 71 | $element->addRule($rules); |
72 | 72 | } |
73 | 73 | unset($attributes["rules"]); |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - protected function _prepareFormFields(HtmlFormField &$field,$name,&$attributes){ |
|
77 | + protected function _prepareFormFields(HtmlFormField&$field, $name, &$attributes) { |
|
78 | 78 | $field->setName($name); |
79 | 79 | $this->_addRules($field, $attributes); |
80 | 80 | return $field; |
81 | 81 | } |
82 | 82 | |
83 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
84 | - $this->setValueFunction($index,function($value,$instance,$index) use (&$attributes,$elementCallback,$prefix){ |
|
83 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
84 | + $this->setValueFunction($index, function($value, $instance, $index) use (&$attributes, $elementCallback, $prefix){ |
|
85 | 85 | $caption=$this->_getFieldCaption($index); |
86 | 86 | $name=$this->_getFieldName($index); |
87 | - $id=$this->_getFieldIdentifier($prefix,$name); |
|
88 | - if(isset($attributes["name"])){ |
|
87 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
88 | + if (isset($attributes["name"])) { |
|
89 | 89 | $name=$attributes["name"]; |
90 | 90 | unset($attributes["name"]); |
91 | 91 | } |
92 | - $element=$elementCallback($id,$name,$value,$caption); |
|
93 | - if(\is_array($attributes)){ |
|
94 | - $this->_applyAttributes($element, $attributes,$index); |
|
92 | + $element=$elementCallback($id, $name, $value, $caption); |
|
93 | + if (\is_array($attributes)) { |
|
94 | + $this->_applyAttributes($element, $attributes, $index); |
|
95 | 95 | } |
96 | 96 | $element->setDisabled(!$this->_edition); |
97 | 97 | return $element; |
@@ -100,188 +100,188 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | |
103 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
104 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
105 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
103 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
104 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
105 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
106 | 106 | return $pb; |
107 | 107 | }); |
108 | 108 | return $this; |
109 | 109 | } |
110 | 110 | |
111 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
112 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
113 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
111 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
112 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
113 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
114 | 114 | return $rating; |
115 | 115 | }); |
116 | 116 | return $this; |
117 | 117 | } |
118 | 118 | |
119 | - public function fieldAsLabel($index,$icon=NULL,$attributes=NULL){ |
|
120 | - return $this->_fieldAs(function($id,$name,$value) use($icon){ |
|
121 | - $lbl=new HtmlLabel($id,$value); |
|
122 | - if(isset($icon)) |
|
119 | + public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) { |
|
120 | + return $this->_fieldAs(function($id, $name, $value) use($icon){ |
|
121 | + $lbl=new HtmlLabel($id, $value); |
|
122 | + if (isset($icon)) |
|
123 | 123 | $lbl->addIcon($icon); |
124 | 124 | return $lbl; |
125 | - }, $index,$attributes,"label"); |
|
125 | + }, $index, $attributes, "label"); |
|
126 | 126 | } |
127 | 127 | |
128 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
129 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
130 | - $header=new HtmlHeader($id,$niveau,$value); |
|
131 | - if(isset($icon)) |
|
128 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
129 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
130 | + $header=new HtmlHeader($id, $niveau, $value); |
|
131 | + if (isset($icon)) |
|
132 | 132 | $header->asIcon($icon, $value); |
133 | 133 | return $header; |
134 | - }, $index,$attributes,"header"); |
|
134 | + }, $index, $attributes, "header"); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | |
138 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
139 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
140 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
138 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
139 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
140 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
141 | 141 | return $image; |
142 | 142 | }); |
143 | 143 | return $this; |
144 | 144 | } |
145 | 145 | |
146 | - public function fieldAsFlag($index){ |
|
147 | - $this->setValueFunction($index,function($flag){ |
|
148 | - $flag=new HtmlFlag($this->_getFieldIdentifier("flag"),$flag); |
|
146 | + public function fieldAsFlag($index) { |
|
147 | + $this->setValueFunction($index, function($flag) { |
|
148 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
149 | 149 | return $flag; |
150 | 150 | }); |
151 | 151 | return $this; |
152 | 152 | } |
153 | 153 | |
154 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
155 | - return $this->_fieldAs(function($id,$name,$value){ |
|
156 | - $img=new HtmlImage($id,$value); |
|
154 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
155 | + return $this->_fieldAs(function($id, $name, $value) { |
|
156 | + $img=new HtmlImage($id, $value); |
|
157 | 157 | $img->asAvatar(); |
158 | 158 | return $img; |
159 | - }, $index,$attributes,"avatar"); |
|
159 | + }, $index, $attributes, "avatar"); |
|
160 | 160 | } |
161 | 161 | |
162 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
163 | - return $this->_fieldAs(function($id,$name,$value) use($attributes){ |
|
164 | - $input= new HtmlFormRadio($id,$name,$value,$value); |
|
162 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
163 | + return $this->_fieldAs(function($id, $name, $value) use($attributes){ |
|
164 | + $input=new HtmlFormRadio($id, $name, $value, $value); |
|
165 | 165 | return $this->_prepareFormFields($input, $name, $attributes); |
166 | - }, $index,$attributes,"radio"); |
|
166 | + }, $index, $attributes, "radio"); |
|
167 | 167 | } |
168 | 168 | |
169 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
170 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
171 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
172 | - }, $index,$attributes,"radios"); |
|
169 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
170 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
171 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
172 | + }, $index, $attributes, "radios"); |
|
173 | 173 | } |
174 | 174 | |
175 | - public function fieldAsInput($index,$attributes=NULL){ |
|
176 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
177 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
175 | + public function fieldAsInput($index, $attributes=NULL) { |
|
176 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
177 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
178 | 178 | return $this->_prepareFormFields($input, $name, $attributes); |
179 | - }, $index,$attributes,"input"); |
|
179 | + }, $index, $attributes, "input"); |
|
180 | 180 | } |
181 | 181 | |
182 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
183 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
184 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
182 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
183 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
184 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
185 | 185 | return $this->_prepareFormFields($textarea, $name, $attributes); |
186 | - }, $index,$attributes,"textarea"); |
|
186 | + }, $index, $attributes, "textarea"); |
|
187 | 187 | } |
188 | 188 | |
189 | - public function fieldAsElement($index,$tagName="div",$baseClass="",$attributes=NULL){ |
|
190 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes,$tagName,$baseClass){ |
|
191 | - $div=new HtmlSemDoubleElement($id,$tagName,$baseClass); |
|
189 | + public function fieldAsElement($index, $tagName="div", $baseClass="", $attributes=NULL) { |
|
190 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass){ |
|
191 | + $div=new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
192 | 192 | $div->setContent(\htmlentities($value)); |
193 | - $textarea=new HtmlFormField("field-".$id, $div,$caption); |
|
193 | + $textarea=new HtmlFormField("field-".$id, $div, $caption); |
|
194 | 194 | return $this->_prepareFormFields($textarea, $name, $attributes); |
195 | - }, $index,$attributes,"element"); |
|
195 | + }, $index, $attributes, "element"); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
199 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
200 | - if(!\is_array($attributes)){ |
|
199 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
200 | + if (!\is_array($attributes)) { |
|
201 | 201 | $attributes=[]; |
202 | 202 | } |
203 | 203 | $attributes["inputType"]="hidden"; |
204 | - return $this->fieldAsInput($index,$attributes); |
|
204 | + return $this->fieldAsInput($index, $attributes); |
|
205 | 205 | } |
206 | 206 | |
207 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
208 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($attributes){ |
|
209 | - if($caption===null || $caption==="") |
|
207 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
208 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($attributes){ |
|
209 | + if ($caption===null || $caption==="") |
|
210 | 210 | $caption=""; |
211 | - $input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier()); |
|
211 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
212 | 212 | $input->setChecked(JString::isBooleanTrue($value)); |
213 | 213 | return $this->_prepareFormFields($input, $name, $attributes); |
214 | - }, $index,$attributes,"ck"); |
|
214 | + }, $index, $attributes, "ck"); |
|
215 | 215 | } |
216 | 216 | |
217 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
218 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple,$attributes){ |
|
219 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value); |
|
220 | - $dd->asSelect($name,$multiple); |
|
217 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
218 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple, $attributes){ |
|
219 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value); |
|
220 | + $dd->asSelect($name, $multiple); |
|
221 | 221 | return $this->_prepareFormFields($dd, $name, $attributes); |
222 | - }, $index,$attributes,"dd"); |
|
222 | + }, $index, $attributes, "dd"); |
|
223 | 223 | } |
224 | 224 | |
225 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
226 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
227 | - $mess= new HtmlMessage("message-".$id,$caption); |
|
225 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
226 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
227 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
228 | 228 | $mess->addHeader($value); |
229 | 229 | return $mess; |
230 | - }, $index,$attributes,"message"); |
|
230 | + }, $index, $attributes, "message"); |
|
231 | 231 | } |
232 | 232 | |
233 | - public function fieldAsLink($index,$attributes=NULL){ |
|
234 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
235 | - $lnk= new HtmlLink("message-".$id,"#",$caption); |
|
233 | + public function fieldAsLink($index, $attributes=NULL) { |
|
234 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
235 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
236 | 236 | return $lnk; |
237 | - }, $index,$attributes,"link"); |
|
237 | + }, $index, $attributes, "link"); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /**Change fields type |
241 | 241 | * @param array $types an array or associative array $type=>$attributes |
242 | 242 | */ |
243 | - public function fieldsAs(array $types){ |
|
243 | + public function fieldsAs(array $types) { |
|
244 | 244 | $i=0; |
245 | - if(JArray::isAssociative($types)){ |
|
246 | - foreach ($types as $type=>$attributes){ |
|
247 | - if(\is_int($type)) |
|
248 | - $this->fieldAs($i++,$attributes,[]); |
|
249 | - else{ |
|
250 | - $type=preg_replace('/\d/', '', $type ); |
|
251 | - $this->fieldAs($i++,$type,$attributes); |
|
245 | + if (JArray::isAssociative($types)) { |
|
246 | + foreach ($types as $type=>$attributes) { |
|
247 | + if (\is_int($type)) |
|
248 | + $this->fieldAs($i++, $attributes, []); |
|
249 | + else { |
|
250 | + $type=preg_replace('/\d/', '', $type); |
|
251 | + $this->fieldAs($i++, $type, $attributes); |
|
252 | 252 | } |
253 | 253 | } |
254 | - }else{ |
|
255 | - foreach ($types as $type){ |
|
256 | - $this->fieldAs($i++,$type); |
|
254 | + } else { |
|
255 | + foreach ($types as $type) { |
|
256 | + $this->fieldAs($i++, $type); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | - public function fieldAs($index,$type,$attributes=NULL){ |
|
261 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
262 | 262 | $method="fieldAs".\ucfirst($type); |
263 | - if(\method_exists($this, $method)){ |
|
264 | - if(!\is_array($attributes)){ |
|
263 | + if (\method_exists($this, $method)) { |
|
264 | + if (!\is_array($attributes)) { |
|
265 | 265 | $attributes=[$index]; |
266 | - }else{ |
|
266 | + } else { |
|
267 | 267 | \array_unshift($attributes, $index); |
268 | 268 | } |
269 | - \call_user_func_array([$this,$method], $attributes); |
|
269 | + \call_user_func_array([$this, $method], $attributes); |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
273 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
274 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
275 | - $button=new HtmlButton($id,$caption,$cssStyle); |
|
276 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]); |
|
273 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
274 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
275 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
276 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
|
277 | 277 | return $button; |
278 | - }, $index,$attributes,"submit"); |
|
278 | + }, $index, $attributes, "submit"); |
|
279 | 279 | } |
280 | 280 | |
281 | - public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){ |
|
282 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
283 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
281 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
282 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
283 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
284 | 284 | return $button; |
285 | - }, $index,$attributes,"button"); |
|
285 | + }, $index, $attributes, "button"); |
|
286 | 286 | } |
287 | 287 | } |
@@ -29,27 +29,27 @@ |
||
29 | 29 | $rowClass="_json"; |
30 | 30 | extract($this->parameters); |
31 | 31 | $result=$this->_eventPreparing($preventDefault, $stopPropagation); |
32 | - switch($this->method) { |
|
32 | + switch ($this->method) { |
|
33 | 33 | case "get": |
34 | - $result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr,$jqueryDone,$ajaxTransition); |
|
34 | + $result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr, $jqueryDone, $ajaxTransition); |
|
35 | 35 | break; |
36 | 36 | case "post": |
37 | - $result.=$js->postDeferred($url, $responseElement, $params, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition); |
|
37 | + $result.=$js->postDeferred($url, $responseElement, $params, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition); |
|
38 | 38 | break; |
39 | 39 | case "postForm": |
40 | - $result.=$js->postFormDeferred($url, $form, $responseElement, $params,$validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition); |
|
40 | + $result.=$js->postFormDeferred($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition); |
|
41 | 41 | break; |
42 | 42 | case "json": |
43 | - $result.=$js->jsonDeferred($url,$method,$params,$jsCallback); |
|
43 | + $result.=$js->jsonDeferred($url, $method, $params, $jsCallback); |
|
44 | 44 | break; |
45 | 45 | case "jsonArray": |
46 | - $result.=$js->jsonArrayDeferred($modelSelector, $url,$method,$params,$jsCallback,$rowClass); |
|
46 | + $result.=$js->jsonArrayDeferred($modelSelector, $url, $method, $params, $jsCallback, $rowClass); |
|
47 | 47 | break; |
48 | 48 | } |
49 | 49 | return $result; |
50 | 50 | } |
51 | 51 | |
52 | - protected function _eventPreparing($preventDefault,$stopPropagation){ |
|
52 | + protected function _eventPreparing($preventDefault, $stopPropagation) { |
|
53 | 53 | $result=""; |
54 | 54 | if ($preventDefault===true) { |
55 | 55 | $result.=Javascript::$preventDefault; |
@@ -2,5 +2,5 @@ |
||
2 | 2 | namespace Ajax\semantic\html\base\constants; |
3 | 3 | use Ajax\common\BaseEnum; |
4 | 4 | abstract class Social extends BaseEnum { |
5 | - const FACEBOOK="facebook", TWITTER="twitter",GOOGLEPLUS="google plus",VK="vk",LINKEDIN="linkedin",INSTAGRAM="instagram",YOUTUBE="youtube",GITHUB="github"; |
|
5 | + const FACEBOOK="facebook", TWITTER="twitter", GOOGLEPLUS="google plus", VK="vk", LINKEDIN="linkedin", INSTAGRAM="instagram", YOUTUBE="youtube", GITHUB="github"; |
|
6 | 6 | } |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | * @return $this |
28 | 28 | */ |
29 | 29 | public function setOnShow($jsCode) { |
30 | - $jsCode=str_ireplace("\"","%quote%", $jsCode); |
|
30 | + $jsCode=str_ireplace("\"", "%quote%", $jsCode); |
|
31 | 31 | return $this->setParam("onShow", "%function(){".$jsCode."}%"); |
32 | 32 | } |
33 | 33 | |
34 | - public function setExclusive($value){ |
|
34 | + public function setExclusive($value) { |
|
35 | 35 | return $this->setParam("exclusive", $value); |
36 | 36 | } |
37 | 37 | |
@@ -40,19 +40,19 @@ discard block |
||
40 | 40 | * @param string $popup the css selector of the popup |
41 | 41 | * @return \Ajax\semantic\components\Popup |
42 | 42 | */ |
43 | - public function setPopup($popup){ |
|
43 | + public function setPopup($popup) { |
|
44 | 44 | return $this->setParam("popup", $popup); |
45 | 45 | } |
46 | 46 | |
47 | - public function setInline($value){ |
|
47 | + public function setInline($value) { |
|
48 | 48 | return $this->setParam("inline", $value); |
49 | 49 | } |
50 | 50 | |
51 | - public function setPosition($value){ |
|
51 | + public function setPosition($value) { |
|
52 | 52 | return $this->setParam("position", $value); |
53 | 53 | } |
54 | 54 | |
55 | - public function setSetFluidWidth($value){ |
|
55 | + public function setSetFluidWidth($value) { |
|
56 | 56 | return $this->setParam("setFluidWidth", $value); |
57 | 57 | } |
58 | 58 | } |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | * @param array $instances |
19 | 19 | * @return DataTable |
20 | 20 | */ |
21 | - public function dataTable($identifier,$model, $instances){ |
|
22 | - return $this->addHtmlComponent(new DataTable($identifier,$model,$instances)); |
|
21 | + public function dataTable($identifier, $model, $instances) { |
|
22 | + return $this->addHtmlComponent(new DataTable($identifier, $model, $instances)); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | * @param array $instances |
29 | 29 | * @return JsonDataTable |
30 | 30 | */ |
31 | - public function jsonDataTable($identifier,$model, $instances){ |
|
32 | - return $this->addHtmlComponent(new JsonDataTable($identifier,$model,$instances)); |
|
31 | + public function jsonDataTable($identifier, $model, $instances) { |
|
32 | + return $this->addHtmlComponent(new JsonDataTable($identifier, $model, $instances)); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * @param object $instance |
38 | 38 | * @return DataElement |
39 | 39 | */ |
40 | - public function dataElement($identifier, $instance){ |
|
41 | - return $this->addHtmlComponent(new DataElement($identifier,$instance)); |
|
40 | + public function dataElement($identifier, $instance) { |
|
41 | + return $this->addHtmlComponent(new DataElement($identifier, $instance)); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * @param object $instance |
47 | 47 | * @return DataForm |
48 | 48 | */ |
49 | - public function dataForm($identifier, $instance){ |
|
50 | - return $this->addHtmlComponent(new DataForm($identifier,$instance)); |
|
49 | + public function dataForm($identifier, $instance) { |
|
50 | + return $this->addHtmlComponent(new DataForm($identifier, $instance)); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * @param object $instance |
56 | 56 | * @return FormLogin |
57 | 57 | */ |
58 | - public function defaultLogin($identifier,$instance=null){ |
|
59 | - return $this->addHtmlComponent(FormLogin::regular($identifier,$instance)); |
|
58 | + public function defaultLogin($identifier, $instance=null) { |
|
59 | + return $this->addHtmlComponent(FormLogin::regular($identifier, $instance)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | * @param object $instance |
65 | 65 | * @return FormLogin |
66 | 66 | */ |
67 | - public function smallLogin($identifier,$instance=null){ |
|
68 | - return $this->addHtmlComponent(FormLogin::small($identifier,$instance)); |
|
67 | + public function smallLogin($identifier, $instance=null) { |
|
68 | + return $this->addHtmlComponent(FormLogin::small($identifier, $instance)); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * @param object $instance |
74 | 74 | * @return FormLogin |
75 | 75 | */ |
76 | - public function segmentedLogin($identifier,$instance=null){ |
|
77 | - return $this->addHtmlComponent(FormLogin::attachedSegment($identifier,$instance)); |
|
76 | + public function segmentedLogin($identifier, $instance=null) { |
|
77 | + return $this->addHtmlComponent(FormLogin::attachedSegment($identifier, $instance)); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param object $instance |
83 | 83 | * @return FormAccount |
84 | 84 | */ |
85 | - public function defaultAccount($identifier,$instance=null){ |
|
86 | - return $this->addHtmlComponent(FormAccount::regular($identifier,$instance)); |
|
85 | + public function defaultAccount($identifier, $instance=null) { |
|
86 | + return $this->addHtmlComponent(FormAccount::regular($identifier, $instance)); |
|
87 | 87 | } |
88 | 88 | } |
@@ -7,26 +7,26 @@ |
||
7 | 7 | |
8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
9 | 9 | |
10 | - public function __construct($identifier,$items=array(), $label=NULL,$value="",$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="", $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="",$associative=true){ |
|
22 | - return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative); |
|
21 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value="", $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 | } |
@@ -10,61 +10,61 @@ |
||
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 FormAccount($identifier,$modelInstance, |
|
23 | - ["message","login","password","passwordConf","email","submit","error"], |
|
21 | + public static function regular($identifier, $modelInstance=null) { |
|
22 | + return new FormAccount($identifier, $modelInstance, |
|
23 | + ["message", "login", "password", "passwordConf", "email", "submit", "error"], |
|
24 | 24 | ["message"=>[["icon"=>"sign in"]], |
25 | 25 | "input0"=>[["rules"=>"empty"]], |
26 | - "input1"=>[["inputType"=>"password","rules"=> ['minLength[6]', 'empty']]], |
|
27 | - "input2"=>[["inputType"=>"password","rules"=> ['minLength[6]', 'empty', 'match[password]']]], |
|
26 | + "input1"=>[["inputType"=>"password", "rules"=> ['minLength[6]', 'empty']]], |
|
27 | + "input2"=>[["inputType"=>"password", "rules"=> ['minLength[6]', 'empty', 'match[password]']]], |
|
28 | 28 | "input3"=>[["rules"=>"email"]], |
29 | 29 | "submit"=>["green fluid"], |
30 | 30 | "message2"=>[["error"=>true]]], |
31 | - ["Account","login","password","passwordConf","email","submit","error"], |
|
32 | - ["Please enter your account informations","Login","Password","Password confirmation","Email address","Creation"], |
|
33 | - [0,1,3,4,5,6]); |
|
31 | + ["Account", "login", "password", "passwordConf", "email", "submit", "error"], |
|
32 | + ["Please enter your account informations", "Login", "Password", "Password confirmation", "Email address", "Creation"], |
|
33 | + [0, 1, 3, 4, 5, 6]); |
|
34 | 34 | } |
35 | 35 | |
36 | - public static function smallInline($identifier,$modelInstance=null){ |
|
37 | - $result=new FormAccount($identifier,$modelInstance, |
|
38 | - ["login","password","submit"], |
|
39 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
40 | - ["login","password","submit"], |
|
41 | - ["","","Connection"], |
|
36 | + public static function smallInline($identifier, $modelInstance=null) { |
|
37 | + $result=new FormAccount($identifier, $modelInstance, |
|
38 | + ["login", "password", "submit"], |
|
39 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
40 | + ["login", "password", "submit"], |
|
41 | + ["", "", "Connection"], |
|
42 | 42 | [2]); |
43 | 43 | $result->addDividerBefore(0, "Connection"); |
44 | 44 | return $result; |
45 | 45 | } |
46 | 46 | |
47 | - public static function small($identifier,$modelInstance=null){ |
|
48 | - $result=new FormAccount($identifier,$modelInstance, |
|
49 | - ["login","password","passwordConf","email","submit"], |
|
47 | + public static function small($identifier, $modelInstance=null) { |
|
48 | + $result=new FormAccount($identifier, $modelInstance, |
|
49 | + ["login", "password", "passwordConf", "email", "submit"], |
|
50 | 50 | [ |
51 | 51 | "input0"=>[["rules"=>"empty"]], |
52 | - "input1"=>[["inputType"=>"password","rules"=>['minLength[6]', 'empty']]], |
|
53 | - "input2"=>[["inputType"=>"password","rules"=> ['minLength[6]', 'empty', 'match[password]']]], |
|
52 | + "input1"=>[["inputType"=>"password", "rules"=>['minLength[6]', 'empty']]], |
|
53 | + "input2"=>[["inputType"=>"password", "rules"=> ['minLength[6]', 'empty', 'match[password]']]], |
|
54 | 54 | "input3"=>[["rules"=>"email"]], |
55 | 55 | "submit"=>["green basic"]], |
56 | - ["login","password","passwordConf","email","submit"], |
|
57 | - ["Login","Password","Password confirmation","Email address","Creation"], |
|
58 | - [1,2]); |
|
56 | + ["login", "password", "passwordConf", "email", "submit"], |
|
57 | + ["Login", "Password", "Password confirmation", "Email address", "Creation"], |
|
58 | + [1, 2]); |
|
59 | 59 | $result->addDividerBefore(0, "Creation"); |
60 | 60 | return $result; |
61 | 61 | } |
62 | 62 | |
63 | - public static function attachedSegment($identifier,$modelInstance=null){ |
|
64 | - $result=self::regular($identifier,$modelInstance); |
|
65 | - $result->fieldAsMessage("message",["icon"=>"sign in","attached"=>true]); |
|
66 | - $result->addWrapper("message",null,"<div class='ui attached segment'>"); |
|
67 | - $result->addWrapper("error", null,"</div>"); |
|
63 | + public static function attachedSegment($identifier, $modelInstance=null) { |
|
64 | + $result=self::regular($identifier, $modelInstance); |
|
65 | + $result->fieldAsMessage("message", ["icon"=>"sign in", "attached"=>true]); |
|
66 | + $result->addWrapper("message", null, "<div class='ui attached segment'>"); |
|
67 | + $result->addWrapper("error", null, "</div>"); |
|
68 | 68 | return $result; |
69 | 69 | } |
70 | 70 | } |