@@ -16,19 +16,19 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | /** |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | $ajaxTransition=null; |
352 | 352 | $params="{}"; |
353 | 353 | extract($parameters); |
354 | - return $this->_add_event($element, $this->_ajax($method,$url, $params,$responseElement,$jsCallback,$attr, $hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
354 | + return $this->_add_event($element, $this->_ajax($method, $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | return $this->getOn("click", $element, $url, $responseElement, $parameters); |
379 | 379 | } |
380 | 380 | |
381 | - private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
382 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
381 | + private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
382 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
393 | 393 | * @param string|callable $ajaxTransition |
394 | 394 | */ |
395 | - public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
396 | - return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
395 | + public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
396 | + return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
@@ -408,8 +408,8 @@ discard block |
||
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 postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
412 | - return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
411 | + public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
412 | + return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $jqueryDone="html"; |
433 | 433 | $ajaxTransition=null; |
434 | 434 | extract($parameters); |
435 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
435 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -448,20 +448,20 @@ discard block |
||
448 | 448 | return $this->postOn("click", $element, $url, $params, $responseElement, $parameters); |
449 | 449 | } |
450 | 450 | |
451 | - private function _postForm($url, $form, $responseElement, $params=null,$validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
451 | + private function _postForm($url, $form, $responseElement, $params=null, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
452 | 452 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
453 | 453 | $retour=$this->_getAjaxUrl($url, $attr); |
454 | 454 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
455 | - if(isset($params)){ |
|
455 | + if (isset($params)) { |
|
456 | 456 | $retour.="params+='&'+$.param(".$params.");\n"; |
457 | 457 | } |
458 | 458 | $responseElement=$this->_getResponseElement($responseElement); |
459 | 459 | $retour.="var self=this;\n"; |
460 | - if($hasLoader===true){ |
|
460 | + if ($hasLoader===true) { |
|
461 | 461 | $this->addLoading($retour, $responseElement); |
462 | 462 | } |
463 | 463 | $retour.="$.post(url,params).done(function( data ) {\n"; |
464 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
464 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
465 | 465 | |
466 | 466 | if ($validation) { |
467 | 467 | $retour="$('#".$form."').validate({submitHandler: function(form) { |
@@ -485,8 +485,8 @@ discard block |
||
485 | 485 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
486 | 486 | * @param string|callable $ajaxTransition |
487 | 487 | */ |
488 | - public function postForm($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
489 | - return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
488 | + public function postForm($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
489 | + return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
504 | 504 | * @param string|callable $ajaxTransition |
505 | 505 | */ |
506 | - public function postFormDeferred($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
507 | - return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
506 | + public function postFormDeferred($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
507 | + return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | $jqueryDone="html"; |
530 | 530 | $ajaxTransition=null; |
531 | 531 | extract($parameters); |
532 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement,$params, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
532 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | /** |
@@ -24,7 +24,7 @@ discard block |
||
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 |
||
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->ajaxOnClick("#".$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->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -83,156 +83,156 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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,7 +320,7 @@ discard block |
||
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 | } |
@@ -331,14 +331,14 @@ discard block |
||
331 | 331 | * @param string $position |
332 | 332 | * @return \Ajax\common\html\HtmlDoubleElement |
333 | 333 | */ |
334 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
334 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
335 | 335 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
336 | 336 | } |
337 | 337 | |
338 | - public function getSearchField(){ |
|
339 | - if(isset($this->_searchField)===false){ |
|
340 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
341 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
338 | + public function getSearchField() { |
|
339 | + if (isset($this->_searchField)===false) { |
|
340 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
341 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
342 | 342 | } |
343 | 343 | return $this->_searchField; |
344 | 344 | } |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | return $this; |
355 | 355 | } |
356 | 356 | |
357 | - public function asForm(){ |
|
357 | + public function asForm() { |
|
358 | 358 | return $this->getForm(); |
359 | 359 | } |
360 | 360 | |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | |
363 | 363 | protected function getTargetSelector($op) { |
364 | 364 | $result=$this->_targetSelector; |
365 | - if(!isset($result[$op])) |
|
365 | + if (!isset($result[$op])) |
|
366 | 366 | $result="#".$this->identifier; |
367 | 367 | return $result[$op]; |
368 | 368 | } |
@@ -373,15 +373,15 @@ discard block |
||
373 | 373 | * @return \Ajax\semantic\widgets\datatable\DataTable |
374 | 374 | */ |
375 | 375 | public function setTargetSelector($_targetSelector) { |
376 | - if(!\is_array($_targetSelector)){ |
|
377 | - $_targetSelector=["edit"=>$_targetSelector,"delete"=>$_targetSelector]; |
|
376 | + if (!\is_array($_targetSelector)) { |
|
377 | + $_targetSelector=["edit"=>$_targetSelector, "delete"=>$_targetSelector]; |
|
378 | 378 | } |
379 | 379 | $this->_targetSelector=$_targetSelector; |
380 | 380 | return $this; |
381 | 381 | } |
382 | 382 | |
383 | 383 | public function getRefreshSelector() { |
384 | - if(isset($this->_refreshSelector)) |
|
384 | + if (isset($this->_refreshSelector)) |
|
385 | 385 | return $this->_refreshSelector; |
386 | 386 | return "#".$this->identifier." tbody"; |
387 | 387 | } |
@@ -399,9 +399,9 @@ discard block |
||
399 | 399 | * {@inheritDoc} |
400 | 400 | * @see \Ajax\common\Widget::show() |
401 | 401 | */ |
402 | - public function show($modelInstance){ |
|
403 | - if(\is_array($modelInstance)){ |
|
404 | - if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
|
402 | + public function show($modelInstance) { |
|
403 | + if (\is_array($modelInstance)) { |
|
404 | + if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
|
405 | 405 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
406 | 406 | } |
407 | 407 | $this->_modelInstance=$modelInstance; |
@@ -436,24 +436,24 @@ discard block |
||
436 | 436 | return $this; |
437 | 437 | } |
438 | 438 | |
439 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
440 | - $this->_self->setActiveRowSelector($class,$event,$multiple); |
|
439 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
440 | + $this->_self->setActiveRowSelector($class, $event, $multiple); |
|
441 | 441 | return $this; |
442 | 442 | } |
443 | 443 | |
444 | - public function hideColumn($colIndex){ |
|
445 | - if(!\is_array($this->_hiddenColumns)) |
|
444 | + public function hideColumn($colIndex) { |
|
445 | + if (!\is_array($this->_hiddenColumns)) |
|
446 | 446 | $this->_hiddenColumns=[]; |
447 | 447 | $this->_hiddenColumns[]=$colIndex; |
448 | 448 | return $this; |
449 | 449 | } |
450 | 450 | |
451 | - public function setColWidth($colIndex,$width){ |
|
451 | + public function setColWidth($colIndex, $width) { |
|
452 | 452 | $this->_colWidths[$colIndex]=$width; |
453 | 453 | return $this; |
454 | 454 | } |
455 | 455 | public function setColWidths($_colWidths) { |
456 | - $this->_colWidths = $_colWidths; |
|
456 | + $this->_colWidths=$_colWidths; |
|
457 | 457 | return $this; |
458 | 458 | } |
459 | 459 | } |