Completed
Push — master ( 874c8c...541414 )
by Jean-Christophe
03:49
created
Ajax/common/traits/JsUtilsAjaxTrait.php 1 patch
Spacing   +64 added lines, -64 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
 	/**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @param string $context
151 151
 	 * @param boolean $immediatly
152 152
 	 */
153
-	private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) {
153
+	private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) {
154 154
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
155 155
 		$retour=$this->_getAjaxUrl($url, $attr);
156 156
 		$retour.="$.{$method}(url,".$params.").done(function( data ) {\n";
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 	 * @param string $context
174 174
 	 * @param boolean $immediatly
175 175
 	 */
176
-	public function json($url, $method="get", $params="{}", $jsCallback=NULL,$context="document",$immediatly=false) {
177
-		return $this->_json($url,$method,$params,$jsCallback,NULL,$context,$immediatly);
176
+	public function json($url, $method="get", $params="{}", $jsCallback=NULL, $context="document", $immediatly=false) {
177
+		return $this->_json($url, $method, $params, $jsCallback, NULL, $context, $immediatly);
178 178
 	}
179 179
 
180 180
 	/**
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	 * @param string $url the request address
185 185
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
186 186
 	 */
187
-	public function jsonOn($event,$element, $url,$parameters=array()) {
187
+	public function jsonOn($event, $element, $url, $parameters=array()) {
188 188
 		$preventDefault=true;
189 189
 		$stopPropagation=true;
190 190
 		$jsCallback=null;
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		$params="{}";
195 195
 		$immediatly=true;
196 196
 		extract($parameters);
197
-		return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly);
197
+		return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly);
198 198
 	}
199 199
 
200 200
 	/**
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 	 * @param string $jsCallback javascript code to execute after the request
206 206
 	 * @param string $context jquery DOM element, array container.
207 207
 	 */
208
-	public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL,$context=NULL) {
209
-		return $this->json($url, $method, $params, $jsCallback, $context,false);
208
+	public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL, $context=NULL) {
209
+		return $this->json($url, $method, $params, $jsCallback, $context, false);
210 210
 	}
211 211
 
212 212
 	/**
@@ -219,22 +219,22 @@  discard block
 block discarded – undo
219 219
 	 * @param string $rowClass the css class for the new element
220 220
 	 * @param boolean $immediatly
221 221
 	 */
222
-	private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$attr="id",$immediatly=false) {
222
+	private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $attr="id", $immediatly=false) {
223 223
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
224 224
 		$retour=$this->_getAjaxUrl($url, $attr);
225
-		if($context===null){
225
+		if ($context===null) {
226 226
 			$parent="$('".$maskSelector."').parent()";
227
-			$newElm = "$('#'+newId)";
228
-		}else{
227
+			$newElm="$('#'+newId)";
228
+		} else {
229 229
 			$parent=$context;
230
-			$newElm = $context.".find('#'+newId)";
230
+			$newElm=$context.".find('#'+newId)";
231 231
 		}
232 232
 		$appendTo="\t\tnewElm.appendTo(".$parent.");\n";
233 233
 		$retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n";
234 234
 		$retour.=$parent.".find('._json').remove();";
235 235
 		$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();
236 236
 		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";
237
-		$retour.= $appendTo;
237
+		$retour.=$appendTo;
238 238
 		$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 239
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
240 240
 		$retour.="\t".$jsCallback."\n"."});\n";
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 	 * @param string $context jquery DOM element, array container.
254 254
 	 * @param boolean $immediatly
255 255
 	 */
256
-	public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$immediatly=false) {
257
-		return $this->_jsonArray($maskSelector, $url,$method,$params,$jsCallback,$rowClass,$context,NULL,$immediatly);
256
+	public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $immediatly=false) {
257
+		return $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, NULL, $immediatly);
258 258
 	}
259 259
 
260 260
 	/**
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 	 * @param string $rowClass the css class for the new element
268 268
 	 * @param string $context jquery DOM element, array container.
269 269
 	 */
270
-	public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL) {
271
-		return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback,$rowClass,$context,false);
270
+	public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL) {
271
+		return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, false);
272 272
 	}
273 273
 
274 274
 	/**
@@ -278,18 +278,18 @@  discard block
 block discarded – undo
278 278
 	 * @param string $url the request url
279 279
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true)
280 280
 	 */
281
-	public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) {
281
+	public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) {
282 282
 		$preventDefault=true;
283 283
 		$stopPropagation=true;
284 284
 		$jsCallback=null;
285 285
 		$attr="id";
286 286
 		$method="get";
287
-		$context = null;
287
+		$context=null;
288 288
 		$params="{}";
289 289
 		$immediatly=true;
290 290
 		$rowClass="_json";
291 291
 		extract($parameters);
292
-		return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $rowClass, $context,$attr), $event, $preventDefault, $stopPropagation,$immediatly);
292
+		return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, $attr), $event, $preventDefault, $stopPropagation, $immediatly);
293 293
 	}
294 294
 
295 295
 	/**
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
304 304
 	 * @param string|callable $ajaxTransition
305 305
 	 */
306
-	public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id",$jqueryDone="html",$ajaxTransition=null) {
307
-		return $this->_get($url, $params,$responseElement,$jsCallback,$attr,false,$jqueryDone,$ajaxTransition);
306
+	public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $jqueryDone="html", $ajaxTransition=null) {
307
+		return $this->_get($url, $params, $responseElement, $jsCallback, $attr, false, $jqueryDone, $ajaxTransition);
308 308
 	}
