@@ -2,20 +2,20 @@ discard block |
||
2 | 2 | namespace Ajax\common\html\traits; |
3 | 3 | use Ajax\JsUtils; |
4 | 4 | |
5 | -trait NavElementTrait{ |
|
5 | +trait NavElementTrait { |
|
6 | 6 | /** |
7 | 7 | * Generate the jquery script to set the elements to the HtmlNavElement |
8 | 8 | * @param JsUtils $jsUtils |
9 | 9 | */ |
10 | - public function jsSetContent(JsUtils $jsUtils){ |
|
11 | - $jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true); |
|
10 | + public function jsSetContent(JsUtils $jsUtils) { |
|
11 | + $jsUtils->html("#".$this->identifier, str_replace("\"", "'", $this->contentAsString()), true); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | public function getRoot() { |
15 | 15 | return $this->root; |
16 | 16 | } |
17 | 17 | public function setRoot($root) { |
18 | - $this->root = $root; |
|
18 | + $this->root=$root; |
|
19 | 19 | return $this; |
20 | 20 | } |
21 | 21 | public function getAttr() { |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | * @return HtmlNavElement |
29 | 29 | */ |
30 | 30 | public function setAttr($attr) { |
31 | - $this->attr = $attr; |
|
31 | + $this->attr=$attr; |
|
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function __call($method, $args) { |
36 | - if(isset($this->$method) && is_callable($this->$method)) { |
|
36 | + if (isset($this->$method) && is_callable($this->$method)) { |
|
37 | 37 | return call_user_func_array( |
38 | 38 | $this->$method, |
39 | 39 | $args |
@@ -41,5 +41,5 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | - abstract public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0); |
|
44 | + abstract public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0); |
|
45 | 45 | } |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | * @author jc |
10 | 10 | * @property BaseWidget $_self |
11 | 11 | */ |
12 | -trait BaseHtmlPropertiesTrait{ |
|
12 | +trait BaseHtmlPropertiesTrait { |
|
13 | 13 | |
14 | - protected $properties=array (); |
|
14 | + protected $properties=array(); |
|
15 | 15 | abstract protected function ctrl($name, $value, $typeCtrl); |
16 | 16 | abstract protected function removeOldValues(&$oldValue, $allValues); |
17 | - abstract protected function _getElementBy($callback,$elements); |
|
17 | + abstract protected function _getElementBy($callback, $elements); |
|
18 | 18 | public function getProperties() { |
19 | 19 | return $this->_self->properties; |
20 | 20 | } |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | |
41 | 41 | public function addToProperty($name, $value, $separator=" ") { |
42 | 42 | if (\is_array($value)) { |
43 | - foreach ( $value as $v ) { |
|
43 | + foreach ($value as $v) { |
|
44 | 44 | $this->_self->addToProperty($name, $v, $separator); |
45 | 45 | } |
46 | - } else if ($value !== "" && $this->_self->propertyContains($name, $value) === false) { |
|
46 | + } else if ($value!=="" && $this->_self->propertyContains($name, $value)===false) { |
|
47 | 47 | $v=@$this->_self->properties[$name]; |
48 | - if (isset($v) && $v !== "") |
|
49 | - $v=$v . $separator . $value; |
|
48 | + if (isset($v) && $v!=="") |
|
49 | + $v=$v.$separator.$value; |
|
50 | 50 | else |
51 | 51 | $v=$value; |
52 | 52 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | public function addToPropertyCtrlCheck($name, $value, $typeCtrl) { |
87 | - if ($this->_self->ctrl($name, $value, $typeCtrl) === true) { |
|
87 | + if ($this->_self->ctrl($name, $value, $typeCtrl)===true) { |
|
88 | 88 | return $this->_self->addToProperty($name, $value); |
89 | 89 | } |
90 | 90 | return $this; |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
108 | - if ($this->_self->ctrl($name, $value, $typeCtrl) === true) |
|
108 | + if ($this->_self->ctrl($name, $value, $typeCtrl)===true) |
|
109 | 109 | return $this->_self->setProperty($name, $value); |
110 | 110 | return $this; |
111 | 111 | } |
112 | 112 | |
113 | - protected function getElementByPropertyValue($propertyName,$value, $elements) { |
|
114 | - return $this->_self->_getElementBy(function($element) use ($propertyName,$value){return $element->propertyContains($propertyName, $value) === true;}, $elements); |
|
113 | + protected function getElementByPropertyValue($propertyName, $value, $elements) { |
|
114 | + return $this->_self->_getElementBy(function($element) use ($propertyName, $value){return $element->propertyContains($propertyName, $value)===true; }, $elements); |
|
115 | 115 | } |
116 | 116 | } |
@@ -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 |
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,66 +136,66 @@ 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){ |
|
165 | + public function addField($field) { |
|
166 | 166 | $this->_instanceViewer->addField($field); |
167 | 167 | return $this; |
168 | 168 | } |
169 | 169 | |
170 | - public function addMessage($attributes=NULL,$fieldName="message"){ |
|
170 | + public function addMessage($attributes=NULL, $fieldName="message") { |
|
171 | 171 | $this->_instanceViewer->addField($fieldName); |
172 | 172 | $count=$this->_instanceViewer->visiblePropertiesCount(); |
173 | - return $this->fieldAsMessage($count-1,$attributes); |
|
173 | + return $this->fieldAsMessage($count-1, $attributes); |
|
174 | 174 | } |
175 | 175 | |
176 | - public function addErrorMessage(){ |
|
177 | - return $this->addMessage(["error"=>true],"message"); |
|
176 | + public function addErrorMessage() { |
|
177 | + return $this->addMessage(["error"=>true], "message"); |
|
178 | 178 | } |
179 | 179 | |
180 | - public function insertField($index,$field){ |
|
180 | + public function insertField($index, $field) { |
|
181 | 181 | $index=$this->_getIndex($index); |
182 | 182 | $this->_instanceViewer->insertField($index, $field); |
183 | 183 | return $this; |
184 | 184 | } |
185 | 185 | |
186 | - public function insertInField($index,$field){ |
|
186 | + public function insertInField($index, $field) { |
|
187 | 187 | $index=$this->_getIndex($index); |
188 | 188 | $this->_instanceViewer->insertInField($index, $field); |
189 | 189 | return $this; |
190 | 190 | } |
191 | 191 | |
192 | - public function setValueFunction($index,$callback){ |
|
192 | + public function setValueFunction($index, $callback) { |
|
193 | 193 | $index=$this->_getIndex($index); |
194 | 194 | $this->_instanceViewer->setValueFunction($index, $callback); |
195 | 195 | return $this; |
196 | 196 | } |
197 | 197 | |
198 | - public function setIdentifierFunction($callback){ |
|
198 | + public function setIdentifierFunction($callback) { |
|
199 | 199 | $this->_instanceViewer->setIdentifierFunction($callback); |
200 | 200 | return $this; |
201 | 201 | } |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | /** |
204 | 204 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
205 | 205 | */ |
206 | - public function getToolbar(){ |
|
207 | - if(isset($this->_toolbar)===false){ |
|
206 | + public function getToolbar() { |
|
207 | + if (isset($this->_toolbar)===false) { |
|
208 | 208 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
209 | 209 | } |
210 | 210 | return $this->_toolbar; |
@@ -216,15 +216,15 @@ discard block |
||
216 | 216 | * @param callable $callback function to call on $element |
217 | 217 | * @return \Ajax\common\html\HtmlDoubleElement |
218 | 218 | */ |
219 | - public function addInToolbar($element,$callback=NULL){ |
|
219 | + public function addInToolbar($element, $callback=NULL) { |
|
220 | 220 | $tb=$this->getToolbar(); |
221 | - if($element instanceof BaseWidget){ |
|
222 | - if($element->getIdentifier()===""){ |
|
221 | + if ($element instanceof BaseWidget) { |
|
222 | + if ($element->getIdentifier()==="") { |
|
223 | 223 | $element->setIdentifier("tb-item-".$this->identifier."-".$tb->count()); |
224 | 224 | } |
225 | 225 | } |
226 | - if(isset($callback)){ |
|
227 | - if(\is_callable($callback)){ |
|
226 | + if (isset($callback)) { |
|
227 | + if (\is_callable($callback)) { |
|
228 | 228 | $callback($element); |
229 | 229 | } |
230 | 230 | } |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | * @param callable $callback function($element) |
238 | 238 | * @return \Ajax\common\html\HtmlDoubleElement |
239 | 239 | */ |
240 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
241 | - $result=$this->addInToolbar($caption,$callback); |
|
242 | - if(isset($icon)) |
|
240 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
241 | + $result=$this->addInToolbar($caption, $callback); |
|
242 | + if (isset($icon)) |
|
243 | 243 | $result->addIcon($icon); |
244 | 244 | return $result; |
245 | 245 | } |
@@ -249,14 +249,14 @@ discard block |
||
249 | 249 | * @param callable $callback function($element) |
250 | 250 | * @return \Ajax\common\Widget |
251 | 251 | */ |
252 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
253 | - if(JArray::isAssociative($items)){ |
|
254 | - foreach ($items as $icon=>$item){ |
|
255 | - $this->addItemInToolbar($item,$icon,$callback); |
|
252 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
253 | + if (JArray::isAssociative($items)) { |
|
254 | + foreach ($items as $icon=>$item) { |
|
255 | + $this->addItemInToolbar($item, $icon, $callback); |
|
256 | 256 | } |
257 | - }else{ |
|
258 | - foreach ($items as $item){ |
|
259 | - $this->addItemInToolbar($item,null,$callback); |
|
257 | + } else { |
|
258 | + foreach ($items as $item) { |
|
259 | + $this->addItemInToolbar($item, null, $callback); |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | return $this; |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | * @param callable $callback function($element) |
269 | 269 | * @return \Ajax\common\html\HtmlDoubleElement |
270 | 270 | */ |
271 | - public function addDropdownInToolbar($value,$items,$callback=NULL){ |
|
271 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
272 | 272 | $dd=$value; |
273 | 273 | if (\is_string($value)) { |
274 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
274 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
275 | 275 | } |
276 | - return $this->addInToolbar($dd,$callback); |
|
276 | + return $this->addInToolbar($dd, $callback); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | * @param callable $callback function($element) |
283 | 283 | * @return \Ajax\common\html\HtmlDoubleElement |
284 | 284 | */ |
285 | - public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){ |
|
286 | - $bt=new HtmlButton("bt-".$caption,$caption,$cssStyle); |
|
287 | - return $this->addInToolbar($bt,$callback); |
|
285 | + public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) { |
|
286 | + $bt=new HtmlButton("bt-".$caption, $caption, $cssStyle); |
|
287 | + return $this->addInToolbar($bt, $callback); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | * @param callable $callback function($element) |
294 | 294 | * @return \Ajax\common\html\HtmlDoubleElement |
295 | 295 | */ |
296 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
297 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
298 | - return $this->addInToolbar($bts,$callback); |
|
296 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
297 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
298 | + return $this->addInToolbar($bts, $callback); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -305,15 +305,15 @@ discard block |
||
305 | 305 | * @param boolean $labeled |
306 | 306 | * @return \Ajax\common\html\HtmlDoubleElement |
307 | 307 | */ |
308 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
309 | - $bt=new HtmlButton("",$caption); |
|
310 | - $bt->addIcon($icon,$before,$labeled); |
|
308 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
309 | + $bt=new HtmlButton("", $caption); |
|
310 | + $bt->addIcon($icon, $before, $labeled); |
|
311 | 311 | return $this->addInToolbar($bt); |
312 | 312 | } |
313 | 313 | |
314 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
315 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
316 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters); |
|
314 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
315 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
316 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters); |
|
317 | 317 | return $this->addInToolbar($button); |
318 | 318 | } |
319 | 319 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model |
344 | 344 | * @return \Ajax\common\Widget |
345 | 345 | */ |
346 | - public function setDefaultValueFunction($defaultValueFunction){ |
|
346 | + public function setDefaultValueFunction($defaultValueFunction) { |
|
347 | 347 | $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction); |
348 | 348 | return $this; |
349 | 349 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * @param string|boolean $disable |
353 | 353 | * @return string |
354 | 354 | */ |
355 | - public function jsDisabled($disable=true){ |
|
355 | + public function jsDisabled($disable=true) { |
|
356 | 356 | return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
357 | 357 | } |
358 | 358 | |
@@ -361,12 +361,12 @@ discard block |
||
361 | 361 | * @param callable $callback function($element) |
362 | 362 | * @return \Ajax\common\html\HtmlDoubleElement |
363 | 363 | */ |
364 | - public function addEditButtonInToolbar($caption,$callback=NULL){ |
|
365 | - $bt=new HtmlButton($this->identifier."-editBtn",$caption); |
|
364 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
365 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
366 | 366 | $bt->setToggle(); |
367 | 367 | $bt->setActive($this->_edition); |
368 | 368 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
369 | - return $this->addInToolbar($bt,$callback); |
|
369 | + return $this->addInToolbar($bt, $callback); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | public function setToolbar(HtmlMenu $_toolbar) { |
@@ -380,35 +380,35 @@ discard block |
||
380 | 380 | } |
381 | 381 | |
382 | 382 | public function getForm() { |
383 | - if(!isset($this->_form)){ |
|
383 | + if (!isset($this->_form)) { |
|
384 | 384 | $this->_form=new HtmlForm("frm-".$this->identifier); |
385 | 385 | $this->setEdition(true); |
386 | 386 | } |
387 | 387 | return $this->_form; |
388 | 388 | } |
389 | 389 | |
390 | - public function run(JsUtils $js){ |
|
390 | + public function run(JsUtils $js) { |
|
391 | 391 | $result=parent::run($js); |
392 | - if(isset($this->_form)){ |
|
392 | + if (isset($this->_form)) { |
|
393 | 393 | $result=$this->runForm($js); |
394 | 394 | } |
395 | 395 | return $result; |
396 | 396 | } |
397 | 397 | |
398 | - protected function runForm(JsUtils $js){ |
|
398 | + protected function runForm(JsUtils $js) { |
|
399 | 399 | $fields=$this->getContentInstances(HtmlFormField::class); |
400 | - foreach ($fields as $field){ |
|
400 | + foreach ($fields as $field) { |
|
401 | 401 | $this->_form->addField($field); |
402 | 402 | } |
403 | 403 | return $this->_form->run($js); |
404 | 404 | } |
405 | 405 | |
406 | - protected function _compileForm(){ |
|
407 | - if(isset($this->_form)){ |
|
406 | + protected function _compileForm() { |
|
407 | + if (isset($this->_form)) { |
|
408 | 408 | $noValidate=""; |
409 | - if(\sizeof($this->_form->getValidationParams())>0) |
|
409 | + if (\sizeof($this->_form->getValidationParams())>0) |
|
410 | 410 | $noValidate="novalidate"; |
411 | - $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>"); |
|
411 | + $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>"); |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
@@ -417,32 +417,32 @@ discard block |
||
417 | 417 | return $this; |
418 | 418 | } |
419 | 419 | |
420 | - public function moveFieldTo($from,$to){ |
|
420 | + public function moveFieldTo($from, $to) { |
|
421 | 421 | return $this->_instanceViewer->moveFieldTo($from, $to); |
422 | 422 | } |
423 | 423 | |
424 | - public function swapFields($index1,$index2){ |
|
424 | + public function swapFields($index1, $index2) { |
|
425 | 425 | $index1=$this->_getIndex($index1); |
426 | 426 | $index2=$this->_getIndex($index2); |
427 | 427 | return $this->_instanceViewer->swapFields($index1, $index2); |
428 | 428 | } |
429 | 429 | |
430 | - public function removeField($index){ |
|
430 | + public function removeField($index) { |
|
431 | 431 | $index=$this->_getIndex($index); |
432 | 432 | $this->_instanceViewer->removeField($index); |
433 | 433 | return $this; |
434 | 434 | } |
435 | 435 | |
436 | - public function asModal($header=null){ |
|
437 | - $modal=new HtmlModal("modal-".$this->identifier,$header); |
|
436 | + public function asModal($header=null) { |
|
437 | + $modal=new HtmlModal("modal-".$this->identifier, $header); |
|
438 | 438 | $modal->setContent($this); |
439 | - if(isset($this->_form)){ |
|
439 | + if (isset($this->_form)) { |
|
440 | 440 | $this->_form->onSuccess($modal->jsHide()); |
441 | 441 | } |
442 | 442 | return $modal; |
443 | 443 | } |
444 | 444 | |
445 | 445 | public function addToProperty($name, $value, $separator=" ") { |
446 | - return $this->getHtmlComponent()->addToProperty($name,$value,$separator); |
|
446 | + return $this->getHtmlComponent()->addToProperty($name, $value, $separator); |
|
447 | 447 | } |
448 | 448 | } |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | * @version 1.001 |
11 | 11 | */ |
12 | 12 | abstract class BaseComponent { |
13 | - public $jquery_code_for_compile=array (); |
|
14 | - protected $params=array (); |
|
13 | + public $jquery_code_for_compile=array(); |
|
14 | + protected $params=array(); |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | public function setParams($params) { |
71 | - foreach ( $params as $k => $v ) { |
|
71 | + foreach ($params as $k => $v) { |
|
72 | 72 | $method="set".ucfirst($k); |
73 | 73 | if (method_exists($this, $method)) |
74 | 74 | $this->$method($v); |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | return $this; |
82 | 82 | } |
83 | 83 | |
84 | - public function addParams($params){ |
|
85 | - foreach ($params as $k=>$v){ |
|
84 | + public function addParams($params) { |
|
85 | + foreach ($params as $k=>$v) { |
|
86 | 86 | $this->setParam($k, $v); |
87 | 87 | } |
88 | 88 | return $this; |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | |
91 | 91 | abstract public function getScript(); |
92 | 92 | |
93 | - public function setDebug($value){ |
|
93 | + public function setDebug($value) { |
|
94 | 94 | return $this->setParam("debug", $value); |
95 | 95 | } |
96 | 96 | |
97 | - public function setVerbose($value){ |
|
97 | + public function setVerbose($value) { |
|
98 | 98 | return $this->setParam("verbose", $value); |
99 | 99 | } |
100 | 100 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @return string |
18 | 18 | */ |
19 | 19 | public function addClass($element='this', $class='', $immediatly=false) { |
20 | - return $this->js->_genericCallValue('addClass',$element, $class, $immediatly); |
|
20 | + return $this->js->_genericCallValue('addClass', $element, $class, $immediatly); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | * @param boolean $immediatly defers the execution if set to false |
28 | 28 | * @return string |
29 | 29 | */ |
30 | - public function after($to, $element, $immediatly=false){ |
|
31 | - return $this->js->_genericCallElement('after',$to, $element, $immediatly); |
|
30 | + public function after($to, $element, $immediatly=false) { |
|
31 | + return $this->js->_genericCallElement('after', $to, $element, $immediatly); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * @param boolean $immediatly defers the execution if set to false |
39 | 39 | * @return string |
40 | 40 | */ |
41 | - public function before($to, $element, $immediatly=false){ |
|
42 | - return $this->js->_genericCallElement('before',$to, $element, $immediatly); |
|
41 | + public function before($to, $element, $immediatly=false) { |
|
42 | + return $this->js->_genericCallElement('before', $to, $element, $immediatly); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | * @param string $value |
60 | 60 | * @param boolean $immediatly defers the execution if set to false |
61 | 61 | */ |
62 | - public function val($element='this',$value='',$immediatly=false){ |
|
63 | - return $this->js->_genericCallValue('val',$element,$value,$immediatly); |
|
62 | + public function val($element='this', $value='', $immediatly=false) { |
|
63 | + return $this->js->_genericCallValue('val', $element, $value, $immediatly); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param boolean $immediatly defers the execution if set to false |
71 | 71 | */ |
72 | 72 | public function html($element='this', $value='', $immediatly=false) { |
73 | - return $this->js->_genericCallValue('html',$element, $value, $immediatly); |
|
73 | + return $this->js->_genericCallValue('html', $element, $value, $immediatly); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return string |
96 | 96 | */ |
97 | 97 | public function append($to, $element, $immediatly=false) { |
98 | - return $this->js->_genericCallElement('append',$to, $element, $immediatly); |
|
98 | + return $this->js->_genericCallElement('append', $to, $element, $immediatly); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @return string |
107 | 107 | */ |
108 | 108 | public function prepend($to, $element, $immediatly=false) { |
109 | - return $this->js->_genericCallElement('prepend',$to, $element, $immediatly); |
|
109 | + return $this->js->_genericCallElement('prepend', $to, $element, $immediatly); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return string |
158 | 158 | */ |
159 | 159 | public function removeClass($element='this', $class='', $immediatly=false) { |
160 | - return $this->js->_genericCall('removeClass',$element, $class, $immediatly); |
|
160 | + return $this->js->_genericCall('removeClass', $element, $class, $immediatly); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @return string |
219 | 219 | */ |
220 | 220 | public function toggleClass($element='this', $class='', $immediatly=false) { |
221 | - return $this->js->_genericCallValue('toggleClass',$element, $class, $immediatly); |
|
221 | + return $this->js->_genericCallValue('toggleClass', $element, $class, $immediatly); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | $preventDefault=false; |
295 | 295 | $immediatly=true; |
296 | 296 | extract($parameters); |
297 | - return $this->js->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback,$immediatly); |
|
297 | + return $this->js->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback, $immediatly); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | $preventDefault=false; |
322 | 322 | $immediatly=true; |
323 | 323 | extract($parameters); |
324 | - $script=$this->js->_execOn($element, $event, $js, $preventDefault, $stopPropagation,$immediatly); |
|
324 | + $script=$this->js->_execOn($element, $event, $js, $preventDefault, $stopPropagation, $immediatly); |
|
325 | 325 | return $script; |
326 | 326 | } |
327 | 327 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | protected $ajaxTransition; |
18 | 18 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
19 | 19 | |
20 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
20 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
21 | 21 | protected function addLoading(&$retour, $responseElement) { |
22 | 22 | $loading_notifier='<div class="ajax-loader">'; |
23 | 23 | if ($this->ajaxLoader=='') { |
@@ -30,66 +30,66 @@ discard block |
||
30 | 30 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
31 | 31 | } |
32 | 32 | |
33 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
34 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
33 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
34 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
35 | 35 | } |
36 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
37 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
36 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
37 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
38 | 38 | } |
39 | 39 | |
40 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
41 | - if(JString::isNull($params)){$params="{}";} |
|
40 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
41 | + if (JString::isNull($params)) {$params="{}"; } |
|
42 | 42 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
43 | 43 | $retour=$this->_getAjaxUrl($url, $attr); |
44 | 44 | $responseElement=$this->_getResponseElement($responseElement); |
45 | 45 | $retour.="var self=this;\n"; |
46 | - if($hasLoader===true){ |
|
46 | + if ($hasLoader===true) { |
|
47 | 47 | $this->addLoading($retour, $responseElement); |
48 | 48 | } |
49 | 49 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
50 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
50 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
51 | 51 | if ($immediatly) |
52 | 52 | $this->jquery_code_for_compile[]=$retour; |
53 | 53 | return $retour; |
54 | 54 | } |
55 | 55 | |
56 | - protected function setAjaxDataCall($params){ |
|
56 | + protected function setAjaxDataCall($params) { |
|
57 | 57 | $result=null; |
58 | - if(!\is_callable($params)){ |
|
59 | - $result=function ($responseElement,$jqueryDone="html") use($params){ |
|
60 | - return AjaxTransition::{$params}($responseElement,$jqueryDone); |
|
58 | + if (!\is_callable($params)) { |
|
59 | + $result=function($responseElement, $jqueryDone="html") use($params){ |
|
60 | + return AjaxTransition::{$params}($responseElement, $jqueryDone); |
|
61 | 61 | }; |
62 | 62 | } |
63 | 63 | return $result; |
64 | 64 | } |
65 | 65 | |
66 | - protected function _getAjaxUrl($url,$attr){ |
|
66 | + protected function _getAjaxUrl($url, $attr) { |
|
67 | 67 | $url=$this->_correctAjaxUrl($url); |
68 | 68 | $retour="url='".$url."';"; |
69 | 69 | $slash="/"; |
70 | - if(JString::endswith($url, "/")===true) |
|
70 | + if (JString::endswith($url, "/")===true) |
|
71 | 71 | $slash=""; |
72 | - if(JString::isNotNull($attr)){ |
|
72 | + if (JString::isNotNull($attr)) { |
|
73 | 73 | if ($attr==="value") |
74 | 74 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
75 | 75 | elseif ($attr==="html") |
76 | 76 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
77 | - elseif($attr!==null && $attr!=="") |
|
77 | + elseif ($attr!==null && $attr!=="") |
|
78 | 78 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
79 | 79 | } |
80 | 80 | return $retour; |
81 | 81 | } |
82 | 82 | |
83 | - protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){ |
|
84 | - $retour="";$call=null; |
|
83 | + protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) { |
|
84 | + $retour=""; $call=null; |
|
85 | 85 | if ($responseElement!=="") { |
86 | - if(isset($ajaxTransition)){ |
|
86 | + if (isset($ajaxTransition)) { |
|
87 | 87 | $call=$this->setAjaxDataCall($ajaxTransition); |
88 | - }elseif(isset($this->ajaxTransition)){ |
|
88 | + }elseif (isset($this->ajaxTransition)) { |
|
89 | 89 | $call=$this->ajaxTransition; |
90 | 90 | } |
91 | - if(\is_callable($call)) |
|
92 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
91 | + if (\is_callable($call)) |
|
92 | + $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
93 | 93 | else |
94 | 94 | $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
95 | 95 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | return $retour; |
98 | 98 | } |
99 | 99 | |
100 | - protected function _getResponseElement($responseElement){ |
|
100 | + protected function _getResponseElement($responseElement) { |
|
101 | 101 | if ($responseElement!=="") { |
102 | 102 | $responseElement=Javascript::prep_value($responseElement); |
103 | 103 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | protected function _correctAjaxUrl($url) { |
108 | 108 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
109 | 109 | $url=substr($url, 0, strlen($url)-1); |
110 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
110 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
111 | 111 | $url=$this->jsUtils->getUrl($url); |
112 | 112 | } |
113 | 113 | return $url; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @param string $jsCallback javascript code to execute after the request |
122 | 122 | * @param boolean $immediatly |
123 | 123 | */ |
124 | - public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
124 | + public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
125 | 125 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
126 | 126 | $retour=$this->_getAjaxUrl($url, $attr); |
127 | 127 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param string $url the request address |
143 | 143 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
144 | 144 | */ |
145 | - public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
145 | + public function _jsonOn($event, $element, $url, $parameters=array()) { |
|
146 | 146 | $preventDefault=true; |
147 | 147 | $stopPropagation=true; |
148 | 148 | $jsCallback=null; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $params="{}"; |
153 | 153 | $immediatly=true; |
154 | 154 | extract($parameters); |
155 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
155 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -165,22 +165,22 @@ discard block |
||
165 | 165 | * @param string $rowClass the css class for the new element |
166 | 166 | * @param boolean $immediatly |
167 | 167 | */ |
168 | - public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$rowClass="_json",$immediatly=false) { |
|
168 | + public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $rowClass="_json", $immediatly=false) { |
|
169 | 169 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
170 | 170 | $retour=$this->_getAjaxUrl($url, $attr); |
171 | - if($context===null){ |
|
171 | + if ($context===null) { |
|
172 | 172 | $parent="$('".$maskSelector."').parent()"; |
173 | - $newElm = "$('#'+newId)"; |
|
174 | - }else{ |
|
173 | + $newElm="$('#'+newId)"; |
|
174 | + } else { |
|
175 | 175 | $parent=$context; |
176 | - $newElm = $context.".find('#'+newId)"; |
|
176 | + $newElm=$context.".find('#'+newId)"; |
|
177 | 177 | } |
178 | 178 | $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
179 | 179 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
180 | 180 | $retour.=$parent.".find('._json').remove();"; |
181 | 181 | $retour.="\tdata=$.parseJSON(data);$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone(); |
182 | 182 | newElm.attr('id',newId);\n;newElm.addClass('{$rowClass}').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n"; |
183 | - $retour.= $appendTo; |
|
183 | + $retour.=$appendTo; |
|
184 | 184 | $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"; |
185 | 185 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
186 | 186 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -195,30 +195,30 @@ discard block |
||
195 | 195 | * @param string $url the request address |
196 | 196 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null) |
197 | 197 | */ |
198 | - public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
198 | + public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
199 | 199 | $preventDefault=true; |
200 | 200 | $stopPropagation=true; |
201 | 201 | $jsCallback=null; |
202 | 202 | $attr="id"; |
203 | 203 | $method="get"; |
204 | - $context = null; |
|
204 | + $context=null; |
|
205 | 205 | $params="{}"; |
206 | 206 | $immediatly=true; |
207 | 207 | extract($parameters); |
208 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
208 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
209 | 209 | } |
210 | 210 | |
211 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
211 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
212 | 212 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
213 | 213 | $retour=$this->_getAjaxUrl($url, $attr); |
214 | 214 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
215 | 215 | $responseElement=$this->_getResponseElement($responseElement); |
216 | 216 | $retour.="var self=this;\n"; |
217 | - if($hasLoader===true){ |
|
217 | + if ($hasLoader===true) { |
|
218 | 218 | $this->addLoading($retour, $responseElement); |
219 | 219 | } |
220 | 220 | $retour.="$.post(url,params).done(function( data ) {\n"; |
221 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
221 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
222 | 222 | |
223 | 223 | if ($validation) { |
224 | 224 | $retour="$('#".$form."').validate({submitHandler: function(form) { |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @param string $responseElement |
242 | 242 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null,"jqueryDone"=>"html") |
243 | 243 | */ |
244 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
244 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
245 | 245 | $preventDefault=true; |
246 | 246 | $stopPropagation=true; |
247 | 247 | $jsCallback=null; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $jqueryDone="html"; |
252 | 252 | $ajaxTransition=null; |
253 | 253 | extract($parameters); |
254 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
254 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @param string $responseElement |
265 | 265 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null) |
266 | 266 | */ |
267 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
267 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
268 | 268 | $preventDefault=true; |
269 | 269 | $stopPropagation=true; |
270 | 270 | $jsCallback=null; |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $jqueryDone="html"; |
275 | 275 | $ajaxTransition=null; |
276 | 276 | extract($parameters); |
277 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
277 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @param string $responseElement |
288 | 288 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null,"immediatly"=>true) |
289 | 289 | */ |
290 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
290 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
291 | 291 | $preventDefault=true; |
292 | 292 | $stopPropagation=true; |
293 | 293 | $validation=false; |
@@ -298,6 +298,6 @@ discard block |
||
298 | 298 | $jqueryDone="html"; |
299 | 299 | $ajaxTransition=null; |
300 | 300 | extract($parameters); |
301 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
301 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
302 | 302 | } |
303 | 303 | } |
@@ -28,10 +28,11 @@ discard block |
||
28 | 28 | $this->setProperty("aria-describedby", $id); |
29 | 29 | $span->setContent($text); |
30 | 30 | $span->setClass("input-group-addon"); |
31 | - if (strtolower($position)==="left") |
|
32 | - $this->addonLeft=$span; |
|
33 | - else |
|
34 | - $this->addonRight=$span; |
|
31 | + if (strtolower($position)==="left") { |
|
32 | + $this->addonLeft=$span; |
|
33 | + } else { |
|
34 | + $this->addonRight=$span; |
|
35 | + } |
|
35 | 36 | return $span; |
36 | 37 | } |
37 | 38 | |
@@ -74,7 +75,7 @@ discard block |
||
74 | 75 | $bt=NULL; |
75 | 76 | if(is_string($item)){ |
76 | 77 | $bt=new HtmlButton($this->identifier."-bt-".$i++,$item); |
77 | - }elseif ($item instanceof HtmlButton){ |
|
78 | + } elseif ($item instanceof HtmlButton){ |
|
78 | 79 | $bt=$item; |
79 | 80 | } |
80 | 81 | if(isset($bt)){ |
@@ -88,10 +89,11 @@ discard block |
||
88 | 89 | $dropdown->setBtnCaption($caption); |
89 | 90 | $dropdown->fromArray($items); |
90 | 91 | |
91 | - if (strtolower($position)==="left") |
|
92 | - $this->addonLeft=$dropdown; |
|
93 | - else |
|
94 | - $this->addonRight=$dropdown; |
|
92 | + if (strtolower($position)==="left") { |
|
93 | + $this->addonLeft=$dropdown; |
|
94 | + } else { |
|
95 | + $this->addonRight=$dropdown; |
|
96 | + } |
|
95 | 97 | return $dropdown; |
96 | 98 | } |
97 | 99 | |
@@ -126,10 +128,12 @@ discard block |
||
126 | 128 | |
127 | 129 | public function run(JsUtils $js) { |
128 | 130 | parent::run($js); |
129 | - if (isset($this->addonLeft)) |
|
130 | - $this->addonLeft->run($js); |
|
131 | - if (isset($this->addonRight)) |
|
132 | - $this->addonRight->run($js); |
|
131 | + if (isset($this->addonLeft)) { |
|
132 | + $this->addonLeft->run($js); |
|
133 | + } |
|
134 | + if (isset($this->addonRight)) { |
|
135 | + $this->addonRight->run($js); |
|
136 | + } |
|
133 | 137 | } |
134 | 138 | |
135 | 139 | } |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | protected $attr; |
22 | 22 | |
23 | 23 | |
24 | - public function __construct($identifier,$tagName){ |
|
25 | - parent::__construct($identifier,$tagName); |
|
24 | + public function __construct($identifier, $tagName) { |
|
25 | + parent::__construct($identifier, $tagName); |
|
26 | 26 | $this->root=""; |
27 | 27 | $this->attr="data-ajax"; |
28 | 28 | } |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * @param string $targetSelector the target of the get |
34 | 34 | * @return HtmlNavElement |
35 | 35 | */ |
36 | - public function autoGetOnClick($targetSelector){ |
|
37 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
36 | + public function autoGetOnClick($targetSelector) { |
|
37 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
38 | 38 | } |
39 | 39 | |
40 | - public function contentAsString(){ |
|
40 | + public function contentAsString() { |
|
41 | 41 | return implode("", $this->content); |
42 | 42 | } |
43 | 43 | } |
@@ -23,19 +23,19 @@ |
||
23 | 23 | return $this; |
24 | 24 | } |
25 | 25 | |
26 | - public function addGlyph($glyphicon,$before=true){ |
|
26 | + public function addGlyph($glyphicon, $before=true) { |
|
27 | 27 | $glyph=new HtmlGlyphicon(""); |
28 | 28 | $glyph->setGlyphicon($glyphicon); |
29 | - $this->addContent($glyph,$before); |
|
29 | + $this->addContent($glyph, $before); |
|
30 | 30 | return $this; |
31 | 31 | } |
32 | 32 | |
33 | - public function wrapContentWithGlyph($glyphBefore,$glyphAfter=""){ |
|
33 | + public function wrapContentWithGlyph($glyphBefore, $glyphAfter="") { |
|
34 | 34 | $before=HtmlGlyphicon::getGlyphicon($glyphBefore)." "; |
35 | 35 | $after=""; |
36 | - if($glyphAfter!==""){ |
|
36 | + if ($glyphAfter!=="") { |
|
37 | 37 | $after=" ".HtmlGlyphicon::getGlyphicon($glyphAfter); |
38 | 38 | } |
39 | - return $this->wrapContent($before,$after); |
|
39 | + return $this->wrapContent($before, $after); |
|
40 | 40 | } |
41 | 41 | } |