@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * JsUtils Class : Phalcon service to be injected |
26 | 26 | */ |
27 | 27 | abstract class _JsUtils implements InjectionAwareInterface { |
28 | - use JsUtilsEventsTrait,JsUtilsActionsTrait,JsUtilsAjaxTrait; |
|
28 | + use JsUtilsEventsTrait, JsUtilsActionsTrait, JsUtilsAjaxTrait; |
|
29 | 29 | |
30 | 30 | protected $_di; |
31 | 31 | protected $js; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | protected function _setDi($di) { |
56 | 56 | $this->_di=$di; |
57 | - if ($this->js!=null&&$di!=null) |
|
57 | + if ($this->js!=null && $di!=null) |
|
58 | 58 | $this->js->setDi($di); |
59 | 59 | } |
60 | 60 | |
@@ -147,18 +147,18 @@ discard block |
||
147 | 147 | |
148 | 148 | |
149 | 149 | public function __construct($params=array()) { |
150 | - $defaults=array ( |
|
150 | + $defaults=array( |
|
151 | 151 | 'driver' => 'Jquery', |
152 | 152 | 'debug' => true |
153 | 153 | ); |
154 | - foreach ( $defaults as $key => $val ) { |
|
155 | - if (isset($params[$key])&&$params[$key]!=="") { |
|
154 | + foreach ($defaults as $key => $val) { |
|
155 | + if (isset($params[$key]) && $params[$key]!=="") { |
|
156 | 156 | $defaults[$key]=$params[$key]; |
157 | 157 | } |
158 | 158 | } |
159 | 159 | extract($defaults); |
160 | 160 | $this->js=new Jquery($defaults); |
161 | - $this->cdns=array (); |
|
161 | + $this->cdns=array(); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | public function addToCompile($jsScript) { |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function compile($view=NULL, $view_var='script_foot', $script_tags=TRUE) { |
198 | 198 | $bs=$this->_bootstrap; |
199 | - if (isset($bs)&&isset($view)) { |
|
199 | + if (isset($bs) && isset($view)) { |
|
200 | 200 | $bs->compileHtml($this, $view); |
201 | 201 | } |
202 | 202 | $sem=$this->_semantic; |
203 | - if (isset($sem)&&isset($view)) { |
|
203 | + if (isset($sem) && isset($view)) { |
|
204 | 204 | $sem->compileHtml($this, $view); |
205 | 205 | } |
206 | 206 | return $this->js->_compile($view, $view_var, $script_tags); |
@@ -280,27 +280,27 @@ discard block |
||
280 | 280 | $json_result=$result->result_array(); |
281 | 281 | } elseif (is_array($result)) { |
282 | 282 | $json_result=$result; |
283 | - } else { |
|
283 | + }else { |
|
284 | 284 | return $this->_prep_args($result); |
285 | 285 | } |
286 | - } else { |
|
286 | + }else { |
|
287 | 287 | return 'null'; |
288 | 288 | } |
289 | 289 | return $this->_create_json($json_result, $match_array_type); |
290 | 290 | } |
291 | 291 | |
292 | 292 | private function _create_json($json_result, $match_array_type) { |
293 | - $json=array (); |
|
293 | + $json=array(); |
|
294 | 294 | $_is_assoc=TRUE; |
295 | - if (!is_array($json_result)&&empty($json_result)) { |
|
295 | + if (!is_array($json_result) && empty($json_result)) { |
|
296 | 296 | show_error("Generate JSON Failed - Illegal key, value pair."); |
297 | 297 | } elseif ($match_array_type) { |
298 | 298 | $_is_assoc=$this->_is_associative_array($json_result); |
299 | 299 | } |
300 | - foreach ( $json_result as $k => $v ) { |
|
300 | + foreach ($json_result as $k => $v) { |
|
301 | 301 | if ($_is_assoc) { |
302 | 302 | $json[]=$this->_prep_args($k, TRUE).':'.$this->generate_json($v, $match_array_type); |
303 | - } else { |
|
303 | + }else { |
|
304 | 304 | $json[]=$this->generate_json($v, $match_array_type); |
305 | 305 | } |
306 | 306 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @return type |
316 | 316 | */ |
317 | 317 | public function _is_associative_array($arr) { |
318 | - foreach ( array_keys($arr) as $key => $val ) { |
|
318 | + foreach (array_keys($arr) as $key => $val) { |
|
319 | 319 | if ($key!==$val) { |
320 | 320 | return TRUE; |
321 | 321 | } |
@@ -334,11 +334,11 @@ discard block |
||
334 | 334 | return 'null'; |
335 | 335 | } elseif (is_bool($result)) { |
336 | 336 | return ($result===TRUE) ? 'true' : 'false'; |
337 | - } elseif (is_string($result)||$is_key) { |
|
338 | - return '"'.str_replace(array ( |
|
339 | - '\\',"\t","\n","\r",'"','/' |
|
340 | - ), array ( |
|
341 | - '\\\\','\\t','\\n',"\\r",'\"','\/' |
|
337 | + } elseif (is_string($result) || $is_key) { |
|
338 | + return '"'.str_replace(array( |
|
339 | + '\\', "\t", "\n", "\r", '"', '/' |
|
340 | + ), array( |
|
341 | + '\\\\', '\\t', '\\n', "\\r", '\"', '\/' |
|
342 | 342 | ), $result).'"'; |
343 | 343 | } elseif (is_scalar($result)) { |
344 | 344 | return $result; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | |
352 | 352 | public function setCDNs($cdns) { |
353 | 353 | if (is_array($cdns)===false) { |
354 | - $cdns=array ( |
|
354 | + $cdns=array( |
|
355 | 355 | $cdns |
356 | 356 | ); |
357 | 357 | } |
@@ -363,9 +363,9 @@ discard block |
||
363 | 363 | $hasJQueryUI=false; |
364 | 364 | $hasBootstrap=false; |
365 | 365 | $hasSemantic=false; |
366 | - $result=array (); |
|
367 | - foreach ( $this->cdns as $cdn ) { |
|
368 | - switch(get_class($cdn)) { |
|
366 | + $result=array(); |
|
367 | + foreach ($this->cdns as $cdn) { |
|
368 | + switch (get_class($cdn)) { |
|
369 | 369 | case "Ajax\lib\CDNJQuery": |
370 | 370 | $hasJQuery=true; |
371 | 371 | $result[0]=$cdn; |
@@ -375,11 +375,11 @@ discard block |
||
375 | 375 | $result[1]=$cdn; |
376 | 376 | break; |
377 | 377 | case "Ajax\lib\CDNCoreCss": |
378 | - if($cdn->getFramework()==="Bootstrap") |
|
378 | + if ($cdn->getFramework()==="Bootstrap") |
|
379 | 379 | $hasBootstrap=true; |
380 | - elseif($cdn->getFramework()==="Semantic") |
|
380 | + elseif ($cdn->getFramework()==="Semantic") |
|
381 | 381 | $hasSemantic=true; |
382 | - if($hasSemantic || $hasBootstrap) |
|
382 | + if ($hasSemantic || $hasBootstrap) |
|
383 | 383 | $result[2]=$cdn; |
384 | 384 | break; |
385 | 385 | } |
@@ -387,14 +387,14 @@ discard block |
||
387 | 387 | if ($hasJQuery===false) { |
388 | 388 | $result[0]=new CDNJQuery("x"); |
389 | 389 | } |
390 | - if ($hasJQueryUI===false&&isset($this->_ui)) { |
|
390 | + if ($hasJQueryUI===false && isset($this->_ui)) { |
|
391 | 391 | $result[1]=new CDNGuiGen("x", $template); |
392 | 392 | } |
393 | - if ($hasBootstrap===false&&isset($this->_bootstrap)) { |
|
394 | - $result[2]=new CDNCoreCss("Bootstrap","x"); |
|
393 | + if ($hasBootstrap===false && isset($this->_bootstrap)) { |
|
394 | + $result[2]=new CDNCoreCss("Bootstrap", "x"); |
|
395 | 395 | } |
396 | - if ($hasSemantic===false&&isset($this->_semantic)) { |
|
397 | - $result[2]=new CDNCoreCss("Semantic","x"); |
|
396 | + if ($hasSemantic===false && isset($this->_semantic)) { |
|
397 | + $result[2]=new CDNCoreCss("Semantic", "x"); |
|
398 | 398 | } |
399 | 399 | ksort($result); |
400 | 400 | return implode("\n", $result); |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | $this->_setDi($di); |
408 | 408 | } |
409 | 409 | } |
410 | -} else { |
|
410 | +}else { |
|
411 | 411 | class JsUtils extends _JsUtils { |
412 | 412 | |
413 | 413 | public function setDi(DiInterface $di) { |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
10 | 10 | |
11 | 11 | public abstract function _prep_value($value); |
12 | - public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
12 | + public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
13 | 13 | protected function addLoading(&$retour, $responseElement) { |
14 | 14 | $loading_notifier='<div class="ajax-loader">'; |
15 | 15 | if ($this->ajaxLoader=='') { |
16 | 16 | $loading_notifier.="Loading..."; |
17 | - } else { |
|
17 | + }else { |
|
18 | 18 | $loading_notifier.=$this->ajaxLoader; |
19 | 19 | } |
20 | 20 | $loading_notifier.='</div>'; |
@@ -22,20 +22,20 @@ discard block |
||
22 | 22 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
23 | 23 | } |
24 | 24 | |
25 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
26 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
25 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
26 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
27 | 27 | } |
28 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
29 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
28 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
29 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
30 | 30 | } |
31 | 31 | |
32 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
33 | - if(JString::isNull($params)){$params="{}";} |
|
32 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
33 | + if (JString::isNull($params)) {$params="{}"; } |
|
34 | 34 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
35 | 35 | $retour=$this->_getAjaxUrl($url, $attr); |
36 | 36 | $responseElement=$this->_getResponseElement($responseElement); |
37 | 37 | $retour.="var self=this;\n"; |
38 | - if($hasLoader===true){ |
|
38 | + if ($hasLoader===true) { |
|
39 | 39 | $this->addLoading($retour, $responseElement); |
40 | 40 | } |
41 | 41 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
@@ -45,22 +45,22 @@ discard block |
||
45 | 45 | return $retour; |
46 | 46 | } |
47 | 47 | |
48 | - protected function _getAjaxUrl($url,$attr){ |
|
48 | + protected function _getAjaxUrl($url, $attr) { |
|
49 | 49 | $url=$this->_correctAjaxUrl($url); |
50 | 50 | $retour="url='".$url."';\n"; |
51 | 51 | $slash="/"; |
52 | - if(PhalconUtils::endsWith($url, "/")) |
|
52 | + if (PhalconUtils::endsWith($url, "/")) |
|
53 | 53 | $slash=""; |
54 | - if(JString::isNotNull($attr)){ |
|
54 | + if (JString::isNotNull($attr)) { |
|
55 | 55 | if ($attr=="value") |
56 | 56 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
57 | - else if($attr!=null && $attr!=="") |
|
57 | + else if ($attr!=null && $attr!=="") |
|
58 | 58 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
59 | 59 | } |
60 | 60 | return $retour; |
61 | 61 | } |
62 | 62 | |
63 | - protected function _getOnAjaxDone($responseElement,$jsCallback){ |
|
63 | + protected function _getOnAjaxDone($responseElement, $jsCallback) { |
|
64 | 64 | $retour=""; |
65 | 65 | if ($responseElement!=="") { |
66 | 66 | $retour="\t$({$responseElement}).html( data );\n"; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | return $retour; |
70 | 70 | } |
71 | 71 | |
72 | - protected function _getResponseElement($responseElement){ |
|
72 | + protected function _getResponseElement($responseElement) { |
|
73 | 73 | if ($responseElement!=="") { |
74 | 74 | $responseElement=$this->_prep_value($responseElement); |
75 | 75 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | protected function _correctAjaxUrl($url) { |
80 | 80 | if (PhalconUtils::endsWith($url, "/")) |
81 | 81 | $url=substr($url, 0, strlen($url)-1); |
82 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
82 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
83 | 83 | $url=$this->_di->get("url")->get($url); |
84 | 84 | } |
85 | 85 | return $url; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $jsCallback javascript code to execute after the request |
94 | 94 | * @param boolean $immediatly |
95 | 95 | */ |
96 | - public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
96 | + public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
97 | 97 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
98 | 98 | $retour=$this->_getAjaxUrl($url, $attr); |
99 | 99 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param string $url the request address |
115 | 115 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
116 | 116 | */ |
117 | - public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
117 | + public function _jsonOn($event, $element, $url, $parameters=array()) { |
|
118 | 118 | $preventDefault=true; |
119 | 119 | $stopPropagation=true; |
120 | 120 | $jsCallback=null; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $params="{}"; |
125 | 125 | $immediatly=true; |
126 | 126 | extract($parameters); |
127 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
127 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -136,19 +136,19 @@ discard block |
||
136 | 136 | * @param string $context jquery DOM element, array container. |
137 | 137 | * @param boolean $immediatly |
138 | 138 | */ |
139 | - public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) { |
|
139 | + public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) { |
|
140 | 140 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
141 | 141 | $retour=$this->_getAjaxUrl($url, $attr); |
142 | - if($context===null){ |
|
142 | + if ($context===null) { |
|
143 | 143 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
144 | - $newElm = "$('#'+newId)"; |
|
145 | - }else{ |
|
144 | + $newElm="$('#'+newId)"; |
|
145 | + }else { |
|
146 | 146 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
147 | - $newElm = $context.".find('#'+newId)"; |
|
147 | + $newElm=$context.".find('#'+newId)"; |
|
148 | 148 | } |
149 | 149 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
150 | 150 | $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();newElm.attr('id',newId);\n"; |
151 | - $retour.= $appendTo; |
|
151 | + $retour.=$appendTo; |
|
152 | 152 | $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"; |
153 | 153 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
154 | 154 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -163,26 +163,26 @@ discard block |
||
163 | 163 | * @param string $url the request address |
164 | 164 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null) |
165 | 165 | */ |
166 | - public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
166 | + public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
167 | 167 | $preventDefault=true; |
168 | 168 | $stopPropagation=true; |
169 | 169 | $jsCallback=null; |
170 | 170 | $attr="id"; |
171 | 171 | $method="get"; |
172 | - $context = null; |
|
172 | + $context=null; |
|
173 | 173 | $params="{}"; |
174 | 174 | $immediatly=true; |
175 | 175 | extract($parameters); |
176 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
176 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
177 | 177 | } |
178 | 178 | |
179 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
179 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
180 | 180 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
181 | 181 | $retour=$this->_getAjaxUrl($url, $attr); |
182 | 182 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
183 | 183 | $responseElement=$this->_getResponseElement($responseElement); |
184 | 184 | $retour.="var self=this;\n"; |
185 | - if($hasLoader===true){ |
|
185 | + if ($hasLoader===true) { |
|
186 | 186 | $this->addLoading($retour, $responseElement); |
187 | 187 | } |
188 | 188 | $retour.="$.post(url,params).done(function( data ) {\n"; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param string $responseElement |
210 | 210 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
211 | 211 | */ |
212 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
212 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
213 | 213 | $preventDefault=true; |
214 | 214 | $stopPropagation=true; |
215 | 215 | $jsCallback=null; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $hasLoader=true; |
218 | 218 | $immediatly=true; |
219 | 219 | extract($parameters); |
220 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
220 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @param string $responseElement |
231 | 231 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
232 | 232 | */ |
233 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
233 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
234 | 234 | $preventDefault=true; |
235 | 235 | $stopPropagation=true; |
236 | 236 | $jsCallback=null; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $hasLoader=true; |
239 | 239 | $immediatly=true; |
240 | 240 | extract($parameters); |
241 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
241 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @param string $responseElement |
252 | 252 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true) |
253 | 253 | */ |
254 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
254 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
255 | 255 | $preventDefault=true; |
256 | 256 | $stopPropagation=true; |
257 | 257 | $validation=false; |
@@ -260,6 +260,6 @@ discard block |
||
260 | 260 | $hasLoader=true; |
261 | 261 | $immediatly=true; |
262 | 262 | extract($parameters); |
263 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
263 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | trait JqueryEventsTrait { |
6 | 6 | public abstract function _prep_element($element); |
7 | - public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
7 | + public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Blur |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function _click($element='this', $js=array(), $ret_false=TRUE) { |
48 | 48 | if (!is_array($js)) { |
49 | - $js=array ( |
|
49 | + $js=array( |
|
50 | 50 | $js |
51 | 51 | ); |
52 | 52 | } |
@@ -17,21 +17,21 @@ discard block |
||
17 | 17 | * jQuery Class |
18 | 18 | */ |
19 | 19 | class Jquery { |
20 | - use JqueryEventsTrait,JqueryAjaxTrait,JqueryActionsTrait; |
|
20 | + use JqueryEventsTrait, JqueryAjaxTrait, JqueryActionsTrait; |
|
21 | 21 | protected $_di; |
22 | 22 | protected $_ui; |
23 | 23 | protected $_bootstrap; |
24 | 24 | protected $_semantic; |
25 | 25 | protected $libraryFile; |
26 | 26 | protected $_javascript_folder='js'; |
27 | - protected $jquery_code_for_load=array (); |
|
28 | - protected $jquery_code_for_compile=array (); |
|
27 | + protected $jquery_code_for_load=array(); |
|
28 | + protected $jquery_code_for_compile=array(); |
|
29 | 29 | protected $jquery_corner_active=FALSE; |
30 | 30 | protected $jquery_table_sorter_active=FALSE; |
31 | 31 | protected $jquery_table_sorter_pager_active=FALSE; |
32 | 32 | |
33 | - protected $jquery_events=array ( |
|
34 | - "bind","blur","change","click","dblclick","delegate","die","error","focus","focusin","focusout","hover","keydown","keypress","keyup","live","load","mousedown","mousseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","off","on","one","ready","resize","scroll","select","submit","toggle","trigger","triggerHandler","undind","undelegate","unload" |
|
33 | + protected $jquery_events=array( |
|
34 | + "bind", "blur", "change", "click", "dblclick", "delegate", "die", "error", "focus", "focusin", "focusout", "hover", "keydown", "keypress", "keyup", "live", "load", "mousedown", "mousseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "off", "on", "one", "ready", "resize", "scroll", "select", "submit", "toggle", "trigger", "triggerHandler", "undind", "undelegate", "unload" |
|
35 | 35 | ); |
36 | 36 | |
37 | 37 | public function setDi($di) { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | public function __construct($params) { |
63 | 63 | $this->params=array(); |
64 | - foreach ( $params as $key => $val ) { |
|
64 | + foreach ($params as $key => $val) { |
|
65 | 65 | $this->params[$key]=$params[$key]; |
66 | 66 | } |
67 | 67 | } |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function _output($array_js='') { |
137 | 137 | if (!is_array($array_js)) { |
138 | - $array_js=array ( |
|
138 | + $array_js=array( |
|
139 | 139 | $array_js |
140 | 140 | ); |
141 | 141 | } |
142 | 142 | |
143 | - foreach ( $array_js as $js ) { |
|
143 | + foreach ($array_js as $js) { |
|
144 | 144 | $this->jquery_code_for_compile[]="\t$js\n"; |
145 | 145 | } |
146 | 146 | } |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * @param string $param |
153 | 153 | * @param boolean $immediatly delayed if false |
154 | 154 | */ |
155 | - public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) { |
|
155 | + public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) { |
|
156 | 156 | $element=$this->_prep_element($element); |
157 | 157 | if (isset($param)) { |
158 | 158 | $param=$this->_prep_value($param); |
159 | 159 | $str="$({$element}).{$jQueryCall}({$param});"; |
160 | - } else |
|
160 | + }else |
|
161 | 161 | $str="$({$element}).{$jQueryCall}();"; |
162 | 162 | if ($immediatly) |
163 | 163 | $this->jquery_code_for_compile[]=$str; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @param boolean $immediatly delayed if false |
172 | 172 | * @return string |
173 | 173 | */ |
174 | - public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) { |
|
174 | + public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) { |
|
175 | 175 | $to=$this->_prep_element($to); |
176 | 176 | $element=$this->_prep_element($element); |
177 | 177 | $str="$({$to}).{$jQueryCall}({$element});"; |
@@ -189,12 +189,12 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function sortable($element, $options=array()) { |
191 | 191 | if (count($options)>0) { |
192 | - $sort_options=array (); |
|
193 | - foreach ( $options as $k => $v ) { |
|
192 | + $sort_options=array(); |
|
193 | + foreach ($options as $k => $v) { |
|
194 | 194 | $sort_options[]="\n\t\t".$k.': '.$v.""; |
195 | 195 | } |
196 | 196 | $sort_options=implode(",", $sort_options); |
197 | - } else { |
|
197 | + }else { |
|
198 | 198 | $sort_options=''; |
199 | 199 | } |
200 | 200 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @param boolean $stopPropagation Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. |
223 | 223 | * @return string |
224 | 224 | */ |
225 | - public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true) { |
|
225 | + public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true) { |
|
226 | 226 | if (is_array($js)) { |
227 | 227 | $js=implode("\n\t\t", $js); |
228 | 228 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
237 | 237 | else |
238 | 238 | $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
239 | - if($immediatly) |
|
239 | + if ($immediatly) |
|
240 | 240 | $this->jquery_code_for_compile[]=$event; |
241 | 241 | return $event; |
242 | 242 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | // External references |
278 | 278 | $external_scripts=implode('', $this->jquery_code_for_load); |
279 | - extract(array ( |
|
279 | + extract(array( |
|
280 | 280 | 'library_src' => $external_scripts |
281 | 281 | )); |
282 | 282 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | $script.='});'; |
292 | 292 | |
293 | 293 | $this->jquery_code_for_compile=array(); |
294 | - if($this->params["debug"]==false){ |
|
294 | + if ($this->params["debug"]==false) { |
|
295 | 295 | $script=$this->minify($script); |
296 | 296 | } |
297 | 297 | $output=($script_tags===FALSE) ? $script : $this->inline($script); |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @return void |
312 | 312 | */ |
313 | 313 | public function _clear_compile() { |
314 | - $this->jquery_code_for_compile=array (); |
|
314 | + $this->jquery_code_for_compile=array(); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -320,12 +320,12 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public function _document_ready($js) { |
322 | 322 | if (!is_array($js)) { |
323 | - $js=array ( |
|
323 | + $js=array( |
|
324 | 324 | $js |
325 | 325 | ); |
326 | 326 | } |
327 | 327 | |
328 | - foreach ( $js as $script ) { |
|
328 | + foreach ($js as $script) { |
|
329 | 329 | $this->jquery_code_for_compile[]=$script; |
330 | 330 | } |
331 | 331 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * @return string |
340 | 340 | */ |
341 | 341 | public function _prep_element($element) { |
342 | - if (strrpos($element, 'this')===false&&strrpos($element, 'event')===false&&strrpos($element, 'self')===false) { |
|
342 | + if (strrpos($element, 'this')===false && strrpos($element, 'event')===false && strrpos($element, 'self')===false) { |
|
343 | 343 | $element='"'.addslashes($element).'"'; |
344 | 344 | } |
345 | 345 | return $element; |
@@ -357,14 +357,14 @@ discard block |
||
357 | 357 | if (is_array($value)) { |
358 | 358 | $value=implode(",", $value); |
359 | 359 | } |
360 | - if (strrpos($value, 'this')===false&&strrpos($value, 'event')===false&&strrpos($value, 'self')===false) { |
|
360 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false && strrpos($value, 'self')===false) { |
|
361 | 361 | $value='"'.$value.'"'; |
362 | 362 | } |
363 | 363 | return $value; |
364 | 364 | } |
365 | 365 | |
366 | 366 | private function minify($input) { |
367 | - if(trim($input) === "") return $input; |
|
367 | + if (trim($input)==="") return $input; |
|
368 | 368 | return preg_replace( |
369 | 369 | array( |
370 | 370 | // Remove comment(s) |
@@ -14,89 +14,89 @@ |
||
14 | 14 | */ |
15 | 15 | class HtmlGridRow extends HtmlBsDoubleElement { |
16 | 16 | private $cols; |
17 | - public function __construct($identifier,$numCols=NULL){ |
|
18 | - parent::__construct($identifier,"div"); |
|
17 | + public function __construct($identifier, $numCols=NULL) { |
|
18 | + parent::__construct($identifier, "div"); |
|
19 | 19 | $this->setProperty("class", "row"); |
20 | 20 | $this->cols=array(); |
21 | - if(isset($numCols)){ |
|
22 | - $numCols=min(12,$numCols); |
|
23 | - $numCols=max(1,$numCols); |
|
24 | - $width=12/$numCols; |
|
25 | - for ($i=0;$i<$numCols;$i++){ |
|
26 | - $this->addCol(CssSize::SIZE_MD,$width); |
|
21 | + if (isset($numCols)) { |
|
22 | + $numCols=min(12, $numCols); |
|
23 | + $numCols=max(1, $numCols); |
|
24 | + $width=12 / $numCols; |
|
25 | + for ($i=0; $i<$numCols; $i++) { |
|
26 | + $this->addCol(CssSize::SIZE_MD, $width); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | - public function addCol($size=CssSize::SIZE_MD,$width=1){ |
|
32 | - $col=new HtmlGridCol($this->identifier."-col-".(sizeof($this->cols)+1),$size,$width); |
|
31 | + public function addCol($size=CssSize::SIZE_MD, $width=1) { |
|
32 | + $col=new HtmlGridCol($this->identifier."-col-".(sizeof($this->cols)+1), $size, $width); |
|
33 | 33 | $this->cols[]=$col; |
34 | 34 | return $col; |
35 | 35 | } |
36 | 36 | |
37 | - public function addColAt($size=CssSize::SIZE_MD,$width=1,$offset=1){ |
|
38 | - $col=$this->addCol($size,$width); |
|
39 | - return $col->setOffset($size, max($offset,sizeof($this->cols)+1)); |
|
37 | + public function addColAt($size=CssSize::SIZE_MD, $width=1, $offset=1) { |
|
38 | + $col=$this->addCol($size, $width); |
|
39 | + return $col->setOffset($size, max($offset, sizeof($this->cols)+1)); |
|
40 | 40 | } |
41 | 41 | |
42 | - public function getCol($index,$force=true){ |
|
42 | + public function getCol($index, $force=true) { |
|
43 | 43 | $result=null; |
44 | - if($index<sizeof($this->cols)+1){ |
|
44 | + if ($index<sizeof($this->cols)+1) { |
|
45 | 45 | $result=$this->cols[$index-1]; |
46 | - }else if ($force){ |
|
47 | - $result=$this->addColAt(CssSize::SIZE_MD,1,$index); |
|
46 | + }else if ($force) { |
|
47 | + $result=$this->addColAt(CssSize::SIZE_MD, 1, $index); |
|
48 | 48 | } |
49 | 49 | return $result; |
50 | 50 | } |
51 | 51 | |
52 | - public function getColAt($offset,$force=true){ |
|
52 | + public function getColAt($offset, $force=true) { |
|
53 | 53 | $result=null; |
54 | - foreach ($this->cols as $col){ |
|
54 | + foreach ($this->cols as $col) { |
|
55 | 55 | $offsets=$col->getOffsets(); |
56 | - if($result=array_search($offset, $offsets)){ |
|
56 | + if ($result=array_search($offset, $offsets)) { |
|
57 | 57 | break; |
58 | 58 | } |
59 | 59 | } |
60 | - if(!$result || isset($result)==false){ |
|
61 | - $result=$this->getCol($offset,$force); |
|
60 | + if (!$result || isset($result)==false) { |
|
61 | + $result=$this->getCol($offset, $force); |
|
62 | 62 | } |
63 | 63 | return $result; |
64 | 64 | } |
65 | 65 | |
66 | 66 | public function compile(JsUtils $js=NULL, View $view=NULL) { |
67 | 67 | |
68 | - foreach ($this->cols as $col){ |
|
68 | + foreach ($this->cols as $col) { |
|
69 | 69 | $this->addContent($col); |
70 | 70 | } |
71 | - return parent::compile($js,$view); |
|
71 | + return parent::compile($js, $view); |
|
72 | 72 | } |
73 | 73 | public function getCols() { |
74 | 74 | return $this->cols; |
75 | 75 | } |
76 | 76 | |
77 | - public function setContentForAll($content){ |
|
78 | - foreach ($this->cols as $col){ |
|
77 | + public function setContentForAll($content) { |
|
78 | + foreach ($this->cols as $col) { |
|
79 | 79 | $col->setContent($content); |
80 | 80 | } |
81 | 81 | } |
82 | - public function merge($size=CssSize::SIZE_MD,$start,$width){ |
|
83 | - $col=$this->getColAt($start,false); |
|
84 | - if(isset($col)){ |
|
85 | - $col->setWidth($size,$width+1); |
|
86 | - $this->delete($size,$start+1, $width); |
|
82 | + public function merge($size=CssSize::SIZE_MD, $start, $width) { |
|
83 | + $col=$this->getColAt($start, false); |
|
84 | + if (isset($col)) { |
|
85 | + $col->setWidth($size, $width+1); |
|
86 | + $this->delete($size, $start+1, $width); |
|
87 | 87 | } |
88 | 88 | } |
89 | - public function delete($size=CssSize::SIZE_MD,$start,$width){ |
|
90 | - while($start<sizeof($this->cols)+1 && $width>0){ |
|
91 | - $col=$this->getColAt($start,false); |
|
92 | - if(isset($col)){ |
|
89 | + public function delete($size=CssSize::SIZE_MD, $start, $width) { |
|
90 | + while ($start<sizeof($this->cols)+1 && $width>0) { |
|
91 | + $col=$this->getColAt($start, false); |
|
92 | + if (isset($col)) { |
|
93 | 93 | $widthCol=$col->getWidth($size); |
94 | - if($widthCol<=$width){ |
|
94 | + if ($widthCol<=$width) { |
|
95 | 95 | unset($this->cols[$start-1]); |
96 | - $this->cols = array_values($this->cols); |
|
96 | + $this->cols=array_values($this->cols); |
|
97 | 97 | $width=$width-$widthCol; |
98 | 98 | } |
99 | - }else{ |
|
99 | + }else { |
|
100 | 100 | $width=0; |
101 | 101 | } |
102 | 102 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | namespace Ajax\common\traits; |
4 | 4 | |
5 | 5 | trait JqueryActionsTrait { |
6 | - public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
6 | + public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
7 | 7 | public abstract function _prep_element($element); |
8 | 8 | public abstract function _prep_value($value); |
9 | 9 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | if (isset($value)) { |
20 | 20 | $value=$this->_prep_value($value); |
21 | 21 | $str="$({$element}).attr(\"$attributeName\",{$value});"; |
22 | - } else |
|
22 | + }else |
|
23 | 23 | $str="$({$element}).attr(\"$attributeName\");"; |
24 | 24 | if ($immediatly) |
25 | 25 | $this->jquery_code_for_compile[]=$str; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param boolean $immediatly defers the execution if set to false |
34 | 34 | * @return string |
35 | 35 | */ |
36 | - public function after($element='this', $value='', $immediatly=false){ |
|
36 | + public function after($element='this', $value='', $immediatly=false) { |
|
37 | 37 | $element=$this->_prep_element($element); |
38 | 38 | $value=$this->_prep_value($value); |
39 | 39 | $str="$({$element}).after({$value});"; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | $animations="\t\t\t"; |
60 | 60 | if (is_array($params)) { |
61 | - foreach ( $params as $param => $value ) { |
|
61 | + foreach ($params as $param => $value) { |
|
62 | 62 | $animations.=$param.': \''.$value.'\', '; |
63 | 63 | } |
64 | 64 | } |
@@ -351,8 +351,8 @@ discard block |
||
351 | 351 | * @param boolean $immediatly |
352 | 352 | * @return string |
353 | 353 | */ |
354 | - public function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="",$immediatly=true) { |
|
355 | - return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation,$immediatly); |
|
354 | + public function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="", $immediatly=true) { |
|
355 | + return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation, $immediatly); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @param boolean $immediatly |
379 | 379 | * @return String |
380 | 380 | */ |
381 | - public function _execOn($element, $event, $js, $preventDefault=false, $stopPropagation=false,$immediatly=true) { |
|
382 | - return $this->_add_event($element, $this->_exec($js), $event, $preventDefault, $stopPropagation,$immediatly); |
|
381 | + public function _execOn($element, $event, $js, $preventDefault=false, $stopPropagation=false, $immediatly=true) { |
|
382 | + return $this->_add_event($element, $this->_exec($js), $event, $preventDefault, $stopPropagation, $immediatly); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -388,8 +388,8 @@ discard block |
||
388 | 388 | * @return string |
389 | 389 | */ |
390 | 390 | private function _validate_speed($speed) { |
391 | - if (in_array($speed, array ( |
|
392 | - 'slow','normal','fast' |
|
391 | + if (in_array($speed, array( |
|
392 | + 'slow', 'normal', 'fast' |
|
393 | 393 | ))) { |
394 | 394 | $speed='"'.$speed.'"'; |
395 | 395 | } elseif (preg_match("/[^0-9]/", $speed)) { |
@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | private $_hasIcon=false; |
9 | 9 | |
10 | 10 | protected abstract function addToPropertyCtrl($name, $value, $typeCtrl); |
11 | - public abstract function addContent($content,$before=false); |
|
11 | + public abstract function addContent($content, $before=false); |
|
12 | 12 | |
13 | - public function addIcon($icon,$direction=Direction::LEFT){ |
|
14 | - if($this->_hasIcon===false){ |
|
13 | + public function addIcon($icon, $direction=Direction::LEFT) { |
|
14 | + if ($this->_hasIcon===false) { |
|
15 | 15 | $iconO=$icon; |
16 | - if(\is_string($icon)){ |
|
16 | + if (\is_string($icon)) { |
|
17 | 17 | $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
18 | 18 | } |
19 | 19 | $this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon")); |
20 | - $this->addContent($iconO,false); |
|
20 | + $this->addContent($iconO, false); |
|
21 | 21 | $this->_hasIcon=true; |
22 | - }else{ |
|
22 | + }else { |
|
23 | 23 | $iconO=$this->getIcon(); |
24 | 24 | $iconO->setIcon($icon); |
25 | 25 | $this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon")); |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | return $iconO; |
28 | 28 | } |
29 | 29 | |
30 | - public function getIcon(){ |
|
31 | - if(\is_array($this->content)){ |
|
32 | - foreach ($this->content as $item){ |
|
33 | - if($item instanceof HtmlIcon) |
|
30 | + public function getIcon() { |
|
31 | + if (\is_array($this->content)) { |
|
32 | + foreach ($this->content as $item) { |
|
33 | + if ($item instanceof HtmlIcon) |
|
34 | 34 | return $item; |
35 | 35 | } |
36 | 36 | } |
@@ -9,26 +9,26 @@ discard block |
||
9 | 9 | use Ajax\semantic\html\collections\form\HtmlFormCheckbox; |
10 | 10 | use Ajax\semantic\html\collections\form\HtmlFormRadio; |
11 | 11 | trait FieldsTrait { |
12 | - public abstract function addFields($fields=NULL,$label=NULL); |
|
12 | + public abstract function addFields($fields=NULL, $label=NULL); |
|
13 | 13 | public abstract function addItem($item); |
14 | 14 | |
15 | - protected function createItem($value){ |
|
16 | - if(\is_array($value)){ |
|
17 | - $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null))); |
|
15 | + protected function createItem($value) { |
|
16 | + if (\is_array($value)) { |
|
17 | + $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id", ""), JArray::getDefaultValue($value, "label", null), JArray::getDefaultValue($value, "type", "text"), JArray::getDefaultValue($value, "value", ""), JArray::getDefaultValue($value, "placeholder", JArray::getDefaultValue($value, "label", null))); |
|
18 | 18 | return $itemO; |
19 | 19 | }else |
20 | 20 | return new HtmlFormInput($value); |
21 | 21 | } |
22 | 22 | |
23 | - public function addInputs($inputs,$fieldslabel=null){ |
|
23 | + public function addInputs($inputs, $fieldslabel=null) { |
|
24 | 24 | $fields=array(); |
25 | - foreach ($inputs as $input){ |
|
25 | + foreach ($inputs as $input) { |
|
26 | 26 | \extract($input); |
27 | - $f=new HtmlFormInput("",""); |
|
27 | + $f=new HtmlFormInput("", ""); |
|
28 | 28 | $f->fromArray($input); |
29 | 29 | $fields[]=$f; |
30 | 30 | } |
31 | - return $this->addFields($fields,$fieldslabel); |
|
31 | + return $this->addFields($fields, $fieldslabel); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,23 +39,23 @@ discard block |
||
39 | 39 | * @param boolean $multiple |
40 | 40 | * @return \Ajax\common\html\HtmlDoubleElement |
41 | 41 | */ |
42 | - public function addDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false){ |
|
43 | - return $this->addItem(new HtmlFormDropdown($identifier,$items,$label,$value,$multiple)); |
|
42 | + public function addDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) { |
|
43 | + return $this->addItem(new HtmlFormDropdown($identifier, $items, $label, $value, $multiple)); |
|
44 | 44 | } |
45 | 45 | |
46 | - public function addInput($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL){ |
|
47 | - return $this->addItem(new HtmlFormInput($identifier,$label,$type,$value,$placeholder)); |
|
46 | + public function addInput($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
47 | + return $this->addItem(new HtmlFormInput($identifier, $label, $type, $value, $placeholder)); |
|
48 | 48 | } |
49 | 49 | |
50 | - public function addButton($identifier,$value,$cssStyle=NULL,$onClick=NULL){ |
|
51 | - return $this->addItem(new HtmlButton($identifier,$value,$cssStyle,$onClick)); |
|
50 | + public function addButton($identifier, $value, $cssStyle=NULL, $onClick=NULL) { |
|
51 | + return $this->addItem(new HtmlButton($identifier, $value, $cssStyle, $onClick)); |
|
52 | 52 | } |
53 | 53 | |
54 | - public function addCheckbox($identifier, $label=NULL,$value=NULL,$type=NULL){ |
|
55 | - return $this->addItem(new HtmlFormCheckbox($identifier,$label,$value,$type)); |
|
54 | + public function addCheckbox($identifier, $label=NULL, $value=NULL, $type=NULL) { |
|
55 | + return $this->addItem(new HtmlFormCheckbox($identifier, $label, $value, $type)); |
|
56 | 56 | } |
57 | 57 | |
58 | - public function addRadio($identifier, $name,$label=NULL,$value=NULL){ |
|
59 | - return $this->addItem(new HtmlFormRadio($identifier,$name,$label,$value)); |
|
58 | + public function addRadio($identifier, $name, $label=NULL, $value=NULL) { |
|
59 | + return $this->addItem(new HtmlFormRadio($identifier, $name, $label, $value)); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | \ No newline at end of file |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | return $this->setParam("onShow", "%function(){".$jsCode."}%"); |
31 | 31 | } |
32 | 32 | |
33 | - public function setExclusive($value){ |
|
33 | + public function setExclusive($value) { |
|
34 | 34 | return $this->setParam("exclusive", $value); |
35 | 35 | } |
36 | 36 | |
@@ -39,15 +39,15 @@ discard block |
||
39 | 39 | * @param string $popup the css selector of the popup |
40 | 40 | * @return \Ajax\semantic\components\Popup |
41 | 41 | */ |
42 | - public function setPopup($popup){ |
|
42 | + public function setPopup($popup) { |
|
43 | 43 | return $this->setParam("popup", $popup); |
44 | 44 | } |
45 | 45 | |
46 | - public function setInline($value){ |
|
46 | + public function setInline($value) { |
|
47 | 47 | return $this->setParam("inline", $value); |
48 | 48 | } |
49 | 49 | |
50 | - public function setPosition($value){ |
|
50 | + public function setPosition($value) { |
|
51 | 51 | return $this->setParam("position", $value); |
52 | 52 | } |
53 | 53 | //TODO other events implementation |