309 309
 
310 310
 	/**
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 		$ajaxTransition=null;
328 328
 		$params="{}";
329 329
 		extract($parameters);
330
-		return $this->_add_event($element, $this->_get($url, $params,$responseElement,$jsCallback,$attr, $hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
330
+		return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
331 331
 	}
332 332
 
333 333
 	/**
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 		return $this->getOn("click", $element, $url, $responseElement, $parameters);
343 343
 	}
344 344
 
345
-	private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
346
-		return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly);
345
+	private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
346
+		return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly);
347 347
 	}
348 348
 
349 349
 	/**
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
357 357
 	 * @param string|callable $ajaxTransition
358 358
 	 */
359
-	public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
360
-		return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true);
359
+	public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
360
+		return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true);
361 361
 	}
362 362
 
363 363
 	/**
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
373 373
 	 * @param string|callable $ajaxTransition
374 374
 	 */
375
-	public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
376
-		return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false);
375
+	public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
376
+		return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false);
377 377
 	}
378 378
 
379 379
 	/**
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 		$jqueryDone="html";
397 397
 		$ajaxTransition=null;
398 398
 		extract($parameters);
399
-		return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
399
+		return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
400 400
 	}
401 401
 
402 402
 	/**
@@ -412,20 +412,20 @@  discard block
 block discarded – undo
412 412
 		return $this->postOn("click", $element, $url, $params, $responseElement, $parameters);
413 413
 	}
414 414
 
415
-	private function _postForm($url, $form, $responseElement, $params=null,$validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) {
415
+	private function _postForm($url, $form, $responseElement, $params=null, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) {
416 416
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
417 417
 		$retour=$this->_getAjaxUrl($url, $attr);
418 418
 		$retour.="\nvar params=$('#".$form."').serialize();\n";
419
-		if(isset($params)){
419
+		if (isset($params)) {
420 420
 			$retour.="params+='&'+$.param(".$params.");\n";
421 421
 		}
422 422
 		$responseElement=$this->_getResponseElement($responseElement);
423 423
 		$retour.="var self=this;\n";
424
-		if($hasLoader===true){
424
+		if ($hasLoader===true) {
425 425
 			$this->addLoading($retour, $responseElement);
426 426
 		}
427 427
 		$retour.="$.post(url,params).done(function( data ) {\n";
428
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
428
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n";
429 429
 
430 430
 		if ($validation) {
431 431
 			$retour="$('#".$form."').validate({submitHandler: function(form) {
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
450 450
 	 * @param string|callable $ajaxTransition
451 451
 	 */
452
-	public function postForm($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
453
-		return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true);
452
+	public function postForm($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
453
+		return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true);
454 454
 	}
455 455
 
456 456
 	/**
@@ -467,8 +467,8 @@  discard block
 block discarded – undo
467 467
 	 * @param string $jqueryDone the jquery function call on ajax data. default:html
468 468
 	 * @param string|callable $ajaxTransition
469 469
 	 */
470
-	public function postFormDeferred($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) {
471
-		return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false);
470
+	public function postFormDeferred($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) {
471
+		return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false);
472 472
 	}
473 473
 
474 474
 	/**
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 		$jqueryDone="html";
494 494
 		$ajaxTransition=null;
495 495
 		extract($parameters);
496
-		return $this->_add_event($element, $this->_postForm($url, $form, $responseElement,$params, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly);
496
+		return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly);
497 497
 	}
498 498
 
499 499
 	/**
Please login to merge, or discard this patch.
Ajax/service/AjaxCall.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,27 +29,27 @@
 block discarded – undo
29 29
 		$rowClass="_json";
30 30
 		extract($this->parameters);
31 31
 		$result=$this->_eventPreparing($preventDefault, $stopPropagation);
32
-		switch($this->method) {
32
+		switch ($this->method) {
33 33
 			case "get":
34
-				$result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr,$jqueryDone,$ajaxTransition);
34
+				$result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr, $jqueryDone, $ajaxTransition);
35 35
 				break;
36 36
 			case "post":
37
-				$result.=$js->postDeferred($url, $responseElement, $params, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition);
37
+				$result.=$js->postDeferred($url, $responseElement, $params, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition);
38 38
 				break;
39 39
 			case "postForm":
40
-				$result.=$js->postFormDeferred($url, $form, $responseElement, $params,$validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition);
40
+				$result.=$js->postFormDeferred($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition);
41 41
 				break;
42 42
 			case "json":
43
-				$result.=$js->jsonDeferred($url,$method,$params,$jsCallback);
43
+				$result.=$js->jsonDeferred($url, $method, $params, $jsCallback);
44 44
 				break;
45 45
 			case "jsonArray":
46
-				$result.=$js->jsonArrayDeferred($modelSelector, $url,$method,$params,$jsCallback,$rowClass);
46
+				$result.=$js->jsonArrayDeferred($modelSelector, $url, $method, $params, $jsCallback, $rowClass);
47 47
 				break;
48 48
 		}
49 49
 		return $result;
50 50
 	}
51 51
 
52
-	protected function _eventPreparing($preventDefault,$stopPropagation){
52
+	protected function _eventPreparing($preventDefault, $stopPropagation) {
53 53
 		$result="";
54 54
 		if ($preventDefault===true) {
55 55
 			$result.=Javascript::$preventDefault;
Please login to merge, or discard this patch.
Ajax/semantic/html/base/constants/Social.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,5 +2,5 @@
 block discarded – undo
2 2
 namespace Ajax\semantic\html\base\constants;
3 3
 	use Ajax\common\BaseEnum;
4 4
 abstract class Social extends BaseEnum {
5
-	const FACEBOOK="facebook", TWITTER="twitter",GOOGLEPLUS="google plus",VK="vk",LINKEDIN="linkedin",INSTAGRAM="instagram",YOUTUBE="youtube",GITHUB="github";
5
+	const FACEBOOK="facebook", TWITTER="twitter", GOOGLEPLUS="google plus", VK="vk", LINKEDIN="linkedin", INSTAGRAM="instagram", YOUTUBE="youtube", GITHUB="github";
6 6
 }
Please login to merge, or discard this patch.
Ajax/semantic/components/Popup.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	 * @return $this
28 28
 	 */
