Completed
Push — master ( eb7f5d...c7a943 )
by Jean-Christophe
03:07
created
Ajax/common/html/traits/NavElementTrait.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,22 +8,22 @@  discard block
 block discarded – undo
8 8
  * @property string $root
9 9
  * @property string $attr
10 10
  */
11
-trait NavElementTrait{
11
+trait NavElementTrait {
12 12
 
13 13
 	abstract public function contentAsString();
14 14
 	/**
15 15
 	 * Generate the jquery script to set the elements to the HtmlNavElement
16 16
 	 * @param JsUtils $jsUtils
17 17
 	 */
18
-	public function jsSetContent(JsUtils $jsUtils){
19
-		$jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true);
18
+	public function jsSetContent(JsUtils $jsUtils) {
19
+		$jsUtils->html("#".$this->identifier, str_replace("\"", "'", $this->contentAsString()), true);
20 20
 	}
21 21
 
22 22
 	public function getRoot() {
23 23
 		return $this->root;
24 24
 	}
25 25
 	public function setRoot($root) {
26
-		$this->root = $root;
26
+		$this->root=$root;
27 27
 		return $this;
28 28
 	}
29 29
 	public function getAttr() {
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 	 * @return HtmlNavElement
37 37
 	 */
38 38
 	public function setAttr($attr) {
39
-		$this->attr = $attr;
39
+		$this->attr=$attr;
40 40
 		return $this;
41 41
 	}
42 42
 
43 43
 	public function __call($method, $args) {
44
-		if(isset($this->$method) && is_callable($this->$method)) {
44
+		if (isset($this->$method) && is_callable($this->$method)) {
45 45
 			return call_user_func_array(
46 46
 					$this->$method,
47 47
 					$args
@@ -49,5 +49,5 @@  discard block
 block discarded – undo
49 49
 		}
50 50
 	}
51 51
 
52
-	abstract public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0);
52
+	abstract public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0);
53 53
 }
Please login to merge, or discard this patch.
Ajax/common/traits/JsUtilsAjaxTrait.php 2 patches
Braces   +32 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,8 +29,9 @@  discard block
 block discarded – undo
29 29
 		}
30 30
 		$retour.="$.".$method."(url,".$params.").done(function( data ) {\n";
31 31
 		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
32
-		if ($immediatly)
33
-			$this->jquery_code_for_compile[]=$retour;
32
+		if ($immediatly) {
33
+					$this->jquery_code_for_compile[]=$retour;
34
+		}
34 35
 			return $retour;
35 36
 	}
36 37
 
@@ -40,15 +41,17 @@  discard block
 block discarded – undo
40 41
 		$url=$this->_correctAjaxUrl($url);
41 42
 		$retour="url='".$url."';";
42 43
 		$slash="/";
43
-		if(JString::endswith($url, "/")===true)
44
-			$slash="";
44
+		if(JString::endswith($url, "/")===true) {
45
+					$slash="";
46
+		}
45 47
 			if(JString::isNotNull($attr)){
46
-				if ($attr==="value")
47
-					$retour.="url=url+'".$slash."'+$(this).val();\n";
48
-				elseif ($attr==="html")
49
-					$retour.="url=url+'".$slash."'+$(this).html();\n";
50
-				elseif($attr!==null && $attr!=="")
51
-					$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
48
+				if ($attr==="value") {
49
+									$retour.="url=url+'".$slash."'+$(this).val();\n";
50
+				} elseif ($attr==="html") {
51
+									$retour.="url=url+'".$slash."'+$(this).html();\n";
52
+				} elseif($attr!==null && $attr!=="") {
53
+									$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
54
+				}
52 55
 			}
53 56
 			return $retour;
54 57
 	}
@@ -58,13 +61,14 @@  discard block
 block discarded – undo
58 61
 		if ($responseElement!=="") {
59 62
 			if(isset($ajaxTransition)){
60 63
 				$call=$this->setAjaxDataCall($ajaxTransition);
61
-			}elseif(isset($this->ajaxTransition)){
64
+			} elseif(isset($this->ajaxTransition)){
62 65
 				$call=$this->ajaxTransition;
63 66
 			}
64
-			if(\is_callable($call))
65
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
66
-				else
67
-					$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
67
+			if(\is_callable($call)) {
68
+							$retour="\t".$call($responseElement,$jqueryDone).";\n";
69
+			} else {
70
+									$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
71
+				}
68 72
 		}
69 73
 		$retour.="\t".$jsCallback."\n";
70 74
 		return $retour;
@@ -78,8 +82,9 @@  discard block
 block discarded – undo
78 82
 	}
79 83
 
80 84
 	protected function _correctAjaxUrl($url) {
81
-		if ($url!=="/" && JString::endsWith($url, "/")===true)
82
-			$url=substr($url, 0, strlen($url)-1);
85
+		if ($url!=="/" && JString::endsWith($url, "/")===true) {
86
+					$url=substr($url, 0, strlen($url)-1);
87
+		}
83 88
 			if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
84 89
 				$url=$this->getUrl($url);
85 90
 			}
@@ -159,8 +164,9 @@  discard block
 block discarded – undo
159 164
 				$retour.="\t".$jsCallback."\n".
160 165
 						"\t$(document).trigger('jsonReady',[data]);\n".
161 166
 						"});\n";
162
-				if ($immediatly)
163
-					$this->jquery_code_for_compile[]=$retour;
167
+				if ($immediatly) {
168
+									$this->jquery_code_for_compile[]=$retour;
169
+				}
164 170
 		return $retour;
165 171
 	}
166 172
 
@@ -225,7 +231,7 @@  discard block
 block discarded – undo
225 231
 		if($context===null){
226 232
 			$parent="$('".$maskSelector."').parent()";
227 233
 			$newElm = "$('#'+newId)";
228
-		}else{
234
+		} else{
229 235
 			$parent=$context;
230 236
 			$newElm = $context.".find('#'+newId)";
231 237
 		}
@@ -238,8 +244,9 @@  discard block
 block discarded – undo
238 244
 		$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";
239 245
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
240 246
 		$retour.="\t".$jsCallback."\n"."});\n";
241
-		if ($immediatly)
242
-			$this->jquery_code_for_compile[]=$retour;
247
+		if ($immediatly) {
248
+					$this->jquery_code_for_compile[]=$retour;
249
+		}
243 250
 		return $retour;
244 251
 	}
245 252
 
@@ -430,8 +437,9 @@  discard block
 block discarded – undo
430 437
 			}});\n";
431 438
 			$retour.="$('#".$form."').submit();\n";
432 439
 		}
433
-		if ($immediatly)
434
-			$this->jquery_code_for_compile[]=$retour;
440
+		if ($immediatly) {
441
+					$this->jquery_code_for_compile[]=$retour;
442
+		}
435 443
 		return $retour;
436 444
 	}
437 445
 
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -16,19 +16,19 @@  discard block
 block discarded – undo
16 16
 	protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>';
17 17
 
18 18
 	abstract public function getUrl($url);
19
-	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
19
+	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true);
20 20
 
