@@ -6,16 +6,16 @@ discard block |
||
6 | 6 | public static $preventDefault="\nif(event && event.preventDefault) event.preventDefault();\n"; |
7 | 7 | public static $stopPropagation="\nif(event && event.stopPropagation) event.stopPropagation();\n"; |
8 | 8 | |
9 | - public static function draggable($attr="id"){ |
|
9 | + public static function draggable($attr="id") { |
|
10 | 10 | return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;dt.setData("text/plain",JSON.stringify({id:$(event.target).attr("id"),data:$(event.target).attr("'.$attr.'")}));'; |
11 | 11 | } |
12 | 12 | |
13 | - public static function dropZone($jqueryDone,$jsCallback=""){ |
|
13 | + public static function dropZone($jqueryDone, $jsCallback="") { |
|
14 | 14 | return 'var dt=event.dataTransfer || event.originalEvent.dataTransfer;var _data=JSON.parse(dt.getData("text/plain"));$(event.target).'.$jqueryDone.'($("#"+_data.id));var data=_data.data;'.$jsCallback; |
15 | 15 | } |
16 | 16 | |
17 | - public static function containsCode($expression){ |
|
18 | - return strrpos($expression, 'this')!==false||strrpos($expression, 'event')!==false||strrpos($expression, 'self')!==false; |
|
17 | + public static function containsCode($expression) { |
|
18 | + return strrpos($expression, 'this')!==false || strrpos($expression, 'event')!==false || strrpos($expression, 'self')!==false; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | $value=implode(",", $value); |
47 | 47 | } |
48 | 48 | if (self::containsCode($value)===false) { |
49 | - $value=\str_replace(["\\","\""], ["\\\\","\\\""], $value); |
|
49 | + $value=\str_replace(["\\", "\""], ["\\\\", "\\\""], $value); |
|
50 | 50 | $value='"'.$value.'"'; |
51 | 51 | } |
52 | - return trim($value,"%"); |
|
52 | + return trim($value, "%"); |
|
53 | 53 | } |
54 | 54 | |
55 | - public static function prep_jquery_selector($value){ |
|
56 | - if(JString::startswith($value, '$(')===false){ |
|
55 | + public static function prep_jquery_selector($value) { |
|
56 | + if (JString::startswith($value, '$(')===false) { |
|
57 | 57 | return '$('.self::prep_value($value).')'; |
58 | 58 | } |
59 | 59 | return $value; |
@@ -31,23 +31,23 @@ discard block |
||
31 | 31 | * @property boolean $_edition |
32 | 32 | * @property mixed _modelInstance |
33 | 33 | */ |
34 | -trait FieldAsTrait{ |
|
34 | +trait FieldAsTrait { |
|
35 | 35 | |
36 | - abstract protected function _getFieldIdentifier($prefix,$name=""); |
|
37 | - abstract public function setValueFunction($index,$callback); |
|
36 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
37 | + abstract public function setValueFunction($index, $callback); |
|
38 | 38 | abstract protected function _getFieldName($index); |
39 | 39 | abstract protected function _getFieldCaption($index); |
40 | - abstract protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
|
40 | + abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @param HtmlFormField $element |
44 | 44 | * @param array $attributes |
45 | 45 | */ |
46 | - protected function _applyAttributes(BaseHtml $element,&$attributes,$index,$instance=null){ |
|
47 | - if(isset($attributes["jsCallback"])){ |
|
46 | + protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance=null) { |
|
47 | + if (isset($attributes["jsCallback"])) { |
|
48 | 48 | $callback=$attributes["jsCallback"]; |
49 | - if(\is_callable($callback)){ |
|
50 | - $callback($element,$instance,$index,InstanceViewer::$index); |
|
49 | + if (\is_callable($callback)) { |
|
50 | + $callback($element, $instance, $index, InstanceViewer::$index); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | unset($attributes["rules"]); |
@@ -56,43 +56,43 @@ discard block |
||
56 | 56 | $element->fromArray($attributes); |
57 | 57 | } |
58 | 58 | |
59 | - private function _getLabelField($caption,$icon=NULL){ |
|
60 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
59 | + private function _getLabelField($caption, $icon=NULL) { |
|
60 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
61 | 61 | return $label; |
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | - protected function _addRules(HtmlFormField $element,&$attributes){ |
|
66 | - if(isset($attributes["rules"])){ |
|
65 | + protected function _addRules(HtmlFormField $element, &$attributes) { |
|
66 | + if (isset($attributes["rules"])) { |
|
67 | 67 | $rules=$attributes["rules"]; |
68 | - if(\is_array($rules)){ |
|
68 | + if (\is_array($rules)) { |
|
69 | 69 | $element->addRules($rules); |
70 | 70 | } |
71 | - else{ |
|
71 | + else { |
|
72 | 72 | $element->addRule($rules); |
73 | 73 | } |
74 | 74 | unset($attributes["rules"]); |
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | - protected function _prepareFormFields(HtmlFormField &$field,$name,&$attributes){ |
|
78 | + protected function _prepareFormFields(HtmlFormField &$field, $name, &$attributes) { |
|
79 | 79 | $field->setName($name); |
80 | 80 | $this->_addRules($field, $attributes); |
81 | 81 | return $field; |
82 | 82 | } |
83 | 83 | |
84 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
85 | - $this->setValueFunction($index,function($value,$instance,$index,$rowIndex) use (&$attributes,$elementCallback,$prefix){ |
|
84 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
85 | + $this->setValueFunction($index, function($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix){ |
|
86 | 86 | $caption=$this->_getFieldCaption($index); |
87 | 87 | $name=$this->_getFieldName($index); |
88 | - $id=$this->_getFieldIdentifier($prefix,$name); |
|
89 | - if(isset($attributes["name"])){ |
|
88 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
89 | + if (isset($attributes["name"])) { |
|
90 | 90 | $name=$attributes["name"]; |
91 | 91 | unset($attributes["name"]); |
92 | 92 | } |
93 | - $element=$elementCallback($id,$name,$value,$caption); |
|
94 | - if(\is_array($attributes)){ |
|
95 | - $this->_applyAttributes($element, $attributes,$index,$instance); |
|
93 | + $element=$elementCallback($id, $name, $value, $caption); |
|
94 | + if (\is_array($attributes)) { |
|
95 | + $this->_applyAttributes($element, $attributes, $index, $instance); |
|
96 | 96 | } |
97 | 97 | $element->setDisabled(!$this->_edition); |
98 | 98 | return $element; |
@@ -101,205 +101,205 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | |
104 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
105 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
106 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
104 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
105 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
106 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
107 | 107 | return $pb; |
108 | 108 | }); |
109 | 109 | return $this; |
110 | 110 | } |
111 | 111 | |
112 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
113 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
114 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
112 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
113 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
114 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
115 | 115 | return $rating; |
116 | 116 | }); |
117 | 117 | return $this; |
118 | 118 | } |
119 | 119 | |
120 | - public function fieldAsLabel($index,$icon=NULL,$attributes=NULL){ |
|
121 | - return $this->_fieldAs(function($id,$name,$value) use($icon){ |
|
122 | - $lbl=new HtmlLabel($id,$value); |
|
123 | - if(isset($icon)) |
|
120 | + public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) { |
|
121 | + return $this->_fieldAs(function($id, $name, $value) use($icon){ |
|
122 | + $lbl=new HtmlLabel($id, $value); |
|
123 | + if (isset($icon)) |
|
124 | 124 | $lbl->addIcon($icon); |
125 | 125 | return $lbl; |
126 | - }, $index,$attributes,"label"); |
|
126 | + }, $index, $attributes, "label"); |
|
127 | 127 | } |
128 | 128 | |
129 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
130 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
131 | - $header=new HtmlHeader($id,$niveau,$value); |
|
132 | - if(isset($icon)) |
|
129 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
130 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
131 | + $header=new HtmlHeader($id, $niveau, $value); |
|
132 | + if (isset($icon)) |
|
133 | 133 | $header->asIcon($icon, $value); |
134 | 134 | return $header; |
135 | - }, $index,$attributes,"header"); |
|
135 | + }, $index, $attributes, "header"); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
139 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
140 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
141 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
139 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
140 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
141 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
142 | 142 | return $image; |
143 | 143 | }); |
144 | 144 | return $this; |
145 | 145 | } |
146 | 146 | |
147 | - public function fieldAsFlag($index){ |
|
148 | - $this->setValueFunction($index,function($flag){ |
|
149 | - $flag=new HtmlFlag($this->_getFieldIdentifier("flag"),$flag); |
|
147 | + public function fieldAsFlag($index) { |
|
148 | + $this->setValueFunction($index, function($flag) { |
|
149 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
150 | 150 | return $flag; |
151 | 151 | }); |
152 | 152 | return $this; |
153 | 153 | } |
154 | 154 | |
155 | - public function fieldAsIcon($index){ |
|
156 | - $this->setValueFunction($index,function($icon){ |
|
157 | - $icon=new HtmlIcon($this->_getFieldIdentifier("icon"),$icon); |
|
155 | + public function fieldAsIcon($index) { |
|
156 | + $this->setValueFunction($index, function($icon) { |
|
157 | + $icon=new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
158 | 158 | return $icon; |
159 | 159 | }); |
160 | 160 | return $this; |
161 | 161 | } |
162 | 162 | |
163 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
164 | - return $this->_fieldAs(function($id,$name,$value){ |
|
165 | - $img=new HtmlImage($id,$value); |
|
163 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
164 | + return $this->_fieldAs(function($id, $name, $value) { |
|
165 | + $img=new HtmlImage($id, $value); |
|
166 | 166 | $img->asAvatar(); |
167 | 167 | return $img; |
168 | - }, $index,$attributes,"avatar"); |
|
168 | + }, $index, $attributes, "avatar"); |
|
169 | 169 | } |
170 | 170 | |
171 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
172 | - return $this->_fieldAs(function($id,$name,$value) use($attributes){ |
|
173 | - $input= new HtmlFormRadio($id,$name,$value,$value); |
|
171 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
172 | + return $this->_fieldAs(function($id, $name, $value) use($attributes){ |
|
173 | + $input=new HtmlFormRadio($id, $name, $value, $value); |
|
174 | 174 | return $this->_prepareFormFields($input, $name, $attributes); |
175 | - }, $index,$attributes,"radio"); |
|
175 | + }, $index, $attributes, "radio"); |
|
176 | 176 | } |
177 | 177 | |
178 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
179 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
180 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
181 | - }, $index,$attributes,"radios"); |
|
178 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
179 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
180 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
181 | + }, $index, $attributes, "radios"); |
|
182 | 182 | } |
183 | 183 | |
184 | - public function fieldAsList($index,$classNames="",$attributes=NULL){ |
|
185 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($classNames){ |
|
186 | - $result= new HtmlList($name,$value); |
|
184 | + public function fieldAsList($index, $classNames="", $attributes=NULL) { |
|
185 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($classNames){ |
|
186 | + $result=new HtmlList($name, $value); |
|
187 | 187 | $result->addClass($classNames); |
188 | 188 | return $result; |
189 | - }, $index,$attributes,"list"); |
|
189 | + }, $index, $attributes, "list"); |
|
190 | 190 | } |
191 | 191 | |
192 | - public function fieldAsInput($index,$attributes=NULL){ |
|
193 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
194 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
192 | + public function fieldAsInput($index, $attributes=NULL) { |
|
193 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
194 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
195 | 195 | return $this->_prepareFormFields($input, $name, $attributes); |
196 | - }, $index,$attributes,"input"); |
|
196 | + }, $index, $attributes, "input"); |
|
197 | 197 | } |
198 | 198 | |
199 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
200 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
201 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
199 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
200 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
201 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
202 | 202 | return $this->_prepareFormFields($textarea, $name, $attributes); |
203 | - }, $index,$attributes,"textarea"); |
|
203 | + }, $index, $attributes, "textarea"); |
|
204 | 204 | } |
205 | 205 | |
206 | - public function fieldAsElement($index,$tagName="div",$baseClass="",$attributes=NULL){ |
|
207 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes,$tagName,$baseClass){ |
|
208 | - $div=new HtmlSemDoubleElement($id,$tagName,$baseClass); |
|
206 | + public function fieldAsElement($index, $tagName="div", $baseClass="", $attributes=NULL) { |
|
207 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass){ |
|
208 | + $div=new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
209 | 209 | $div->setContent(\htmlentities($value)); |
210 | - $textarea=new HtmlFormField("field-".$id, $div,$caption); |
|
210 | + $textarea=new HtmlFormField("field-".$id, $div, $caption); |
|
211 | 211 | return $this->_prepareFormFields($textarea, $name, $attributes); |
212 | - }, $index,$attributes,"element"); |
|
212 | + }, $index, $attributes, "element"); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
216 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
217 | - if(!\is_array($attributes)){ |
|
216 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
217 | + if (!\is_array($attributes)) { |
|
218 | 218 | $attributes=[]; |
219 | 219 | } |
220 | 220 | $attributes["inputType"]="hidden"; |
221 | 221 | $attributes["style"]="display:none;"; |
222 | - return $this->fieldAsInput($index,$attributes); |
|
222 | + return $this->fieldAsInput($index, $attributes); |
|
223 | 223 | } |
224 | 224 | |
225 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
226 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($attributes){ |
|
227 | - if($caption===null || $caption==="") |
|
225 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
226 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($attributes){ |
|
227 | + if ($caption===null || $caption==="") |
|
228 | 228 | $caption=""; |
229 | - $input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier()); |
|
229 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
230 | 230 | $input->setChecked(JString::isBooleanTrue($value)); |
231 | 231 | return $this->_prepareFormFields($input, $name, $attributes); |
232 | - }, $index,$attributes,"ck"); |
|
232 | + }, $index, $attributes, "ck"); |
|
233 | 233 | } |
234 | 234 | |
235 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
236 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple,$attributes){ |
|
237 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value); |
|
238 | - $dd->asSelect($name,$multiple); |
|
235 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
236 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple, $attributes){ |
|
237 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value); |
|
238 | + $dd->asSelect($name, $multiple); |
|
239 | 239 | return $this->_prepareFormFields($dd, $name, $attributes); |
240 | - }, $index,$attributes,"dd"); |
|
240 | + }, $index, $attributes, "dd"); |
|
241 | 241 | } |
242 | 242 | |
243 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
244 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
245 | - $mess= new HtmlMessage("message-".$id,$caption); |
|
243 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
244 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
245 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
246 | 246 | $mess->addHeader($value); |
247 | 247 | return $mess; |
248 | - }, $index,$attributes,"message"); |
|
248 | + }, $index, $attributes, "message"); |
|
249 | 249 | } |
250 | 250 | |
251 | - public function fieldAsLink($index,$attributes=NULL){ |
|
252 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
253 | - $lnk= new HtmlLink("message-".$id,"#",$caption); |
|
251 | + public function fieldAsLink($index, $attributes=NULL) { |
|
252 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
253 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
254 | 254 | return $lnk; |
255 | - }, $index,$attributes,"link"); |
|
255 | + }, $index, $attributes, "link"); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /**Change fields type |
259 | 259 | * @param array $types an array or associative array $type=>$attributes |
260 | 260 | */ |
261 | - public function fieldsAs(array $types){ |
|
261 | + public function fieldsAs(array $types) { |
|
262 | 262 | $i=0; |
263 | - if(JArray::isAssociative($types)){ |
|
264 | - foreach ($types as $type=>$attributes){ |
|
265 | - if(\is_int($type)) |
|
266 | - $this->fieldAs($i++,$attributes,[]); |
|
267 | - else{ |
|
268 | - $type=preg_replace('/\d/', '', $type ); |
|
269 | - $this->fieldAs($i++,$type,$attributes); |
|
263 | + if (JArray::isAssociative($types)) { |
|
264 | + foreach ($types as $type=>$attributes) { |
|
265 | + if (\is_int($type)) |
|
266 | + $this->fieldAs($i++, $attributes, []); |
|
267 | + else { |
|
268 | + $type=preg_replace('/\d/', '', $type); |
|
269 | + $this->fieldAs($i++, $type, $attributes); |
|
270 | 270 | } |
271 | 271 | } |
272 | - }else{ |
|
273 | - foreach ($types as $type){ |
|
274 | - $this->fieldAs($i++,$type); |
|
272 | + } else { |
|
273 | + foreach ($types as $type) { |
|
274 | + $this->fieldAs($i++, $type); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | } |
278 | 278 | |
279 | - public function fieldAs($index,$type,$attributes=NULL){ |
|
279 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
280 | 280 | $method="fieldAs".\ucfirst($type); |
281 | - if(\method_exists($this, $method)){ |
|
282 | - if(!\is_array($attributes)){ |
|
281 | + if (\method_exists($this, $method)) { |
|
282 | + if (!\is_array($attributes)) { |
|
283 | 283 | $attributes=[$index]; |
284 | - }else{ |
|
284 | + } else { |
|
285 | 285 | \array_unshift($attributes, $index); |
286 | 286 | } |
287 | - \call_user_func_array([$this,$method], $attributes); |
|
287 | + \call_user_func_array([$this, $method], $attributes); |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | |
291 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
292 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
293 | - $button=new HtmlButton($id,$caption,$cssStyle); |
|
294 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]); |
|
291 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
292 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
293 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
294 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
|
295 | 295 | return $button; |
296 | - }, $index,$attributes,"submit"); |
|
296 | + }, $index, $attributes, "submit"); |
|
297 | 297 | } |
298 | 298 | |
299 | - public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){ |
|
300 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
301 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
299 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
300 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
301 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
302 | 302 | return $button; |
303 | - }, $index,$attributes,"button"); |
|
303 | + }, $index, $attributes, "button"); |
|
304 | 304 | } |
305 | 305 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | use Ajax\semantic\html\modules\HtmlModal; |
21 | 21 | |
22 | 22 | abstract class Widget extends HtmlDoubleElement { |
23 | - use FieldAsTrait,FormTrait; |
|
23 | + use FieldAsTrait, FormTrait; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @var string classname |
@@ -53,17 +53,17 @@ discard block |
||
53 | 53 | protected $_generated; |
54 | 54 | |
55 | 55 | |
56 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
56 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
57 | 57 | parent::__construct($identifier); |
58 | 58 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
59 | 59 | $this->setModel($model); |
60 | - if(isset($modelInstance)){ |
|
60 | + if (isset($modelInstance)) { |
|
61 | 61 | $this->show($modelInstance); |
62 | 62 | } |
63 | 63 | $this->_generated=false; |
64 | 64 | } |
65 | 65 | |
66 | - protected function _init($instanceViewer,$contentKey,$content,$edition){ |
|
66 | + protected function _init($instanceViewer, $contentKey, $content, $edition) { |
|
67 | 67 | $this->_instanceViewer=$instanceViewer; |
68 | 68 | $this->content=[$contentKey=>$content]; |
69 | 69 | $this->_self=$content; |
@@ -75,31 +75,31 @@ discard block |
||
75 | 75 | * @param int|string $fieldName |
76 | 76 | * @return int|string|boolean |
77 | 77 | */ |
78 | - protected function _getIndex($fieldName){ |
|
78 | + protected function _getIndex($fieldName) { |
|
79 | 79 | $index=$fieldName; |
80 | - if(\is_string($fieldName)){ |
|
80 | + if (\is_string($fieldName)) { |
|
81 | 81 | $fields=$this->_instanceViewer->getVisibleProperties(); |
82 | 82 | $index=\array_search($fieldName, $fields); |
83 | 83 | } |
84 | 84 | return $index; |
85 | 85 | } |
86 | 86 | |
87 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
87 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
88 | 88 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
89 | 89 | } |
90 | 90 | |
91 | - protected function _getFieldName($index){ |
|
91 | + protected function _getFieldName($index) { |
|
92 | 92 | return $this->_instanceViewer->getFieldName($index); |
93 | 93 | } |
94 | 94 | |
95 | - protected function _getFieldCaption($index){ |
|
95 | + protected function _getFieldCaption($index) { |
|
96 | 96 | return $this->_instanceViewer->getCaption($index); |
97 | 97 | } |
98 | 98 | |
99 | - abstract protected function _setToolbarPosition($table,$captions=NULL); |
|
99 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
100 | 100 | |
101 | - public function show($modelInstance){ |
|
102 | - if(\is_array($modelInstance)){ |
|
101 | + public function show($modelInstance) { |
|
102 | + if (\is_array($modelInstance)) { |
|
103 | 103 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
104 | 104 | } |
105 | 105 | $this->_modelInstance=$modelInstance; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | abstract public function getHtmlComponent(); |
127 | 127 | |
128 | - public function setAttached($value=true){ |
|
128 | + public function setAttached($value=true) { |
|
129 | 129 | return $this->getHtmlComponent()->setAttached($value); |
130 | 130 | } |
131 | 131 | |
@@ -136,65 +136,65 @@ discard block |
||
136 | 136 | * @param callable $callback function called after the field compilation |
137 | 137 | * @return Widget |
138 | 138 | */ |
139 | - public function afterCompile($index,$callback){ |
|
139 | + public function afterCompile($index, $callback) { |
|
140 | 140 | $index=$this->_getIndex($index); |
141 | 141 | $this->_instanceViewer->afterCompile($index, $callback); |
142 | 142 | return $this; |
143 | 143 | } |
144 | 144 | |
145 | - public function setColor($color){ |
|
145 | + public function setColor($color) { |
|
146 | 146 | return $this->getHtmlComponent()->setColor($color); |
147 | 147 | } |
148 | 148 | |
149 | 149 | |
150 | - public function setCaptions($captions){ |
|
150 | + public function setCaptions($captions) { |
|
151 | 151 | $this->_instanceViewer->setCaptions($captions); |
152 | 152 | return $this; |
153 | 153 | } |
154 | 154 | |
155 | - public function setCaption($index,$caption){ |
|
155 | + public function setCaption($index, $caption) { |
|
156 | 156 | $this->_instanceViewer->setCaption($this->_getIndex($index), $caption); |
157 | 157 | return $this; |
158 | 158 | } |
159 | 159 | |
160 | - public function setFields($fields){ |
|
160 | + public function setFields($fields) { |
|
161 | 161 | $this->_instanceViewer->setVisibleProperties($fields); |
162 | 162 | return $this; |
163 | 163 | } |
164 | 164 | |
165 | - public function addField($field,$key=null){ |
|
166 | - $this->_instanceViewer->addField($field,$key); |
|
165 | + public function addField($field, $key=null) { |
|
166 | + $this->_instanceViewer->addField($field, $key); |
|
167 | 167 | return $this; |
168 | 168 | } |
169 | 169 | |
170 | - public function addFields($fields){ |
|
170 | + public function addFields($fields) { |
|
171 | 171 | $this->_instanceViewer->addFields($fields); |
172 | 172 | return $this; |
173 | 173 | } |
174 | 174 | |
175 | - public function countFields(){ |
|
175 | + public function countFields() { |
|
176 | 176 | return $this->_instanceViewer->visiblePropertiesCount(); |
177 | 177 | } |
178 | 178 | |
179 | - public function addMessage($attributes=NULL,$fieldName="message"){ |
|
179 | + public function addMessage($attributes=NULL, $fieldName="message") { |
|
180 | 180 | $this->_instanceViewer->addField($fieldName); |
181 | 181 | $count=$this->_instanceViewer->visiblePropertiesCount(); |
182 | - return $this->fieldAsMessage($count-1,$attributes); |
|
182 | + return $this->fieldAsMessage($count-1, $attributes); |
|
183 | 183 | } |
184 | 184 | |
185 | - public function addErrorMessage(){ |
|
186 | - return $this->addMessage(["error"=>true],"message"); |
|
185 | + public function addErrorMessage() { |
|
186 | + return $this->addMessage(["error"=>true], "message"); |
|
187 | 187 | } |
188 | 188 | |
189 | - public function insertField($index,$field,$key=null){ |
|
189 | + public function insertField($index, $field, $key=null) { |
|
190 | 190 | $index=$this->_getIndex($index); |
191 | - $this->_instanceViewer->insertField($index, $field,$key); |
|
191 | + $this->_instanceViewer->insertField($index, $field, $key); |
|
192 | 192 | return $this; |
193 | 193 | } |
194 | 194 | |
195 | - public function insertInField($index,$field,$key=null){ |
|
195 | + public function insertInField($index, $field, $key=null) { |
|
196 | 196 | $index=$this->_getIndex($index); |
197 | - $this->_instanceViewer->insertInField($index, $field,$key); |
|
197 | + $this->_instanceViewer->insertInField($index, $field, $key); |
|
198 | 198 | return $this; |
199 | 199 | } |
200 | 200 | |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | * @param callable $callback function parameters are : $value : the field value, $instance : the active instance of model, $fieldIndex : the field index, $rowIndex : the row index |
205 | 205 | * @return Widget |
206 | 206 | */ |
207 | - public function setValueFunction($index,$callback){ |
|
207 | + public function setValueFunction($index, $callback) { |
|
208 | 208 | $index=$this->_getIndex($index); |
209 | 209 | $this->_instanceViewer->setValueFunction($index, $callback); |
210 | 210 | return $this; |
211 | 211 | } |
212 | 212 | |
213 | - public function setIdentifierFunction($callback){ |
|
213 | + public function setIdentifierFunction($callback) { |
|
214 | 214 | $this->_instanceViewer->setIdentifierFunction($callback); |
215 | 215 | return $this; |
216 | 216 | } |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | /** |
219 | 219 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
220 | 220 | */ |
221 | - public function getToolbar(){ |
|
222 | - if(isset($this->_toolbar)===false){ |
|
221 | + public function getToolbar() { |
|
222 | + if (isset($this->_toolbar)===false) { |
|
223 | 223 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
224 | 224 | } |
225 | 225 | return $this->_toolbar; |
@@ -231,15 +231,15 @@ discard block |
||
231 | 231 | * @param callable $callback function to call on $element |
232 | 232 | * @return \Ajax\common\html\HtmlDoubleElement |
233 | 233 | */ |
234 | - public function addInToolbar($element,$callback=NULL){ |
|
234 | + public function addInToolbar($element, $callback=NULL) { |
|
235 | 235 | $tb=$this->getToolbar(); |
236 | - if($element instanceof BaseWidget){ |
|
237 | - if($element->getIdentifier()===""){ |
|
236 | + if ($element instanceof BaseWidget) { |
|
237 | + if ($element->getIdentifier()==="") { |
|
238 | 238 | $element->setIdentifier("tb-item-".$this->identifier."-".$tb->count()); |
239 | 239 | } |
240 | 240 | } |
241 | - if(isset($callback)){ |
|
242 | - if(\is_callable($callback)){ |
|
241 | + if (isset($callback)) { |
|
242 | + if (\is_callable($callback)) { |
|
243 | 243 | $callback($element); |
244 | 244 | } |
245 | 245 | } |
@@ -252,9 +252,9 @@ discard block |
||
252 | 252 | * @param callable $callback function($element) |
253 | 253 | * @return \Ajax\common\html\HtmlDoubleElement |
254 | 254 | */ |
255 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
256 | - $result=$this->addInToolbar($caption,$callback); |
|
257 | - if(isset($icon) && method_exists($result, "addIcon")) |
|
255 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
256 | + $result=$this->addInToolbar($caption, $callback); |
|
257 | + if (isset($icon) && method_exists($result, "addIcon")) |
|
258 | 258 | $result->addIcon($icon); |
259 | 259 | return $result; |
260 | 260 | } |
@@ -264,14 +264,14 @@ discard block |
||
264 | 264 | * @param callable $callback function($element) |
265 | 265 | * @return \Ajax\common\Widget |
266 | 266 | */ |
267 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
268 | - if(JArray::isAssociative($items)){ |
|
269 | - foreach ($items as $icon=>$item){ |
|
270 | - $this->addItemInToolbar($item,$icon,$callback); |
|
267 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
268 | + if (JArray::isAssociative($items)) { |
|
269 | + foreach ($items as $icon=>$item) { |
|
270 | + $this->addItemInToolbar($item, $icon, $callback); |
|
271 | 271 | } |
272 | - }else{ |
|
273 | - foreach ($items as $item){ |
|
274 | - $this->addItemInToolbar($item,null,$callback); |
|
272 | + } else { |
|
273 | + foreach ($items as $item) { |
|
274 | + $this->addItemInToolbar($item, null, $callback); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | return $this; |
@@ -283,12 +283,12 @@ discard block |
||
283 | 283 | * @param callable $callback function($element) |
284 | 284 | * @return \Ajax\common\html\HtmlDoubleElement |
285 | 285 | */ |
286 | - public function addDropdownInToolbar($value,$items,$callback=NULL){ |
|
286 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
287 | 287 | $dd=$value; |
288 | 288 | if (\is_string($value)) { |
289 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
289 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
290 | 290 | } |
291 | - return $this->addInToolbar($dd,$callback); |
|
291 | + return $this->addInToolbar($dd, $callback); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | * @param callable $callback function($element) |
298 | 298 | * @return \Ajax\common\html\HtmlDoubleElement |
299 | 299 | */ |
300 | - public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){ |
|
301 | - $bt=new HtmlButton("bt-".$caption,$caption,$cssStyle); |
|
302 | - return $this->addInToolbar($bt,$callback); |
|
300 | + public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) { |
|
301 | + $bt=new HtmlButton("bt-".$caption, $caption, $cssStyle); |
|
302 | + return $this->addInToolbar($bt, $callback); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | * @param callable $callback function($element) |
309 | 309 | * @return \Ajax\common\html\HtmlDoubleElement |
310 | 310 | */ |
311 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
312 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
313 | - return $this->addInToolbar($bts,$callback); |
|
311 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
312 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
313 | + return $this->addInToolbar($bts, $callback); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -320,15 +320,15 @@ discard block |
||
320 | 320 | * @param boolean $labeled |
321 | 321 | * @return \Ajax\common\html\HtmlDoubleElement |
322 | 322 | */ |
323 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
324 | - $bt=new HtmlButton("",$caption); |
|
325 | - $bt->addIcon($icon,$before,$labeled); |
|
323 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
324 | + $bt=new HtmlButton("", $caption); |
|
325 | + $bt->addIcon($icon, $before, $labeled); |
|
326 | 326 | return $this->addInToolbar($bt); |
327 | 327 | } |
328 | 328 | |
329 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
330 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
331 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters); |
|
329 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
330 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
331 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters); |
|
332 | 332 | return $this->addInToolbar($button); |
333 | 333 | } |
334 | 334 | |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model |
359 | 359 | * @return \Ajax\common\Widget |
360 | 360 | */ |
361 | - public function setDefaultValueFunction($defaultValueFunction){ |
|
361 | + public function setDefaultValueFunction($defaultValueFunction) { |
|
362 | 362 | $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction); |
363 | 363 | return $this; |
364 | 364 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | /** |
367 | 367 | * @return callable |
368 | 368 | */ |
369 | - public function getDefaultValueFunction(){ |
|
369 | + public function getDefaultValueFunction() { |
|
370 | 370 | return $this->_instanceViewer->getDefaultValueFunction(); |
371 | 371 | } |
372 | 372 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * @param string|boolean $disable |
375 | 375 | * @return string |
376 | 376 | */ |
377 | - public function jsDisabled($disable=true){ |
|
377 | + public function jsDisabled($disable=true) { |
|
378 | 378 | return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
379 | 379 | } |
380 | 380 | |
@@ -383,12 +383,12 @@ discard block |
||
383 | 383 | * @param callable $callback function($element) |
384 | 384 | * @return \Ajax\common\html\HtmlDoubleElement |
385 | 385 | */ |
386 | - public function addEditButtonInToolbar($caption,$callback=NULL){ |
|
387 | - $bt=new HtmlButton($this->identifier."-editBtn",$caption); |
|
386 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
387 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
388 | 388 | $bt->setToggle(); |
389 | 389 | $bt->setActive($this->_edition); |
390 | 390 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
391 | - return $this->addInToolbar($bt,$callback); |
|
391 | + return $this->addInToolbar($bt, $callback); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | public function setToolbar(HtmlMenu $_toolbar) { |
@@ -402,34 +402,34 @@ discard block |
||
402 | 402 | } |
403 | 403 | |
404 | 404 | public function getForm() { |
405 | - if(!isset($this->_form)){ |
|
405 | + if (!isset($this->_form)) { |
|
406 | 406 | $this->_form=new HtmlForm("frm-".$this->identifier); |
407 | 407 | $this->setEdition(true); |
408 | 408 | } |
409 | 409 | return $this->_form; |
410 | 410 | } |
411 | 411 | |
412 | - public function run(JsUtils $js){ |
|
412 | + public function run(JsUtils $js) { |
|
413 | 413 | parent::run($js); |
414 | - if(isset($this->_form)){ |
|
414 | + if (isset($this->_form)) { |
|
415 | 415 | $this->runForm($js); |
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
419 | - protected function runForm(JsUtils $js){ |
|
419 | + protected function runForm(JsUtils $js) { |
|
420 | 420 | $fields=$this->getContentInstances(HtmlFormField::class); |
421 | - foreach ($fields as $field){ |
|
421 | + foreach ($fields as $field) { |
|
422 | 422 | $this->_form->addField($field); |
423 | 423 | } |
424 | 424 | return $this->_form->run($js); |
425 | 425 | } |
426 | 426 | |
427 | - protected function _compileForm(){ |
|
428 | - if(isset($this->_form)){ |
|
427 | + protected function _compileForm() { |
|
428 | + if (isset($this->_form)) { |
|
429 | 429 | $noValidate=""; |
430 | - if(\sizeof($this->_form->getValidationParams())>0) |
|
430 | + if (\sizeof($this->_form->getValidationParams())>0) |
|
431 | 431 | $noValidate="novalidate"; |
432 | - $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>"); |
|
432 | + $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>"); |
|
433 | 433 | } |
434 | 434 | } |
435 | 435 | |
@@ -444,32 +444,32 @@ discard block |
||
444 | 444 | return $this; |
445 | 445 | } |
446 | 446 | |
447 | - public function moveFieldTo($from,$to){ |
|
447 | + public function moveFieldTo($from, $to) { |
|
448 | 448 | return $this->_instanceViewer->moveFieldTo($from, $to); |
449 | 449 | } |
450 | 450 | |
451 | - public function swapFields($index1,$index2){ |
|
451 | + public function swapFields($index1, $index2) { |
|
452 | 452 | $index1=$this->_getIndex($index1); |
453 | 453 | $index2=$this->_getIndex($index2); |
454 | 454 | return $this->_instanceViewer->swapFields($index1, $index2); |
455 | 455 | } |
456 | 456 | |
457 | - public function removeField($index){ |
|
457 | + public function removeField($index) { |
|
458 | 458 | $index=$this->_getIndex($index); |
459 | 459 | $this->_instanceViewer->removeField($index); |
460 | 460 | return $this; |
461 | 461 | } |
462 | 462 | |
463 | - public function asModal($header=null){ |
|
464 | - $modal=new HtmlModal("modal-".$this->identifier,$header); |
|
463 | + public function asModal($header=null) { |
|
464 | + $modal=new HtmlModal("modal-".$this->identifier, $header); |
|
465 | 465 | $modal->setContent($this); |
466 | - if(isset($this->_form)){ |
|
466 | + if (isset($this->_form)) { |
|
467 | 467 | $this->_form->onSuccess($modal->jsHide()); |
468 | 468 | } |
469 | 469 | return $modal; |
470 | 470 | } |
471 | 471 | |
472 | 472 | public function addToProperty($name, $value, $separator=" ") { |
473 | - return $this->getHtmlComponent()->addToProperty($name,$value,$separator); |
|
473 | + return $this->getHtmlComponent()->addToProperty($name, $value, $separator); |
|
474 | 474 | } |
475 | 475 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | private $row_count; |
13 | 13 | private $menu; |
14 | 14 | |
15 | - public function __construct($items_per_page=10,$pages_visibles=null,$page=1,$row_count=null){ |
|
15 | + public function __construct($items_per_page=10, $pages_visibles=null, $page=1, $row_count=null) { |
|
16 | 16 | $this->items_per_page=$items_per_page; |
17 | 17 | $this->row_count=$row_count; |
18 | 18 | $this->page=$page; |
@@ -20,30 +20,30 @@ discard block |
||
20 | 20 | $this->visible=true; |
21 | 21 | } |
22 | 22 | |
23 | - public function getObjects($objects){ |
|
23 | + public function getObjects($objects) { |
|
24 | 24 | $auto=(!isset($this->row_count)); |
25 | 25 | $os=$objects; |
26 | - if(!\is_array($os)){ |
|
26 | + if (!\is_array($os)) { |
|
27 | 27 | $os=[]; |
28 | - foreach ($objects as $o){ |
|
28 | + foreach ($objects as $o) { |
|
29 | 29 | $os[]=$o; |
30 | 30 | } |
31 | 31 | } |
32 | - $this->page_count = 0; |
|
33 | - $row_count=($auto)?\sizeof($os):$this->row_count; |
|
34 | - if (0 === $row_count) { |
|
32 | + $this->page_count=0; |
|
33 | + $row_count=($auto) ?\sizeof($os) : $this->row_count; |
|
34 | + if (0===$row_count) { |
|
35 | 35 | $this->visible=false; |
36 | 36 | } else { |
37 | 37 | |
38 | - $this->page_count = (int)ceil($row_count / $this->items_per_page); |
|
38 | + $this->page_count=(int)ceil($row_count/$this->items_per_page); |
|
39 | 39 | $this->visible=$this->page_count>1; |
40 | - if($this->page > $this->page_count+1) { |
|
41 | - $this->page = 1; |
|
40 | + if ($this->page>$this->page_count+1) { |
|
41 | + $this->page=1; |
|
42 | 42 | } |
43 | 43 | } |
44 | - if($auto){ |
|
45 | - $offset = ($this->page - 1) * $this->items_per_page; |
|
46 | - return array_slice($os, $offset,$this->items_per_page); |
|
44 | + if ($auto) { |
|
45 | + $offset=($this->page-1)*$this->items_per_page; |
|
46 | + return array_slice($os, $offset, $this->items_per_page); |
|
47 | 47 | } |
48 | 48 | return $os; |
49 | 49 | } |
@@ -79,28 +79,28 @@ discard block |
||
79 | 79 | return $this->page_count; |
80 | 80 | } |
81 | 81 | |
82 | - public function getPagesNumbers(){ |
|
83 | - $middle= (int)ceil(($this->pages_visibles-1)/ 2); |
|
82 | + public function getPagesNumbers() { |
|
83 | + $middle=(int)ceil(($this->pages_visibles-1)/2); |
|
84 | 84 | $first=$this->page-$middle; |
85 | - if($first<1){ |
|
85 | + if ($first<1) { |
|
86 | 86 | $first=1; |
87 | 87 | } |
88 | 88 | $last=$first+$this->pages_visibles-1; |
89 | - if($last>$this->page_count){ |
|
89 | + if ($last>$this->page_count) { |
|
90 | 90 | $last=$this->page_count; |
91 | 91 | } |
92 | 92 | return \range($first, $last); |
93 | 93 | } |
94 | 94 | |
95 | 95 | public function setPagesVisibles($pages_visibles) { |
96 | - if(!isset($pages_visibles)) |
|
97 | - $pages_visibles=(int)ceil($this->row_count / $this->items_per_page)+1; |
|
96 | + if (!isset($pages_visibles)) |
|
97 | + $pages_visibles=(int)ceil($this->row_count/$this->items_per_page)+1; |
|
98 | 98 | $this->pages_visibles=$pages_visibles; |
99 | 99 | return $this; |
100 | 100 | } |
101 | 101 | |
102 | - public function generateMenu($identifier){ |
|
103 | - $menu=new HtmlPaginationMenu("pagination-".$identifier,$this->getPagesNumbers()); |
|
102 | + public function generateMenu($identifier) { |
|
103 | + $menu=new HtmlPaginationMenu("pagination-".$identifier, $this->getPagesNumbers()); |
|
104 | 104 | $menu->setMax($this->page_count); |
105 | 105 | $menu->floatRight(); |
106 | 106 | $menu->setActivePage($this->getPage()); |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | return $this->menu; |
115 | 115 | } |
116 | 116 | |
117 | - public static function getPageOfRow($rownum,$itemsPerPage=10){ |
|
118 | - $pageNum=0;$activeRow=0; |
|
119 | - while($activeRow<$rownum){ |
|
117 | + public static function getPageOfRow($rownum, $itemsPerPage=10) { |
|
118 | + $pageNum=0; $activeRow=0; |
|
119 | + while ($activeRow<$rownum) { |
|
120 | 120 | $activeRow+=$itemsPerPage; |
121 | 121 | $pageNum++; |
122 | 122 | } |
@@ -10,12 +10,12 @@ |
||
10 | 10 | * @author jc |
11 | 11 | * |
12 | 12 | */ |
13 | -class Visibility extends SimpleSemExtComponent{ |
|
13 | +class Visibility extends SimpleSemExtComponent { |
|
14 | 14 | |
15 | 15 | public function __construct(JsUtils $js) { |
16 | 16 | parent::__construct($js); |
17 | 17 | $this->uiName="visibility"; |
18 | - $this->params=["once"=>false,"observeChanges"=>true]; |
|
18 | + $this->params=["once"=>false, "observeChanges"=>true]; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function setOnce($value=false) { |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | * @return HtmlMenu |
42 | 42 | */ |
43 | 43 | public function setType($type="") { |
44 | - return $this->addToPropertyCtrl("class", $type, array ("","item","text" )); |
|
44 | + return $this->addToPropertyCtrl("class", $type, array("", "item", "text")); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | public function setActiveItem($index) { |
48 | 48 | $item=$this->getItem($index); |
49 | - if ($item !== null) { |
|
49 | + if ($item!==null) { |
|
50 | 50 | $item->addToProperty("class", "active"); |
51 | 51 | } |
52 | 52 | return $this; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | private function getItemToInsert($item) { |
56 | 56 | if ($item instanceof HtmlInput || $item instanceof HtmlImg || $item instanceof HtmlIcon || $item instanceof HtmlButtonGroups || $item instanceof HtmlButton || $item instanceof HtmlLabel) { |
57 | - $itemO=new HtmlMenuItem("item-" . $this->identifier . "-" . \sizeof($this->content) , $item); |
|
57 | + $itemO=new HtmlMenuItem("item-".$this->identifier."-".\sizeof($this->content), $item); |
|
58 | 58 | $itemO->addClass("no-active"); |
59 | 59 | $item=$itemO; |
60 | 60 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | private function afterInsert($item) { |
65 | 65 | if (!$item instanceof HtmlMenu && $item->propertyContains("class", "header")===false) |
66 | - $item->addToPropertyCtrl("class", "item", array ("item" )); |
|
66 | + $item->addToPropertyCtrl("class", "item", array("item")); |
|
67 | 67 | else { |
68 | 68 | $this->setSecondary(); |
69 | 69 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function addItem($item) { |
80 | 80 | $number=$item; |
81 | 81 | $item=parent::addItem($this->getItemToInsert($item)); |
82 | - if(\is_int($number)) |
|
82 | + if (\is_int($number)) |
|
83 | 83 | $item->setProperty("data-page", $number); |
84 | 84 | return $this->afterInsert($item); |
85 | 85 | } |
@@ -97,15 +97,15 @@ discard block |
||
97 | 97 | |
98 | 98 | public function generateMenuAsItem($menu, $header=null) { |
99 | 99 | $count=$this->count(); |
100 | - $item=new HtmlSemDoubleElement("item-" . $this->identifier . "-" . $count, "div"); |
|
100 | + $item=new HtmlSemDoubleElement("item-".$this->identifier."-".$count, "div"); |
|
101 | 101 | if (isset($header)) { |
102 | - $headerItem=new HtmlSemDoubleElement("item-header-" . $this->identifier . "-" . $count, "div", "header"); |
|
102 | + $headerItem=new HtmlSemDoubleElement("item-header-".$this->identifier."-".$count, "div", "header"); |
|
103 | 103 | $headerItem->setContent($header); |
104 | 104 | $item->addContent($headerItem); |
105 | 105 | $this->_itemHeader=$headerItem; |
106 | 106 | } |
107 | - if(\is_array($menu)){ |
|
108 | - $menu=new HtmlMenu("menu-" . $this->identifier . "-" . $count,$menu); |
|
107 | + if (\is_array($menu)) { |
|
108 | + $menu=new HtmlMenu("menu-".$this->identifier."-".$count, $menu); |
|
109 | 109 | } |
110 | 110 | $menu->setClass("menu"); |
111 | 111 | $item->addContent($menu); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $value=new HtmlSemDoubleElement($identifier, "a", "browse item", $value); |
121 | 121 | $value->addContent(new HtmlIcon("", "dropdown")); |
122 | 122 | $value=$this->addItem($value); |
123 | - $popup=new HtmlPopup($value, "popup-" . $this->identifier . "-" . $this->count(), $content); |
|
123 | + $popup=new HtmlPopup($value, "popup-".$this->identifier."-".$this->count(), $content); |
|
124 | 124 | $popup->setFlowing()->setPosition("bottom left")->setOn("click"); |
125 | 125 | $this->wrap("", $popup); |
126 | 126 | return $popup; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | public function addDropdownAsItem($value, $items=NULL) { |
130 | 130 | $dd=$value; |
131 | 131 | if (\is_string($value)) { |
132 | - $dd=new HtmlDropdown("dropdown-" . $this->identifier . "-" . $this->count(), $value, $items); |
|
132 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$this->count(), $value, $items); |
|
133 | 133 | } |
134 | 134 | $this->addItem($dd); |
135 | 135 | return $dd; |
@@ -142,14 +142,14 @@ discard block |
||
142 | 142 | * @see HtmlCollection::createItem() |
143 | 143 | */ |
144 | 144 | protected function createItem($value) { |
145 | - $itemO=new HtmlMenuItem($this->identifier."-item-" . \sizeof($this->content),""); |
|
145 | + $itemO=new HtmlMenuItem($this->identifier."-item-".\sizeof($this->content), ""); |
|
146 | 146 | $itemO->setTagName("a"); |
147 | 147 | $itemO->setContent($value); |
148 | 148 | return $itemO; |
149 | 149 | } |
150 | 150 | |
151 | 151 | public function setSecondary($value=true) { |
152 | - if($value) |
|
152 | + if ($value) |
|
153 | 153 | $this->addToProperty("class", "secondary"); |
154 | 154 | else |
155 | 155 | $this->removePropertyValue("class", "secondary"); |
@@ -157,28 +157,28 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | public function setVertical() { |
160 | - return $this->addToPropertyCtrl("class", "vertical", array ("vertical" )); |
|
160 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | public function setPosition($value="right") { |
164 | - return $this->addToPropertyCtrl("class", $value, array ("right","left" )); |
|
164 | + return $this->addToPropertyCtrl("class", $value, array("right", "left")); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | public function setPointing($value=Direction::NONE) { |
168 | - return $this->addToPropertyCtrl("class", $value . " pointing", Direction::getConstantValues("pointing")); |
|
168 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | public function asTab($vertical=false) { |
172 | - $this->apply(function (HtmlDoubleElement &$item) { |
|
172 | + $this->apply(function(HtmlDoubleElement &$item) { |
|
173 | 173 | $item->setTagName("a"); |
174 | 174 | }); |
175 | - if ($vertical === true) |
|
175 | + if ($vertical===true) |
|
176 | 176 | $this->setVertical(); |
177 | 177 | return $this->addToProperty("class", "tabular"); |
178 | 178 | } |
179 | 179 | |
180 | 180 | public function asPagination() { |
181 | - $this->apply(function (HtmlDoubleElement &$item) { |
|
181 | + $this->apply(function(HtmlDoubleElement &$item) { |
|
182 | 182 | $item->setTagName("a"); |
183 | 183 | }); |
184 | 184 | return $this->addToProperty("class", "pagination"); |
@@ -215,10 +215,10 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function setWidth($width) { |
217 | 217 | if (\is_int($width)) { |
218 | - $width=Wide::getConstants()["W" . $width]; |
|
218 | + $width=Wide::getConstants()["W".$width]; |
|
219 | 219 | } |
220 | 220 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
221 | - return $this->addToPropertyCtrl("class", "item", array ("item" )); |
|
221 | + return $this->addToPropertyCtrl("class", "item", array("item")); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | public function addImage($identifier, $src="", $alt="") { |
@@ -233,14 +233,14 @@ discard block |
||
233 | 233 | return $this->_itemHeader; |
234 | 234 | } |
235 | 235 | |
236 | - public function setHasContainer(){ |
|
237 | - return $this->wrapContent("<div class='ui container'>","</div>"); |
|
236 | + public function setHasContainer() { |
|
237 | + return $this->wrapContent("<div class='ui container'>", "</div>"); |
|
238 | 238 | } |
239 | 239 | |
240 | - public function run(JsUtils $js){ |
|
241 | - if($this->identifier!=="" && !isset($this->_bsComponent)) |
|
242 | - $this->onClick('if(!$(this).hasClass("dropdown")&&!$(this).hasClass("no-active")){$(this).addClass("active").siblings().removeClass("active");}',false,false); |
|
243 | - $result= parent::run($js); |
|
240 | + public function run(JsUtils $js) { |
|
241 | + if ($this->identifier!=="" && !isset($this->_bsComponent)) |
|
242 | + $this->onClick('if(!$(this).hasClass("dropdown")&&!$(this).hasClass("no-active")){$(this).addClass("active").siblings().removeClass("active");}', false, false); |
|
243 | + $result=parent::run($js); |
|
244 | 244 | return $result->setItemSelector(".item"); |
245 | 245 | } |
246 | 246 | } |
@@ -5,20 +5,20 @@ |
||
5 | 5 | use Ajax\common\html\HtmlDoubleElement; |
6 | 6 | use Ajax\common\html\HtmlCollection; |
7 | 7 | |
8 | -class HtmlDatalist extends HtmlCollection{ |
|
8 | +class HtmlDatalist extends HtmlCollection { |
|
9 | 9 | |
10 | - public function __construct($identifier){ |
|
11 | - parent::__construct($identifier,"datalist"); |
|
10 | + public function __construct($identifier) { |
|
11 | + parent::__construct($identifier, "datalist"); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | protected function createItem($value) { |
15 | - $elm= new HtmlDoubleElement("","option"); |
|
15 | + $elm=new HtmlDoubleElement("", "option"); |
|
16 | 16 | $elm->setProperty("value", $value->getContent()); |
17 | 17 | $elm->setContent($value); |
18 | 18 | return $elm; |
19 | 19 | } |
20 | 20 | |
21 | - protected function createCondition($value){ |
|
21 | + protected function createCondition($value) { |
|
22 | 22 | return true; |
23 | 23 | } |
24 | 24 | } |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * @return HtmlButton |
43 | 43 | */ |
44 | 44 | public function setValue($value) { |
45 | - if(is_array($this->content)){ |
|
46 | - foreach ($this->content as $i=>$content){ |
|
47 | - if(is_string($content)){ |
|
45 | + if (is_array($this->content)) { |
|
46 | + foreach ($this->content as $i=>$content) { |
|
47 | + if (is_string($content)) { |
|
48 | 48 | $this->content[$i]=$value; |
49 | 49 | return $this; |
50 | 50 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | public function setFocusable($value=true) { |
67 | - if ($value === true) |
|
67 | + if ($value===true) |
|
68 | 68 | $this->setProperty("tabindex", "0"); |
69 | 69 | else { |
70 | 70 | $this->removeProperty("tabindex"); |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | |
75 | 75 | public function setAnimated($content, $animation="") { |
76 | 76 | $this->setTagName("div"); |
77 | - $this->addToProperty("class", "animated " . $animation); |
|
78 | - $visible=new HtmlSemDoubleElement("visible-" . $this->identifier, "div"); |
|
77 | + $this->addToProperty("class", "animated ".$animation); |
|
78 | + $visible=new HtmlSemDoubleElement("visible-".$this->identifier, "div"); |
|
79 | 79 | $visible->setClass("visible content"); |
80 | 80 | $visible->setContent($this->content); |
81 | - $hidden=new HtmlSemDoubleElement("hidden-" . $this->identifier, "div"); |
|
81 | + $hidden=new HtmlSemDoubleElement("hidden-".$this->identifier, "div"); |
|
82 | 82 | $hidden->setClass("hidden content"); |
83 | 83 | $hidden->setContent($content); |
84 | - $this->content=array ($visible,$hidden ); |
|
84 | + $this->content=array($visible, $hidden); |
|
85 | 85 | return $hidden; |
86 | 86 | } |
87 | 87 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | public function asIcon($icon) { |
94 | 94 | $iconO=$icon; |
95 | 95 | if (\is_string($icon)) { |
96 | - $iconO=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
96 | + $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
|
97 | 97 | } |
98 | 98 | $this->addToProperty("class", "icon"); |
99 | 99 | $this->content=$iconO; |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | * @return HtmlLabel |
114 | 114 | */ |
115 | 115 | public function addLabel($label, $before=false, $icon=NULL) { |
116 | - $this->tagName="div";$prefix=""; |
|
117 | - if($before) |
|
116 | + $this->tagName="div"; $prefix=""; |
|
117 | + if ($before) |
|
118 | 118 | $prefix="left "; |
119 | 119 | $this->addToProperty("class", $prefix."labeled"); |
120 | 120 | $isIcon=(isset($this->content[0]) && $this->content[0] instanceof HtmlIcon); |
121 | - $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
|
122 | - if($isIcon){ |
|
121 | + $this->content=new HtmlButton("button-".$this->identifier, $this->content); |
|
122 | + if ($isIcon) { |
|
123 | 123 | $this->content->addClass("icon"); |
124 | 124 | } |
125 | 125 | $this->content->setTagName("div"); |
126 | - $label=new HtmlLabel("label-" . $this->identifier, $label, $icon,"a"); |
|
126 | + $label=new HtmlLabel("label-".$this->identifier, $label, $icon, "a"); |
|
127 | 127 | $label->setBasic(); |
128 | 128 | $this->addContent($label, $before); |
129 | 129 | return $label; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function fromArray($array) { |
137 | 137 | $array=parent::fromArray($array); |
138 | - foreach ( $array as $key => $value ) { |
|
138 | + foreach ($array as $key => $value) { |
|
139 | 139 | $this->setProperty($key, $value); |
140 | 140 | } |
141 | 141 | return $array; |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | return $this->addToProperty("class", "positive"); |
150 | 150 | } |
151 | 151 | |
152 | - public function setColor($color){ |
|
153 | - if(\is_array($this->content)){ |
|
154 | - foreach ($this->content as $content){ |
|
155 | - if($content instanceof HtmlButton) |
|
152 | + public function setColor($color) { |
|
153 | + if (\is_array($this->content)) { |
|
154 | + foreach ($this->content as $content) { |
|
155 | + if ($content instanceof HtmlButton) |
|
156 | 156 | $content->setColor($color); |
157 | 157 | } |
158 | 158 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @return HtmlButton |
211 | 211 | */ |
212 | 212 | public static function social($identifier, $social, $value=NULL) { |
213 | - if ($value === NULL) |
|
213 | + if ($value===NULL) |
|
214 | 214 | $value=\ucfirst($social); |
215 | 215 | $return=new HtmlButton($identifier, $value); |
216 | 216 | $return->addIcon($social); |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | * {@inheritDoc} |
248 | 248 | * @see HtmlSemDoubleElement::asLink() |
249 | 249 | */ |
250 | - public function asLink($href=NULL,$target=NULL) { |
|
251 | - parent::asLink($href,$target); |
|
250 | + public function asLink($href=NULL, $target=NULL) { |
|
251 | + parent::asLink($href, $target); |
|
252 | 252 | return $this; |
253 | 253 | } |
254 | 254 | |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | * @param string $icon |
262 | 262 | * @return HtmlButtonGroups |
263 | 263 | */ |
264 | - public static function dropdown($identifier,$value,$items=[],$asCombo=false,$icon=null){ |
|
265 | - $result=new HtmlButtonGroups($identifier,[$value]); |
|
266 | - $dd=$result->addDropdown($items,$asCombo); |
|
267 | - if(isset($icon) && $dd instanceof HtmlDropdown) |
|
264 | + public static function dropdown($identifier, $value, $items=[], $asCombo=false, $icon=null) { |
|
265 | + $result=new HtmlButtonGroups($identifier, [$value]); |
|
266 | + $dd=$result->addDropdown($items, $asCombo); |
|
267 | + if (isset($icon) && $dd instanceof HtmlDropdown) |
|
268 | 268 | $dd->setIcon($icon); |
269 | 269 | return $result; |
270 | 270 | } |
@@ -14,29 +14,29 @@ discard block |
||
14 | 14 | use Ajax\common\html\HtmlDoubleElement; |
15 | 15 | |
16 | 16 | class HtmlDropdown extends HtmlSemDoubleElement { |
17 | - use FieldTrait,LabeledIconTrait { |
|
17 | + use FieldTrait, LabeledIconTrait { |
|
18 | 18 | addIcon as addIconP; |
19 | 19 | } |
20 | 20 | protected $mClass="menu"; |
21 | 21 | protected $mTagName="div"; |
22 | - protected $items=array (); |
|
23 | - protected $_params=array("action"=>"nothing","on"=>"hover","showOnFocus"=>false); |
|
22 | + protected $items=array(); |
|
23 | + protected $_params=array("action"=>"nothing", "on"=>"hover", "showOnFocus"=>false); |
|
24 | 24 | protected $input; |
25 | 25 | protected $value; |
26 | 26 | protected $_associative; |
27 | 27 | protected $_multiple; |
28 | 28 | |
29 | - public function __construct($identifier, $value="", $items=array(),$associative=true) { |
|
29 | + public function __construct($identifier, $value="", $items=array(), $associative=true) { |
|
30 | 30 | parent::__construct($identifier, "div"); |
31 | 31 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
32 | 32 | $this->setProperty("class", "ui dropdown"); |
33 | 33 | $this->_multiple=false; |
34 | 34 | $content=[]; |
35 | - if(isset($value)){ |
|
36 | - if($value instanceof HtmlSemDoubleElement){ |
|
35 | + if (isset($value)) { |
|
36 | + if ($value instanceof HtmlSemDoubleElement) { |
|
37 | 37 | $text=$value; |
38 | - }else{ |
|
39 | - $text=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
38 | + } else { |
|
39 | + $text=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
40 | 40 | $text->setClass("text"); |
41 | 41 | $this->setValue($value); |
42 | 42 | } |
@@ -49,29 +49,29 @@ discard block |
||
49 | 49 | $this->addItems($items); |
50 | 50 | } |
51 | 51 | |
52 | - public function getField(){ |
|
52 | + public function getField() { |
|
53 | 53 | return $this->input; |
54 | 54 | } |
55 | 55 | |
56 | - public function getDataField(){ |
|
56 | + public function getDataField() { |
|
57 | 57 | return $this->input; |
58 | 58 | } |
59 | 59 | |
60 | - public function addItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
61 | - $itemO=$this->beforeAddItem($item,$value,$image,$description); |
|
60 | + public function addItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
61 | + $itemO=$this->beforeAddItem($item, $value, $image, $description); |
|
62 | 62 | $this->items[]=$itemO; |
63 | 63 | return $itemO; |
64 | 64 | } |
65 | 65 | |
66 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
66 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
67 | 67 | $this->removeArrow(); |
68 | - $this->addIconP($icon,$before,$labeled); |
|
68 | + $this->addIconP($icon, $before, $labeled); |
|
69 | 69 | return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter(""); |
70 | 70 | } |
71 | 71 | |
72 | - public function addIcons($icons){ |
|
72 | + public function addIcons($icons) { |
|
73 | 73 | $count=$this->count(); |
74 | - for ($i=0;$i<\sizeof($icons) && $i<$count;$i++){ |
|
74 | + for ($i=0; $i<\sizeof($icons) && $i<$count; $i++) { |
|
75 | 75 | $this->getItem($i)->addIcon($icons[$i]); |
76 | 76 | } |
77 | 77 | } |
@@ -82,33 +82,33 @@ discard block |
||
82 | 82 | * @param int $position |
83 | 83 | * @return HtmlDropdownItem |
84 | 84 | */ |
85 | - public function insertItem($item,$position=0){ |
|
85 | + public function insertItem($item, $position=0) { |
|
86 | 86 | $itemO=$this->beforeAddItem($item); |
87 | - $start = array_slice($this->items, 0, $position); |
|
88 | - $end = array_slice($this->items, $position); |
|
89 | - $start[] = $item; |
|
87 | + $start=array_slice($this->items, 0, $position); |
|
88 | + $end=array_slice($this->items, $position); |
|
89 | + $start[]=$item; |
|
90 | 90 | $this->items=array_merge($start, $end); |
91 | 91 | return $itemO; |
92 | 92 | } |
93 | 93 | |
94 | - protected function removeArrow(){ |
|
95 | - if(\sizeof($this->content)>1){ |
|
94 | + protected function removeArrow() { |
|
95 | + if (\sizeof($this->content)>1) { |
|
96 | 96 | unset($this->content["arrow"]); |
97 | 97 | $this->content=\array_values($this->content); |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - protected function beforeAddItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
101 | + protected function beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
102 | 102 | $itemO=$item; |
103 | - if(\is_array($item)){ |
|
103 | + if (\is_array($item)) { |
|
104 | 104 | $description=JArray::getValue($item, "description", 3); |
105 | 105 | $value=JArray::getValue($item, "value", 1); |
106 | 106 | $image=JArray::getValue($item, "image", 2); |
107 | 107 | $item=JArray::getValue($item, "item", 0); |
108 | 108 | } |
109 | - if(!$item instanceof HtmlDropdownItem){ |
|
110 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
|
111 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
109 | + if (!$item instanceof HtmlDropdownItem) { |
|
110 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image, $description); |
|
111 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
112 | 112 | $this->addToProperty("class", "vertical"); |
113 | 113 | } |
114 | 114 | return $itemO; |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | $this->addItem($function($object)); |
122 | 122 | } |
123 | 123 | |
124 | - public function addInput($name){ |
|
125 | - if(!isset($name)) |
|
124 | + public function addInput($name) { |
|
125 | + if (!isset($name)) |
|
126 | 126 | $name="input-".$this->identifier; |
127 | 127 | $this->setAction("activate"); |
128 | - $this->input=new HtmlInput($name,"hidden"); |
|
128 | + $this->input=new HtmlInput($name, "hidden"); |
|
129 | 129 | $this->input->setIdentifier("input-".$this->identifier); |
130 | 130 | return $this->input; |
131 | 131 | } |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | * @param string $icon |
137 | 137 | * @return HtmlDropdownItem |
138 | 138 | */ |
139 | - public function addSearchInputItem($placeHolder=NULL,$icon=NULL){ |
|
140 | - return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon)); |
|
139 | + public function addSearchInputItem($placeHolder=NULL, $icon=NULL) { |
|
140 | + return $this->addItem(HtmlDropdownItem::searchInput($placeHolder, $icon)); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
144 | 144 | * Adds a divider item |
145 | 145 | * @return HtmlDropdownItem |
146 | 146 | */ |
147 | - public function addDividerItem(){ |
|
147 | + public function addDividerItem() { |
|
148 | 148 | return $this->addItem(HtmlDropdownItem::divider()); |
149 | 149 | } |
150 | 150 | |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | * @param string $icon |
155 | 155 | * @return HtmlDropdownItem |
156 | 156 | */ |
157 | - public function addHeaderItem($caption=NULL,$icon=NULL){ |
|
158 | - return $this->addItem(HtmlDropdownItem::header($caption,$icon)); |
|
157 | + public function addHeaderItem($caption=NULL, $icon=NULL) { |
|
158 | + return $this->addItem(HtmlDropdownItem::header($caption, $icon)); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @param string $color |
165 | 165 | * @return HtmlDropdownItem |
166 | 166 | */ |
167 | - public function addCircularLabelItem($caption,$color){ |
|
167 | + public function addCircularLabelItem($caption, $color) { |
|
168 | 168 | return $this->addItem(HtmlDropdownItem::circular($caption, $color)); |
169 | 169 | } |
170 | 170 | |
@@ -173,17 +173,17 @@ discard block |
||
173 | 173 | * @param string $image |
174 | 174 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
175 | 175 | */ |
176 | - public function addMiniAvatarImageItem($caption,$image){ |
|
176 | + public function addMiniAvatarImageItem($caption, $image) { |
|
177 | 177 | return $this->addItem(HtmlDropdownItem::avatar($caption, $image)); |
178 | 178 | } |
179 | 179 | |
180 | - public function addItems($items){ |
|
181 | - if(\is_array($items) && $this->_associative){ |
|
182 | - foreach ($items as $k=>$v){ |
|
180 | + public function addItems($items) { |
|
181 | + if (\is_array($items) && $this->_associative) { |
|
182 | + foreach ($items as $k=>$v) { |
|
183 | 183 | $this->addItem($v)->setData($k); |
184 | 184 | } |
185 | - }else{ |
|
186 | - foreach ($items as $item){ |
|
185 | + } else { |
|
186 | + foreach ($items as $item) { |
|
187 | 187 | $this->addItem($item); |
188 | 188 | } |
189 | 189 | } |
@@ -195,98 +195,98 @@ discard block |
||
195 | 195 | * @param array|mixed $values |
196 | 196 | * @return $this |
197 | 197 | */ |
198 | - public function setPropertyValues($property,$values){ |
|
198 | + public function setPropertyValues($property, $values) { |
|
199 | 199 | $i=0; |
200 | - if(\is_array($values)===false){ |
|
201 | - $values=\array_fill(0, $this->count(),$values); |
|
200 | + if (\is_array($values)===false) { |
|
201 | + $values=\array_fill(0, $this->count(), $values); |
|
202 | 202 | } |
203 | - foreach ($values as $value){ |
|
203 | + foreach ($values as $value) { |
|
204 | 204 | $c=$this->items[$i++]; |
205 | - if(isset($c)){ |
|
206 | - $c->setProperty($property,$value); |
|
205 | + if (isset($c)) { |
|
206 | + $c->setProperty($property, $value); |
|
207 | 207 | } |
208 | - else{ |
|
208 | + else { |
|
209 | 209 | return $this; |
210 | 210 | } |
211 | 211 | } |
212 | 212 | return $this; |
213 | 213 | } |
214 | 214 | |
215 | - public function each($callBack){ |
|
216 | - foreach ($this->items as $index=>$value){ |
|
217 | - $callBack($index,$value); |
|
215 | + public function each($callBack) { |
|
216 | + foreach ($this->items as $index=>$value) { |
|
217 | + $callBack($index, $value); |
|
218 | 218 | } |
219 | 219 | return $this; |
220 | 220 | } |
221 | 221 | |
222 | - public function getItem($index){ |
|
222 | + public function getItem($index) { |
|
223 | 223 | return $this->items[$index]; |
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
227 | 227 | * @return int |
228 | 228 | */ |
229 | - public function count(){ |
|
229 | + public function count() { |
|
230 | 230 | return \sizeof($this->items); |
231 | 231 | } |
232 | 232 | /** |
233 | 233 | * @param boolean $dropdown |
234 | 234 | */ |
235 | - public function asDropdown($dropdown){ |
|
236 | - if($dropdown===false){ |
|
235 | + public function asDropdown($dropdown) { |
|
236 | + if ($dropdown===false) { |
|
237 | 237 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
238 | 238 | $dropdown="menu"; |
239 | - }else{ |
|
239 | + } else { |
|
240 | 240 | $dropdown="dropdown"; |
241 | 241 | $this->mClass="menu"; |
242 | 242 | } |
243 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
243 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
244 | 244 | } |
245 | 245 | |
246 | - public function setVertical(){ |
|
247 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
246 | + public function setVertical() { |
|
247 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
248 | 248 | } |
249 | 249 | |
250 | - public function setInline(){ |
|
251 | - return $this->addToPropertyCtrl("class", "inline",["inline"]); |
|
250 | + public function setInline() { |
|
251 | + return $this->addToPropertyCtrl("class", "inline", ["inline"]); |
|
252 | 252 | } |
253 | 253 | |
254 | - public function setSimple(){ |
|
255 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
254 | + public function setSimple() { |
|
255 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
256 | 256 | } |
257 | 257 | |
258 | - public function asButton($floating=false){ |
|
258 | + public function asButton($floating=false) { |
|
259 | 259 | $this->removeArrow(); |
260 | - if($floating) |
|
260 | + if ($floating) |
|
261 | 261 | $this->addToProperty("class", "floating"); |
262 | 262 | $this->removePropertyValue("class", "selection"); |
263 | 263 | return $this->addToProperty("class", "button"); |
264 | 264 | } |
265 | 265 | |
266 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
266 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
267 | 267 | $this->_multiple=$multiple; |
268 | - if(isset($name)) |
|
268 | + if (isset($name)) |
|
269 | 269 | $this->addInput($name); |
270 | - if($multiple){ |
|
270 | + if ($multiple) { |
|
271 | 271 | $this->addToProperty("class", "multiple"); |
272 | 272 | } |
273 | - if ($selection){ |
|
274 | - if($this->propertyContains("class", "button")===false) |
|
275 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
273 | + if ($selection) { |
|
274 | + if ($this->propertyContains("class", "button")===false) |
|
275 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
276 | 276 | } |
277 | 277 | return $this; |
278 | 278 | } |
279 | 279 | |
280 | - public function asSearch($name=NULL,$multiple=false,$selection=true){ |
|
281 | - $this->asSelect($name,$multiple,$selection); |
|
280 | + public function asSearch($name=NULL, $multiple=false, $selection=true) { |
|
281 | + $this->asSelect($name, $multiple, $selection); |
|
282 | 282 | return $this->addToProperty("class", "search"); |
283 | 283 | } |
284 | 284 | |
285 | - public function setSelect($name=NULL,$multiple=false){ |
|
286 | - if(!isset($name)) |
|
285 | + public function setSelect($name=NULL, $multiple=false) { |
|
286 | + if (!isset($name)) |
|
287 | 287 | $name="select-".$this->identifier; |
288 | 288 | $this->input=null; |
289 | - if($multiple){ |
|
289 | + if ($multiple) { |
|
290 | 290 | $this->setProperty("multiple", true); |
291 | 291 | $this->addToProperty("class", "multiple"); |
292 | 292 | } |
@@ -294,42 +294,42 @@ discard block |
||
294 | 294 | $this->tagName="select"; |
295 | 295 | $this->setProperty("name", $name); |
296 | 296 | $this->content=null; |
297 | - foreach ($this->items as $item){ |
|
297 | + foreach ($this->items as $item) { |
|
298 | 298 | $item->asOption(); |
299 | 299 | } |
300 | 300 | return $this; |
301 | 301 | } |
302 | 302 | |
303 | - public function asSubmenu($pointing=NULL){ |
|
303 | + public function asSubmenu($pointing=NULL) { |
|
304 | 304 | $this->setClass("ui dropdown link item"); |
305 | - if(isset($pointing)){ |
|
305 | + if (isset($pointing)) { |
|
306 | 306 | $this->setPointing($pointing); |
307 | 307 | } |
308 | 308 | return $this; |
309 | 309 | } |
310 | 310 | |
311 | - public function setPointing($value=Direction::NONE){ |
|
312 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
311 | + public function setPointing($value=Direction::NONE) { |
|
312 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
313 | 313 | } |
314 | 314 | |
315 | - public function setValue($value){ |
|
315 | + public function setValue($value) { |
|
316 | 316 | $this->value=$value; |
317 | 317 | return $this; |
318 | 318 | } |
319 | 319 | |
320 | - public function setDefaultText($text){ |
|
321 | - $this->content["text"]=new HtmlSemDoubleElement("","div","default text",$text); |
|
320 | + public function setDefaultText($text) { |
|
321 | + $this->content["text"]=new HtmlSemDoubleElement("", "div", "default text", $text); |
|
322 | 322 | } |
323 | 323 | |
324 | - private function applyValue(){ |
|
324 | + private function applyValue() { |
|
325 | 325 | $value=$this->value; |
326 | - if(isset($this->input) && isset($value)){ |
|
326 | + if (isset($this->input) && isset($value)) { |
|
327 | 327 | $this->input->setProperty("value", $value); |
328 | - }else{ |
|
328 | + } else { |
|
329 | 329 | $this->setProperty("value", $value); |
330 | 330 | } |
331 | 331 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
332 | - if(isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple) |
|
332 | + if (isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple) |
|
333 | 333 | $textElement->setContent($value); |
334 | 334 | return $this; |
335 | 335 | } |
@@ -339,9 +339,9 @@ discard block |
||
339 | 339 | * @see BaseHtml::run() |
340 | 340 | */ |
341 | 341 | public function run(JsUtils $js) { |
342 | - if($this->propertyContains("class", "simple")===false){ |
|
343 | - if(isset($this->_bsComponent)===false){ |
|
344 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
342 | + if ($this->propertyContains("class", "simple")===false) { |
|
343 | + if (isset($this->_bsComponent)===false) { |
|
344 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params); |
|
345 | 345 | $this->_bsComponent->setItemSelector(".item"); |
346 | 346 | } |
347 | 347 | $this->addEventsOnRun($js); |
@@ -349,41 +349,41 @@ discard block |
||
349 | 349 | } |
350 | 350 | } |
351 | 351 | |
352 | - public function setCompact(){ |
|
352 | + public function setCompact() { |
|
353 | 353 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
354 | 354 | } |
355 | 355 | |
356 | - public function setAction($action){ |
|
356 | + public function setAction($action) { |
|
357 | 357 | $this->_params["action"]=$action; |
358 | 358 | } |
359 | 359 | |
360 | - public function setOn($on){ |
|
360 | + public function setOn($on) { |
|
361 | 361 | $this->_params["on"]=$on; |
362 | 362 | } |
363 | 363 | |
364 | - public function setShowOnFocus($value){ |
|
364 | + public function setShowOnFocus($value) { |
|
365 | 365 | $this->_params["showOnFocus"]=$value; |
366 | 366 | } |
367 | 367 | |
368 | - public function setFullTextSearch($value){ |
|
368 | + public function setFullTextSearch($value) { |
|
369 | 369 | $this->_params["fullTextSearch"]=$value; |
370 | 370 | } |
371 | 371 | |
372 | 372 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
373 | 373 | $this->applyValue(); |
374 | - return parent::compile($js,$view); |
|
374 | + return parent::compile($js, $view); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | public function getInput() { |
378 | 378 | return $this->input; |
379 | 379 | } |
380 | 380 | |
381 | - public function setIcon($icon="dropdown"){ |
|
381 | + public function setIcon($icon="dropdown") { |
|
382 | 382 | $this->content["arrow"]=new HtmlIcon($this->identifier."-icon", $icon); |
383 | 383 | return $this; |
384 | 384 | } |
385 | 385 | |
386 | - public function jsAddItem($caption){ |
|
386 | + public function jsAddItem($caption) { |
|
387 | 387 | $js="var first=$('#{$this->identifier} .item').first();if(first!=undefined){var new =first.clone();first.parent().append(new);first.html('{$caption}};')"; |
388 | 388 | return $js; |
389 | 389 | } |