29 29
 	public function setOnShow($jsCode) {
30
-		$jsCode=str_ireplace("\"","%quote%", $jsCode);
30
+		$jsCode=str_ireplace("\"", "%quote%", $jsCode);
31 31
 		return $this->setParam("onShow", "%function(){".$jsCode."}%");
32 32
 	}
33 33
 
34
-	public function setExclusive($value){
34
+	public function setExclusive($value) {
35 35
 		return $this->setParam("exclusive", $value);
36 36
 	}
37 37
 
@@ -40,19 +40,19 @@  discard block
 block discarded – undo
40 40
 	 * @param string $popup the css selector of the popup
41 41
 	 * @return \Ajax\semantic\components\Popup
42 42
 	 */
43
-	public function setPopup($popup){
43
+	public function setPopup($popup) {
44 44
 		return $this->setParam("popup", $popup);
45 45
 	}
46 46
 
47
-	public function setInline($value){
47
+	public function setInline($value) {
48 48
 		return $this->setParam("inline", $value);
49 49
 	}
50 50
 
51
-	public function setPosition($value){
51
+	public function setPosition($value) {
52 52
 		return $this->setParam("position", $value);
53 53
 	}
54 54
 
55
-	public function setSetFluidWidth($value){
55
+	public function setSetFluidWidth($value) {
56 56
 		return $this->setParam("setFluidWidth", $value);
57 57
 	}
58 58
 }
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/Pagination.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	private $pages_visibles;
10 10
 	private $row_count;
11 11
 
12
-	public function __construct($items_per_page=10,$pages_visibles=null,$page=1,$row_count=null){
12
+	public function __construct($items_per_page=10, $pages_visibles=null, $page=1, $row_count=null) {
13 13
 		$this->items_per_page=$items_per_page;
14 14
 		$this->row_count=$row_count;
15 15
 		$this->page=$page;
@@ -17,30 +17,30 @@  discard block
 block discarded – undo
17 17
 		$this->visible=true;
18 18
 	}
19 19
 
20
-	public function getObjects($objects){
20
+	public function getObjects($objects) {
21 21
 		$auto=(!isset($this->row_count));
22 22
 		$os=$objects;
23
-		if(!\is_array($os)){
23
+		if (!\is_array($os)) {
24 24
 			$os=[];
25
-			foreach ($objects as $o){
25
+			foreach ($objects as $o) {
26 26
 				$os[]=$o;
27 27
 			}
28 28
 		}
29
-		$this->page_count = 0;
30
-		$row_count=($auto)?\sizeof($os):$this->row_count;
31
-		if (0 === $row_count) {
29
+		$this->page_count=0;
30
+		$row_count=($auto) ? \sizeof($os) : $this->row_count;
31
+		if (0===$row_count) {
32 32
 			$this->visible=false;
33 33
 		} else {
34 34
 
35
-			$this->page_count = (int)ceil($row_count / $this->items_per_page);
35
+			$this->page_count=(int)ceil($row_count/$this->items_per_page);
36 36
 			$this->visible=$this->page_count>1;
37
-			if($this->page > $this->page_count+1) {
38
-				$this->page = 1;
37
+			if ($this->page>$this->page_count+1) {
38
+				$this->page=1;
39 39
 			}
40 40
 		}
41
-		if($auto){
42
-			$offset = ($this->page - 1) * $this->items_per_page;
43
-			return array_slice($os, $offset,$this->items_per_page);
41
+		if ($auto) {
42
+			$offset=($this->page-1)*$this->items_per_page;
43
+			return array_slice($os, $offset, $this->items_per_page);
44 44
 		}
45 45
 		return $os;
46 46
 	}
@@ -76,22 +76,22 @@  discard block
 block discarded – undo
76 76
 		return $this->page_count;
77 77
 	}
78 78
 
79
-	public function getPagesNumbers(){
80
-		$middle= (int)ceil(($this->pages_visibles-1)/ 2);
79
+	public function getPagesNumbers() {
80
+		$middle=(int)ceil(($this->pages_visibles-1)/2);
81 81
 		$first=$this->page-$middle;
82
-		if($first<1){
82
+		if ($first<1) {
83 83
 			$first=1;
84 84
 		}
85 85
 		$last=$first+$this->pages_visibles-1;
86
-		if($last>$this->page_count){
86
+		if ($last>$this->page_count) {
87 87
 			$last=$this->page_count;
88 88
 		}
89 89
 		return \range($first, $last);
90 90
 	}
91 91
 
92 92
 	public function setPagesVisibles($pages_visibles) {
93
-		if(!isset($pages_visibles))
94
-			$pages_visibles=(int)ceil($this->row_count / $this->items_per_page)+1;
93
+		if (!isset($pages_visibles))
94
+			$pages_visibles=(int)ceil($this->row_count/$this->items_per_page)+1;
95 95
 		$this->pages_visibles=$pages_visibles;
96 96
 		return $this;
97 97
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *
25 25
  */
26 26
 class DataTable extends Widget {
27
-	use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait;
27
+	use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait;
28 28
 	protected $_searchField;
29 29
 	protected $_urls;
30 30
 	protected $_pagination;
@@ -42,35 +42,35 @@  discard block
 block discarded – undo
42 42
 	protected $_colWidths;
43 43
 
44 44
 
45
-	public function __construct($identifier,$model,$modelInstance=NULL) {
46
-		parent::__construct($identifier, $model,$modelInstance);
47
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
45
+	public function __construct($identifier, $model, $modelInstance=NULL) {
46
+		parent::__construct($identifier, $model, $modelInstance);
47
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
48 48
 		$this->_urls=[];
49
-		$this->_emptyMessage=new HtmlMessage("","nothing to display");
49
+		$this->_emptyMessage=new HtmlMessage("", "nothing to display");
50 50
 		$this->_emptyMessage->setIcon("info circle");
51 51
 	}
52 52
 
53
-	public function run(JsUtils $js){
54
-		if($this->_hasCheckboxes && isset($js)){
53
+	public function run(JsUtils $js) {
54
+		if ($this->_hasCheckboxes && isset($js)) {
55 55
 			$this->_runCheckboxes($js);
56 56
 		}
57
-		if($this->_visibleHover){
58
-			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
59
-			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
57
+		if ($this->_visibleHover) {
58
+			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]);
59
+			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]);
60 60
 		}
61
-		if(\is_array($this->_deleteBehavior))
62
-			$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
63
-		if(\is_array($this->_editBehavior))
64
-			$this->_generateBehavior("edit",$this->_editBehavior,$js);
61
+		if (\is_array($this->_deleteBehavior))
62
+			$this->_generateBehavior("delete", $this->_deleteBehavior, $js);
63
+		if (\is_array($this->_editBehavior))
64
+			$this->_generateBehavior("edit", $this->_editBehavior, $js);
65 65
 		return parent::run($js);
66 66
 	}
67 67
 
68 68
 
69 69
 
70
-	protected function _generateBehavior($op,$params,JsUtils $js){
71
-		if(isset($this->_urls[$op])){
72
-			$params=\array_merge($params,["attr"=>"data-ajax"]);
73
-			$js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector($op),$params);
70
+	protected function _generateBehavior($op, $params, JsUtils $js) {
71
+		if (isset($this->_urls[$op])) {
72
+			$params=\array_merge($params, ["attr"=>"data-ajax"]);
73
+			$js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params);
74 74
 		}
75 75
 	}
76 76
 
@@ -83,156 +83,156 @@  discard block
 block discarded – undo
83 83
 	}
84 84
 
85 85
 
86
-	public function compile(JsUtils $js=NULL,&$view=NULL){
87
-		if(!$this->_generated){
86
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
87
+		if (!$this->_generated) {
88 88
 			$this->_instanceViewer->setInstance($this->_model);
89 89
 			$captions=$this->_instanceViewer->getCaptions();
90 90
 			$table=$this->content["table"];
91
-			if($this->_hasCheckboxes){
91
+			if ($this->_hasCheckboxes) {
92 92
 				$this->_generateMainCheckbox($captions);
93 93
 			}
94 94
 			$table->setRowCount(0, \sizeof($captions));
95
-			$this->_generateHeader($table,$captions);
95
+			$this->_generateHeader($table, $captions);
96 96
 
97
-			if(isset($this->_compileParts))
97
+			if (isset($this->_compileParts))
98 98
 				$table->setCompileParts($this->_compileParts);
99 99
 
100 100
 			$this->_generateContent($table);
101 101
 
102
-			$this->compileExtraElements($table, $captions,$js);
102
+			$this->compileExtraElements($table, $captions, $js);
103 103
 
104
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
104
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
105 105
 			$this->_compileForm();
106 106
 			$this->_applyStyleAttributes($table);
107 107
 			$this->_generated=true;
108 108
 		}
109
-		return parent::compile($js,$view);
109
+		return parent::compile($js, $view);
110 110
 	}
111 111
 
112
-	protected function compileExtraElements($table,$captions,JsUtils $js=NULL){
113
-		if(isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])){
114
-				$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
112
+	protected function compileExtraElements($table, $captions, JsUtils $js=NULL) {
113
+		if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) {
114
+				$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
115 115
 		}
116
-		if($this->_hasCheckboxes && $table->hasPart("thead")){
116
+		if ($this->_hasCheckboxes && $table->hasPart("thead")) {
117 117
 			$table->getHeader()->getCell(0, 0)->addClass("no-sort");
118 118
 		}
119 119
 
120
-		if(isset($this->_toolbar)){
120
+		if (isset($this->_toolbar)) {
121 121
 			$this->_setToolbarPosition($table, $captions);
122 122
 		}
123
-		if(isset($this->_pagination) && $this->_pagination->getVisible()){
124
-			$this->_generatePagination($table,$js);
123
+		if (isset($this->_pagination) && $this->_pagination->getVisible()) {
124
+			$this->_generatePagination($table, $js);
125 125
 		}
126 126
 	}
127 127
 
128
-	protected function _applyStyleAttributes($table){
129
-		if(isset($this->_hiddenColumns))
128
+	protected function _applyStyleAttributes($table) {
129
+		if (isset($this->_hiddenColumns))
130 130
 			$this->_hideColumns();
131
-			if(isset($this->_colWidths)){
132
-				foreach ($this->_colWidths as $colIndex=>$width){
133
-					$table->setColWidth($colIndex,$width);
131
+			if (isset($this->_colWidths)) {
132
+				foreach ($this->_colWidths as $colIndex=>$width) {
133
+					$table->setColWidth($colIndex, $width);
134 134
 				}
135 135
 			}
136 136
 	}
137 137
 
138
-	protected function _hideColumns(){
139
-		foreach ($this->_hiddenColumns as $colIndex){
138
+	protected function _hideColumns() {
139
+		foreach ($this->_hiddenColumns as $colIndex) {
140 140
 			$this->_self->hideColumn($colIndex);
141 141
 		}
142 142
 		return $this;
143 143
 	}
144 144
 
145
-	protected function _generateHeader(HtmlTable $table,$captions){
145
+	protected function _generateHeader(HtmlTable $table, $captions) {
146 146
 		$table->setHeaderValues($captions);
147
-		if(isset($this->_sortable)){
147
+		if (isset($this->_sortable)) {
148 148
 			$table->setSortable($this->_sortable);
149 149
 		}
150 150
 	}
151 151
 
152 152
 
153 153
 
154
-	protected function _generateContent($table){
154
+	protected function _generateContent($table) {
155 155
 		$objects=$this->_modelInstance;
156
-		if(isset($this->_pagination)){
156
+		if (isset($this->_pagination)) {
157 157
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
158 158
 		}
159 159
 			InstanceViewer::setIndex(0);
160 160
 			$table->fromDatabaseObjects($objects, function($instance) use($table){
161 161
 				return $this->_generateRow($instance, $table);
162 162
 			});
163
-		if($table->getRowCount()==0){
163
+		if ($table->getRowCount()==0) {
164 164
 			$result=$table->addRow();
165 165
 			$result->mergeRow();
166 166
 			$result->setValues([$this->_emptyMessage]);
167 167
 		}
168 168
 	}
169 169
 
170
-	protected function _generateRow($instance,&$table,$checkedClass=null){
170
+	protected function _generateRow($instance, &$table, $checkedClass=null) {
171 171
 		$this->_instanceViewer->setInstance($instance);
172 172
 		InstanceViewer::$index++;
173
-		$values= $this->_instanceViewer->getValues();
173
+		$values=$this->_instanceViewer->getValues();
174 174
 		$id=$this->_instanceViewer->getIdentifier();
175
-		if($this->_hasCheckboxes){
176
-			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,"");
175
+		if ($this->_hasCheckboxes) {
176
+			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, "");
177 177
 			$ck->setOnChange("event.stopPropagation();");
178 178
 			$field=$ck->getField();
179
-			$field->setProperty("value",$id);
179
+			$field->setProperty("value", $id);
180 180
 			$field->setProperty("name", "selection[]");
181
-			if(isset($checkedClass))
181
+			if (isset($checkedClass))
182 182
 				$field->setClass($checkedClass);
183 183
 			\array_unshift($values, $ck);
184 184
 		}
185 185
 		$result=$table->newRow();
186 186
 		$result->setIdentifier($this->identifier."-tr-".$id);
187
-		$result->setProperty("data-ajax",$id);
187
+		$result->setProperty("data-ajax", $id);
188 188
 		$result->setValues($values);
189
-		$result->addToProperty("class",$this->_rowClass);
189
+		$result->addToProperty("class", $this->_rowClass);
190 190
 		return $result;
191 191
 	}
192 192
 
193
-	protected function _generatePagination($table,$js=NULL){
194
-		if(isset($this->_toolbar)){
195
-			if($this->_toolbarPosition==PositionInTable::FOOTER)
193
+	protected function _generatePagination($table, $js=NULL) {
194
+		if (isset($this->_toolbar)) {
195
+			if ($this->_toolbarPosition==PositionInTable::FOOTER)
196 196
 				$this->_toolbar->setFloated("left");
197 197
 		}
198 198
 		$footer=$table->getFooter();
199 199
 		$footer->mergeCol();
200
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
200
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
201 201
 		$menu->floatRight();
202 202
 		$menu->setActiveItem($this->_pagination->getPage()-1);
203 203
 		$footer->addValues($menu);
204
-		$this->_associatePaginationBehavior($menu,$js);
204
+		$this->_associatePaginationBehavior($menu, $js);
205 205
 	}
206 206
 
207
-	protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){
208
-		if(isset($this->_urls["refresh"])){
209
-			$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith","hasLoader"=>false]);
207
+	protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) {
208
+		if (isset($this->_urls["refresh"])) {
209
+			$menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith", "hasLoader"=>false]);
210 210
 		}
211 211
 	}
212 212
 
213
-	protected function _getFieldName($index){
213
+	protected function _getFieldName($index) {
214 214
 		$fieldName=parent::_getFieldName($index);
215
-		if(\is_object($fieldName))
215
+		if (\is_object($fieldName))
216 216
 			$fieldName="field-".$index;
217 217
 		return $fieldName."[]";
218 218
 	}
219 219
 
220
-	protected function _getFieldCaption($index){
220
+	protected function _getFieldCaption($index) {
221 221
 		return null;
222 222
 	}
223 223
 
224
-	protected function _setToolbarPosition($table,$captions=NULL){
225
-		switch ($this->_toolbarPosition){
224
+	protected function _setToolbarPosition($table, $captions=NULL) {
225
+		switch ($this->_toolbarPosition) {
226 226
 			case PositionInTable::BEFORETABLE:
227 227
 			case PositionInTable::AFTERTABLE:
228
-				if(isset($this->_compileParts)===false){
228
+				if (isset($this->_compileParts)===false) {
229 229
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
230 230
 				}
231 231
 				break;
232 232
 			case PositionInTable::HEADER:
233 233
 			case PositionInTable::FOOTER:
234 234
 			case PositionInTable::BODY:
235
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
235
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
236 236
 				break;
237 237
 		}
238 238
 	}
@@ -244,16 +244,16 @@  discard block
 block discarded – undo
244 244
 	 * @param callable $callback function called after the field compilation
245 245
 	 * @return DataTable
246 246
 	 */
247
-	public function afterCompile($index,$callback){
248
-		$this->_instanceViewer->afterCompile($index,$callback);
247
+	public function afterCompile($index, $callback) {
248
+		$this->_instanceViewer->afterCompile($index, $callback);
249 249
 		return $this;
250 250
 	}
251 251
 
252
-	private function addToolbarRow($part,$table,$captions){
252
+	private function addToolbarRow($part, $table, $captions) {
253 253
 		$hasPart=$table->hasPart($part);
254
-		if($hasPart){
254
+		if ($hasPart) {
255 255
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
256
-		}else{
256
+		} else {
257 257
 			$row=$table->getPart($part)->getRow(0);
258 258
 		}
259 259
 		$row->mergeCol();
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 	 * @see Widget::getHtmlComponent()
266 266
 	 * @return HtmlTable
267 267
 	 */
268
-	public function getHtmlComponent(){
268
+	public function getHtmlComponent() {
269 269
 		return $this->content["table"];
270 270
 	}
271 271
 
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
 	 * @return DataTable
280 280
 	 */
281 281
 	public function setUrls($urls) {
282
-		if(\is_array($urls)){
283
-			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
284
-			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
285
-			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
286
-		}else{
287
-			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
282
+		if (\is_array($urls)) {
283
+			$this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0);
284
+			$this->_urls["edit"]=JArray::getValue($urls, "edit", 1);
285
+			$this->_urls["delete"]=JArray::getValue($urls, "delete", 2);
286
+		} else {
287
+			$this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls];
288 288
 		}
289 289
 		return $this;
290 290
 	}
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
298 298
 	 * @return DataTable
299 299
 	 */
300
-	public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){
301
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount);
300
+	public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) {
301
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
302 302
 		return $this;
303 303
 	}
304 304
 
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
310 310
 	 * @return DataTable
311 311
 	 */
312
-	public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){
313
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page);
312
+	public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) {
313
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page);
314 314
 		return $this;
315 315
 	}
316 316
 
@@ -320,20 +320,20 @@  discard block
 block discarded – undo
320 320
 	 * @param array $compileParts
321 321
 	 * @return DataTable
322 322
 	 */
323
-	public function refresh($compileParts=["tbody"]){
323
+	public function refresh($compileParts=["tbody"]) {
324 324
 		$this->_compileParts=$compileParts;
325 325
 		return $this;
326 326
 	}
327 327
 
328 328
 
329
-	public function addSearchInToolbar($position=Direction::RIGHT){
329
+	public function addSearchInToolbar($position=Direction::RIGHT) {
330 330
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
331 331
 	}
332 332
 
333
-	public function getSearchField(){
334
-		if(isset($this->_searchField)===false){
335
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
336
-			$this->_searchField->addIcon("search",Direction::RIGHT);
333
+	public function getSearchField() {
334
+		if (isset($this->_searchField)===false) {
335
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
336
+			$this->_searchField->addIcon("search", Direction::RIGHT);
337 337
 		}
338 338
 		return $this->_searchField;
339 339
 	}
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 		return $this;
350 350
 	}
351 351
 
352
-	public function asForm(){
352
+	public function asForm() {
353 353
 		return $this->getForm();
354 354
 	}
355 355
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 
358 358
 	protected function getTargetSelector($op) {
359 359
 		$result=$this->_targetSelector;
360
-		if(!isset($result[$op]))
360
+		if (!isset($result[$op]))
361 361
 			$result="#".$this->identifier;
362 362
 		return $result[$op];
363 363
 	}
@@ -368,15 +368,15 @@  discard block
 block discarded – undo
368 368
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
369 369
 	 */
370 370
 	public function setTargetSelector($_targetSelector) {
371
-		if(!\is_array($_targetSelector)){
372
-			$_targetSelector=["edit"=>$_targetSelector,"delete"=>$_targetSelector];
371
+		if (!\is_array($_targetSelector)) {
372
+			$_targetSelector=["edit"=>$_targetSelector, "delete"=>$_targetSelector];
373 373
 		}
374 374
 		$this->_targetSelector=$_targetSelector;
375 375
 		return $this;
376 376
 	}
377 377
 
378 378
 	public function getRefreshSelector() {
379
-		if(isset($this->_refreshSelector))
379
+		if (isset($this->_refreshSelector))
380 380
 			return $this->_refreshSelector;
381 381
 		return "#".$this->identifier." tbody";
382 382
 	}
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
 	 * {@inheritDoc}
395 395
 	 * @see \Ajax\common\Widget::show()
396 396
 	 */
397
-	public function show($modelInstance){
398
-		if(\is_array($modelInstance)){
399
-			if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
397
+	public function show($modelInstance) {
398
+		if (\is_array($modelInstance)) {
399
+			if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
400 400
 				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
401 401
 		}
402 402
 		$this->_modelInstance=$modelInstance;
@@ -431,24 +431,24 @@  discard block
 block discarded – undo
431 431
 		return $this;
432 432
 	}
433 433
 
434
-	public function setActiveRowSelector($class="active",$event="click",$multiple=false){
435
-		$this->_self->setActiveRowSelector($class,$event,$multiple);
434
+	public function setActiveRowSelector($class="active", $event="click", $multiple=false) {
435
+		$this->_self->setActiveRowSelector($class, $event, $multiple);
436 436
 		return $this;
437 437
 	}
438 438
 
439
-	public function hideColumn($colIndex){
440
-		if(!\is_array($this->_hiddenColumns))
439
+	public function hideColumn($colIndex) {
440
+		if (!\is_array($this->_hiddenColumns))
441 441
 			$this->_hiddenColumns=[];
442 442
 		$this->_hiddenColumns[]=$colIndex;
443 443
 		return $this;
444 444
 	}
445 445
 
446
-	public function setColWidth($colIndex,$width){
446
+	public function setColWidth($colIndex, $width) {
447 447
 		$this->_colWidths[$colIndex]=$width;
448 448
 		return $this;
449 449
 	}
450 450
 	public function setColWidths($_colWidths) {
451
-		$this->_colWidths = $_colWidths;
451
+		$this->_colWidths=$_colWidths;
452 452
 		return $this;
453 453
 	}
454 454
 }
Please login to merge, or discard this patch.
Ajax/semantic/traits/SemanticWidgetsTrait.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 	 * @param array $instances
19 19
 	 * @return DataTable
20 20
 	 */
21
-	public function dataTable($identifier,$model, $instances){
22
-		return $this->addHtmlComponent(new DataTable($identifier,$model,$instances));
21
+	public function dataTable($identifier, $model, $instances) {
22
+		return $this->addHtmlComponent(new DataTable($identifier, $model, $instances));
23 23
 	}
24 24
 
25 25
 	/**
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 	 * @param array $instances
29 29
 	 * @return JsonDataTable
30 30
 	 */
31
-	public function jsonDataTable($identifier,$model, $instances){
32
-		return $this->addHtmlComponent(new JsonDataTable($identifier,$model,$instances));
31
+	public function jsonDataTable($identifier, $model, $instances) {
32
+		return $this->addHtmlComponent(new JsonDataTable($identifier, $model, $instances));
33 33
 	}
34 34
 
35 35
 	/**
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	 * @param object $instance
38 38
 	 * @return DataElement
39 39
 	 */
40
-	public function dataElement($identifier, $instance){
41
-		return $this->addHtmlComponent(new DataElement($identifier,$instance));
40
+	public function dataElement($identifier, $instance) {
41
+		return $this->addHtmlComponent(new DataElement($identifier, $instance));
42 42
 	}
43 43
 
44 44
 	/**
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	 * @param object $instance
47 47
 	 * @return DataForm
48 48
 	 */
49
-	public function dataForm($identifier, $instance){
50
-		return $this->addHtmlComponent(new DataForm($identifier,$instance));
49
+	public function dataForm($identifier, $instance) {
50
+		return $this->addHtmlComponent(new DataForm($identifier, $instance));
51 51
 	}
52 52
 
53 53
 	/**
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 	 * @param object $instance
56 56
 	 * @return FormLogin
57 57
 	 */
58
-	public function defaultLogin($identifier,$instance=null){
59
-		return $this->addHtmlComponent(FormLogin::regular($identifier,$instance));
58
+	public function defaultLogin($identifier, $instance=null) {
59
+		return $this->addHtmlComponent(FormLogin::regular($identifier, $instance));
60 60
 	}
61 61
 
62 62
 	/**
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 	 * @param object $instance
65 65
 	 * @return FormLogin
66 66
 	 */
67
-	public function smallLogin($identifier,$instance=null){
68
-		return $this->addHtmlComponent(FormLogin::small($identifier,$instance));
67
+	public function smallLogin($identifier, $instance=null) {
68
+		return $this->addHtmlComponent(FormLogin::small($identifier, $instance));
69 69
 	}
70 70
 
71 71
 	/**
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 * @param object $instance
74 74
 	 * @return FormLogin
75 75
 	 */
76
-	public function segmentedLogin($identifier,$instance=null){
77
-		return $this->addHtmlComponent(FormLogin::attachedSegment($identifier,$instance));
76
+	public function segmentedLogin($identifier, $instance=null) {
77
+		return $this->addHtmlComponent(FormLogin::attachedSegment($identifier, $instance));
78 78
 	}
79 79
 
80 80
 	/**
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 * @param object $instance
83 83
 	 * @return FormAccount
84 84
 	 */
85
-	public function defaultAccount($identifier,$instance=null){
86
-		return $this->addHtmlComponent(FormAccount::regular($identifier,$instance));
85
+	public function defaultAccount($identifier, $instance=null) {
86
+		return $this->addHtmlComponent(FormAccount::regular($identifier, $instance));
87 87
 	}
88 88
 }
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlFormDropdown.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,26 +7,26 @@
 block discarded – undo
7 7
 
8 8
 class HtmlFormDropdown extends HtmlFormField {
9 9
 
10
-	public function __construct($identifier,$items=array(), $label=NULL,$value="",$multiple=false,$associative=true) {
11
-		parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label);
10
+	public function __construct($identifier, $items=array(), $label=NULL, $value="", $multiple=false, $associative=true) {
11
+		parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label);
12 12
 		$this->_identifier=$identifier;
13 13
 	}
14 14
 
15
-	public function setItems($items){
15
+	public function setItems($items) {
16 16
 		return $this->getField()->setItems($items);
17 17
 	}
18
-	public function addItem($item,$value=NULL,$image=NULL){
19
-		return $this->getField()->addItem($item,$value,$image);
18
+	public function addItem($item, $value=NULL, $image=NULL) {
19
+		return $this->getField()->addItem($item, $value, $image);
20 20
 	}
21
-	public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value="",$associative=true){
22
-		return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative);
21
+	public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value="", $associative=true) {
22
+		return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative);
23 23
 	}
24 24
 
25
-	public function getDataField(){
25
+	public function getDataField() {
26 26
 		return $this->getField()->getInput();
27 27
 	}
28
-	public function asSelect($name=NULL,$multiple=false,$selection=true){
29
-		$this->getField()->asSelect($name,$multiple,$selection);
28
+	public function asSelect($name=NULL, $multiple=false, $selection=true) {
29
+		$this->getField()->asSelect($name, $multiple, $selection);
30 30
 		return $this;
31 31
 	}
32 32
 }
Please login to merge, or discard this patch.
Ajax/semantic/html/elements/HtmlButton.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	}
56 56
 
57 57
 	public function setFocusable($value=true) {
58
-		if ($value === true)
58
+		if ($value===true)
59 59
 			$this->setProperty("tabindex", "0");
60 60
 		else {
61 61
 			$this->removeProperty("tabindex");
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 
66 66
 	public function setAnimated($content, $animation="") {
67 67
 		$this->setTagName("div");
68
-		$this->addToProperty("class", "animated " . $animation);
69
-		$visible=new HtmlSemDoubleElement("visible-" . $this->identifier, "div");
68
+		$this->addToProperty("class", "animated ".$animation);
69
+		$visible=new HtmlSemDoubleElement("visible-".$this->identifier, "div");
70 70
 		$visible->setClass("visible content");
71 71
 		$visible->setContent($this->content);
72
-		$hidden=new HtmlSemDoubleElement("hidden-" . $this->identifier, "div");
72
+		$hidden=new HtmlSemDoubleElement("hidden-".$this->identifier, "div");
73 73
 		$hidden->setClass("hidden content");
74 74
 		$hidden->setContent($content);
75
-		$this->content=array ($visible,$hidden );
75
+		$this->content=array($visible, $hidden);
76 76
 		return $hidden;
77 77
 	}
78 78
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	public function asIcon($icon) {
85 85
 		$iconO=$icon;
86 86
 		if (\is_string($icon)) {
87
-			$iconO=new HtmlIcon("icon-" . $this->identifier, $icon);
87
+			$iconO=new HtmlIcon("icon-".$this->identifier, $icon);
88 88
 		}
89 89
 		$this->addToProperty("class", "icon");
90 90
 		$this->content=$iconO;
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
 	 * @return HtmlLabel
105 105
 	 */
106 106
 	public function addLabel($label, $before=false, $icon=NULL) {
107
-		$this->tagName="div";$prefix="";
108
-		if($before)
107
+		$this->tagName="div"; $prefix="";
108
+		if ($before)
109 109
 			$prefix="left ";
110 110
 		$this->addToProperty("class", $prefix."labeled");
111 111
 		$isIcon=(isset($this->content[0]) && $this->content[0] instanceof HtmlIcon);
112
-		$this->content=new HtmlButton("button-" . $this->identifier, $this->content);
113
-		if($isIcon){
112
+		$this->content=new HtmlButton("button-".$this->identifier, $this->content);
113
+		if ($isIcon) {
114 114
 			$this->content->addClass("icon");
115 115
 		}
116 116
 		$this->content->setTagName("div");
117
-		$label=new HtmlLabel("label-" . $this->identifier, $label, $icon,"a");
117
+		$label=new HtmlLabel("label-".$this->identifier, $label, $icon, "a");
118 118
 		$label->setBasic();
119 119
 		$this->addContent($label, $before);
120 120
 		return $label;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	public function fromArray($array) {
128 128
 		$array=parent::fromArray($array);
129
-		foreach ( $array as $key => $value ) {
129
+		foreach ($array as $key => $value) {
130 130
 			$this->setProperty($key, $value);
131 131
 		}
132 132
 		return $array;
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 		return $this->addToProperty("class", "positive");
141 141
 	}
142 142
 
143
-	public function setColor($color){
144
-		if(\is_array($this->content)){
145
-			foreach ($this->content as $content){
146
-				if($content instanceof HtmlButton)
143
+	public function setColor($color) {
144
+		if (\is_array($this->content)) {
145
+			foreach ($this->content as $content) {
146
+				if ($content instanceof HtmlButton)
147 147
 					$content->setColor($color);
148 148
 			}
149 149
 		}
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 * @return HtmlButton
202 202
 	 */
203 203
 	public static function social($identifier, $social, $value=NULL) {
204
-		if ($value === NULL)
204
+		if ($value===NULL)
205 205
 			$value=\ucfirst($social);
206 206
 		$return=new HtmlButton($identifier, $value);
207 207
 		$return->addIcon($social);
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 	 * {@inheritDoc}
239 239
 	 * @see HtmlSemDoubleElement::asLink()
240 240
 	 */
241
-	public function asLink($href=NULL,$target=NULL) {
242
-		parent::asLink($href,$target);
241
+	public function asLink($href=NULL, $target=NULL) {
242
+		parent::asLink($href, $target);
243 243
 		return $this;
244 244
 	}
245 245
 }
Please login to merge, or discard this patch.