21
-	protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
22
-		if(JString::isNull($params)){$params="{}";}
21
+	protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
22
+		if (JString::isNull($params)) {$params="{}"; }
23 23
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
24 24
 		$retour=$this->_getAjaxUrl($url, $attr);
25 25
 		$responseElement=$this->_getResponseElement($responseElement);
26 26
 		$retour.="var self=this;\n";
27
-		if($hasLoader===true){
27
+		if ($hasLoader===true) {
28 28
 			$this->addLoading($retour, $responseElement);
29 29
 		}
30 30
 		$retour.="$.".$method."(url,".$params.").done(function( data ) {\n";
31
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
31
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n";
32 32
 		if ($immediatly)
33 33
 			$this->jquery_code_for_compile[]=$retour;
34 34
 			return $retour;
@@ -36,33 +36,33 @@  discard block
 block discarded – undo
36 36
 
37 37
 
38 38
 
39
-	protected function _getAjaxUrl($url,$attr){
39
+	protected function _getAjaxUrl($url, $attr) {
40 40
 		$url=$this->_correctAjaxUrl($url);
41 41
 		$retour="url='".$url."';";
42 42
 		$slash="/";
43
-		if(JString::endswith($url, "/")===true)
43
+		if (JString::endswith($url, "/")===true)
44 44
 			$slash="";
45
-			if(JString::isNotNull($attr)){
45
+			if (JString::isNotNull($attr)) {
46 46
 				if ($attr==="value")
47 47
 					$retour.="url=url+'".$slash."'+$(this).val();\n";
48 48
 				elseif ($attr==="html")
49 49
 					$retour.="url=url+'".$slash."'+$(this).html();\n";
50
-				elseif($attr!==null && $attr!=="")
50
+				elseif ($attr!==null && $attr!=="")
51 51
 					$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
52 52
 			}
53 53
 			return $retour;
54 54
 	}
55 55
 
56
-	protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){
57
-		$retour="";$call=null;
56
+	protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) {
57
+		$retour=""; $call=null;
58 58
 		if ($responseElement!=="") {
59
-			if(isset($ajaxTransition)){
59
+			if (isset($ajaxTransition)) {
60 60
 				$call=$this->setAjaxDataCall($ajaxTransition);
61
-			}elseif(isset($this->ajaxTransition)){
61
+			}elseif (isset($this->ajaxTransition)) {
62 62
 				$call=$this->ajaxTransition;
63 63
 			}
64
-			if(\is_callable($call))
65
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
64
+			if (\is_callable($call))
65
+				$retour="\t".$call($responseElement, $jqueryDone).";\n";
66 66
 				else
67 67
 					$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
68 68
 		}
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		return $retour;
71 71
 	}
72 72
 
73
-	protected function _getResponseElement($responseElement){
73
+	protected function _getResponseElement($responseElement) {
74 74
 		if ($responseElement!=="") {
75 75
 			$responseElement=Javascript::prep_value($responseElement);
76 76
 		}
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	protected function _correctAjaxUrl($url) {
81 81
 		if ($url!=="/" && JString::endsWith($url, "/")===true)
82 82
 			$url=substr($url, 0, strlen($url)-1);
83
-			if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
83
+			if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) {
84 84
 				$url=$this->getUrl($url);
85 85
 			}
86 86
 			return $url;
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 		$retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n";
99 99
 	}
100 100
 
101
-	protected function setAjaxDataCall($params){
101
+	protected function setAjaxDataCall($params) {
102 102
 		$result=null;
103
-		if(!\is_callable($params)){
104
-			$result=function ($responseElement,$jqueryDone="html") use($params){
105
-				return AjaxTransition::{$params}($responseElement,$jqueryDone);
103
+		if (!\is_callable($params)) {
104
+			$result=function($responseElement, $jqueryDone="html") use($params){
105
+				return AjaxTransition::{$params}($responseElement, $jqueryDone);
106 106
 			};
107 107
 		}
108 108
 		return $result;
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
123 123
 	 * @param string|callable $ajaxTransition
124 124
 	 */
125
-	private function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
126
-		return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly);
125
+	private function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
126
+		return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly);
127 127
 	}
128 128
 
129 129
 	/**
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
137 137
 	 * @param string|callable $ajaxTransition
138 138
 	 */
139
-	public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
140
-		return $this->_get($url,$params,$responseElement,$jsCallback,null,$hasLoader,$jqueryDone,$ajaxTransition,true);
139
+	public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
140
+		return $this->_get($url, $params, $responseElement, $jsCallback, null, $hasLoader, $jqueryDone, $ajaxTransition, true);
141 141
 	}
142 142
 
143 143
 	/**
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
152 152
 	 * @param string|callable $ajaxTransition
153 153
 	 */
154
-	public function ajax($method,$url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
154
+	public function ajax($method, $url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
155 155
 		$method=\strtolower($method);
156
-		return $this->_ajax($method,$url,$params,$responseElement,$jsCallback,null,$hasLoader,$jqueryDone,$ajaxTransition,true);
156
+		return $this->_ajax($method, $url, $params, $responseElement, $jsCallback, null, $hasLoader, $jqueryDone, $ajaxTransition, true);
157 157
 	}
158 158
 
159 159
 	/**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * @param string $context
167 167
 	 * @param boolean $immediatly
168 168
 	 */
169
-	private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) {
169
+	private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) {
170 170
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
171 171
 		$retour=$this->_getAjaxUrl($url, $attr);
172 172
 		$retour.="$.{$method}(url,".$params.").done(function( data ) {\n";
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 	 * @param string $context
190 190
 	 * @param boolean $immediatly
191 191
 	 */
192
-	public function json($url, $method="get", $params="{}", $jsCallback=NULL,$context="document",$immediatly=false) {
193
-		return $this->_json($url,$method,$params,$jsCallback,NULL,$context,$immediatly);
192
+	public function json($url, $method="get", $params="{}", $jsCallback=NULL, $context="document", $immediatly=false) {
193
+		return $this->_json($url, $method, $params, $jsCallback, NULL, $context, $immediatly);
194 194
 	}
195 195
 
196 196
 	/**
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @param string $url the request address
201 201
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
202 202
 	 */
203
-	public function jsonOn($event,$element, $url,$parameters=array()) {
203
+	public function jsonOn($event, $element, $url, $parameters=array()) {
204 204
 		$preventDefault=true;
205 205
 		$stopPropagation=true;
206 206
 		$jsCallback=null;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 		$params="{}";
211 211
 		$immediatly=true;
212 212
 		extract($parameters);
213
-		return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly);
213
+		return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly);
214 214
 	}
215 215
 
216 216
 	/**
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	 * @param string $jsCallback javascript code to execute after the request
222 222
 	 * @param string $context jquery DOM element, array container.
223 223
 	 */
224
-	public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL,$context=NULL) {
225
-		return $this->json($url, $method, $params, $jsCallback, $context,false);
224
+	public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL, $context=NULL) {
225
+		return $this->json($url, $method, $params, $jsCallback, $context, false);
226 226
 	}
227 227
 
228 228
 	/**
@@ -235,22 +235,22 @@  discard block
 block discarded – undo
235 235
 	 * @param string $rowClass the css class for the new element
236 236
 	 * @param boolean $immediatly
237 237
 	 */
238
-	private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$attr="id",$immediatly=false) {
238
+	private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $attr="id", $immediatly=false) {
239 239
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
240 240
 		$retour=$this->_getAjaxUrl($url, $attr);
241
-		if($context===null){
241
+		if ($context===null) {
242 242
 			$parent="$('".$maskSelector."').parent()";
243
-			$newElm = "$('#'+newId)";
244
-		}else{
243
+			$newElm="$('#'+newId)";
244
+		} else {
245 245
 			$parent=$context;
246
-			$newElm = $context.".find('#'+newId)";
246
+			$newElm=$context.".find('#'+newId)";
247 247
 		}
248 248
 		$appendTo="\t\tnewElm.appendTo(".$parent.");\n";
249 249
 		$retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n";
250 250
 		$retour.=$parent.".find('._json').remove();";
251 251
 		$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();
252 252
 		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";
253
-		$retour.= $appendTo;
253
+		$retour.=$appendTo;
254 254
 		$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";
255 255
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
256 256
 		$retour.="\t".$jsCallback."\n"."});\n";
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 	 * @param string $context jquery DOM element, array container.
270 270
 	 * @param boolean $immediatly
271 271
 	 */
272
-	public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$immediatly=false) {
273
-		return $this->_jsonArray($maskSelector, $url,$method,$params,$jsCallback,$rowClass,$context,NULL,$immediatly);
272
+	public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $immediatly=false) {
273
+		return $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, NULL, $immediatly);
274 274
 	}
275 275
 
276 276
 	/**
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
 	 * @param string $rowClass the css class for the new element
284 284
 	 * @param string $context jquery DOM element, array container.
285 285
 	 */
286
-	public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL) {
287
-		return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback,$rowClass,$context,false);
286
+	public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL) {
287
+		return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, false);
288 288
 	}
