@@ -30,23 +30,23 @@ discard block |
||
30 | 30 | * @property boolean $_edition |
31 | 31 | * @property mixed _modelInstance |
32 | 32 | */ |
33 | -trait FieldAsTrait{ |
|
33 | +trait FieldAsTrait { |
|
34 | 34 | |
35 | - abstract protected function _getFieldIdentifier($prefix,$name=""); |
|
36 | - abstract public function setValueFunction($index,$callback); |
|
35 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
36 | + abstract public function setValueFunction($index, $callback); |
|
37 | 37 | abstract protected function _getFieldName($index); |
38 | 38 | abstract protected function _getFieldCaption($index); |
39 | - abstract protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
|
39 | + abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @param HtmlFormField $element |
43 | 43 | * @param array $attributes |
44 | 44 | */ |
45 | - protected function _applyAttributes(BaseHtml $element,&$attributes,$index,$instance=null){ |
|
46 | - if(isset($attributes["jsCallback"])){ |
|
45 | + protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance=null) { |
|
46 | + if (isset($attributes["jsCallback"])) { |
|
47 | 47 | $callback=$attributes["jsCallback"]; |
48 | - if(\is_callable($callback)){ |
|
49 | - $callback($element,$instance,$index,InstanceViewer::$index); |
|
48 | + if (\is_callable($callback)) { |
|
49 | + $callback($element, $instance, $index, InstanceViewer::$index); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | unset($attributes["rules"]); |
@@ -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,$rowIndex) use (&$attributes,$elementCallback,$prefix){ |
|
83 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
84 | + $this->setValueFunction($index, function($value, $instance, $index, $rowIndex) 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,$instance); |
|
92 | + $element=$elementCallback($id, $name, $value, $caption); |
|
93 | + if (\is_array($attributes)) { |
|
94 | + $this->_applyAttributes($element, $attributes, $index, $instance); |
|
95 | 95 | } |
96 | 96 | $element->setDisabled(!$this->_edition); |
97 | 97 | return $element; |
@@ -100,197 +100,197 @@ 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 fieldAsIcon($index){ |
|
155 | - $this->setValueFunction($index,function($icon){ |
|
156 | - $icon=new HtmlIcon($this->_getFieldIdentifier("icon"),$icon); |
|
154 | + public function fieldAsIcon($index) { |
|
155 | + $this->setValueFunction($index, function($icon) { |
|
156 | + $icon=new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
157 | 157 | return $icon; |
158 | 158 | }); |
159 | 159 | return $this; |
160 | 160 | } |
161 | 161 | |
162 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
163 | - return $this->_fieldAs(function($id,$name,$value){ |
|
164 | - $img=new HtmlImage($id,$value); |
|
162 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
163 | + return $this->_fieldAs(function($id, $name, $value) { |
|
164 | + $img=new HtmlImage($id, $value); |
|
165 | 165 | $img->asAvatar(); |
166 | 166 | return $img; |
167 | - }, $index,$attributes,"avatar"); |
|
167 | + }, $index, $attributes, "avatar"); |
|
168 | 168 | } |
169 | 169 | |
170 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
171 | - return $this->_fieldAs(function($id,$name,$value) use($attributes){ |
|
172 | - $input= new HtmlFormRadio($id,$name,$value,$value); |
|
170 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
171 | + return $this->_fieldAs(function($id, $name, $value) use($attributes){ |
|
172 | + $input=new HtmlFormRadio($id, $name, $value, $value); |
|
173 | 173 | return $this->_prepareFormFields($input, $name, $attributes); |
174 | - }, $index,$attributes,"radio"); |
|
174 | + }, $index, $attributes, "radio"); |
|
175 | 175 | } |
176 | 176 | |
177 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
178 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
179 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
180 | - }, $index,$attributes,"radios"); |
|
177 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
178 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
179 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
180 | + }, $index, $attributes, "radios"); |
|
181 | 181 | } |
182 | 182 | |
183 | - public function fieldAsInput($index,$attributes=NULL){ |
|
184 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
185 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
183 | + public function fieldAsInput($index, $attributes=NULL) { |
|
184 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
185 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
186 | 186 | return $this->_prepareFormFields($input, $name, $attributes); |
187 | - }, $index,$attributes,"input"); |
|
187 | + }, $index, $attributes, "input"); |
|
188 | 188 | } |
189 | 189 | |
190 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
191 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
192 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
190 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
191 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
192 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
193 | 193 | return $this->_prepareFormFields($textarea, $name, $attributes); |
194 | - }, $index,$attributes,"textarea"); |
|
194 | + }, $index, $attributes, "textarea"); |
|
195 | 195 | } |
196 | 196 | |
197 | - public function fieldAsElement($index,$tagName="div",$baseClass="",$attributes=NULL){ |
|
198 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes,$tagName,$baseClass){ |
|
199 | - $div=new HtmlSemDoubleElement($id,$tagName,$baseClass); |
|
197 | + public function fieldAsElement($index, $tagName="div", $baseClass="", $attributes=NULL) { |
|
198 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass){ |
|
199 | + $div=new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
200 | 200 | $div->setContent(\htmlentities($value)); |
201 | - $textarea=new HtmlFormField("field-".$id, $div,$caption); |
|
201 | + $textarea=new HtmlFormField("field-".$id, $div, $caption); |
|
202 | 202 | return $this->_prepareFormFields($textarea, $name, $attributes); |
203 | - }, $index,$attributes,"element"); |
|
203 | + }, $index, $attributes, "element"); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | |
207 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
208 | - if(!\is_array($attributes)){ |
|
207 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
208 | + if (!\is_array($attributes)) { |
|
209 | 209 | $attributes=[]; |
210 | 210 | } |
211 | 211 | $attributes["inputType"]="hidden"; |
212 | 212 | $attributes["style"]="display:none;"; |
213 | - return $this->fieldAsInput($index,$attributes); |
|
213 | + return $this->fieldAsInput($index, $attributes); |
|
214 | 214 | } |
215 | 215 | |
216 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
217 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($attributes){ |
|
218 | - if($caption===null || $caption==="") |
|
216 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
217 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($attributes){ |
|
218 | + if ($caption===null || $caption==="") |
|
219 | 219 | $caption=""; |
220 | - $input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier()); |
|
220 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
221 | 221 | $input->setChecked(JString::isBooleanTrue($value)); |
222 | 222 | return $this->_prepareFormFields($input, $name, $attributes); |
223 | - }, $index,$attributes,"ck"); |
|
223 | + }, $index, $attributes, "ck"); |
|
224 | 224 | } |
225 | 225 | |
226 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
227 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple,$attributes){ |
|
228 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value); |
|
229 | - $dd->asSelect($name,$multiple); |
|
226 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
227 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple, $attributes){ |
|
228 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value); |
|
229 | + $dd->asSelect($name, $multiple); |
|
230 | 230 | return $this->_prepareFormFields($dd, $name, $attributes); |
231 | - }, $index,$attributes,"dd"); |
|
231 | + }, $index, $attributes, "dd"); |
|
232 | 232 | } |
233 | 233 | |
234 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
235 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
236 | - $mess= new HtmlMessage("message-".$id,$caption); |
|
234 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
235 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
236 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
237 | 237 | $mess->addHeader($value); |
238 | 238 | return $mess; |
239 | - }, $index,$attributes,"message"); |
|
239 | + }, $index, $attributes, "message"); |
|
240 | 240 | } |
241 | 241 | |
242 | - public function fieldAsLink($index,$attributes=NULL){ |
|
243 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
244 | - $lnk= new HtmlLink("message-".$id,"#",$caption); |
|
242 | + public function fieldAsLink($index, $attributes=NULL) { |
|
243 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
244 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
245 | 245 | return $lnk; |
246 | - }, $index,$attributes,"link"); |
|
246 | + }, $index, $attributes, "link"); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /**Change fields type |
250 | 250 | * @param array $types an array or associative array $type=>$attributes |
251 | 251 | */ |
252 | - public function fieldsAs(array $types){ |
|
252 | + public function fieldsAs(array $types) { |
|
253 | 253 | $i=0; |
254 | - if(JArray::isAssociative($types)){ |
|
255 | - foreach ($types as $type=>$attributes){ |
|
256 | - if(\is_int($type)) |
|
257 | - $this->fieldAs($i++,$attributes,[]); |
|
258 | - else{ |
|
259 | - $type=preg_replace('/\d/', '', $type ); |
|
260 | - $this->fieldAs($i++,$type,$attributes); |
|
254 | + if (JArray::isAssociative($types)) { |
|
255 | + foreach ($types as $type=>$attributes) { |
|
256 | + if (\is_int($type)) |
|
257 | + $this->fieldAs($i++, $attributes, []); |
|
258 | + else { |
|
259 | + $type=preg_replace('/\d/', '', $type); |
|
260 | + $this->fieldAs($i++, $type, $attributes); |
|
261 | 261 | } |
262 | 262 | } |
263 | - }else{ |
|
264 | - foreach ($types as $type){ |
|
265 | - $this->fieldAs($i++,$type); |
|
263 | + } else { |
|
264 | + foreach ($types as $type) { |
|
265 | + $this->fieldAs($i++, $type); |
|
266 | 266 | } |
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | - public function fieldAs($index,$type,$attributes=NULL){ |
|
270 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
271 | 271 | $method="fieldAs".\ucfirst($type); |
272 | - if(\method_exists($this, $method)){ |
|
273 | - if(!\is_array($attributes)){ |
|
272 | + if (\method_exists($this, $method)) { |
|
273 | + if (!\is_array($attributes)) { |
|
274 | 274 | $attributes=[$index]; |
275 | - }else{ |
|
275 | + } else { |
|
276 | 276 | \array_unshift($attributes, $index); |
277 | 277 | } |
278 | - \call_user_func_array([$this,$method], $attributes); |
|
278 | + \call_user_func_array([$this, $method], $attributes); |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 | |
282 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
283 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
284 | - $button=new HtmlButton($id,$caption,$cssStyle); |
|
285 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]); |
|
282 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
283 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
284 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
285 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
|
286 | 286 | return $button; |
287 | - }, $index,$attributes,"submit"); |
|
287 | + }, $index, $attributes, "submit"); |
|
288 | 288 | } |
289 | 289 | |
290 | - public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){ |
|
291 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
292 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
290 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
291 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
292 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
293 | 293 | return $button; |
294 | - }, $index,$attributes,"button"); |
|
294 | + }, $index, $attributes, "button"); |
|
295 | 295 | } |
296 | 296 | } |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | * @param boolean $autoActive sets the last element's class to <b>active</b> if true |
42 | 42 | * @param callable $hrefFunction the function who generates the href elements. default : function($e){return $e->getContent()} |
43 | 43 | */ |
44 | - public function __construct($identifier,$elements=array(),$autoActive=true,$startIndex=0,$hrefFunction=NULL){ |
|
45 | - parent::__construct($identifier,"ol"); |
|
44 | + public function __construct($identifier, $elements=array(), $autoActive=true, $startIndex=0, $hrefFunction=NULL) { |
|
45 | + parent::__construct($identifier, "ol"); |
|
46 | 46 | $this->startIndex=$startIndex; |
47 | 47 | $this->setProperty("class", "breadcrumb"); |
48 | 48 | $this->content=array(); |
49 | 49 | $this->autoActive=$autoActive; |
50 | 50 | $this->absolutePaths; |
51 | - $this->_hrefFunction=function (HtmlDoubleElement $e){return $e->getContent();}; |
|
52 | - if(isset($hrefFunction)){ |
|
51 | + $this->_hrefFunction=function(HtmlDoubleElement $e) {return $e->getContent(); }; |
|
52 | + if (isset($hrefFunction)) { |
|
53 | 53 | $this->_hrefFunction=$hrefFunction; |
54 | 54 | } |
55 | 55 | $this->addElements($elements); |
@@ -60,43 +60,43 @@ discard block |
||
60 | 60 | * @param string $href |
61 | 61 | * @return \Ajax\bootstrap\html\HtmlLink |
62 | 62 | */ |
63 | - public function addElement($element,$href="",$glyph=NULL){ |
|
63 | + public function addElement($element, $href="", $glyph=NULL) { |
|
64 | 64 | $size=sizeof($this->content); |
65 | - if(\is_array($element)){ |
|
65 | + if (\is_array($element)) { |
|
66 | 66 | $elm=new HtmlLink("lnk-".$this->identifier."-".$size); |
67 | 67 | $elm->fromArray($element); |
68 | - }else if($element instanceof HtmlLink){ |
|
68 | + } else if ($element instanceof HtmlLink) { |
|
69 | 69 | $elm=$element; |
70 | - }else{ |
|
71 | - $elm=new HtmlLink("lnk-".$this->identifier."-".$size,$href,$element); |
|
72 | - if(isset($glyph)){ |
|
70 | + } else { |
|
71 | + $elm=new HtmlLink("lnk-".$this->identifier."-".$size, $href, $element); |
|
72 | + if (isset($glyph)) { |
|
73 | 73 | $elm->wrapContentWithGlyph($glyph); |
74 | 74 | } |
75 | 75 | } |
76 | - $elm->wrap("<li>","</li>"); |
|
76 | + $elm->wrap("<li>", "</li>"); |
|
77 | 77 | $this->content[]=$elm; |
78 | 78 | $elm->setProperty($this->attr, $this->getHref($size)); |
79 | 79 | return $elm; |
80 | 80 | } |
81 | 81 | |
82 | - public function setActive($index=null){ |
|
83 | - if(!isset($index)){ |
|
82 | + public function setActive($index=null) { |
|
83 | + if (!isset($index)) { |
|
84 | 84 | $index=sizeof($this->content)-1; |
85 | 85 | } |
86 | - $li=new HtmlBsDoubleElement("","li"); |
|
86 | + $li=new HtmlBsDoubleElement("", "li"); |
|
87 | 87 | $li->setClass("active"); |
88 | 88 | $li->setContent($this->content[$index]->getContent()); |
89 | 89 | $this->content[$index]=$li; |
90 | 90 | } |
91 | 91 | |
92 | - public function addElements($elements){ |
|
93 | - foreach ( $elements as $element ) { |
|
92 | + public function addElements($elements) { |
|
93 | + foreach ($elements as $element) { |
|
94 | 94 | $this->addElement($element); |
95 | 95 | } |
96 | 96 | return $this; |
97 | 97 | } |
98 | 98 | |
99 | - public function fromArray($array){ |
|
99 | + public function fromArray($array) { |
|
100 | 100 | $array=parent::fromArray($array); |
101 | 101 | $this->addElements($array); |
102 | 102 | return $array; |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | * @param string $separator |
109 | 109 | * @return string |
110 | 110 | */ |
111 | - public function getHref($index=null,$separator="/"){ |
|
112 | - if(!isset($index)){ |
|
111 | + public function getHref($index=null, $separator="/") { |
|
112 | + if (!isset($index)) { |
|
113 | 113 | $index=sizeof($this->content); |
114 | 114 | } |
115 | - if($this->absolutePaths===true){ |
|
115 | + if ($this->absolutePaths===true) { |
|
116 | 116 | return $this->_hrefFunction($this->content[$index]); |
117 | - }else{ |
|
118 | - return $this->root.implode($separator, array_slice(array_map(function($e){return $this->_hrefFunction($e);}, $this->content),$this->startIndex,$index+1)); |
|
117 | + } else { |
|
118 | + return $this->root.implode($separator, array_slice(array_map(function($e) {return $this->_hrefFunction($e); }, $this->content), $this->startIndex, $index+1)); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @see \Ajax\bootstrap\html\BaseHtml::compile() |
125 | 125 | */ |
126 | 126 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
127 | - if($this->autoActive){ |
|
127 | + if ($this->autoActive) { |
|
128 | 128 | $this->setActive(); |
129 | 129 | } |
130 | 130 | return parent::compile($js, $view); |
@@ -142,19 +142,19 @@ discard block |
||
142 | 142 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
143 | 143 | */ |
144 | 144 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
145 | - foreach ($this->content as $element){ |
|
146 | - $element->on($event,$jsCode,$stopPropagation,$preventDefault); |
|
145 | + foreach ($this->content as $element) { |
|
146 | + $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
|
147 | 147 | } |
148 | 148 | return $this; |
149 | 149 | } |
150 | 150 | |
151 | 151 | public function setAutoActive($autoActive) { |
152 | - $this->autoActive = $autoActive; |
|
152 | + $this->autoActive=$autoActive; |
|
153 | 153 | return $this; |
154 | 154 | } |
155 | 155 | |
156 | 156 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
157 | - foreach ($this->content as $element){ |
|
157 | + foreach ($this->content as $element) { |
|
158 | 158 | $element->_ajaxOn($operation, $event, $url, $responseElement, $parameters); |
159 | 159 | } |
160 | 160 | return $this; |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | * @param string $targetSelector the target of the get |
167 | 167 | * @return HtmlBreadcrumbs |
168 | 168 | */ |
169 | - public function autoGetOnClick($targetSelector){ |
|
170 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
169 | + public function autoGetOnClick($targetSelector) { |
|
170 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
171 | 171 | } |
172 | 172 | |
173 | - public function contentAsString(){ |
|
174 | - if($this->autoActive){ |
|
173 | + public function contentAsString() { |
|
174 | + if ($this->autoActive) { |
|
175 | 175 | $this->setActive(); |
176 | 176 | } |
177 | 177 | return parent::contentAsString(); |
178 | 178 | } |
179 | 179 | |
180 | - public function getElement($index){ |
|
180 | + public function getElement($index) { |
|
181 | 181 | return $this->content[$index]; |
182 | 182 | } |
183 | 183 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @param mixed $glyph |
187 | 187 | * @param int $index |
188 | 188 | */ |
189 | - public function addGlyph($glyph,$index=0){ |
|
189 | + public function addGlyph($glyph, $index=0) { |
|
190 | 190 | $elm=$this->getElement($index); |
191 | 191 | return $elm->wrapContentWithGlyph($glyph); |
192 | 192 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param object $dispatcher the request dispatcher |
198 | 198 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
199 | 199 | */ |
200 | - public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0){ |
|
200 | + public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0) { |
|
201 | 201 | $this->startIndex=$startIndex; |
202 | 202 | return $this->addElements($js->fromDispatcher($dispatcher)); |
203 | 203 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
210 | 210 | */ |
211 | 211 | public function setHrefFunction($_hrefFunction) { |
212 | - $this->_hrefFunction = $_hrefFunction; |
|
212 | + $this->_hrefFunction=$_hrefFunction; |
|
213 | 213 | return $this; |
214 | 214 | } |
215 | 215 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | class HtmlModal extends BaseHtml { |
15 | 15 | protected $title="Titre de ma boîte"; |
16 | 16 | protected $content=""; |
17 | - protected $buttons=array (); |
|
17 | + protected $buttons=array(); |
|
18 | 18 | protected $showOnStartup=false; |
19 | 19 | protected $draggable=false; |
20 | 20 | protected $validCondition=NULL; |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | public function __construct($identifier, $title="", $content="", $buttonCaptions=array()) { |
28 | 28 | parent::__construct($identifier); |
29 | 29 | $this->_template=include 'templates/tplModal.php'; |
30 | - $this->buttons=array (); |
|
30 | + $this->buttons=array(); |
|
31 | 31 | $this->title=$title; |
32 | 32 | $this->content=$content; |
33 | - foreach ( $buttonCaptions as $button ) { |
|
33 | + foreach ($buttonCaptions as $button) { |
|
34 | 34 | $this->addButton($button); |
35 | 35 | } |
36 | 36 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param string $value |
66 | 66 | * @return HtmlButton |
67 | 67 | */ |
68 | - public function addOkayButton($value="Okay",$jsCode="") { |
|
68 | + public function addOkayButton($value="Okay", $jsCode="") { |
|
69 | 69 | $btn=$this->addButton($value, "btn-primary"); |
70 | 70 | $btn->onClick("if(".$this->getValidCondition()."){ ".$jsCode."$('#".$this->identifier."').modal('hide');}"); |
71 | 71 | return $btn; |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @param string $viewName |
115 | 115 | * @param array $params The parameters to pass to the view |
116 | 116 | */ |
117 | - public function renderView(JsUtils $js,$initialController,$viewName, $params=array()) { |
|
118 | - $this->content=$js->renderContent($initialController, $viewName,$params); |
|
117 | + public function renderView(JsUtils $js, $initialController, $viewName, $params=array()) { |
|
118 | + $this->content=$js->renderContent($initialController, $viewName, $params); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @param string $actionName the action name |
127 | 127 | * @param array $params |
128 | 128 | */ |
129 | - public function forward(JsUtils $js,$initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
130 | - $this->content=$js->forward($initialControllerInstance, $controllerName, $actionName,$params); |
|
129 | + public function forward(JsUtils $js, $initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
130 | + $this->content=$js->forward($initialControllerInstance, $controllerName, $actionName, $params); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /* |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | * @see BaseHtml::run() |
136 | 136 | */ |
137 | 137 | public function run(JsUtils $js) { |
138 | - if($this->content instanceof BaseHtml){ |
|
138 | + if ($this->content instanceof BaseHtml) { |
|
139 | 139 | $this->content->run($js); |
140 | 140 | } |
141 | - $this->_bsComponent=$js->bootstrap()->modal("#".$this->identifier, array ( |
|
141 | + $this->_bsComponent=$js->bootstrap()->modal("#".$this->identifier, array( |
|
142 | 142 | "show" => $this->showOnStartup |
143 | 143 | )); |
144 | 144 | if ($this->draggable) |
@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | class HtmlGridSystem extends HtmlBsDoubleElement { |
17 | 17 | private $rows; |
18 | 18 | |
19 | - public function __construct($identifier,$numRows=1,$numCols=NULL){ |
|
20 | - parent::__construct($identifier,"div"); |
|
19 | + public function __construct($identifier, $numRows=1, $numCols=NULL) { |
|
20 | + parent::__construct($identifier, "div"); |
|
21 | 21 | $this->setProperty("class", "container-fluid"); |
22 | 22 | $this->rows=array(); |
23 | - $this->setNumRows($numRows,$numCols); |
|
23 | + $this->setNumRows($numRows, $numCols); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | * @param int $numCols |
29 | 29 | * @return \Ajax\bootstrap\html\content\HtmlGridRow |
30 | 30 | */ |
31 | - public function addRow($numCols=NULL){ |
|
32 | - $row=new HtmlGridRow($this->identifier."-row-".(sizeof($this->rows)+1),$numCols); |
|
31 | + public function addRow($numCols=NULL) { |
|
32 | + $row=new HtmlGridRow($this->identifier."-row-".(sizeof($this->rows)+1), $numCols); |
|
33 | 33 | $this->rows[]=$row; |
34 | 34 | return $row; |
35 | 35 | } |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | * @param boolean $force add the row at $index if true |
41 | 41 | * @return \Ajax\bootstrap\html\content\HtmlGridRow |
42 | 42 | */ |
43 | - public function getRow($index,$force=true){ |
|
44 | - if($index<sizeof($this->rows)){ |
|
43 | + public function getRow($index, $force=true) { |
|
44 | + if ($index<sizeof($this->rows)) { |
|
45 | 45 | $result=$this->rows[$index-1]; |
46 | - }else if ($force){ |
|
46 | + } else if ($force) { |
|
47 | 47 | $this->setNumRows($index); |
48 | 48 | $result=$this->rows[$index-1]; |
49 | 49 | } |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param int $numCols |
57 | 57 | * @return \Ajax\bootstrap\html\HtmlGridSystem |
58 | 58 | */ |
59 | - public function setNumRows($numRows,$numCols=NULL){ |
|
60 | - for($i=sizeof($this->rows);$i<$numRows;$i++){ |
|
59 | + public function setNumRows($numRows, $numCols=NULL) { |
|
60 | + for ($i=sizeof($this->rows); $i<$numRows; $i++) { |
|
61 | 61 | $this->addRow($numCols); |
62 | 62 | } |
63 | 63 | return $this; |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * @param boolean $force add the cell at $row,$col if true |
70 | 70 | * @return HtmlGridCol |
71 | 71 | */ |
72 | - public function getCell($row,$col,$force=true){ |
|
73 | - $row=$this->getRow($row,$force); |
|
74 | - if(isset($row)){ |
|
75 | - $col=$row->getCol($col,$force); |
|
72 | + public function getCell($row, $col, $force=true) { |
|
73 | + $row=$this->getRow($row, $force); |
|
74 | + if (isset($row)) { |
|
75 | + $col=$row->getCol($col, $force); |
|
76 | 76 | } |
77 | 77 | return $col; |
78 | 78 | } |
@@ -82,22 +82,22 @@ discard block |
||
82 | 82 | * @param int $col |
83 | 83 | * @return HtmlGridCol |
84 | 84 | */ |
85 | - public function getCellAt($row,$col,$force=true){ |
|
86 | - $row=$this->getRow($row,$force); |
|
87 | - if(isset($row)){ |
|
88 | - $col=$row->getColAt($col,$force); |
|
85 | + public function getCellAt($row, $col, $force=true) { |
|
86 | + $row=$this->getRow($row, $force); |
|
87 | + if (isset($row)) { |
|
88 | + $col=$row->getColAt($col, $force); |
|
89 | 89 | } |
90 | 90 | return $col; |
91 | 91 | } |
92 | 92 | |
93 | 93 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
94 | - foreach ($this->rows as $row){ |
|
94 | + foreach ($this->rows as $row) { |
|
95 | 95 | $this->addContent($row); |
96 | 96 | } |
97 | - return parent::compile($js,$view); |
|
97 | + return parent::compile($js, $view); |
|
98 | 98 | } |
99 | - public function setContentForAll($content){ |
|
100 | - foreach ($this->rows as $row){ |
|
99 | + public function setContentForAll($content) { |
|
100 | + foreach ($this->rows as $row) { |
|
101 | 101 | $row->setContentForAll($content); |
102 | 102 | } |
103 | 103 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | use Ajax\bootstrap\html\content\HtmlTabContent; |
16 | 16 | |
17 | 17 | class HtmlTabs extends HtmlBsDoubleElement { |
18 | - protected $tabs=array (); |
|
18 | + protected $tabs=array(); |
|
19 | 19 | protected $_tabsType="tabs"; |
20 | 20 | protected $stacked=""; |
21 | 21 | |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | } |
27 | 27 | |
28 | 28 | protected function addTab_($tab, $index=null) { |
29 | - if($tab instanceof HtmlDropdown){ |
|
29 | + if ($tab instanceof HtmlDropdown) { |
|
30 | 30 | $tab->setMTagName("li"); |
31 | 31 | } |
32 | 32 | if (isset($index)) { |
33 | - $inserted=array ( |
|
33 | + $inserted=array( |
|
34 | 34 | $tab |
35 | 35 | ); |
36 | 36 | array_splice($this->tabs, $index, 0, $inserted); |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | $this->tabs []=$tab; |
39 | 39 | } |
40 | 40 | |
41 | - public function setActive($index){ |
|
41 | + public function setActive($index) { |
|
42 | 42 | $size=\sizeof($this->tabs); |
43 | - for ($i=0;$i<$size;$i++){ |
|
43 | + for ($i=0; $i<$size; $i++) { |
|
44 | 44 | $this->tabs[$i]->setActive($i==$index); |
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | - public function disable($index){ |
|
48 | + public function disable($index) { |
|
49 | 49 | $this->tabs[$index]->disable(); |
50 | 50 | } |
51 | 51 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | public function addTabs($tabs) { |
79 | - foreach ( $tabs as $tab ) { |
|
79 | + foreach ($tabs as $tab) { |
|
80 | 80 | $this->addTab($tab); |
81 | 81 | } |
82 | 82 | return $this; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function run(JsUtils $js) { |
108 | 108 | $this->_bsComponent=new Tabs($js); |
109 | - foreach ( $this->tabs as $tab ) { |
|
109 | + foreach ($this->tabs as $tab) { |
|
110 | 110 | $this->_bsComponent->addTab($tab->run($js)); |
111 | 111 | } |
112 | 112 | $this->addEventsOnRun($js); |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | |
116 | 116 | public function createTabContents() { |
117 | 117 | $tabContent=new HtmlTabContent("tabcontent-".$this->identifier); |
118 | - foreach ( $this->tabs as $tab ) { |
|
118 | + foreach ($this->tabs as $tab) { |
|
119 | 119 | if ($tab instanceof HtmlTabItem) |
120 | 120 | $tabContent->addTabItem($tab->getHref()); |
121 | 121 | elseif ($tab instanceof HtmlDropdown) { |
122 | - foreach ( $tab->getItems() as $dropdownItem ) { |
|
122 | + foreach ($tab->getItems() as $dropdownItem) { |
|
123 | 123 | $tabContent->addTabItem($dropdownItem->getHref()); |
124 | 124 | } |
125 | 125 | } |
@@ -154,21 +154,21 @@ discard block |
||
154 | 154 | if (sizeof($this->content->getTabItems())>0) { |
155 | 155 | $this->content->getTabItem(0)->addToProperty("class", "fade in"); |
156 | 156 | $size=sizeof($this->tabs); |
157 | - for($index=0; $index<$size; $index++) { |
|
157 | + for ($index=0; $index<$size; $index++) { |
|
158 | 158 | $this->content->getTabItem($index)->addToProperty("class", "fade"); |
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - public function on($event, $jsCode,$stopPropagation=false,$preventDefault=false){ |
|
164 | - foreach ($this->tabs as $tab){ |
|
165 | - $tab->on($event,$jsCode,$stopPropagation,$preventDefault); |
|
163 | + public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
|
164 | + foreach ($this->tabs as $tab) { |
|
165 | + $tab->on($event, $jsCode, $stopPropagation, $preventDefault); |
|
166 | 166 | } |
167 | 167 | return $this; |
168 | 168 | } |
169 | 169 | |
170 | - public function setStacked($stacked=true){ |
|
171 | - if($stacked) |
|
170 | + public function setStacked($stacked=true) { |
|
171 | + if ($stacked) |
|
172 | 172 | $this->stacked="nav-stacked"; |
173 | 173 | else $this->stacked=""; |
174 | 174 | } |
@@ -45,70 +45,70 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * @param string $identifier |
47 | 47 | */ |
48 | - public function __construct($identifier,$from=1,$to=1,$active=NULL,$countVisible=NULL){ |
|
49 | - parent::__construct($identifier,"ul"); |
|
48 | + public function __construct($identifier, $from=1, $to=1, $active=NULL, $countVisible=NULL) { |
|
49 | + parent::__construct($identifier, "ul"); |
|
50 | 50 | $this->setProperty("class", "pagination"); |
51 | 51 | $this->active=$active; |
52 | 52 | $this->from=$from; |
53 | 53 | $this->to=$to; |
54 | 54 | $this->urlMask="%page%"; |
55 | - if(!isset($countVisible)) |
|
55 | + if (!isset($countVisible)) |
|
56 | 56 | $this->countVisible=$to-$from+1; |
57 | 57 | else |
58 | 58 | $this->countVisible=$countVisible; |
59 | 59 | $this->createContent(); |
60 | 60 | } |
61 | 61 | |
62 | - private function createElement($num,$content,$disabled=false,$current=false){ |
|
62 | + private function createElement($num, $content, $disabled=false, $current=false) { |
|
63 | 63 | $count=sizeof($this->content)+1; |
64 | - $elem=new HtmlBsDoubleElement("li-".$this->identifier."-".$count,"li"); |
|
65 | - if($disabled){ |
|
64 | + $elem=new HtmlBsDoubleElement("li-".$this->identifier."-".$count, "li"); |
|
65 | + if ($disabled) { |
|
66 | 66 | $elem->setProperty("class", "disabled"); |
67 | 67 | } |
68 | - if($current){ |
|
68 | + if ($current) { |
|
69 | 69 | $content.="<span class='sr-only'>(current)</span>"; |
70 | 70 | $elem->setProperty("class", "active"); |
71 | 71 | } |
72 | - if(!$disabled){ |
|
72 | + if (!$disabled) { |
|
73 | 73 | $url=$this->getUrl($num); |
74 | - $href=new HtmlLink("a-".$this->identifier."-".$count,$url,$content); |
|
74 | + $href=new HtmlLink("a-".$this->identifier."-".$count, $url, $content); |
|
75 | 75 | $href->setProperty($this->attr, $url); |
76 | 76 | $elem->setContent($href); |
77 | - }else{ |
|
77 | + } else { |
|
78 | 78 | $elem->setContent($content); |
79 | 79 | } |
80 | 80 | $this->content[]=$elem; |
81 | 81 | return $this; |
82 | 82 | } |
83 | 83 | |
84 | - protected function createContent(){ |
|
84 | + protected function createContent() { |
|
85 | 85 | $this->content=array(); |
86 | - $this->createElement($this->active-1,"<span aria-hidden='true'>«</span>",$this->active===1); |
|
86 | + $this->createElement($this->active-1, "<span aria-hidden='true'>«</span>", $this->active===1); |
|
87 | 87 | $start=$this->getStart(); |
88 | - $end=min($start+$this->countVisible-1,$this->to); |
|
89 | - for($index=$start;$index<=$end;$index++){ |
|
90 | - $this->createElement($index,$index,false,$index===$this->active); |
|
88 | + $end=min($start+$this->countVisible-1, $this->to); |
|
89 | + for ($index=$start; $index<=$end; $index++) { |
|
90 | + $this->createElement($index, $index, false, $index===$this->active); |
|
91 | 91 | } |
92 | - $this->createElement($this->active+1,"<span aria-hidden='true'>»</span>",$this->active===$this->to); |
|
92 | + $this->createElement($this->active+1, "<span aria-hidden='true'>»</span>", $this->active===$this->to); |
|
93 | 93 | } |
94 | 94 | |
95 | - protected function half(){ |
|
95 | + protected function half() { |
|
96 | 96 | return (int)($this->countVisible/2); |
97 | 97 | } |
98 | 98 | |
99 | - protected function getStart(){ |
|
99 | + protected function getStart() { |
|
100 | 100 | $result=1; |
101 | - if($this->countVisible!==$this->to-$this->from+1){ |
|
102 | - $result=max($this->active-$this->half(),$result); |
|
101 | + if ($this->countVisible!==$this->to-$this->from+1) { |
|
102 | + $result=max($this->active-$this->half(), $result); |
|
103 | 103 | } |
104 | 104 | return $result; |
105 | 105 | } |
106 | 106 | |
107 | 107 | public function _addEvent($event, $jsCode) { |
108 | - foreach ($this->content as $li){ |
|
108 | + foreach ($this->content as $li) { |
|
109 | 109 | $content=$li->getContent(); |
110 | - if($content instanceof BaseHtml) |
|
111 | - $content->_addEvent($event,$jsCode); |
|
110 | + if ($content instanceof BaseHtml) |
|
111 | + $content->_addEvent($event, $jsCode); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | /** |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | * @param object $dispatcher the request dispatcher |
118 | 118 | * @return \Ajax\bootstrap\html\HtmlPagination |
119 | 119 | */ |
120 | - public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0){ |
|
120 | + public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0) { |
|
121 | 121 | $items=$js->fromDispatcher($dispatcher); |
122 | 122 | $url=implode("/", $items); |
123 | - if($this->urlMask==="%page%"){ |
|
123 | + if ($this->urlMask==="%page%") { |
|
124 | 124 | $this->urlMask=preg_replace("/[0-9]/", "%page%", $url); |
125 | 125 | } |
126 | - for($index=$this->from;$index<=$this->to;$index++){ |
|
127 | - if($this->getUrl($index)==$url){ |
|
126 | + for ($index=$this->from; $index<=$this->to; $index++) { |
|
127 | + if ($this->getUrl($index)==$url) { |
|
128 | 128 | $this->setActive($index); |
129 | 129 | break; |
130 | 130 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | return $this; |
133 | 133 | } |
134 | 134 | |
135 | - public function getUrl($index){ |
|
135 | + public function getUrl($index) { |
|
136 | 136 | return str_ireplace("%page%", $index, $this->urlMask); |
137 | 137 | } |
138 | 138 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | if (is_int($size)) { |
147 | 147 | return $this->addToPropertyUnique("class", CssRef::sizes("pagination")[$size], CssRef::sizes("pagination")); |
148 | 148 | } |
149 | - if(!JString::startsWith($size, "pagination-") && $size!=="") |
|
149 | + if (!JString::startsWith($size, "pagination-") && $size!=="") |
|
150 | 150 | $size="pagination-".$size; |
151 | 151 | return $this->addToPropertyCtrl("class", $size, CssRef::sizes("pagination")); |
152 | 152 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | return $this->from; |
156 | 156 | } |
157 | 157 | public function setFrom($from) { |
158 | - $this->from = $from; |
|
158 | + $this->from=$from; |
|
159 | 159 | $this->createContent(); |
160 | 160 | return $this; |
161 | 161 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | return $this->to; |
164 | 164 | } |
165 | 165 | public function setTo($to) { |
166 | - $this->to = $to; |
|
166 | + $this->to=$to; |
|
167 | 167 | $this->createContent(); |
168 | 168 | return $this; |
169 | 169 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | return $this->active; |
172 | 172 | } |
173 | 173 | public function setActive($active) { |
174 | - $this->active = $active; |
|
174 | + $this->active=$active; |
|
175 | 175 | $this->createContent(); |
176 | 176 | return $this; |
177 | 177 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | return $this->urlMask; |
180 | 180 | } |
181 | 181 | public function setUrlMask($urlMask) { |
182 | - $this->urlMask = $urlMask; |
|
182 | + $this->urlMask=$urlMask; |
|
183 | 183 | $this->createContent(); |
184 | 184 | return $this; |
185 | 185 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | return $this->countVisible; |
188 | 188 | } |
189 | 189 | public function setCountVisible($countVisible) { |
190 | - $this->countVisible = $countVisible; |
|
190 | + $this->countVisible=$countVisible; |
|
191 | 191 | $this->createContent(); |
192 | 192 | return $this; |
193 | 193 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $this->setClass("panel-group"); |
20 | 20 | $this->setRole("tablist"); |
21 | 21 | $this->setProperty("aria-multiselectable", "true"); |
22 | - $this->content=array (); |
|
22 | + $this->content=array(); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function addPanel($title, $content) { |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | * @param string $viewName |
46 | 46 | * @param array $params The parameters to pass to the view |
47 | 47 | */ |
48 | - public function renderViewPanel(JsUtils $js,$title,$initialController, $viewName, $params=array()) { |
|
49 | - return $this->addPanel($title, $js->renderContent($initialController, $viewName,$params)); |
|
48 | + public function renderViewPanel(JsUtils $js, $title, $initialController, $viewName, $params=array()) { |
|
49 | + return $this->addPanel($title, $js->renderContent($initialController, $viewName, $params)); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * @param string $action a Phalcon action |
59 | 59 | * @param array $params |
60 | 60 | */ |
61 | - public function forwardPanel(JsUtils $js,$title,$initialController,$controller,$action,$params=array()){ |
|
62 | - return $this->addPanel($title, $js->forward($initialController, $controller, $action,$params)); |
|
61 | + public function forwardPanel(JsUtils $js, $title, $initialController, $controller, $action, $params=array()) { |
|
62 | + return $this->addPanel($title, $js->forward($initialController, $controller, $action, $params)); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | public function run(JsUtils $js) { |
66 | - foreach ( $this->content as $content ) { |
|
66 | + foreach ($this->content as $content) { |
|
67 | 67 | $content->run($js); |
68 | 68 | } |
69 | 69 | } |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | $this->parameters["immediatly"]=false; |
24 | 24 | extract($this->parameters); |
25 | 25 | $result=$this->_eventPreparing($preventDefault, $stopPropagation); |
26 | - switch($this->method) { |
|
26 | + switch ($this->method) { |
|
27 | 27 | case "get": |
28 | 28 | $result.=$js->getDeferred($url, $responseElement, $this->parameters); |
29 | 29 | break; |
30 | 30 | case "post": |
31 | - $result.=$js->postDeferred($url, $params,$responseElement, $this->parameters); |
|
31 | + $result.=$js->postDeferred($url, $params, $responseElement, $this->parameters); |
|
32 | 32 | break; |
33 | 33 | case "postForm": |
34 | 34 | $result.=$js->postFormDeferred($url, $form, $responseElement, $this->parameters); |
35 | 35 | break; |
36 | 36 | case "json": |
37 | - $result.=$js->jsonDeferred($url,$method,$this->parameters); |
|
37 | + $result.=$js->jsonDeferred($url, $method, $this->parameters); |
|
38 | 38 | break; |
39 | 39 | case "jsonArray": |
40 | - $result.=$js->jsonArrayDeferred($modelSelector, $url,$method,$this->parameters); |
|
40 | + $result.=$js->jsonArrayDeferred($modelSelector, $url, $method, $this->parameters); |
|
41 | 41 | break; |
42 | 42 | default: |
43 | 43 | break; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | return $result; |
46 | 46 | } |
47 | 47 | |
48 | - protected function _eventPreparing($preventDefault,$stopPropagation){ |
|
48 | + protected function _eventPreparing($preventDefault, $stopPropagation) { |
|
49 | 49 | $result=""; |
50 | 50 | if ($preventDefault===true) { |
51 | 51 | $result.=Javascript::$preventDefault; |
@@ -3,11 +3,11 @@ |
||
3 | 3 | namespace Ajax\common\html\html5; |
4 | 4 | |
5 | 5 | class HtmlUtils { |
6 | - public static function javascriptInclude($url){ |
|
6 | + public static function javascriptInclude($url) { |
|
7 | 7 | return '<script src="'.$url.'"></script>'; |
8 | 8 | } |
9 | 9 | |
10 | - public static function stylesheetInclude($url){ |
|
10 | + public static function stylesheetInclude($url) { |
|
11 | 11 | return '<link rel="stylesheet" type="text/css" href="'.$url.'">'; |
12 | 12 | } |
13 | 13 | } |