@@ -21,8 +21,9 @@ discard block |
||
21 | 21 | $this->widgetIdentifier=$identifier; |
22 | 22 | $this->values=[]; |
23 | 23 | $this->afterCompile=[]; |
24 | - if(isset($instance)) |
|
25 | - $this->setInstance($instance); |
|
24 | + if(isset($instance)) { |
|
25 | + $this->setInstance($instance); |
|
26 | + } |
|
26 | 27 | $this->setCaptions($captions); |
27 | 28 | $this->captionCallback=NULL; |
28 | 29 | $this->defaultValueFunction=function($name,$value){return $value;}; |
@@ -39,11 +40,13 @@ discard block |
||
39 | 40 | } |
40 | 41 | |
41 | 42 | public function getIdentifier($index=NULL){ |
42 | - if(!isset($index)) |
|
43 | - $index=self::$index; |
|
43 | + if(!isset($index)) { |
|
44 | + $index=self::$index; |
|
45 | + } |
|
44 | 46 | $value=$index; |
45 | - if(isset($this->values["identifier"])) |
|
46 | - $value=$this->values["identifier"]($index,$this->instance); |
|
47 | + if(isset($this->values["identifier"])) { |
|
48 | + $value=$this->values["identifier"]($index,$this->instance); |
|
49 | + } |
|
47 | 50 | return $value; |
48 | 51 | } |
49 | 52 | |
@@ -66,7 +69,7 @@ discard block |
||
66 | 69 | $value=$property->getValue($this->instance); |
67 | 70 | if(isset($this->values[$index])){ |
68 | 71 | $value= $this->values[$index]($value,$this->instance,$index); |
69 | - }else{ |
|
72 | + } else{ |
|
70 | 73 | $value=$this->_getDefaultValue($property->getName(),$value, $index); |
71 | 74 | } |
72 | 75 | return $value; |
@@ -76,16 +79,16 @@ discard block |
||
76 | 79 | $value=null; |
77 | 80 | if($property instanceof \ReflectionProperty){ |
78 | 81 | $value=$this->_getPropertyValue($property, $index); |
79 | - }else{ |
|
80 | - if(\is_callable($property)) |
|
81 | - $value=$property($this->instance); |
|
82 | - elseif(\is_array($property)){ |
|
82 | + } else{ |
|
83 | + if(\is_callable($property)) { |
|
84 | + $value=$property($this->instance); |
|
85 | + } elseif(\is_array($property)){ |
|
83 | 86 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
84 | 87 | $value=\implode("", $values); |
85 | - }else{ |
|
88 | + } else{ |
|
86 | 89 | if(isset($this->values[$index])){ |
87 | 90 | $value= $this->values[$index]($property,$this->instance,$index); |
88 | - }elseif(isset($this->instance->{$property})){ |
|
91 | + } elseif(isset($this->instance->{$property})){ |
|
89 | 92 | $value=$this->instance->{$property}; |
90 | 93 | } |
91 | 94 | } |
@@ -108,10 +111,10 @@ discard block |
||
108 | 111 | if(isset($vb[$index])){ |
109 | 112 | if(\is_array($vb[$index])){ |
110 | 113 | $this->visibleProperties[$index][]=$field; |
111 | - }else{ |
|
114 | + } else{ |
|
112 | 115 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
113 | 116 | } |
114 | - }else{ |
|
117 | + } else{ |
|
115 | 118 | return $this->insertField($index, $field); |
116 | 119 | } |
117 | 120 | return $this; |
@@ -138,9 +141,9 @@ discard block |
||
138 | 141 | $property=$this->getProperty($index); |
139 | 142 | if($property instanceof \ReflectionProperty){ |
140 | 143 | $result=$property->getName(); |
141 | - }elseif(\is_callable($property)){ |
|
144 | + } elseif(\is_callable($property)){ |
|
142 | 145 | $result=$this->visibleProperties[$index]; |
143 | - }else{ |
|
146 | + } else{ |
|
144 | 147 | $result=$property; |
145 | 148 | } |
146 | 149 | return $result; |
@@ -160,7 +163,7 @@ discard block |
||
160 | 163 | $this->reflect=new \ReflectionClass($instance); |
161 | 164 | if(\sizeof($this->visibleProperties)===0){ |
162 | 165 | $this->properties=$this->getDefaultProperties(); |
163 | - }else{ |
|
166 | + } else{ |
|
164 | 167 | foreach ($this->visibleProperties as $property){ |
165 | 168 | $this->setInstanceProperty($property); |
166 | 169 | } |
@@ -171,22 +174,23 @@ discard block |
||
171 | 174 | private function setInstanceProperty($property){ |
172 | 175 | if(\is_callable($property)){ |
173 | 176 | $this->properties[]=$property; |
174 | - }elseif(\is_string($property)){ |
|
177 | + } elseif(\is_string($property)){ |
|
175 | 178 | try{ |
176 | 179 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
177 | 180 | $rProperty=$this->reflect->getProperty($property); |
178 | 181 | $this->properties[]=$rProperty; |
179 | - }catch(\Exception $e){ |
|
182 | + } catch(\Exception $e){ |
|
180 | 183 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
181 | 184 | $this->properties[]=$property; |
182 | 185 | } |
183 | - }elseif(\is_int($property)){ |
|
186 | + } elseif(\is_int($property)){ |
|
184 | 187 | $props=$this->getDefaultProperties(); |
185 | - if(isset($props[$property])) |
|
186 | - $this->properties[]=$props[$property]; |
|
187 | - else |
|
188 | - $this->properties[]=$property; |
|
189 | - }else{ |
|
188 | + if(isset($props[$property])) { |
|
189 | + $this->properties[]=$props[$property]; |
|
190 | + } else { |
|
191 | + $this->properties[]=$property; |
|
192 | + } |
|
193 | + } else{ |
|
190 | 194 | $this->properties[]=$property; |
191 | 195 | } |
192 | 196 | } |
@@ -230,12 +234,13 @@ discard block |
||
230 | 234 | if(isset($this->captions[$index])){ |
231 | 235 | return $this->captions[$index]; |
232 | 236 | } |
233 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
234 | - return $this->properties[$index]->getName(); |
|
235 | - elseif(\is_callable($this->properties[$index])) |
|
236 | - return ""; |
|
237 | - else |
|
238 | - return $this->properties[$index]; |
|
237 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
238 | + return $this->properties[$index]->getName(); |
|
239 | + } elseif(\is_callable($this->properties[$index])) { |
|
240 | + return ""; |
|
241 | + } else { |
|
242 | + return $this->properties[$index]; |
|
243 | + } |
|
239 | 244 | } |
240 | 245 | |
241 | 246 | public function getCaptions(){ |
@@ -244,7 +249,7 @@ discard block |
||
244 | 249 | for($i=\sizeof($captions);$i<$this->count();$i++){ |
245 | 250 | $captions[]=""; |
246 | 251 | } |
247 | - }else{ |
|
252 | + } else{ |
|
248 | 253 | $captions=[]; |
249 | 254 | $index=0; |
250 | 255 | $count=$this->count(); |
@@ -260,8 +265,9 @@ discard block |
||
260 | 265 | } |
261 | 266 | |
262 | 267 | public function setCaption($index,$caption){ |
263 | - if(isset($this->captions)===false) |
|
264 | - $this->captions=[]; |
|
268 | + if(isset($this->captions)===false) { |
|
269 | + $this->captions=[]; |
|
270 | + } |
|
265 | 271 | $this->captions[$index]=$caption; |
266 | 272 | return $this; |
267 | 273 | } |
@@ -49,8 +49,9 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | public function setStyle($value) { |
52 | - foreach ( $this->elements as $element ) |
|
53 | - $element->setStyle($value); |
|
52 | + foreach ( $this->elements as $element ) { |
|
53 | + $element->setStyle($value); |
|
54 | + } |
|
54 | 55 | } |
55 | 56 | |
56 | 57 | private function dropdownAsButton($bt) { |
@@ -76,18 +77,19 @@ discard block |
||
76 | 77 | } elseif (is_string($element)) { |
77 | 78 | $result=new HtmlButton($this->identifier."-button-".$iid,$element); |
78 | 79 | } |
79 | - if($result instanceof HtmlButton) |
|
80 | - $this->elements[]=$result; |
|
80 | + if($result instanceof HtmlButton) { |
|
81 | + $this->elements[]=$result; |
|
82 | + } |
|
81 | 83 | return $result; |
82 | 84 | } |
83 | 85 | |
84 | 86 | private function _addArrayElement(array $element,$iid){ |
85 | - if (array_key_exists("glyph", $element)) |
|
86 | - $bt=new HtmlGlyphButton($this->identifier."-button-".$iid); |
|
87 | - elseif (array_key_exists("btnCaption", $element)) { |
|
88 | - if (array_key_exists("split", $element)) |
|
89 | - $bt=new HtmlSplitbutton($this->identifier."-dropdown-".$iid); |
|
90 | - else{ |
|
87 | + if (array_key_exists("glyph", $element)) { |
|
88 | + $bt=new HtmlGlyphButton($this->identifier."-button-".$iid); |
|
89 | + } elseif (array_key_exists("btnCaption", $element)) { |
|
90 | + if (array_key_exists("split", $element)) { |
|
91 | + $bt=new HtmlSplitbutton($this->identifier."-dropdown-".$iid); |
|
92 | + } else{ |
|
91 | 93 | $bt=new HtmlDropdown($this->identifier."-dropdown-".$iid); |
92 | 94 | $this->dropdownAsButton($bt); |
93 | 95 | } |
@@ -116,8 +118,9 @@ discard block |
||
116 | 118 | public function setAlignment($value) { |
117 | 119 | if (is_int($value)) { |
118 | 120 | $value=CssRef::alignment("btn-group")[$value]; |
119 | - } else |
|
120 | - $value="btn-group-".$value; |
|
121 | + } else { |
|
122 | + $value="btn-group-".$value; |
|
123 | + } |
|
121 | 124 | if (strstr($value, "justified")) { |
122 | 125 | foreach ( $this->elements as $element ) { |
123 | 126 | $element->wrap('<div class="btn-group" role="group">', '</div>'); |
@@ -132,9 +135,9 @@ discard block |
||
132 | 135 | * @return HtmlButton |
133 | 136 | */ |
134 | 137 | public function getElement($index) { |
135 | - if (is_int($index)) |
|
136 | - return $this->elements[$index]; |
|
137 | - else { |
|
138 | + if (is_int($index)) { |
|
139 | + return $this->elements[$index]; |
|
140 | + } else { |
|
138 | 141 | $elm=$this->getElementById($index, $this->elements); |
139 | 142 | return $elm; |
140 | 143 | } |
@@ -58,8 +58,9 @@ discard block |
||
58 | 58 | */ |
59 | 59 | private function getFieldButton($caption,$visibleHover=true){ |
60 | 60 | $bt= new HtmlButton("",$caption); |
61 | - if($visibleHover) |
|
62 | - $this->_visibleOver($bt); |
|
61 | + if($visibleHover) { |
|
62 | + $this->_visibleOver($bt); |
|
63 | + } |
|
63 | 64 | return $bt; |
64 | 65 | } |
65 | 66 | |
@@ -76,8 +77,9 @@ discard block |
||
76 | 77 | return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
77 | 78 | $button=new HtmlButton($id,$value,$cssStyle); |
78 | 79 | $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
79 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
80 | - $this->_visibleOver($button); |
|
80 | + if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) { |
|
81 | + $this->_visibleOver($button); |
|
82 | + } |
|
81 | 83 | return $button; |
82 | 84 | }, $index,$attributes); |
83 | 85 | } |
@@ -136,8 +138,9 @@ discard block |
||
136 | 138 | private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
137 | 139 | $bt=$this->getFieldButton("",$visibleHover); |
138 | 140 | $bt->asIcon($icon); |
139 | - if(isset($class)) |
|
140 | - $bt->addClass($class); |
|
141 | + if(isset($class)) { |
|
142 | + $bt->addClass($class); |
|
143 | + } |
|
141 | 144 | return $bt; |
142 | 145 | } |
143 | 146 |
@@ -54,8 +54,9 @@ discard block |
||
54 | 54 | $this->params[$key]=$params[$key]; |
55 | 55 | } |
56 | 56 | $this->jsUtils=$jsUtils; |
57 | - if(isset($params["ajaxTransition"])) |
|
58 | - $this->ajaxTransition=$this->setAjaxDataCall($params["ajaxTransition"]); |
|
57 | + if(isset($params["ajaxTransition"])) { |
|
58 | + $this->ajaxTransition=$this->setAjaxDataCall($params["ajaxTransition"]); |
|
59 | + } |
|
59 | 60 | } |
60 | 61 | |
61 | 62 | /** |
@@ -138,10 +139,12 @@ discard block |
||
138 | 139 | if (isset($param)) { |
139 | 140 | $param=Javascript::prep_value($param); |
140 | 141 | $str="$({$element}).{$jQueryCall}({$param});"; |
141 | - } else |
|
142 | - $str="$({$element}).{$jQueryCall}();"; |
|
143 | - if ($immediatly) |
|
144 | - $this->jquery_code_for_compile[]=$str; |
|
142 | + } else { |
|
143 | + $str="$({$element}).{$jQueryCall}();"; |
|
144 | + } |
|
145 | + if ($immediatly) { |
|
146 | + $this->jquery_code_for_compile[]=$str; |
|
147 | + } |
|
145 | 148 | return $str; |
146 | 149 | } |
147 | 150 | /** |
@@ -156,8 +159,9 @@ discard block |
||
156 | 159 | $to=Javascript::prep_element($to); |
157 | 160 | $element=Javascript::prep_element($element); |
158 | 161 | $str="$({$to}).{$jQueryCall}({$element});"; |
159 | - if ($immediatly) |
|
160 | - $this->jquery_code_for_compile[]=$str; |
|
162 | + if ($immediatly) { |
|
163 | + $this->jquery_code_for_compile[]=$str; |
|
164 | + } |
|
161 | 165 | return $str; |
162 | 166 | } |
163 | 167 | |
@@ -213,12 +217,14 @@ discard block |
||
213 | 217 | if ($stopPropagation===true) { |
214 | 218 | $js=Javascript::$stopPropagation.$js; |
215 | 219 | } |
216 | - if (array_search($event, $this->jquery_events)===false) |
|
217 | - $event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
218 | - else |
|
219 | - $event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
220 | - if($immediatly) |
|
221 | - $this->jquery_code_for_compile[]=$event; |
|
220 | + if (array_search($event, $this->jquery_events)===false) { |
|
221 | + $event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
222 | + } else { |
|
223 | + $event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
224 | + } |
|
225 | + if($immediatly) { |
|
226 | + $this->jquery_code_for_compile[]=$event; |
|
227 | + } |
|
222 | 228 | return $event; |
223 | 229 | } |
224 | 230 | |
@@ -303,7 +309,9 @@ discard block |
||
303 | 309 | } |
304 | 310 | |
305 | 311 | private function minify($input) { |
306 | - if(trim($input) === "") return $input; |
|
312 | + if(trim($input) === "") { |
|
313 | + return $input; |
|
314 | + } |
|
307 | 315 | return preg_replace( |
308 | 316 | array( |
309 | 317 | // Remove comment(s) |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | |
49 | 49 | public function setAttached($value=true){ |
50 | 50 | $form=$this->getForm(); |
51 | - if($value) |
|
52 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
51 | + if($value) { |
|
52 | + $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
53 | + } |
|
53 | 54 | return $form; |
54 | 55 | } |
55 | 56 | |
@@ -91,8 +92,9 @@ discard block |
||
91 | 92 | if(isset($url) && isset($responseElement)){ |
92 | 93 | $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true); |
93 | 94 | $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true]; |
94 | - if(\is_array($parameters)) |
|
95 | - $params=\array_merge($params,$parameters); |
|
95 | + if(\is_array($parameters)) { |
|
96 | + $params=\array_merge($params,$parameters); |
|
97 | + } |
|
96 | 98 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
97 | 99 | } |
98 | 100 | return $button; |
@@ -42,8 +42,9 @@ discard block |
||
42 | 42 | protected function _generateMainCheckbox(&$captions){ |
43 | 43 | $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
44 | 44 | $checkedMessageCall=""; |
45 | - if($this->_hasCheckedMessage) |
|
46 | - $checkedMessageCall="updateChecked();"; |
|
45 | + if($this->_hasCheckedMessage) { |
|
46 | + $checkedMessageCall="updateChecked();"; |
|
47 | + } |
|
47 | 48 | |
48 | 49 | $ck->setOnChecked($this->_setAllChecked("true").$checkedMessageCall); |
49 | 50 | $ck->setOnUnchecked($this->_setAllChecked("false").$checkedMessageCall); |
@@ -91,8 +92,9 @@ discard block |
||
91 | 92 | * @param callable $callback |
92 | 93 | */ |
93 | 94 | public function addCountCheckedInToolbar(array $checkedMessage=null,$callback=null){ |
94 | - if(isset($checkedMessage)) |
|
95 | - $this->_checkedMessage=$checkedMessage; |
|
95 | + if(isset($checkedMessage)) { |
|
96 | + $this->_checkedMessage=$checkedMessage; |
|
97 | + } |
|
96 | 98 | $checkedMessage=$this->getCheckedMessage(); |
97 | 99 | $this->_hasCheckboxes=true; |
98 | 100 | $this->_hasCheckedMessage=true; |
@@ -46,10 +46,12 @@ discard block |
||
46 | 46 | $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
47 | 47 | $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
48 | 48 | } |
49 | - if(\is_array($this->_deleteBehavior)) |
|
50 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
51 | - if(\is_array($this->_editBehavior)) |
|
52 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
49 | + if(\is_array($this->_deleteBehavior)) { |
|
50 | + $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
51 | + } |
|
52 | + if(\is_array($this->_editBehavior)) { |
|
53 | + $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
54 | + } |
|
53 | 55 | return parent::run($js); |
54 | 56 | } |
55 | 57 | |
@@ -84,12 +86,14 @@ discard block |
||
84 | 86 | |
85 | 87 | $table->setRowCount(0, \sizeof($captions)); |
86 | 88 | $table->setHeaderValues($captions); |
87 | - if(isset($this->_compileParts)) |
|
88 | - $table->setCompileParts($this->_compileParts); |
|
89 | + if(isset($this->_compileParts)) { |
|
90 | + $table->setCompileParts($this->_compileParts); |
|
91 | + } |
|
89 | 92 | |
90 | 93 | if(isset($this->_searchField) && isset($js)){ |
91 | - if(isset($this->_urls["refresh"])) |
|
92 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
94 | + if(isset($this->_urls["refresh"])) { |
|
95 | + $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
96 | + } |
|
93 | 97 | } |
94 | 98 | |
95 | 99 | $this->_generateContent($table); |
@@ -144,8 +148,9 @@ discard block |
||
144 | 148 | $menu->floatRight(); |
145 | 149 | $menu->setActiveItem($this->_pagination->getPage()-1); |
146 | 150 | $footer->setValues($menu); |
147 | - if(isset($this->_urls["refresh"])) |
|
148 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
151 | + if(isset($this->_urls["refresh"])) { |
|
152 | + $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
153 | + } |
|
149 | 154 | } |
150 | 155 | |
151 | 156 | protected function _getFieldName($index){ |
@@ -188,7 +193,7 @@ discard block |
||
188 | 193 | $hasPart=$table->hasPart($part); |
189 | 194 | if($hasPart){ |
190 | 195 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
191 | - }else{ |
|
196 | + } else{ |
|
192 | 197 | $row=$table->getPart($part)->getRow(0); |
193 | 198 | } |
194 | 199 | $row->mergeCol(); |
@@ -213,7 +218,7 @@ discard block |
||
213 | 218 | $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
214 | 219 | $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
215 | 220 | $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
216 | - }else{ |
|
221 | + } else{ |
|
217 | 222 | $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
218 | 223 | } |
219 | 224 | return $this; |
@@ -262,8 +267,9 @@ discard block |
||
262 | 267 | |
263 | 268 | protected function getTargetSelector() { |
264 | 269 | $result=$this->_targetSelector; |
265 | - if(!isset($result)) |
|
266 | - $result="#".$this->identifier; |
|
270 | + if(!isset($result)) { |
|
271 | + $result="#".$this->identifier; |
|
272 | + } |
|
267 | 273 | return $result; |
268 | 274 | } |
269 | 275 |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | } |
49 | 49 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
50 | 50 | $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
51 | - if ($immediatly) |
|
52 | - $this->jquery_code_for_compile[]=$retour; |
|
51 | + if ($immediatly) { |
|
52 | + $this->jquery_code_for_compile[]=$retour; |
|
53 | + } |
|
53 | 54 | return $retour; |
54 | 55 | } |
55 | 56 | |
@@ -67,15 +68,17 @@ discard block |
||
67 | 68 | $url=$this->_correctAjaxUrl($url); |
68 | 69 | $retour="url='".$url."';"; |
69 | 70 | $slash="/"; |
70 | - if(JString::endswith($url, "/")===true) |
|
71 | - $slash=""; |
|
71 | + if(JString::endswith($url, "/")===true) { |
|
72 | + $slash=""; |
|
73 | + } |
|
72 | 74 | if(JString::isNotNull($attr)){ |
73 | - if ($attr==="value") |
|
74 | - $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
75 | - elseif ($attr==="html") |
|
76 | - $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
77 | - elseif($attr!=null && $attr!=="") |
|
78 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
75 | + if ($attr==="value") { |
|
76 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
77 | + } elseif ($attr==="html") { |
|
78 | + $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
79 | + } elseif($attr!=null && $attr!=="") { |
|
80 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
81 | + } |
|
79 | 82 | } |
80 | 83 | return $retour; |
81 | 84 | } |
@@ -85,13 +88,14 @@ discard block |
||
85 | 88 | if ($responseElement!=="") { |
86 | 89 | if(isset($ajaxTransition)){ |
87 | 90 | $call=$this->setAjaxDataCall($ajaxTransition); |
88 | - }elseif(isset($this->ajaxTransition)){ |
|
91 | + } elseif(isset($this->ajaxTransition)){ |
|
89 | 92 | $call=$this->ajaxTransition; |
90 | 93 | } |
91 | - if(\is_callable($call)) |
|
92 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
93 | - else |
|
94 | - $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
|
94 | + if(\is_callable($call)) { |
|
95 | + $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
96 | + } else { |
|
97 | + $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
|
98 | + } |
|
95 | 99 | } |
96 | 100 | $retour.="\t".$jsCallback."\n"; |
97 | 101 | return $retour; |
@@ -105,8 +109,9 @@ discard block |
||
105 | 109 | } |
106 | 110 | |
107 | 111 | protected function _correctAjaxUrl($url) { |
108 | - if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
109 | - $url=substr($url, 0, strlen($url)-1); |
|
112 | + if ($url!=="/" && JString::endsWith($url, "/")===true) { |
|
113 | + $url=substr($url, 0, strlen($url)-1); |
|
114 | + } |
|
110 | 115 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
111 | 116 | $url=$this->jsUtils->getUrl($url); |
112 | 117 | } |
@@ -130,8 +135,9 @@ discard block |
||
130 | 135 | $retour.="\t".$jsCallback."\n". |
131 | 136 | "\t$(document).trigger('jsonReady',[data]);\n". |
132 | 137 | "});\n"; |
133 | - if ($immediatly) |
|
134 | - $this->jquery_code_for_compile[]=$retour; |
|
138 | + if ($immediatly) { |
|
139 | + $this->jquery_code_for_compile[]=$retour; |
|
140 | + } |
|
135 | 141 | return $retour; |
136 | 142 | } |
137 | 143 | |
@@ -170,7 +176,7 @@ discard block |
||
170 | 176 | if($context===null){ |
171 | 177 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
172 | 178 | $newElm = "$('#'+newId)"; |
173 | - }else{ |
|
179 | + } else{ |
|
174 | 180 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
175 | 181 | $newElm = $context.".find('#'+newId)"; |
176 | 182 | } |
@@ -180,8 +186,9 @@ discard block |
||
180 | 186 | $retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('[['+key+']]')>-1){\n"."\t\t\t\tcontent=$(html.split('[['+key+']]').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n"; |
181 | 187 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
182 | 188 | $retour.="\t".$jsCallback."\n"."});\n"; |
183 | - if ($immediatly) |
|
184 | - $this->jquery_code_for_compile[]=$retour; |
|
189 | + if ($immediatly) { |
|
190 | + $this->jquery_code_for_compile[]=$retour; |
|
191 | + } |
|
185 | 192 | return $retour; |
186 | 193 | } |
187 | 194 | /** |
@@ -222,8 +229,9 @@ discard block |
||
222 | 229 | }});\n"; |
223 | 230 | $retour.="$('#".$form."').submit();\n"; |
224 | 231 | } |
225 | - if ($immediatly) |
|
226 | - $this->jquery_code_for_compile[]=$retour; |
|
232 | + if ($immediatly) { |
|
233 | + $this->jquery_code_for_compile[]=$retour; |
|
234 | + } |
|
227 | 235 | return $retour; |
228 | 236 | } |
229 | 237 |
@@ -47,15 +47,17 @@ |
||
47 | 47 | |
48 | 48 | |
49 | 49 | public function addSeparatorAfter($fieldNum){ |
50 | - if(\array_search($fieldNum, $this->separators)===false) |
|
51 | - $this->separators[]=$fieldNum; |
|
50 | + if(\array_search($fieldNum, $this->separators)===false) { |
|
51 | + $this->separators[]=$fieldNum; |
|
52 | + } |
|
52 | 53 | return $this; |
53 | 54 | } |
54 | 55 | |
55 | 56 | public function addHeaderDividerBefore($fieldNum,$header){ |
56 | 57 | $this->headers[$fieldNum]=$header; |
57 | - if($fieldNum>0) |
|
58 | - $this->addSeparatorAfter($fieldNum-1); |
|
58 | + if($fieldNum>0) { |
|
59 | + $this->addSeparatorAfter($fieldNum-1); |
|
60 | + } |
|
59 | 61 | return $this; |
60 | 62 | } |
61 | 63 |