289 289
 
290 290
 	/**
@@ -294,18 +294,18 @@  discard block
 block discarded – undo
294 294
 	 * @param string $url the request url
295 295
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true)
296 296
 	 */
297
-	public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) {
297
+	public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) {
298 298
 		$preventDefault=true;
299 299
 		$stopPropagation=true;
300 300
 		$jsCallback=null;
301 301
 		$attr="id";
302 302
 		$method="get";
303
-		$context = null;
303
+		$context=null;
304 304
 		$params="{}";
305 305
 		$immediatly=true;
306 306
 		$rowClass="_json";
307 307
 		extract($parameters);
308
-		return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $rowClass, $context,$attr), $event, $preventDefault, $stopPropagation,$immediatly);
308
+		return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, $attr), $event, $preventDefault, $stopPropagation, $immediatly);
309 309
 	}
310 310
 
311 311
 	/**
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
320 320
 	 * @param string|callable $ajaxTransition
321 321
 	 */
322
-	public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id",$jqueryDone="html",$ajaxTransition=null) {
323
-		return $this->_get($url, $params,$responseElement,$jsCallback,$attr,false,$jqueryDone,$ajaxTransition);
322
+	public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $jqueryDone="html", $ajaxTransition=null) {
323
+		return $this->_get($url, $params, $responseElement, $jsCallback, $attr, false, $jqueryDone, $ajaxTransition);
324 324
 	}
325 325
 
326 326
 	/**
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 		$ajaxTransition=null;
344 344
 		$params="{}";
345 345
 		extract($parameters);
346
-		return $this->_add_event($element, $this->_get($url, $params,$responseElement,$jsCallback,$attr, $hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
346
+		return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
347 347
 	}
348 348
 
349 349
 	/**
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 		$ajaxTransition=null;
368 368
 		$params="{}";
369 369
 		extract($parameters);
370
-		return $this->_add_event($element, $this->_ajax($method,$url, $params,$responseElement,$jsCallback,$attr, $hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
370
+		return $this->_add_event($element, $this->_ajax($method, $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
371 371
 	}
372 372
 
373 373
 	/**
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 		return $this->getOn("click", $element, $url, $responseElement, $parameters);
395 395
 	}
396 396
 
397
-	private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
398
-		return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly);
397
+	private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
398
+		return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly);
399 399
 	}
400 400
 
401 401
 	/**
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
409 409
 	 * @param string|callable $ajaxTransition
410 410
 	 */
411
-	public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
412
-		return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true);
411
+	public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
412
+		return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true);
413 413
 	}
414 414
 
415 415
 	/**
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
425 425
 	 * @param string|callable $ajaxTransition
426 426
 	 */
427
-	public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
428
-		return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false);
427
+	public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
428
+		return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false);
429 429
 	}
430 430
 
431 431
 	/**
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 		$jqueryDone="html";
449 449
 		$ajaxTransition=null;
450 450
 		extract($parameters);
451
-		return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
451
+		return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
452 452
 	}
453 453
 
454 454
 	/**
@@ -464,20 +464,20 @@  discard block
 block discarded – undo
464 464
 		return $this->postOn("click", $element, $url, $params, $responseElement, $parameters);
465 465
 	}
466 466
 
467
-	private function _postForm($url, $form, $responseElement, $params=null,$validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
467
+	private function _postForm($url, $form, $responseElement, $params=null, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
468 468
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
469 469
 		$retour=$this->_getAjaxUrl($url, $attr);
470 470
 		$retour.="\nvar params=$('#".$form."').serialize();\n";
471
-		if(isset($params)){
471
+		if (isset($params)) {
472 472
 			$retour.="params+='&'+$.param(".$params.");\n";
473 473
 		}
474 474
 		$responseElement=$this->_getResponseElement($responseElement);
475 475
 		$retour.="var self=this;\n";
476
-		if($hasLoader===true){
476
+		if ($hasLoader===true) {
477 477
 			$this->addLoading($retour, $responseElement);
478 478
 		}
479 479
 		$retour.="$.post(url,params).done(function( data ) {\n";
480
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
480
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n";
481 481
 
482 482
 		if ($validation) {
483 483
 			$retour="$('#".$form."').validate({submitHandler: function(form) {
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
502 502
 	 * @param string|callable $ajaxTransition
503 503
 	 */
504
-	public function postForm($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
505
-		return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true);
504
+	public function postForm($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
505
+		return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true);
506 506
 	}
507 507
 
508 508
 	/**
@@ -519,8 +519,8 @@  discard block
 block discarded – undo
519 519
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
520 520
 	 * @param string|callable $ajaxTransition
521 521
 	 */
522
-	public function postFormDeferred($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
523
-		return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false);
522
+	public function postFormDeferred($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
523
+		return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false);
524 524
 	}
525 525
 
526 526
 	/**
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 		$jqueryDone="html";
546 546
 		$ajaxTransition=null;
547 547
 		extract($parameters);
548
-		return $this->_add_event($element, $this->_postForm($url, $form, $responseElement,$params, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
548
+		return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
549 549
 	}
550 550
 
551 551
 	/**
Please login to merge, or discard this patch.
Ajax/common/traits/JsUtilsActionsTrait.php 3 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 trait JsUtilsActionsTrait {
12 12
 
13
-	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
13
+	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true);
14 14
 	/**
15 15
 	 * show or hide with effect
16 16
 	 *
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @param boolean $immediatly defers the execution if set to false
22 22
 	 * @return string
23 23
 	 */
24
-	protected function _showHideWithEffect($action,$element='this', $speed='', $callback='', $immediatly=false) {
24
+	protected function _showHideWithEffect($action, $element='this', $speed='', $callback='', $immediatly=false) {
25 25
 		$element=Javascript::prep_element($element);
26 26
 		$speed=$this->_validate_speed($speed);
27 27
 		if ($callback!='') {
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 	 * @return string
39 39
 	 */
40 40
 	private function _validate_speed($speed) {
41
-		if (in_array($speed, array (
42
-				'slow','normal','fast'
41
+		if (in_array($speed, array(
42
+				'slow', 'normal', 'fast'
43 43
 		))) {
44 44
 			$speed='"'.$speed.'"';
45 45
 		} elseif (preg_match("/[^0-9]/", $speed)) {
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @param string $param
57 57
 	 * @param boolean $immediatly delayed if false
58 58
 	 */
59
-	public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) {
59
+	public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) {
60 60
 		$element=Javascript::prep_element($element);
61 61
 		if (isset($param)) {
62 62
 			$param=Javascript::prep_value($param);
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param boolean $immediatly delayed if false
77 77
 	 * @return string
78 78
 	 */
79
-	public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) {
79
+	public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) {
80 80
 		$to=Javascript::prep_element($to);
81 81
 		$element=Javascript::prep_element($element);
82 82
 		$str="$({$to}).{$jQueryCall}({$element});";
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @return string
94 94
 	 */
95 95
 	public function addClass($element='this', $class='', $immediatly=false) {
96
-		return $this->_genericCallValue('addClass',$element, $class, $immediatly);
96
+		return $this->_genericCallValue('addClass', $element, $class, $immediatly);
97 97
 	}
98 98
 
99 99
 	/**
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	 * @param boolean $immediatly defers the execution if set to false
104 104
 	 * @return string
105 105
 	 */
106
-	public function after($to, $element, $immediatly=false){
107
-		return $this->_genericCallElement('after',$to, $element, $immediatly);
106
+	public function after($to, $element, $immediatly=false) {
107
+		return $this->_genericCallElement('after', $to, $element, $immediatly);
108 108
 	}
109 109
 
110 110
 	/**
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * @param boolean $immediatly defers the execution if set to false
115 115
 	 * @return string
116 116
 	 */
117
-	public function before($to, $element, $immediatly=false){
118
-		return $this->_genericCallElement('before',$to, $element, $immediatly);
117
+	public function before($to, $element, $immediatly=false) {
118
+		return $this->_genericCallElement('before', $to, $element, $immediatly);
119 119
 	}
120 120
 
121 121
 	/**
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
 	 * @param string $value
144 144
 	 * @param boolean $immediatly defers the execution if set to false
145 145
 	 */
146
-	public function val($element='this',$value='',$immediatly=false){
147
-		return $this->_genericCallValue('val',$element,$value,$immediatly);
146
+	public function val($element='this', $value='', $immediatly=false) {
147
+		return $this->_genericCallValue('val', $element, $value, $immediatly);
148 148
 	}
149 149
 
150 150
 	/**
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 * @param boolean $immediatly defers the execution if set to false
155 155
 	 */
156 156
 	public function html($element='this', $value='', $immediatly=false) {
157
-		return $this->_genericCallValue('html',$element, $value, $immediatly);
157
+		return $this->_genericCallValue('html', $element, $value, $immediatly);
158 158
 	}
159 159
 
160 160
 	/**
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
 		$animations="\t\t\t";
175 175
 		if (\is_array($params)) {
176
-			foreach ( $params as $param => $value ) {
176
+			foreach ($params as $param => $value) {
177 177
 				$animations.=$param.': \''.$value.'\', ';
178 178
 			}
179 179
 		}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 * @return string
203 203
 	 */
204 204
 	public function append($to, $element, $immediatly=false) {
205
-		return $this->_genericCallElement('append',$to, $element, $immediatly);
205
+		return $this->_genericCallElement('append', $to, $element, $immediatly);
206 206
 	}
207 207
 
208 208
 	/**
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	 * @return string
214 214
 	 */
215 215
 	public function prepend($to, $element, $immediatly=false) {
216
-		return $this->_genericCallElement('prepend',$to, $element, $immediatly);
216
+		return $this->_genericCallElement('prepend', $to, $element, $immediatly);
217 217
 	}
218 218
 
219 219
 	/**
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 * @return string
227 227
 	 */
228 228
 	public function fadeIn($element='this', $speed='', $callback='', $immediatly=false) {
229
-		return $this->_showHideWithEffect("fadeIn",$element,$speed,$callback,$immediatly);
229
+		return $this->_showHideWithEffect("fadeIn", $element, $speed, $callback, $immediatly);
230 230
 	}
231 231
 
232 232
 	/**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 * @return string
240 240
 	 */
241 241
 	public function fadeOut($element='this', $speed='', $callback='', $immediatly=false) {
242
-		return $this->_showHideWithEffect("fadeOut",$element,$speed,$callback,$immediatly);
242
+		return $this->_showHideWithEffect("fadeOut", $element, $speed, $callback, $immediatly);
243 243
 	}
244 244
 
245 245
 	/**
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	 * @return string
253 253
 	 */
254 254
 	public function slideUp($element='this', $speed='', $callback='', $immediatly=false) {
255
-		return $this->_showHideWithEffect("slideUp",$element,$speed,$callback,$immediatly);
255
+		return $this->_showHideWithEffect("slideUp", $element, $speed, $callback, $immediatly);
256 256
 	}
257 257
 
258 258
 	/**
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	 * @return string
265 265
 	 */
266 266
 	public function removeClass($element='this', $class='', $immediatly=false) {
267
-		return $this->_genericCall('removeClass',$element, $class, $immediatly);
267
+		return $this->_genericCall('removeClass', $element, $class, $immediatly);
268 268
 	}
269 269
 
270 270
 	/**
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 * @return string
278 278
 	 */
279 279
 	public function slideDown($element='this', $speed='', $callback='', $immediatly=false) {
280
-		return $this->_showHideWithEffect("slideDown",$element,$speed,$callback,$immediatly);
280
+		return $this->_showHideWithEffect("slideDown", $element, $speed, $callback, $immediatly);
281 281
 	}
282 282
 
283 283
 	/**
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * @return string
291 291
 	 */
292 292
 	public function slideToggle($element='this', $speed='', $callback='', $immediatly=false) {
293
-		return $this->_showHideWithEffect("slideToggle",$element,$speed,$callback,$immediatly);
293
+		return $this->_showHideWithEffect("slideToggle", $element, $speed, $callback, $immediatly);
294 294
 	}
295 295
 
296 296
 	/**
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	 * @return string
304 304
 	 */
305 305
 	public function hide($element='this', $speed='', $callback='', $immediatly=false) {
306
-		return $this->_showHideWithEffect("hide",$element,$speed,$callback,$immediatly);
306
+		return $this->_showHideWithEffect("hide", $element, $speed, $callback, $immediatly);
307 307
 	}
308 308
 
309 309
 	/**
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * @return string
317 317
 	 */
318 318
 	public function toggle($element='this', $speed='', $callback='', $immediatly=false) {
319
-		return $this->_showHideWithEffect("toggle",$element,$speed,$callback,$immediatly);
319
+		return $this->_showHideWithEffect("toggle", $element, $speed, $callback, $immediatly);
320 320
 	}
321 321
 
322 322
 	/**
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 	 * @return string
328 328
 	 */
329 329
 	public function toggleClass($element='this', $class='', $immediatly=false) {
330
-		return $this->_genericCallValue('toggleClass',$element, $class, $immediatly);
330
+		return $this->_genericCallValue('toggleClass', $element, $class, $immediatly);
331 331
 	}
332 332
 
333 333
 	/**
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	 * @return string
356 356
 	 */
357 357
 	public function show($element='this', $speed='', $callback='', $immediatly=false) {
358
-		return $this->_showHideWithEffect("show",$element,$speed,$callback,$immediatly);
358
+		return $this->_showHideWithEffect("show", $element, $speed, $callback, $immediatly);
359 359
 	}
360 360
 
361 361
 	/**
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 	 */
368 368
 	public function sortable($element, $options=array()) {
369 369
 		if (count($options)>0) {
370
-			$sort_options=array ();
371
-			foreach ( $options as $k => $v ) {
370
+			$sort_options=array();
371
+			foreach ($options as $k => $v) {
372 372
 				$sort_options[]="\n\t\t".$k.': '.$v."";
373 373
 			}
374 374
 			$sort_options=implode(",", $sort_options);
@@ -465,8 +465,8 @@  discard block
 block discarded – undo
465 465
 	 * @param boolean $immediatly
466 466
 	 * @return string
467 467
 	 */
468
-	private function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="",$immediatly=true) {
469
-		return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation,$immediatly);
468
+	private function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="", $immediatly=true) {
469
+		return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation, $immediatly);
470 470
 	}
471 471
 
472 472
 	/**
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 		$preventDefault=false;
485 485
 		$immediatly=true;
486 486
 		extract($parameters);
487
-		return $this->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback,$immediatly);
487
+		return $this->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback, $immediatly);
488 488
 	}
489 489
 
490 490
 	/**
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 		$preventDefault=false;
514 514
 		$immediatly=true;
515 515
 		extract($parameters);
516
-		$script=$this->_add_event($element, $this->exec($js), $event, $preventDefault, $stopPropagation,$immediatly);
516
+		$script=$this->_add_event($element, $this->exec($js), $event, $preventDefault, $stopPropagation, $immediatly);
517 517
 		return $script;
518 518
 	}
519 519
 }
Please login to merge, or discard this patch.
Braces   +36 added lines, -24 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@  discard block
 block discarded – undo
28 28
 			$callback=", function(){\n{$callback}\n}";
29 29
 		}
30 30
 		$str="$({$element}).{$action}({$speed}{$callback});";
31
-		if ($immediatly)
32
-			$this->jquery_code_for_compile[]=$str;
31
+		if ($immediatly) {
32
+					$this->jquery_code_for_compile[]=$str;
33
+		}
33 34
 			return $str;
34 35
 	}
35 36
 	/**
@@ -61,10 +62,12 @@  discard block
 block discarded – undo
61 62
 		if (isset($param)) {
62 63
 			$param=Javascript::prep_value($param);
63 64
 			$str="$({$element}).{$jQueryCall}({$param});";
64
-		} else
65
-			$str="$({$element}).{$jQueryCall}();";
66
-		if ($immediatly)
67
-			$this->jquery_code_for_compile[]=$str;
65
+		} else {
66
+					$str="$({$element}).{$jQueryCall}();";
67
+		}
68
+		if ($immediatly) {
69
+					$this->jquery_code_for_compile[]=$str;
70
+		}
68 71
 		return $str;
69 72
 	}
70 73
 
@@ -80,8 +83,9 @@  discard block
 block discarded – undo
80 83
 		$to=Javascript::prep_element($to);
81 84
 		$element=Javascript::prep_element($element);
82 85
 		$str="$({$to}).{$jQueryCall}({$element});";
83
-		if ($immediatly)
84
-			$this->jquery_code_for_compile[]=$str;
86
+		if ($immediatly) {
87
+					$this->jquery_code_for_compile[]=$str;
88
+		}
85 89
 		return $str;
86 90
 	}
87 91
 	/**
@@ -130,10 +134,12 @@  discard block
 block discarded – undo
130 134
 		if (isset($value)) {
131 135
 			$value=Javascript::prep_value($value);
132 136
 			$str="$({$element}).attr(\"$attributeName\",{$value});";
133
-		} else
134
-			$str="$({$element}).attr(\"$attributeName\");";
135
-		if ($immediatly)
136
-			$this->jquery_code_for_compile[]=$str;
137
+		} else {
138
+					$str="$({$element}).attr(\"$attributeName\");";
139
+		}
140
+		if ($immediatly) {
141
+					$this->jquery_code_for_compile[]=$str;
142
+		}
137 143
 		return $str;
138 144
 	}
139 145
 
@@ -189,8 +195,9 @@  discard block
 block discarded – undo
189 195
 
190 196
 		$str="$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");";
191 197
 
192
-		if ($immediatly)
193
-			$this->jquery_code_for_compile[]=$str;
198
+		if ($immediatly) {
199
+					$this->jquery_code_for_compile[]=$str;
200
+		}
194 201
 		return $str;
195 202
 	}
196 203
 
@@ -340,8 +347,9 @@  discard block
 block discarded – undo
340 347
 		$element=Javascript::prep_element($element);
341 348
 		$str="$({$element}).trigger(\"$event\");";
342 349
 
343
-		if ($immediatly)
344
-			$this->jquery_code_for_compile[]=$str;
350
+		if ($immediatly) {
351
+					$this->jquery_code_for_compile[]=$str;
352
+		}
345 353
 		return $str;
346 354
 	}
347 355
 
@@ -403,8 +411,9 @@  discard block
 block discarded – undo
403 411
 			$str.="else{".$jsCodeIfFalse."}";
404 412
 		}
405 413
 
406
-		if ($immediatly)
407
-			$this->jquery_code_for_compile[]=$str;
414
+		if ($immediatly) {
415
+					$this->jquery_code_for_compile[]=$str;
416
+		}
408 417
 		return $str;
409 418
 	}
410 419
 
@@ -420,11 +429,13 @@  discard block
 block discarded – undo
420 429
 	private function _doJQuery($element, $jqueryCall, $param="", $jsCallback="", $immediatly=false) {
421 430
 		$param=Javascript::prep_value($param);
422 431
 		$callback="";
423
-		if ($jsCallback!="")
424
-			$callback=", function(event){\n{$jsCallback}\n}";
432
+		if ($jsCallback!="") {
433
+					$callback=", function(event){\n{$jsCallback}\n}";
434
+		}
425 435
 			$script="$(".Javascript::prep_element($element).").".$jqueryCall."(".$param.$callback.");\n";
426
-			if ($immediatly)
427
-				$this->jquery_code_for_compile[]=$script;
436
+			if ($immediatly) {
437
+							$this->jquery_code_for_compile[]=$script;
438
+			}
428 439
 				return $script;
429 440
 	}
430 441
 
@@ -495,8 +506,9 @@  discard block
 block discarded – undo
495 506
 	 */
496 507
 	public function exec($js, $immediatly=false) {
497 508
 		$script=$js."\n";
498
-		if ($immediatly)
499
-			$this->jquery_code_for_compile[]=$script;
509
+		if ($immediatly) {
510
+					$this->jquery_code_for_compile[]=$script;
511
+		}
500 512
 		return $script;
501 513
 	}
502 514
 
Please login to merge, or discard this patch.
Doc Comments   +10 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,6 +11,11 @@  discard block
 block discarded – undo
11 11
  */
12 12
 trait JsUtilsActionsTrait {
13 13
 
14
+	/**
15
+	 * @param string $element
16
+	 * @param string $js
17
+	 * @param string $event
18
+	 */
14 19
 	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
15 20
 	/**
16 21
 	 * show or hide with effect
@@ -35,7 +40,7 @@  discard block
 block discarded – undo
35 40
 	}
36 41
 	/**
37 42
 	 * Ensures the speed parameter is valid for jQuery
38
-	 * @param string|int $speed
43
+	 * @param string $speed
39 44
 	 * @return string
40 45
 	 */
41 46
 	private function _validate_speed($speed) {
@@ -364,7 +369,7 @@  discard block
 block discarded – undo
364 369
 	 *
365 370
 	 * @param string $element
366 371
 	 * @param array $options
367
-	 * @return void
372
+	 * @return string
368 373
 	 */
369 374
 	public function sortable($element, $options=array()) {
370 375
 		if (count($options)>0) {
@@ -435,7 +440,7 @@  discard block
 block discarded – undo
435 440
 	 * @param string $jqueryCall the JQuery callback
436 441
 	 * @param mixed $param array or string parameters
437 442
 	 * @param string $jsCallback javascript code to execute after the jquery call
438
-	 * @return mixed
443
+	 * @return string
439 444
 	 */
440 445
 	public function doJQuery($element, $jqueryCall, $param="", $jsCallback="") {
441 446
 		return $this->_doJQuery($element, $jqueryCall, $param, $jsCallback, true);
@@ -447,7 +452,7 @@  discard block
 block discarded – undo
447 452
 	 * @param string $jqueryCall the JQuery callback
448 453
 	 * @param mixed $param array or string parameters
449 454
 	 * @param string $jsCallback javascript code to execute after the jquery call
450
-	 * @return mixed
455
+	 * @return string
451 456
 	 */
452 457
 	public function doJQueryDeferred($element, $jqueryCall, $param="", $jsCallback="") {
453 458
 		return $this->_doJQuery($element, $jqueryCall, $param, $jsCallback, false);
@@ -459,7 +464,7 @@  discard block
 block discarded – undo
459 464
 	 * @param string $element
460 465
 	 * @param string $elementToModify
461 466
 	 * @param string $jqueryCall
462
-	 * @param string|array $param
467
+	 * @param string $param
463 468
 	 * @param boolean $preventDefault
464 469
 	 * @param boolean $stopPropagation
465 470
 	 * @param string $jsCallback javascript code to execute after the jquery call
@@ -504,7 +509,6 @@  discard block
 block discarded – undo
504 509
 	/**
505 510
 	 * Executes the code $js
506 511
 	 * @param string $js Code to execute
507
-	 * @param boolean $immediatly delayed if false
508 512
 	 * @return String
509 513
 	 */
510 514
 	public function execAtLast($js) {
Please login to merge, or discard this patch.
Ajax/common/components/SimpleComponent.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -18,27 +18,27 @@  discard block
 block discarded – undo
18 18
 
19 19
 	public function __construct(JsUtils $js=NULL) {
20 20
 		parent::__construct($js);
21
-		$this->events=array ();
21
+		$this->events=array();
22 22
 	}
23 23
 
24 24
 	protected function compileEvents() {
25
-		foreach ( $this->events as $event => $jsCode ) {
25
+		foreach ($this->events as $event => $jsCode) {
26 26
 			$itemSelector=JString::getValueBetween($event);
27
-			if($event=="execute"){
27
+			if ($event=="execute") {
28 28
 				$this->jquery_code_for_compile []=$jsCode;
29
-			}else if($event=="beforeExecute"){
29
+			} else if ($event=="beforeExecute") {
30 30
 				\array_unshift($this->jquery_code_for_compile, $jsCode);
31
-			}else{
31
+			} else {
32 32
 				$selector=$this->_createSelector($itemSelector, $this->attachTo);
33 33
 				$this->jquery_code_for_compile []="$( \"".$selector."\" ).on(\"".$event."\" , function( event, data ) {".$jsCode."});";
34 34
 			}
35 35
 		}
36 36
 	}
37 37
 
38
-	protected function _createSelector($itemSelector,$selector){
39
-		if(!isset($itemSelector))
38
+	protected function _createSelector($itemSelector, $selector) {
39
+		if (!isset($itemSelector))
40 40
 			$itemSelector=$this->itemSelector;
41
-		if(isset($itemSelector) && $itemSelector!=="")
41
+		if (isset($itemSelector) && $itemSelector!=="")
42 42
 			$selector.=" ".$itemSelector;
43 43
 		return $selector;
44 44
 	}
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		$result=implode("\n", $this->jquery_code_for_compile);
48 48
 		$result=str_ireplace("\"%", "", $result);
49 49
 		$result=str_ireplace("%\"", "", $result);
50
-		$result=str_replace(array (
50
+		$result=str_replace(array(
51 51
 				"\\n",
52 52
 				"\\r",
53 53
 				"\\t"
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
 	public function getScript() {
59 59
 		$allParams=$this->params;
60
-		$this->jquery_code_for_compile=array ();
60
+		$this->jquery_code_for_compile=array();
61 61
 		$this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).");";
62 62
 		$this->compileEvents();
63 63
 		return $this->compileJQueryCode();
Please login to merge, or discard this patch.
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 			$itemSelector=JString::getValueBetween($event);
27 27
 			if($event=="execute"){
28 28
 				$this->jquery_code_for_compile []=$jsCode;
29
-			}else if($event=="beforeExecute"){
29
+			} else if($event=="beforeExecute"){
30 30
 				\array_unshift($this->jquery_code_for_compile, $jsCode);
31
-			}else{
31
+			} else{
32 32
 				$selector=$this->_createSelector($itemSelector, $this->attachTo);
33 33
 				$this->jquery_code_for_compile []="$( \"".$selector."\" ).on(\"".$event."\" , function( event, data ) {".$jsCode."});";
34 34
 			}
@@ -36,10 +36,12 @@  discard block
 block discarded – undo
36 36
 	}
37 37
 
38 38
 	protected function _createSelector($itemSelector,$selector){
39
-		if(!isset($itemSelector))
40
-			$itemSelector=$this->itemSelector;
41
-		if(isset($itemSelector) && $itemSelector!=="")
42
-			$selector.=" ".$itemSelector;
39
+		if(!isset($itemSelector)) {
40
+					$itemSelector=$this->itemSelector;
41
+		}
42
+		if(isset($itemSelector) && $itemSelector!=="") {
43
+					$selector.=" ".$itemSelector;
44
+		}
43 45
 		return $selector;
44 46
 	}
45 47
 
@@ -82,8 +84,9 @@  discard block
 block discarded – undo
82 84
 
83 85
 	protected function setParamCtrl($key, $value, $typeCtrl) {
84 86
 		if (\is_array($typeCtrl)) {
85
-			if (array_search($value, $typeCtrl)===false)
86
-				throw new \Exception("La valeur passée a propriété `".$key."` pour le composant `".$this->uiName."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
87
+			if (array_search($value, $typeCtrl)===false) {
88
+							throw new \Exception("La valeur passée a propriété `".$key."` pour le composant `".$this->uiName."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
89
+			}
87 90
 		} else {
88 91
 			if (!$typeCtrl($value)) {
89 92
 				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key." au composant ".$this->uiName);
Please login to merge, or discard this patch.
Ajax/semantic/components/Sticky.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 		return $this->setParam("context", $value);
22 22
 	}
23 23
 
24
-	public function setOffset($offset=0){
24
+	public function setOffset($offset=0) {
25 25
 		return $this->setParam("offset", $offset);
26 26
 	}
27 27
 }
Please login to merge, or discard this patch.
Ajax/semantic/components/Checkbox.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 		$this->params["onUnchecked"]="%function(){".$value."}%";
21 21
 	}
22 22
 
23
-	public function setOnChange($value){
23
+	public function setOnChange($value) {
24 24
 		$this->params["onChange"]="%function(){".$value."}%";
25 25
 	}
26 26
 }
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlFormInput.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@
 block discarded – undo
8 8
 class HtmlFormInput extends HtmlFormField {
9 9
 	use TextFieldsTrait;
10 10
 
11
-	public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) {
12
-		if(!isset($placeholder) && $type==="text")
11
+	public function __construct($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) {
12
+		if (!isset($placeholder) && $type==="text")
13 13
 			$placeholder=$label;
14
-		parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label);
14
+		parent::__construct("field-".$identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label);
15 15
 		$this->_identifier=$identifier;
16 16
 	}
17 17
 
18
-	public function getDataField(){
19
-		$field= $this->getField();
20
-		if($field instanceof HtmlInput)
18
+	public function getDataField() {
19
+		$field=$this->getField();
20
+		if ($field instanceof HtmlInput)
21 21
 			$field=$field->getDataField();
22 22
 		return $field;
23 23
 	}
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,16 +9,18 @@
 block discarded – undo
9 9
 	use TextFieldsTrait;
10 10
 
11 11
 	public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) {
12
-		if(!isset($placeholder) && $type==="text")
13
-			$placeholder=$label;
12
+		if(!isset($placeholder) && $type==="text") {
13
+					$placeholder=$label;
14
+		}
14 15
 		parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label);
15 16
 		$this->_identifier=$identifier;
16 17
 	}
17 18
 
18 19
 	public function getDataField(){
19 20
 		$field= $this->getField();
20
-		if($field instanceof HtmlInput)
21
-			$field=$field->getDataField();
21
+		if($field instanceof HtmlInput) {
22
+					$field=$field->getDataField();
23
+		}
22 24
 		return $field;
23 25
 	}
24 26
 }
Please login to merge, or discard this patch.
Ajax/ui/components/Autocomplete.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @return $this
51 51
 	 */
52 52
 	public function setSource($source) {
53
-		$source=str_ireplace(array (
53
+		$source=str_ireplace(array(
54 54
 				"\"",
55 55
 				"'"
56 56
 		), "%quote%", $source);
Please login to merge, or discard this patch.
Ajax/semantic/html/base/traits/BaseTrait.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
  * @property HtmlSemDoubleElement $_self
16 16
  */
17 17
 trait BaseTrait {
18
-	protected $_variations=[ ];
19
-	protected $_states=[ ];
18
+	protected $_variations=[];
19
+	protected $_states=[];
20 20
 	protected $_baseClass;
21 21
 
22 22
 	abstract protected function setPropertyCtrl($name, $value, $typeCtrl);
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 
30 30
 	abstract public function setProperty($name, $value);
31 31
 
32
-	abstract public function addContent($content,$before=false);
32
+	abstract public function addContent($content, $before=false);
33 33
 
34 34
 	abstract public function onCreate($jsCode);
35 35
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		$this->_self->setProperty("class", $this->_self->getBaseClass());
51 51
 		if (\is_string($variations))
52 52
 			$variations=\explode(" ", $variations);
53
-		foreach ( $variations as $variation ) {
53
+		foreach ($variations as $variation) {
54 54
 			$this->_self->addVariation($variation);
55 55
 		}
56 56
 		return $this;
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	public function addVariations($variations=array()) {
65 65
 		if (\is_string($variations))
66 66
 			$variations=\explode(" ", $variations);
67
-		foreach ( $variations as $variation ) {
67
+		foreach ($variations as $variation) {
68 68
 			$this->_self->addVariation($variation);
69 69
 		}
70 70
 		return $this;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	public function addStates($states=array()) {
74 74
 		if (\is_string($states))
75 75
 			$states=\explode(" ", $states);
76
-		foreach ( $states as $state ) {
76
+		foreach ($states as $state) {
77 77
 			$this->_self->addState($state);
78 78
 		}
79 79
 		return $this;
@@ -83,17 +83,17 @@  discard block
 block discarded – undo
83 83
 		$this->_self->setProperty("class", $this->_self->getBaseClass());
84 84
 		if (\is_string($states))
85 85
 			$states=\explode(" ", $states);
86
-		foreach ( $states as $state ) {
86
+		foreach ($states as $state) {
87 87
 			$this->_self->addState($state);
88 88
 		}
89 89
 		return $this;
90 90
 	}
91 91
 
92 92
 	public function addIcon($icon, $before=true) {
93
-		return $this->_self->addContent(new HtmlIcon("icon-" . $this->_self->getIdentifier(), $icon), $before);
93
+		return $this->_self->addContent(new HtmlIcon("icon-".$this->_self->getIdentifier(), $icon), $before);
94 94
 	}
95 95
 
96
-	public function addSticky($context="body"){
96
+	public function addSticky($context="body") {
97 97
 		$this->_self->onCreate("$('#".$this->_self->getIdentifier()."').sticky({ context: '".$context."'});");
98 98
 		return $this;
99 99
 	}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @return HtmlSemDoubleElement
115 115
 	 */
116 116
 	public function setDisabled($disable=true) {
117
-		if($disable)
117
+		if ($disable)
118 118
 			$this->_self->addToProperty("class", "disabled");
119 119
 		return $this;
120 120
 	}
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 *
141 141
 	 * @return HtmlSemDoubleElement
142 142
 	 */
143
-	public function asHeader(){
143
+	public function asHeader() {
144 144
 		return $this->_self->addToProperty("class", "header");
145 145
 	}
146 146
 
@@ -148,15 +148,15 @@  discard block
 block discarded – undo
148 148
 	 * show it is currently the active user selection
149 149
 	 * @return HtmlSemDoubleElement
150 150
 	 */
151
-	public function setActive($value=true){
152
-		if($value)
151
+	public function setActive($value=true) {
152
+		if ($value)
153 153
 			$this->_self->addToProperty("class", "active");
154 154
 		return $this;
155 155
 	}
156 156
 
157
-	public function setAttached($value=true){
158
-		if($value)
159
-			$this->_self->addToPropertyCtrl("class", "attached", array ("attached" ));
157
+	public function setAttached($value=true) {
158
+		if ($value)
159
+			$this->_self->addToPropertyCtrl("class", "attached", array("attached"));
160 160
 		return $this;
161 161
 	}
162 162
 
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
 	 * can be formatted to appear on dark backgrounds
165 165
 	 */
166 166
 	public function setInverted($recursive=true) {
167
-		if($recursive===true){
167
+		if ($recursive===true) {
168 168
 			$content=$this->_self->getContent();
169
-			if($content instanceof HtmlSemDoubleElement)
169
+			if ($content instanceof HtmlSemDoubleElement)
170 170
 				$content->setInverted($recursive);
171
-			elseif(\is_array($content) || $content instanceof \Traversable){
172
-				foreach ($content as $elm){
173
-					if($elm instanceof  HtmlSemDoubleElement){
171
+			elseif (\is_array($content) || $content instanceof \Traversable) {
172
+				foreach ($content as $elm) {
173
+					if ($elm instanceof  HtmlSemDoubleElement) {
174 174
 						$elm->setInverted($recursive);
175 175
 					}
176 176
 				}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	}
185 185
 
186 186
 	public function setFloated($direction="right") {
187
-		return $this->_self->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated"));
187
+		return $this->_self->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated"));
188 188
 	}
189 189
 
190 190
 	public function floatRight() {
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 		return $this->_baseClass;
200 200
 	}
201 201
 
202
-	protected function addBehavior(&$array,$key,$value,$before="",$after=""){
203
-		if(\is_string($value)){
204
-			if(isset($array[$key])){
202
+	protected function addBehavior(&$array, $key, $value, $before="", $after="") {
203
+		if (\is_string($value)) {
204
+			if (isset($array[$key])) {
205 205
 				$p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, "");
206 206
 				$array[$key]=$before.$p.$value.$after;
207
-			}else
207
+			} else
208 208
 				$array[$key]=$before.$value.$after;
209
-		}else{
209
+		} else {
210 210
 			$array[$key]=$value;
211 211
 		}
212 212
 		return $this;
Please login to merge, or discard this patch.
Braces   +28 added lines, -20 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
 
49 49
 	public function setVariations($variations) {
50 50
 		$this->_self->setProperty("class", $this->_self->getBaseClass());
51
-		if (\is_string($variations))
52
-			$variations=\explode(" ", $variations);
51
+		if (\is_string($variations)) {
52
+					$variations=\explode(" ", $variations);
53
+		}
53 54
 		foreach ( $variations as $variation ) {
54 55
 			$this->_self->addVariation($variation);
55 56
 		}
@@ -62,8 +63,9 @@  discard block
 block discarded – undo
62 63
 	}
63 64
 
64 65
 	public function addVariations($variations=array()) {
65
-		if (\is_string($variations))
66
-			$variations=\explode(" ", $variations);
66
+		if (\is_string($variations)) {
67
+					$variations=\explode(" ", $variations);
68
+		}
67 69
 		foreach ( $variations as $variation ) {
68 70
 			$this->_self->addVariation($variation);
69 71
 		}
@@ -71,8 +73,9 @@  discard block
 block discarded – undo
71 73
 	}
72 74
 
73 75
 	public function addStates($states=array()) {
74
-		if (\is_string($states))
75
-			$states=\explode(" ", $states);
76
+		if (\is_string($states)) {
77
+					$states=\explode(" ", $states);
78
+		}
76 79
 		foreach ( $states as $state ) {
77 80
 			$this->_self->addState($state);
78 81
 		}
@@ -81,8 +84,9 @@  discard block
 block discarded – undo
81 84
 
82 85
 	public function setStates($states) {
83 86
 		$this->_self->setProperty("class", $this->_self->getBaseClass());
84
-		if (\is_string($states))
85
-			$states=\explode(" ", $states);
87
+		if (\is_string($states)) {
88
+					$states=\explode(" ", $states);
89
+		}
86 90
 		foreach ( $states as $state ) {
87 91
 			$this->_self->addState($state);
88 92
 		}
@@ -114,8 +118,9 @@  discard block
 block discarded – undo
114 118
 	 * @return HtmlSemDoubleElement
115 119
 	 */
116 120
 	public function setDisabled($disable=true) {
117
-		if($disable)
118
-			$this->_self->addToProperty("class", "disabled");
121
+		if($disable) {
122
+					$this->_self->addToProperty("class", "disabled");
123
+		}
119 124
 		return $this;
120 125
 	}
121 126
 
@@ -149,14 +154,16 @@  discard block
 block discarded – undo
149 154
 	 * @return HtmlSemDoubleElement
150 155
 	 */
151 156
 	public function setActive($value=true){
152
-		if($value)
153
-			$this->_self->addToProperty("class", "active");
157
+		if($value) {
158
+					$this->_self->addToProperty("class", "active");
159
+		}
154 160
 		return $this;
155 161
 	}
156 162
 
157 163
 	public function setAttached($value=true){
158
-		if($value)
159
-			$this->_self->addToPropertyCtrl("class", "attached", array ("attached" ));
164
+		if($value) {
165
+					$this->_self->addToPropertyCtrl("class", "attached", array ("attached" ));
166
+		}
160 167
 		return $this;
161 168
 	}
162 169
 
@@ -166,9 +173,9 @@  discard block
 block discarded – undo
166 173
 	public function setInverted($recursive=true) {
167 174
 		if($recursive===true){
168 175
 			$content=$this->_self->getContent();
169
-			if($content instanceof HtmlSemDoubleElement)
170
-				$content->setInverted($recursive);
171
-			elseif(\is_array($content) || $content instanceof \Traversable){
176
+			if($content instanceof HtmlSemDoubleElement) {
177
+							$content->setInverted($recursive);
178
+			} elseif(\is_array($content) || $content instanceof \Traversable){
172 179
 				foreach ($content as $elm){
173 180
 					if($elm instanceof  HtmlSemDoubleElement){
174 181
 						$elm->setInverted($recursive);
@@ -204,9 +211,10 @@  discard block
 block discarded – undo
204 211
 			if(isset($array[$key])){
205 212
 				$p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, "");
206 213
 				$array[$key]=$before.$p.$value.$after;
207
-			}else
208
-				$array[$key]=$before.$value.$after;
209
-		}else{
214
+			} else {
215
+							$array[$key]=$before.$value.$after;
216
+			}
217
+		} else{
210 218
 			$array[$key]=$value;
211 219
 		}
212 220
 		return $this;
Please login to merge, or discard this patch.