Passed
Push — master ( 42337f...468e47 )
by Jean-Christophe
02:24
created
Ajax/common/Widget.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 use Ajax\semantic\html\modules\HtmlModal;
21 21
 
22 22
 abstract class Widget extends HtmlDoubleElement {
23
-	use FieldAsTrait,FormTrait;
23
+	use FieldAsTrait, FormTrait;
24 24
 
25 25
 	/**
26 26
 	 * @var string classname
@@ -53,17 +53,17 @@  discard block
 block discarded – undo
53 53
 	protected $_generated;
54 54
 
55 55
 
56
-	public function __construct($identifier,$model,$modelInstance=NULL) {
56
+	public function __construct($identifier, $model, $modelInstance=NULL) {
57 57
 		parent::__construct($identifier);
58 58
 		$this->_template="%wrapContentBefore%%content%%wrapContentAfter%";
59 59
 		$this->setModel($model);
60
-		if(isset($modelInstance)){
60
+		if (isset($modelInstance)) {
61 61
 			$this->show($modelInstance);
62 62
 		}
63 63
 		$this->_generated=false;
64 64
 	}
65 65
 
66
-	protected function _init($instanceViewer,$contentKey,$content,$edition){
66
+	protected function _init($instanceViewer, $contentKey, $content, $edition) {
67 67
 		$this->_instanceViewer=$instanceViewer;
68 68
 		$this->content=[$contentKey=>$content];
69 69
 		$this->_self=$content;
@@ -75,31 +75,31 @@  discard block
 block discarded – undo
75 75
 	 * @param int|string $fieldName
76 76
 	 * @return int|string|boolean
77 77
 	 */
78
-	protected function _getIndex($fieldName){
78
+	protected function _getIndex($fieldName) {
79 79
 		$index=$fieldName;
80
-		if(\is_string($fieldName)){
80
+		if (\is_string($fieldName)) {
81 81
 			$fields=$this->_instanceViewer->getVisibleProperties();
82 82
 			$index=\array_search($fieldName, $fields);
83 83
 		}
84 84
 		return $index;
85 85
 	}
86 86
 
87
-	protected function _getFieldIdentifier($prefix,$name=""){
87
+	protected function _getFieldIdentifier($prefix, $name="") {
88 88
 		return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier();
89 89
 	}
90 90
 
91
-	protected function _getFieldName($index){
91
+	protected function _getFieldName($index) {
92 92
 		return $this->_instanceViewer->getFieldName($index);
93 93
 	}
94 94
 
95
-	protected function _getFieldCaption($index){
95
+	protected function _getFieldCaption($index) {
96 96
 		return $this->_instanceViewer->getCaption($index);
97 97
 	}
98 98
 
99
-	abstract protected  function _setToolbarPosition($table,$captions=NULL);
99
+	abstract protected  function _setToolbarPosition($table, $captions=NULL);
100 100
 
101
-	public function show($modelInstance){
102
-		if(\is_array($modelInstance)){
101
+	public function show($modelInstance) {
102
+		if (\is_array($modelInstance)) {
103 103
 			$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
104 104
 		}
105 105
 		$this->_modelInstance=$modelInstance;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
 	abstract public function getHtmlComponent();
127 127
 
128
-	public function setAttached($value=true){
128
+	public function setAttached($value=true) {
129 129
 		return $this->getHtmlComponent()->setAttached($value);
130 130
 	}
131 131
 
@@ -136,65 +136,65 @@  discard block
 block discarded – undo
136 136
 	 * @param callable $callback function called after the field compilation
137 137
 	 * @return Widget
138 138
 	 */
139
-	public function afterCompile($index,$callback){
139
+	public function afterCompile($index, $callback) {
140 140
 		$index=$this->_getIndex($index);
141 141
 		$this->_instanceViewer->afterCompile($index, $callback);
142 142
 		return $this;
143 143
 	}
144 144
 
145
-	public function setColor($color){
145
+	public function setColor($color) {
146 146
 		return $this->getHtmlComponent()->setColor($color);
147 147
 	}
148 148
 
149 149
 
150
-	public function setCaptions($captions){
150
+	public function setCaptions($captions) {
151 151
 		$this->_instanceViewer->setCaptions($captions);
152 152
 		return $this;
153 153
 	}
154 154
 
155
-	public function setCaption($index,$caption){
155
+	public function setCaption($index, $caption) {
156 156
 		$this->_instanceViewer->setCaption($this->_getIndex($index), $caption);
157 157
 		return $this;
158 158
 	}
159 159
 
160
-	public function setFields($fields){
160
+	public function setFields($fields) {
161 161
 		$this->_instanceViewer->setVisibleProperties($fields);
162 162
 		return $this;
163 163
 	}
164 164
 
165
-	public function addField($field,$key=null){
166
-		$this->_instanceViewer->addField($field,$key);
165
+	public function addField($field, $key=null) {
166
+		$this->_instanceViewer->addField($field, $key);
167 167
 		return $this;
168 168
 	}
169 169
 
170
-	public function addFields($fields){
170
+	public function addFields($fields) {
171 171
 		$this->_instanceViewer->addFields($fields);
172 172
 		return $this;
173 173
 	}
174 174
 	
175
-	public function countFields(){
175
+	public function countFields() {
176 176
 		return $this->_instanceViewer->visiblePropertiesCount();
177 177
 	}
178 178
 
179
-	public function addMessage($attributes=NULL,$fieldName="message"){
179
+	public function addMessage($attributes=NULL, $fieldName="message") {
180 180
 		$this->_instanceViewer->addField($fieldName);
181 181
 		$count=$this->_instanceViewer->visiblePropertiesCount();
182
-		return $this->fieldAsMessage($count-1,$attributes);
182
+		return $this->fieldAsMessage($count-1, $attributes);
183 183
 	}
184 184
 
185
-	public function addErrorMessage(){
186
-		return $this->addMessage(["error"=>true],"message");
185
+	public function addErrorMessage() {
186
+		return $this->addMessage(["error"=>true], "message");
187 187
 	}
188 188
 
189
-	public function insertField($index,$field,$key=null){
189
+	public function insertField($index, $field, $key=null) {
190 190
 		$index=$this->_getIndex($index);
191
-		$this->_instanceViewer->insertField($index, $field,$key);
191
+		$this->_instanceViewer->insertField($index, $field, $key);
192 192
 		return $this;
193 193
 	}
194 194
 
195
-	public function insertInField($index,$field,$key=null){
195
+	public function insertInField($index, $field, $key=null) {
196 196
 		$index=$this->_getIndex($index);
197
-		$this->_instanceViewer->insertInField($index, $field,$key);
197
+		$this->_instanceViewer->insertInField($index, $field, $key);
198 198
 		return $this;
199 199
 	}
200 200
 
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
 	 * @param callable $callback function parameters are : $value : the field value, $instance : the active instance of model, $fieldIndex : the field index, $rowIndex : the row index
205 205
 	 * @return Widget
206 206
 	 */
207
-	public function setValueFunction($index,$callback){
207
+	public function setValueFunction($index, $callback) {
208 208
 		$index=$this->_getIndex($index);
209 209
 		$this->_instanceViewer->setValueFunction($index, $callback);
210 210
 		return $this;
211 211
 	}
212 212
 
213
-	public function setIdentifierFunction($callback){
213
+	public function setIdentifierFunction($callback) {
214 214
 		$this->_instanceViewer->setIdentifierFunction($callback);
215 215
 		return $this;
216 216
 	}
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 	/**
219 219
 	 * @return \Ajax\semantic\html\collections\menus\HtmlMenu
220 220
 	 */
221
-	public function getToolbar(){
222
-		if(isset($this->_toolbar)===false){
221
+	public function getToolbar() {
222
+		if (isset($this->_toolbar)===false) {
223 223
 			$this->_toolbar=new HtmlMenu("toolbar-".$this->identifier);
224 224
 		}
225 225
 		return $this->_toolbar;
@@ -231,15 +231,15 @@  discard block
 block discarded – undo
231 231
 	 * @param callable $callback function to call on $element
232 232
 	 * @return \Ajax\common\html\HtmlDoubleElement
233 233
 	 */
234
-	public function addInToolbar($element,$callback=NULL){
234
+	public function addInToolbar($element, $callback=NULL) {
235 235
 		$tb=$this->getToolbar();
236
-		if($element instanceof BaseWidget){
237
-			if($element->getIdentifier()===""){
236
+		if ($element instanceof BaseWidget) {
237
+			if ($element->getIdentifier()==="") {
238 238
 				$element->setIdentifier("tb-item-".$this->identifier."-".$tb->count());
239 239
 			}
240 240
 		}
241
-		if(isset($callback)){
242
-			if(\is_callable($callback)){
241
+		if (isset($callback)) {
242
+			if (\is_callable($callback)) {
243 243
 				$callback($element);
244 244
 			}
245 245
 		}
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
 	 * @param callable $callback function($element)
253 253
 	 * @return \Ajax\common\html\HtmlDoubleElement
254 254
 	 */
255
-	public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){
256
-		$result=$this->addInToolbar($caption,$callback);
257
-		if(isset($icon) && method_exists($result, "addIcon"))
255
+	public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) {
256
+		$result=$this->addInToolbar($caption, $callback);
257
+		if (isset($icon) && method_exists($result, "addIcon"))
258 258
 			$result->addIcon($icon);
259 259
 		return $result;
260 260
 	}
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
 	 * @param callable $callback function($element)
265 265
 	 * @return \Ajax\common\Widget
266 266
 	 */
267
-	public function addItemsInToolbar(array $items,$callback=NULL){
268
-		if(JArray::isAssociative($items)){
269
-			foreach ($items as $icon=>$item){
270
-				$this->addItemInToolbar($item,$icon,$callback);
267
+	public function addItemsInToolbar(array $items, $callback=NULL) {
268
+		if (JArray::isAssociative($items)) {
269
+			foreach ($items as $icon=>$item) {
270
+				$this->addItemInToolbar($item, $icon, $callback);
271 271
 			}
272
-		}else{
273
-			foreach ($items as $item){
274
-				$this->addItemInToolbar($item,null,$callback);
272
+		} else {
273
+			foreach ($items as $item) {
274
+				$this->addItemInToolbar($item, null, $callback);
275 275
 			}
276 276
 		}
277 277
 		return $this;
@@ -283,12 +283,12 @@  discard block
 block discarded – undo
283 283
 	 * @param callable $callback function($element)
284 284
 	 * @return \Ajax\common\html\HtmlDoubleElement
285 285
 	 */
286
-	public function addDropdownInToolbar($value,$items,$callback=NULL){
286
+	public function addDropdownInToolbar($value, $items, $callback=NULL) {
287 287
 		$dd=$value;
288 288
 		if (\is_string($value)) {
289
-			$dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items);
289
+			$dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items);
290 290
 		}
291
-		return $this->addInToolbar($dd,$callback);
291
+		return $this->addInToolbar($dd, $callback);
292 292
 	}
293 293
 
294 294
 	/**
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
 	 * @param callable $callback function($element)
298 298
 	 * @return \Ajax\common\html\HtmlDoubleElement
299 299
 	 */
300
-	public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){
301
-		$bt=new HtmlButton("bt-".$caption,$caption,$cssStyle);
302
-		return $this->addInToolbar($bt,$callback);
300
+	public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) {
301
+		$bt=new HtmlButton("bt-".$caption, $caption, $cssStyle);
302
+		return $this->addInToolbar($bt, $callback);
303 303
 	}
304 304
 
305 305
 	/**
@@ -308,9 +308,9 @@  discard block
 block discarded – undo
308 308
 	 * @param callable $callback function($element)
309 309
 	 * @return \Ajax\common\html\HtmlDoubleElement
310 310
 	 */
311
-	public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){
312
-		$bts=new HtmlButtonGroups("",$captions,$asIcon);
313
-		return $this->addInToolbar($bts,$callback);
311
+	public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) {
312
+		$bts=new HtmlButtonGroups("", $captions, $asIcon);
313
+		return $this->addInToolbar($bts, $callback);
314 314
 	}
315 315
 
316 316
 	/**
@@ -320,15 +320,15 @@  discard block
 block discarded – undo
320 320
 	 * @param boolean $labeled
321 321
 	 * @return \Ajax\common\html\HtmlDoubleElement
322 322
 	 */
323
-	public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){
324
-		$bt=new HtmlButton("",$caption);
325
-		$bt->addIcon($icon,$before,$labeled);
323
+	public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) {
324
+		$bt=new HtmlButton("", $caption);
325
+		$bt->addIcon($icon, $before, $labeled);
326 326
 		return $this->addInToolbar($bt);
327 327
 	}
328 328
 
329
-	public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){
330
-		$button=new HtmlButton($identifier,$value,$cssStyle);
331
-		$this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters);
329
+	public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) {
330
+		$button=new HtmlButton($identifier, $value, $cssStyle);
331
+		$this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters);
332 332
 		return $this->addInToolbar($button);
333 333
 	}
334 334
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 	 * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model
359 359
 	 * @return \Ajax\common\Widget
360 360
 	 */
361
-	public function setDefaultValueFunction($defaultValueFunction){
361
+	public function setDefaultValueFunction($defaultValueFunction) {
362 362
 		$this->_instanceViewer->setDefaultValueFunction($defaultValueFunction);
363 363
 		return $this;
364 364
 	}
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	/**
367 367
 	 * @return callable
368 368
 	 */
369
-	public function getDefaultValueFunction(){
369
+	public function getDefaultValueFunction() {
370 370
 		return $this->_instanceViewer->getDefaultValueFunction();
371 371
 	}
372 372
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 	 * @param string|boolean $disable
375 375
 	 * @return string
376 376
 	 */
377
-	public function jsDisabled($disable=true){
377
+	public function jsDisabled($disable=true) {
378 378
 		return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");";
379 379
 	}
380 380
 
@@ -383,12 +383,12 @@  discard block
 block discarded – undo
383 383
 	 * @param callable $callback function($element)
384 384
 	 * @return \Ajax\common\html\HtmlDoubleElement
385 385
 	 */
386
-	public function addEditButtonInToolbar($caption,$callback=NULL){
387
-		$bt=new HtmlButton($this->identifier."-editBtn",$caption);
386
+	public function addEditButtonInToolbar($caption, $callback=NULL) {
387
+		$bt=new HtmlButton($this->identifier."-editBtn", $caption);
388 388
 		$bt->setToggle();
389 389
 		$bt->setActive($this->_edition);
390 390
 		$bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')")));
391
-		return $this->addInToolbar($bt,$callback);
391
+		return $this->addInToolbar($bt, $callback);
392 392
 	}
393 393
 
394 394
 	public function setToolbar(HtmlMenu $_toolbar) {
@@ -402,34 +402,34 @@  discard block
 block discarded – undo
402 402
 	}
403 403
 
404 404
 	public function getForm() {
405
-		if(!isset($this->_form)){
405
+		if (!isset($this->_form)) {
406 406
 			$this->_form=new HtmlForm("frm-".$this->identifier);
407 407
 			$this->setEdition(true);
408 408
 		}
409 409
 		return $this->_form;
410 410
 	}
411 411
 
412
-	public function run(JsUtils $js){
412
+	public function run(JsUtils $js) {
413 413
 		parent::run($js);
414
-		if(isset($this->_form)){
414
+		if (isset($this->_form)) {
415 415
 			$this->runForm($js);
416 416
 		}
417 417
 	}
418 418
 
419
-	protected function runForm(JsUtils $js){
419
+	protected function runForm(JsUtils $js) {
420 420
 		$fields=$this->getContentInstances(HtmlFormField::class);
421
-		foreach ($fields as $field){
421
+		foreach ($fields as $field) {
422 422
 			$this->_form->addField($field);
423 423
 		}
424 424
 		return $this->_form->run($js);
425 425
 	}
426 426
 
427
-	protected function _compileForm(){
428
-		if(isset($this->_form)){
427
+	protected function _compileForm() {
428
+		if (isset($this->_form)) {
429 429
 			$noValidate="";
430
-			if(\sizeof($this->_form->getValidationParams())>0)
430
+			if (\sizeof($this->_form->getValidationParams())>0)
431 431
 				$noValidate="novalidate";
432
-			$this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>");
432
+			$this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>");
433 433
 		}
434 434
 	}
435 435
 
@@ -444,32 +444,32 @@  discard block
 block discarded – undo
444 444
 		return $this;
445 445
 	}
446 446
 
447
-	public function moveFieldTo($from,$to){
447
+	public function moveFieldTo($from, $to) {
448 448
 		return $this->_instanceViewer->moveFieldTo($from, $to);
449 449
 	}
450 450
 
451
-	public function swapFields($index1,$index2){
451
+	public function swapFields($index1, $index2) {
452 452
 		$index1=$this->_getIndex($index1);
453 453
 		$index2=$this->_getIndex($index2);
454 454
 		return $this->_instanceViewer->swapFields($index1, $index2);
455 455
 	}
456 456
 
457
-	public function removeField($index){
457
+	public function removeField($index) {
458 458
 		$index=$this->_getIndex($index);
459 459
 		$this->_instanceViewer->removeField($index);
460 460
 		return $this;
461 461
 	}
462 462
 
463
-	public function asModal($header=null){
464
-		$modal=new HtmlModal("modal-".$this->identifier,$header);
463
+	public function asModal($header=null) {
464
+		$modal=new HtmlModal("modal-".$this->identifier, $header);
465 465
 		$modal->setContent($this);
466
-		if(isset($this->_form)){
466
+		if (isset($this->_form)) {
467 467
 			$this->_form->onSuccess($modal->jsHide());
468 468
 		}
469 469
 		return $modal;
470 470
 	}
471 471
 
472 472
 	public function addToProperty($name, $value, $separator=" ") {
473
-		return $this->getHtmlComponent()->addToProperty($name,$value,$separator);
473
+		return $this->getHtmlComponent()->addToProperty($name, $value, $separator);
474 474
 	}
475 475
 }
Please login to merge, or discard this patch.
Ajax/common/traits/JsUtilsAjaxTrait.php 1 patch
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 	protected $ajaxLoader="<div class=\"ui active centered inline text loader\">Loading</div>";
18 18
 
19 19
 	abstract public function getUrl($url);
20
-	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
20
+	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true);
21 21
 
22
-	protected function _ajax($method,$url,$responseElement="",$parameters=[]) {
23
-		if(isset($this->params["ajax"])){
22
+	protected function _ajax($method, $url, $responseElement="", $parameters=[]) {
23
+		if (isset($this->params["ajax"])) {
24 24
 			extract($this->params["ajax"]);
25 25
 		}
26 26
 		extract($parameters);
@@ -30,109 +30,109 @@  discard block
 block discarded – undo
30 30
 		$originalSelector=$responseElement;
31 31
 		$responseElement=$this->_getResponseElement($responseElement);
32 32
 		$retour.="var self=this;\n";
33
-		if($hasLoader===true && JString::isNotNull($responseElement)){
34
-			$this->addLoading($retour, $responseElement,$ajaxLoader);
35
-		}elseif($hasLoader==="internal"){
33
+		if ($hasLoader===true && JString::isNotNull($responseElement)) {
34
+			$this->addLoading($retour, $responseElement, $ajaxLoader);
35
+		}elseif ($hasLoader==="internal") {
36 36
 			$retour.="\n$(this).addClass('loading');";
37 37
 		}
38
-		$ajaxParameters=["url"=>"url","method"=>"'".\strtoupper($method)."'"];
38
+		$ajaxParameters=["url"=>"url", "method"=>"'".\strtoupper($method)."'"];
39 39
 		
40
-		$ajaxParameters["async"]=($async?"true":"false");
40
+		$ajaxParameters["async"]=($async ? "true" : "false");
41 41
 		
42
-		if(isset($params)){
42
+		if (isset($params)) {
43 43
 			$ajaxParameters["data"]=self::_correctParams($params);
44 44
 		}
45
-		if(isset($headers)){
45
+		if (isset($headers)) {
46 46
 			$ajaxParameters["headers"]=$headers;
47 47
 		}
48 48
 		$this->createAjaxParameters($ajaxParameters, $parameters);
49 49
 		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n";
50
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback,$hasLoader,($historize?$originalSelector:null))."});\n";
51
-		$retour=$this->_addJsCondition($jsCondition,$retour);
50
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null))."});\n";
51
+		$retour=$this->_addJsCondition($jsCondition, $retour);
52 52
 		if ($immediatly)
53 53
 			$this->jquery_code_for_compile[]=$retour;
54 54
 		return $retour;
55 55
 	}
56 56
 
57
-	protected function createAjaxParameters(&$original,$parameters){
58
-		$validParameters=["dataType"=>"'%value%'","beforeSend"=>"function(jqXHR,settings){%value%}","complete"=>"function(jqXHR){%value%}"];
59
-		foreach ($validParameters as $param=>$mask){
60
-			if(isset($parameters[$param])){
57
+	protected function createAjaxParameters(&$original, $parameters) {
58
+		$validParameters=["dataType"=>"'%value%'", "beforeSend"=>"function(jqXHR,settings){%value%}", "complete"=>"function(jqXHR){%value%}"];
59
+		foreach ($validParameters as $param=>$mask) {
60
+			if (isset($parameters[$param])) {
61 61
 				$original[$param]=\str_replace("%value%", $parameters[$param], $mask);
62 62
 			}
63 63
 		}
64 64
 	}
65 65
 
66
-	protected function implodeAjaxParameters($ajaxParameters){
67
-		$s = ''; foreach ($ajaxParameters as $k=>$v) { if ($s !== '') { $s .= ','; } $s .= "'{$k}':{$v}"; }
66
+	protected function implodeAjaxParameters($ajaxParameters) {
67
+		$s=''; foreach ($ajaxParameters as $k=>$v) { if ($s!=='') { $s.=','; } $s.="'{$k}':{$v}"; }
68 68
 		return $s;
69 69
 	}
70 70
 
71
-	protected function _addJsCondition($jsCondition,$jsSource){
72
-		if(isset($jsCondition)){
71
+	protected function _addJsCondition($jsCondition, $jsSource) {
72
+		if (isset($jsCondition)) {
73 73
 			return "if(".$jsCondition."){\n".$jsSource."\n}";
74 74
 		}
75 75
 		return $jsSource;
76 76
 	}
77 77
 
78 78
 
79
-	protected function _getAjaxUrl($url,$attr){
79
+	protected function _getAjaxUrl($url, $attr) {
80 80
 		$url=$this->_correctAjaxUrl($url);
81 81
 		$retour="url='".$url."';";
82 82
 		$slash="/";
83
-		if(JString::endswith($url, "/")===true){
83
+		if (JString::endswith($url, "/")===true) {
84 84
 			$slash="";
85 85
 		}
86
-		if(JString::isNotNull($attr)){
87
-			if ($attr==="value"){
86
+		if (JString::isNotNull($attr)) {
87
+			if ($attr==="value") {
88 88
 				$retour.="url=url+'".$slash."'+$(this).val();\n";
89
-			}elseif ($attr==="html"){
89
+			}elseif ($attr==="html") {
90 90
 				$retour.="url=url+'".$slash."'+$(this).html();\n";
91
-			}elseif(\substr($attr, 0,3)==="js:"){
91
+			}elseif (\substr($attr, 0, 3)==="js:") {
92 92
 				$retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n";
93
-			}elseif($attr!==null && $attr!=="")
93
+			}elseif ($attr!==null && $attr!=="")
94 94
 				$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
95 95
 		}
96 96
 		return $retour;
97 97
 	}
98 98
 	
99
-	protected function onPopstate(){
99
+	protected function onPopstate() {
100 100
 		return "window.onpopstate = function(e){if(e.state){var target=e.state.jqueryDone;$(e.state.selector)[target](e.state.html);}};";
101 101
 	}
102 102
 	
103
-	protected function autoActiveLinks($previousURL="window.location.href"){
104
-		$result= "\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}";
103
+	protected function autoActiveLinks($previousURL="window.location.href") {
104
+		$result="\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}";
105 105
 		$result.="\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;";
106 106
 		return $result;
107 107
 	}
108 108
 
109
-	protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback,$hasLoader=false,$history=null){
110
-		$retour="";$call=null;
109
+	protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader=false, $history=null) {
110
+		$retour=""; $call=null;
111 111
 		if (JString::isNotNull($responseElement)) {
112
-			if(isset($ajaxTransition)){
112
+			if (isset($ajaxTransition)) {
113 113
 				$call=$this->setAjaxDataCall($ajaxTransition);
114
-			}elseif(isset($this->ajaxTransition)){
114
+			}elseif (isset($this->ajaxTransition)) {
115 115
 				$call=$this->ajaxTransition;
116 116
 			}
117
-			if(\is_callable($call))
118
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
117
+			if (\is_callable($call))
118
+				$retour="\t".$call($responseElement, $jqueryDone).";\n";
119 119
 			else
120 120
 				$retour="\t{$responseElement}.{$jqueryDone}( data );\n";
121 121
 		}
122
-		if(isset($history)){
123
-			if($this->params["autoActiveLinks"]){
122
+		if (isset($history)) {
123
+			if ($this->params["autoActiveLinks"]) {
124 124
 				$retour.=$this->autoActiveLinks("url");
125 125
 			}
126 126
 			$retour.="\nwindow.history.pushState({'html':data,'selector':".Javascript::prep_value($history).",'jqueryDone':'{$jqueryDone}'},'', url);";
127 127
 		}
128
-		if($hasLoader==="internal"){
128
+		if ($hasLoader==="internal") {
129 129
 			$retour.="\n$(self).removeClass('loading');";
130 130
 		}
131 131
 		$retour.="\t".$jsCallback."\n";
132 132
 		return $retour;
133 133
 	}
134 134
 
135
-	protected function _getResponseElement($responseElement){
135
+	protected function _getResponseElement($responseElement) {
136 136
 		if (JString::isNotNull($responseElement)) {
137 137
 			$responseElement=Javascript::prep_jquery_selector($responseElement);
138 138
 		}
@@ -142,33 +142,33 @@  discard block
 block discarded – undo
142 142
 	protected function _correctAjaxUrl($url) {
143 143
 		if ($url!=="/" && JString::endsWith($url, "/")===true)
144 144
 			$url=substr($url, 0, strlen($url)-1);
145
-			if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
145
+			if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) {
146 146
 				$url=$this->getUrl($url);
147 147
 			}
148 148
 			return $url;
149 149
 	}
150 150
 
151
-	public static function _correctParams($params){
152
-		if(JString::isNull($params)){
151
+	public static function _correctParams($params) {
152
+		if (JString::isNull($params)) {
153 153
 			return "";
154 154
 		}
155
-		if(\preg_match("@^\{.*?\}$@", $params)){
155
+		if (\preg_match("@^\{.*?\}$@", $params)) {
156 156
 			return '$.param('.$params.')';
157 157
 		}
158 158
 		return $params;
159 159
 	}
160 160
 
161
-	public static function _implodeParams($parameters){
161
+	public static function _implodeParams($parameters) {
162 162
 		$allParameters=[];
163
-		foreach ($parameters as $params){
164
-			if(isset($params))
163
+		foreach ($parameters as $params) {
164
+			if (isset($params))
165 165
 				$allParameters[]=self::_correctParams($params);
166 166
 		}
167 167
 		return \implode("+'&'+", $allParameters);
168 168
 	}
169 169
 
170
-	protected function addLoading(&$retour, $responseElement,$ajaxLoader=null) {
171
-		if(!isset($ajaxLoader)){
170
+	protected function addLoading(&$retour, $responseElement, $ajaxLoader=null) {
171
+		if (!isset($ajaxLoader)) {
172 172
 			$ajaxLoader=$this->ajaxLoader;
173 173
 		}
174 174
 		$loading_notifier='<div class="ajax-loader">'.$ajaxLoader.'</div>';
@@ -176,19 +176,19 @@  discard block
 block discarded – undo
176 176
 		$retour.="\t\t{$responseElement}.prepend('{$loading_notifier}');\n";
177 177
 	}
178 178
 
179
-	protected function setAjaxDataCall($params){
179
+	protected function setAjaxDataCall($params) {
180 180
 		$result=null;
181
-		if(!\is_callable($params)){
182
-			$result=function ($responseElement,$jqueryDone="html") use($params){
183
-				return AjaxTransition::{$params}($responseElement,$jqueryDone);
181
+		if (!\is_callable($params)) {
182
+			$result=function($responseElement, $jqueryDone="html") use($params){
183
+				return AjaxTransition::{$params}($responseElement, $jqueryDone);
184 184
 			};
185 185
 		}
186 186
 		return $result;
187 187
 	}
188 188
 
189
-	protected function setDefaultParameters(&$parameters,$default){
190
-		foreach ($default as $k=>$v){
191
-			if(!isset($parameters[$k]))
189
+	protected function setDefaultParameters(&$parameters, $default) {
190
+		foreach ($default as $k=>$v) {
191
+			if (!isset($parameters[$k]))
192 192
 				$parameters[$k]=$v;
193 193
 		}
194 194
 	}
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 	 * @param string $url The url of the request
203 203
 	 * @param string $responseElement selector of the HTML element displaying the answer
204 204
 	 */
205
-	private function _get($url, $responseElement="",$parameters=[]) {
206
-		return $this->_ajax("get", $url,$responseElement,$parameters);
205
+	private function _get($url, $responseElement="", $parameters=[]) {
206
+		return $this->_ajax("get", $url, $responseElement, $parameters);
207 207
 	}
208 208
 
209 209
 	/**
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
 	 * @param string $responseElement selector of the HTML element displaying the answer
213 213
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
214 214
 	 */
215
-	public function get($url, $responseElement="",$parameters=[]) {
215
+	public function get($url, $responseElement="", $parameters=[]) {
216 216
 		$parameters["immediatly"]=true;
217
-		return $this->_get($url,$responseElement,$parameters);
217
+		return $this->_get($url, $responseElement, $parameters);
218 218
 	}
219 219
 
220 220
 	/**
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 	 * @param string $responseElement selector of the HTML element displaying the answer
225 225
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
226 226
 	 */
227
-	public function ajax($method,$url, $responseElement="", $parameters=[]) {
227
+	public function ajax($method, $url, $responseElement="", $parameters=[]) {
228 228
 		$parameters["immediatly"]=true;
229
-		return $this->_ajax($method,$url,$responseElement,$parameters);
229
+		return $this->_ajax($method, $url, $responseElement, $parameters);
230 230
 	}
231 231
 
232 232
 	/**
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 	 * @param string $responseElement selector of the HTML element displaying the answer
237 237
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
238 238
 	 */
239
-	public function ajaxDeferred($method,$url, $responseElement="", $parameters=[]) {
239
+	public function ajaxDeferred($method, $url, $responseElement="", $parameters=[]) {
240 240
 		$parameters["immediatly"]=false;
241
-		return $this->_ajax($method,$url,$responseElement,$parameters);
241
+		return $this->_ajax($method, $url, $responseElement, $parameters);
242 242
 	}
243 243
 
244 244
 	/**
@@ -247,15 +247,15 @@  discard block
 block discarded – undo
247 247
 	 * @param string $method Method used
248 248
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false)
249 249
 	 */
250
-	private function _json($url, $method="get",$parameters=[]) {
251
-		$parameters=\array_merge($parameters,["hasLoader"=>false]);
250
+	private function _json($url, $method="get", $parameters=[]) {
251
+		$parameters=\array_merge($parameters, ["hasLoader"=>false]);
252 252
 		$jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : "";
253 253
 		$context=isset($parameters['context']) ? $parameters['context'] : "document";
254 254
 		$retour="\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t".$jsCallback.";\n\tfor(var key in data){"
255 255
 				."if($('#'+key,".$context.").length){ if($('#'+key,".$context.").is('[value]')) { $('#'+key,".$context.").val(data[key]);} else { $('#'+key,".$context.").html(data[key]); }}};\n";
256 256
 				$retour.="\t$(document).trigger('jsonReady',[data]);\n";
257 257
 		$parameters["jsCallback"]=$retour;
258
-		return $this->_ajax($method, $url,null,$parameters);
258
+		return $this->_ajax($method, $url, null, $parameters);
259 259
 	}
260 260
 
261 261
 	/**
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false)
266 266
 	 */
267 267
 	public function json($url, $method="get", $parameters=[]) {
268
-		return $this->_json($url,$method,$parameters);
268
+		return $this->_json($url, $method, $parameters);
269 269
 	}
270 270
 
271 271
 	/**
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
 	 * @param string $method default get
277 277
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
278 278
 	 */
279
-	public function jsonOn($event,$element, $url,$method="get",$parameters=array()) {
280
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
281
-		return $this->_add_event($element, $this->jsonDeferred($url,$method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
279
+	public function jsonOn($event, $element, $url, $method="get", $parameters=array()) {
280
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
281
+		return $this->_add_event($element, $this->jsonDeferred($url, $method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
282 282
 	}
283 283
 
284 284
 	/**
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 */
290 290
 	public function jsonDeferred($url, $method="get", $parameters=[]) {
291 291
 		$parameters["immediatly"]=false;
292
-		return $this->_json($url,$method,$parameters);
292
+		return $this->_json($url, $method, $parameters);
293 293
 	}
294 294
 
295 295
 	/**
@@ -300,27 +300,27 @@  discard block
 block discarded – undo
300 300
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json")
301 301
 	 */
302 302
 	private function _jsonArray($maskSelector, $url, $method="get", $parameters=[]) {
303
-		$parameters=\array_merge($parameters,["hasLoader"=>false]);
303
+		$parameters=\array_merge($parameters, ["hasLoader"=>false]);
304 304
 		$rowClass=isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json";
305 305
 		$jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : "";
306 306
 		$context=isset($parameters['context']) ? $parameters['context'] : null;
307
-		if($context===null){
307
+		if ($context===null) {
308 308
 			$parent="$('".$maskSelector."').parent()";
309
-			$newElm = "$('#'+newId)";
310
-		}else{
309
+			$newElm="$('#'+newId)";
310
+		} else {
311 311
 			$parent=$context;
312
-			$newElm = $context.".find('#'+newId)";
312
+			$newElm=$context.".find('#'+newId)";
313 313
 		}
314 314
 		$appendTo="\t\tnewElm.appendTo(".$parent.");\n";
315 315
 		$retour=$parent.".find('.{$rowClass}').remove();";
316 316
 		$retour.="\tdata=($.isPlainObject(data)||$.isArray(data))?data:JSON.parse(data);\n$.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();
317 317
 		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";
318
-		$retour.= $appendTo;
318
+		$retour.=$appendTo;
319 319
 		$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";
320 320
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
321 321
 		$retour.="\t".$jsCallback;
322 322
 		$parameters["jsCallback"]=$retour;
323
-		return $this->_ajax($method, $url,null,$parameters);
323
+		return $this->_ajax($method, $url, null, $parameters);
324 324
 	}
325 325
 
326 326
 	/**
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json")
332 332
 	 */
333 333
 	public function jsonArray($maskSelector, $url, $method="get", $parameters=[]) {
334
-		return $this->_jsonArray($maskSelector, $url,$method,$parameters);
334
+		return $this->_jsonArray($maskSelector, $url, $method, $parameters);
335 335
 	}
336 336
 
337 337
 	/**
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
 	 * @param string $method Method used, default : get
355 355
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true)
356 356
 	 */
357
-	public function jsonArrayOn($event,$element,$maskSelector, $url,$method="get",$parameters=array()) {
358
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
359
-		return $this->_add_event($element, $this->jsonArrayDeferred($maskSelector,$url,$method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
357
+	public function jsonArrayOn($event, $element, $maskSelector, $url, $method="get", $parameters=array()) {
358
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
359
+		return $this->_add_event($element, $this->jsonArrayDeferred($maskSelector, $url, $method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
360 360
 	}
361 361
 
362 362
 	/**
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 */
369 369
 	public function getDeferred($url, $responseElement="", $parameters=[]) {
370 370
 		$parameters["immediatly"]=false;
371
-		return $this->_get($url, $responseElement,$parameters);
371
+		return $this->_get($url, $responseElement, $parameters);
372 372
 	}
373 373
 
374 374
 	/**
@@ -381,8 +381,8 @@  discard block
 block discarded – undo
381 381
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false)
382 382
 	 */
383 383
 	public function getOn($event, $element, $url, $responseElement="", $parameters=array()) {
384
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
385
-		return $this->_add_event($element, $this->getDeferred($url,$responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
384
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
385
+		return $this->_add_event($element, $this->getDeferred($url, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
386 386
 	}
387 387
 
388 388
 	/**
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
 	 * @param array $parameters default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false)
396 396
 	 */
397 397
 	public function ajaxOn($event, $element, $url, $responseElement="", $parameters=array()) {
398
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true,"method"=>"get"]);
399
-		return $this->_add_event($element, $this->ajaxDeferred($parameters["method"],$url,$responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
398
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true, "method"=>"get"]);
399
+		return $this->_add_event($element, $this->ajaxDeferred($parameters["method"], $url, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
400 400
 	}
401 401
 
402 402
 	/**
@@ -430,15 +430,15 @@  discard block
 block discarded – undo
430 430
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true)
431 431
 	 * @return $this
432 432
 	 */
433
-	public function getHref($element,$responseElement="",$parameters=array()){
433
+	public function getHref($element, $responseElement="", $parameters=array()) {
434 434
 		$parameters["attr"]="href";
435
-		if(JString::isNull($responseElement)){
435
+		if (JString::isNull($responseElement)) {
436 436
 			$responseElement='%$(self).attr("data-target")%';
437 437
 		}
438
-		if(!isset($parameters["historize"])){
438
+		if (!isset($parameters["historize"])) {
439 439
 			$parameters["historize"]=true;
440 440
 		}
441
-		return $this->getOnClick($element, "",$responseElement,$parameters);
441
+		return $this->getOnClick($element, "", $responseElement, $parameters);
442 442
 	}
443 443
 	
444 444
 	/**
@@ -448,20 +448,20 @@  discard block
 block discarded – undo
448 448
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false)
449 449
 	 * @return $this
450 450
 	 */
451
-	public function postHref($element,$responseElement="",$parameters=array()){
451
+	public function postHref($element, $responseElement="", $parameters=array()) {
452 452
 		$parameters["attr"]="href";
453
-		if(JString::isNull($responseElement)){
453
+		if (JString::isNull($responseElement)) {
454 454
 			$responseElement='%$(this).attr("data-target")%';
455 455
 		}
456
-		if(!isset($parameters["historize"])){
456
+		if (!isset($parameters["historize"])) {
457 457
 			$parameters["historize"]=true;
458 458
 		}
459
-		return $this->postOnClick($element, "","{}",$responseElement,$parameters);
459
+		return $this->postOnClick($element, "", "{}", $responseElement, $parameters);
460 460
 	}
461 461
 
462
-	private function _post($url, $params="{}",$responseElement="", $parameters=[]) {
462
+	private function _post($url, $params="{}", $responseElement="", $parameters=[]) {
463 463
 		$parameters["params"]=$params;
464
-		return $this->_ajax("POST", $url,$responseElement,$parameters);
464
+		return $this->_ajax("POST", $url, $responseElement, $parameters);
465 465
 	}
466 466
 
467 467
 	/**
@@ -471,8 +471,8 @@  discard block
 block discarded – undo
471 471
 	 * @param string $params JSON parameters
472 472
 	 * @param array $parameters default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
473 473
 	 */
474
-	public function post($url, $params="{}",$responseElement="", $parameters=[]) {
475
-		return $this->_post($url, $params,$responseElement, $parameters);
474
+	public function post($url, $params="{}", $responseElement="", $parameters=[]) {
475
+		return $this->_post($url, $params, $responseElement, $parameters);
476 476
 	}
477 477
 
478 478
 	/**
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 	 * @param string $responseElement selector of the HTML element displaying the answer
484 484
 	 * @param array $parameters default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
485 485
 	 */
486
-	public function postDeferred($url, $params="{}",$responseElement="", $parameters=[]) {
486
+	public function postDeferred($url, $params="{}", $responseElement="", $parameters=[]) {
487 487
 		$parameters["immediatly"]=false;
488 488
 		return $this->_post($url, $params, $responseElement, $parameters);
489 489
 	}
@@ -499,8 +499,8 @@  discard block
 block discarded – undo
499 499
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
500 500
 	 */
501 501
 	public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
502
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
503
-		return $this->_add_event($element, $this->postDeferred($url, $params, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
502
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
503
+		return $this->_add_event($element, $this->postDeferred($url, $params, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
504 504
 	}
505 505
 
506 506
 	/**
@@ -517,33 +517,33 @@  discard block
 block discarded – undo
517 517
 	}
518 518
 
519 519
 	private function _postForm($url, $form, $responseElement, $parameters=[]) {
520
-		if(isset($this->params["ajax"])){
520
+		if (isset($this->params["ajax"])) {
521 521
 			extract($this->params["ajax"]);
522 522
 		}
523
-		$params="{}";$validation=false;
523
+		$params="{}"; $validation=false;
524 524
 		\extract($parameters);
525
-		$async=($async)?"true":"false";
525
+		$async=($async) ? "true" : "false";
526 526
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
527 527
 		$retour=$this->_getAjaxUrl($url, $attr);
528 528
 		$retour.="\n$('#".$form."').trigger('ajaxSubmit');";
529 529
 		$retour.="\nvar params=$('#".$form."').serialize();\n";
530
-		if(isset($params)){
530
+		if (isset($params)) {
531 531
 			$retour.="params+='&'+".self::_correctParams($params).";\n";
532 532
 		}
533 533
 		$responseElement=$this->_getResponseElement($responseElement);
534 534
 		$retour.="var self=this;\n";
535
-		if($hasLoader===true){
536
-			$this->addLoading($retour, $responseElement,$ajaxLoader);
537
-		}elseif($hasLoader==="internal"){
535
+		if ($hasLoader===true) {
536
+			$this->addLoading($retour, $responseElement, $ajaxLoader);
537
+		}elseif ($hasLoader==="internal") {
538 538
 			$retour.="\n$(this).addClass('loading');";
539 539
 		}
540
-		$ajaxParameters=["url"=>"url","method"=>"'POST'","data"=>"params","async"=>$async];
541
-		if(isset($headers)){
540
+		$ajaxParameters=["url"=>"url", "method"=>"'POST'", "data"=>"params", "async"=>$async];
541
+		if (isset($headers)) {
542 542
 			$ajaxParameters["headers"]=$headers;
543 543
 		}
544 544
 		$this->createAjaxParameters($ajaxParameters, $parameters);
545 545
 		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data ) {\n";
546
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback,$hasLoader)."});\n";
546
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader)."});\n";
547 547
 
548 548
 		if ($validation) {
549 549
 			$retour="$('#".$form."').validate({submitHandler: function(form) {
@@ -593,8 +593,8 @@  discard block
 block discarded – undo
593 593
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false)
594 594
 	 */
595 595
 	public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) {
596
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
597
-		return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
596
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
597
+		return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
598 598
 	}
599 599
 
600 600
 	/**
Please login to merge, or discard this patch.
Ajax/common/html/traits/BaseHtmlEventsTrait.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
  * @property string identifier
12 12
  * @property BaseHtml _self
13 13
  */
14
-trait BaseHtmlEventsTrait{
14
+trait BaseHtmlEventsTrait {
15 15
 
16
-	protected $_events=array ();
16
+	protected $_events=array();
17 17
 
18 18
 	/**
19 19
 	 * @param string $event
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
 	 * @return BaseHtml
24 24
 	 */
25 25
 	public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
26
-		if ($stopPropagation === true) {
27
-			$jsCode=Javascript::$stopPropagation . $jsCode;
26
+		if ($stopPropagation===true) {
27
+			$jsCode=Javascript::$stopPropagation.$jsCode;
28 28
 		}
29
-		if ($preventDefault === true) {
30
-			$jsCode=Javascript::$preventDefault . $jsCode;
29
+		if ($preventDefault===true) {
30
+			$jsCode=Javascript::$preventDefault.$jsCode;
31 31
 		}
32 32
 		return $this->_addEvent($event, $jsCode);
33 33
 	}
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	public function _addEvent($event, $jsCode) {
41 41
 		if (array_key_exists($event, $this->_events)) {
42 42
 			if (\is_array($this->_events[$event])) {
43
-				if(array_search($jsCode, $this->_events[$event])===false){
43
+				if (array_search($jsCode, $this->_events[$event])===false) {
44 44
 					$this->_events[$event][]=$jsCode;
45 45
 				}
46 46
 			} else {
47
-				$this->_events[$event]=array ($this->_events[$event],$jsCode );
47
+				$this->_events[$event]=array($this->_events[$event], $jsCode);
48 48
 			}
49 49
 		} else {
50 50
 			$this->_events[$event]=$jsCode;
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
 		return $this->onClick($jsCode);
72 72
 	}
73 73
 
74
-	public function onCreate($jsCode){
75
-		if(isset($this->_events["_create"])){
74
+	public function onCreate($jsCode) {
75
+		if (isset($this->_events["_create"])) {
76 76
 			$this->_events["_create"][]=$jsCode;
77
-		}else{
77
+		} else {
78 78
 			$this->_events["_create"]=[$jsCode];
79 79
 		}
80 80
 		return $this;
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
 	public function addEventsOnRun(JsUtils $js=NULL) {
84 84
 		$this->_eventsOnCreate($js);
85 85
 		if (isset($this->_bsComponent)) {
86
-			foreach ( $this->_events as $event => $jsCode ) {
86
+			foreach ($this->_events as $event => $jsCode) {
87 87
 				$code=$jsCode;
88 88
 				if (\is_array($jsCode)) {
89 89
 					$code="";
90
-					foreach ( $jsCode as $jsC ) {
90
+					foreach ($jsCode as $jsC) {
91 91
 						if ($jsC instanceof AjaxCall) {
92
-							$code.="\n" . $jsC->compile($js);
92
+							$code.="\n".$jsC->compile($js);
93 93
 						} else {
94
-							$code.="\n" . $jsC;
94
+							$code.="\n".$jsC;
95 95
 						}
96 96
 					}
97 97
 				} elseif ($jsCode instanceof AjaxCall) {
@@ -99,20 +99,20 @@  discard block
 block discarded – undo
99 99
 				}
100 100
 				$this->_bsComponent->addEvent($event, $code);
101 101
 			}
102
-			$this->_events=array ();
102
+			$this->_events=array();
103 103
 			return $this->_bsComponent->getScript();
104 104
 		}
105 105
 		return "";
106 106
 	}
107 107
 
108
-	protected function _eventsOnCreate(JsUtils $js=NULL){
109
-		if(isset($this->_events["_create"])){
108
+	protected function _eventsOnCreate(JsUtils $js=NULL) {
109
+		if (isset($this->_events["_create"])) {
110 110
 			$create=$this->_events["_create"];
111
-			if(\is_array($create)){
111
+			if (\is_array($create)) {
112 112
 				$create=\implode("", $create);
113 113
 			}
114
-			if(isset($js) && $create!=="")
115
-				$js->exec($create,true);
114
+			if (isset($js) && $create!=="")
115
+				$js->exec($create, true);
116 116
 			unset($this->_events["_create"]);
117 117
 		}
118 118
 	}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @return $this
127 127
 	 */
128 128
 	public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) {
129
-		$params=array ("url" => $url,"responseElement" => $responseElement );
129
+		$params=array("url" => $url, "responseElement" => $responseElement);
130 130
 		$params=array_merge($params, $parameters);
131 131
 		$this->_addEvent($event, new AjaxCall($operation, $params));
132 132
 		return $this;
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 	 **/
170 170
 	public function postOn($event, $url, $params="{}", $responseElement="", $parameters=array()) {
171 171
 		$allParameters=[];
172
-		if(isset($parameters["params"])){
172
+		if (isset($parameters["params"])) {
173 173
 			$allParameters[]=JsUtils::_correctParams($parameters["params"]);
174 174
 		}
175
-		if(isset($params)){
175
+		if (isset($params)) {
176 176
 			$allParameters[]=JsUtils::_correctParams($params);
177 177
 		}
178 178
 		$parameters["params"]=\implode("+'&'+", $allParameters);
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	}
220 220
 
221 221
 	public function jsDoJquery($jqueryCall, $param="") {
222
-		return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . Javascript::prep_value($param) . ");";
222
+		return "$('#".$this->identifier."').".$jqueryCall."(".Javascript::prep_value($param).");";
223 223
 	}
224 224
 
225 225
 	public function executeOnRun($jsCode) {
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 
241 241
 	public function jsToggle($value) {
242
-		return $this->jsDoJquery("toggle",$value);
242
+		return $this->jsDoJquery("toggle", $value);
243 243
 	}
244 244
 	/**
245 245
 	 * @return multitype:
Please login to merge, or discard this patch.
Ajax/common/html/HtmlCollection.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -14,44 +14,44 @@  discard block
 block discarded – undo
14 14
  */
15 15
 abstract class HtmlCollection extends HtmlDoubleElement {
16 16
 
17
-	public function __construct($identifier,$tagName="div"){
18
-		parent::__construct($identifier,$tagName);
17
+	public function __construct($identifier, $tagName="div") {
18
+		parent::__construct($identifier, $tagName);
19 19
 		$this->content=array();
20 20
 	}
21 21
 
22
-	public function addItems($items){
23
-		if(JArray::isAssociative($items)){
24
-			foreach ($items as $k=>$v){
25
-				$this->addItem([$k,$v]);
22
+	public function addItems($items) {
23
+		if (JArray::isAssociative($items)) {
24
+			foreach ($items as $k=>$v) {
25
+				$this->addItem([$k, $v]);
26 26
 			}
27
-		}else{
28
-			foreach ($items as $item){
27
+		} else {
28
+			foreach ($items as $item) {
29 29
 				$this->addItem($item);
30 30
 			}
31 31
 		}
32 32
 		return $this;
33 33
 	}
34 34
 
35
-	public function setItems($items){
35
+	public function setItems($items) {
36 36
 		$this->content=$items;
37 37
 		return $this;
38 38
 	}
39 39
 
40
-	public function getItems(){
40
+	public function getItems() {
41 41
 		return $this->content;
42 42
 	}
43 43
 
44
-	protected function getItemToAdd($item){
44
+	protected function getItemToAdd($item) {
45 45
 		$itemO=$item;
46
-		if($this->createCondition($item)===true){
46
+		if ($this->createCondition($item)===true) {
47 47
 			$itemO=$this->createItem($item);
48 48
 		}
49 49
 		return $itemO;
50 50
 	}
51 51
 
52
-	protected function setItemIdentifier($item,$classname,$index){
53
-		if($item instanceof BaseWidget){
54
-			if(JString::isNull($item->getIdentifier())){
52
+	protected function setItemIdentifier($item, $classname, $index) {
53
+		if ($item instanceof BaseWidget) {
54
+			if (JString::isNull($item->getIdentifier())) {
55 55
 				$item->setIdentifier($classname."-".$this->identifier."-".$index);
56 56
 			}
57 57
 		}
@@ -62,15 +62,15 @@  discard block
 block discarded – undo
62 62
 	 * @param HtmlDoubleElement|string|array $item
63 63
 	 * @return \Ajax\common\html\HtmlDoubleElement
64 64
 	 */
65
-	public function addItem($item){
65
+	public function addItem($item) {
66 66
 		$itemO=$this->getItemToAdd($item);
67 67
 		$this->addContent($itemO);
68 68
 		return $itemO;
69 69
 	}
70 70
 
71
-	public function insertItem($item,$position=0){
71
+	public function insertItem($item, $position=0) {
72 72
 		$itemO=$this->getItemToAdd($item);
73
-		\array_splice( $this->content, $position, 0, array($itemO));
73
+		\array_splice($this->content, $position, 0, array($itemO));
74 74
 		return $itemO;
75 75
 	}
76 76
 
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
 		return $this;
94 94
 	}
95 95
 
96
-	public function removeItem($index){
96
+	public function removeItem($index) {
97 97
 		return array_splice($this->content, $index, 1);
98 98
 	}
99 99
 
100
-	public function count(){
100
+	public function count() {
101 101
 		return \sizeof($this->content);
102 102
 	}
103 103
 
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 		return $this->addItem($function($object));
109 109
 	}
110 110
 
111
-	public function apply($callBack){
112
-		foreach ($this->content as $item){
111
+	public function apply($callBack) {
112
+		foreach ($this->content as $item) {
113 113
 			$callBack($item);
114 114
 		}
115 115
 		return $this;
@@ -129,23 +129,23 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	abstract protected function createItem($value);
131 131
 
132
-	protected function createCondition($value){
132
+	protected function createCondition($value) {
133 133
 		return \is_object($value)===false;
134 134
 	}
135 135
 
136
-	protected function contentAs($tagName){
137
-		foreach ($this->content as $item){
136
+	protected function contentAs($tagName) {
137
+		foreach ($this->content as $item) {
138 138
 			$item->setTagName($tagName);
139 139
 		}
140 140
 		return $this;
141 141
 	}
142 142
 
143
-	public function setProperties($properties){
143
+	public function setProperties($properties) {
144 144
 		$i=0;
145
-		foreach ($properties as $k=>$v){
145
+		foreach ($properties as $k=>$v) {
146 146
 			$c=$this->content[$i++];
147
-			if(isset($c))
148
-				$c->setProperty($k,$v);
147
+			if (isset($c))
148
+				$c->setProperty($k, $v);
149 149
 			else
150 150
 				return $this;
151 151
 		}
@@ -158,17 +158,17 @@  discard block
 block discarded – undo
158 158
 	 * @param array|mixed $values
159 159
 	 * @return $this
160 160
 	 */
161
-	public function setPropertyValues($property,$values){
161
+	public function setPropertyValues($property, $values) {
162 162
 		$i=0;
163
-		if(\is_array($values)===false){
164
-			$values=\array_fill(0, $this->count(),$values);
163
+		if (\is_array($values)===false) {
164
+			$values=\array_fill(0, $this->count(), $values);
165 165
 		}
166
-		foreach ($values as $value){
166
+		foreach ($values as $value) {
167 167
 			$c=$this->content[$i++];
168
-			if(isset($c)){
169
-				$c->setProperty($property,$value);
168
+			if (isset($c)) {
169
+				$c->setProperty($property, $value);
170 170
 			}
171
-			else{
171
+			else {
172 172
 				return $this;
173 173
 			}
174 174
 		}
@@ -181,17 +181,17 @@  discard block
 block discarded – undo
181 181
 	 * @param array|mixed $values
182 182
 	 * @return $this
183 183
 	 */
184
-	public function addPropertyValues($property,$values){
184
+	public function addPropertyValues($property, $values) {
185 185
 		$i=0;
186
-		if(\is_array($values)===false){
187
-			$values=\array_fill(0, $this->count(),$values);
186
+		if (\is_array($values)===false) {
187
+			$values=\array_fill(0, $this->count(), $values);
188 188
 		}
189
-		foreach ($values as $value){
189
+		foreach ($values as $value) {
190 190
 			$c=$this->content[$i++];
191
-			if(isset($c)){
192
-				$c->addToProperty($property,$value);
191
+			if (isset($c)) {
192
+				$c->addToProperty($property, $value);
193 193
 			}
194
-			else{
194
+			else {
195 195
 				return $this;
196 196
 			}
197 197
 		}
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
202 202
 		$index=0;
203 203
 		$classname=\strtolower(JReflection::shortClassName($this));
204
-		foreach ($this->content as $item){
205
-			$this->setItemIdentifier($item,$classname,$index++);
204
+		foreach ($this->content as $item) {
205
+			$this->setItemIdentifier($item, $classname, $index++);
206 206
 		}
207
-		return parent::compile($js,$view);
207
+		return parent::compile($js, $view);
208 208
 	}
209 209
 
210
-	public function getItemById($identifier){
210
+	public function getItemById($identifier) {
211 211
 		return $this->getElementById($identifier, $this->content);
212 212
 	}
213 213
 
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
 	 * @param string $target
217 217
 	 * @return HtmlCollection
218 218
 	 */
219
-	public function asLinks($hrefs=[],$target=NUll) {
220
-		foreach ( $this->content as $index=>$item ) {
221
-			if($item instanceof HtmlDoubleElement){
219
+	public function asLinks($hrefs=[], $target=NUll) {
220
+		foreach ($this->content as $index=>$item) {
221
+			if ($item instanceof HtmlDoubleElement) {
222 222
 				$href="";
223
-				if(isset($hrefs[$index]))
223
+				if (isset($hrefs[$index]))
224 224
 					$href=$hrefs[$index];
225
-				$item->asLink($href,$target);
225
+				$item->asLink($href, $target);
226 226
 			}
227 227
 		}
228 228
 		return $this;
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 	 * @param int $length  If length is omitted, removes everything from offset to the end of the array. If length is specified and is positive, then that many elements will be removed. If length is specified and is negative then the end of the removed portion will be that many elements from the end of the array. If length is specified and is zero, no elements will be removed. Tip: to remove everything from offset to the end of the array when replacement is also specified, use count($input) for length. 
235 235
 	 * @return $this
236 236
 	 */
237
-	public function splice($offset,$length=null){
238
-		$this->content=array_slice($this->content, $offset,$length);
237
+	public function splice($offset, $length=null) {
238
+		$this->content=array_slice($this->content, $offset, $length);
239 239
 		return $this;
240 240
 	}
241 241
 }
Please login to merge, or discard this patch.
Ajax/common/html/BaseHtml.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
  * @version 1.3
16 16
  */
17 17
 abstract class BaseHtml extends BaseWidget {
18
-	use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait;
18
+	use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait;
19 19
 	protected $_template;
20 20
 	protected $tagName;
21
-	protected $_wrapBefore=array ();
22
-	protected $_wrapAfter=array ();
21
+	protected $_wrapBefore=array();
22
+	protected $_wrapAfter=array();
23 23
 	protected $_bsComponent;
24 24
 	protected $_compiled=false;
25 25
 	protected $_runned=false;
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 	 */
34 34
 	abstract public function run(JsUtils $js);
35 35
 
36
-	private function _callSetter($setter,$key,$value,&$array){
36
+	private function _callSetter($setter, $key, $value, &$array) {
37 37
 		$result=false;
38
-		if (method_exists($this, $setter) && substr($setter, 0, 1) !== "_") {
38
+		if (method_exists($this, $setter) && substr($setter, 0, 1)!=="_") {
39 39
 			try {
40 40
 				$this->$setter($value);
41 41
 				unset($array[$key]);
42 42
 				$result=true;
43
-			} catch ( \Exception $e ) {
43
+			}catch (\Exception $e) {
44 44
 				$result=false;
45 45
 			}
46 46
 		}
@@ -48,17 +48,17 @@  discard block
 block discarded – undo
48 48
 	}
49 49
 
50 50
 	protected function getTemplate(JsUtils $js=NULL) {
51
-		return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js);
51
+		return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js);
52 52
 	}
53 53
 
54 54
 	protected function ctrl($name, $value, $typeCtrl) {
55 55
 		if (\is_array($typeCtrl)) {
56
-			if (array_search($value, $typeCtrl) === false) {
57
-				throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}");
56
+			if (array_search($value, $typeCtrl)===false) {
57
+				throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
58 58
 			}
59 59
 		} else {
60 60
 			if (!$typeCtrl($value)) {
61
-				throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name);
61
+				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name);
62 62
 			}
63 63
 		}
64 64
 		return true;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") {
76 76
 		if (\is_array($typeCtrl)) {
77 77
 			$this->removeOldValues($name, $typeCtrl);
78
-			$name.=$separator . $value;
78
+			$name.=$separator.$value;
79 79
 		}
80 80
 		return $this;
81 81
 	}
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 		if (\is_array($typeCtrl)) {
88 88
 			$this->removeOldValues($name, $typeCtrl);
89 89
 		}
90
-		$name.=$separator . $value;
90
+		$name.=$separator.$value;
91 91
 		return $this;
92 92
 	}
93 93
 
94 94
 	protected function addToMember(&$name, $value, $separator=" ") {
95
-		$name=str_ireplace($value, "", $name) . $separator . $value;
95
+		$name=str_ireplace($value, "", $name).$separator.$value;
96 96
 		return $this;
97 97
 	}
98 98
 
@@ -103,18 +103,18 @@  discard block
 block discarded – undo
103 103
 		$oldValue=trim($oldValue);
104 104
 	}
105 105
 
106
-	protected function _getElementBy($callback,$elements){
106
+	protected function _getElementBy($callback, $elements) {
107 107
 		if (\is_array($elements)) {
108 108
 			$elements=\array_values($elements);
109 109
 			$flag=false;
110 110
 			$index=0;
111
-			while ( !$flag && $index < sizeof($elements) ) {
111
+			while (!$flag && $index<sizeof($elements)) {
112 112
 				if ($elements[$index] instanceof BaseHtml)
113 113
 					$flag=($callback($elements[$index]));
114 114
 					$index++;
115 115
 			}
116
-			if ($flag === true)
117
-				return $elements[$index - 1];
116
+			if ($flag===true)
117
+				return $elements[$index-1];
118 118
 		} elseif ($elements instanceof BaseHtml) {
119 119
 			if ($callback($elements))
120 120
 				return $elements;
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
 	}
143 143
 
144 144
 	public function fromArray($array) {
145
-		foreach ( $this as $key => $value ) {
146
-			if(array_key_exists($key, $array)===true)
147
-				$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
145
+		foreach ($this as $key => $value) {
146
+			if (array_key_exists($key, $array)===true)
147
+				$this->_callSetter("set".ucfirst($key), $key, $array[$key], $array);
148 148
 		}
149
-		foreach ( $array as $key => $value ) {
150
-			if($this->_callSetter($key, $key, $value, $array)===false){
151
-				$this->_callSetter("set" . ucfirst($key), $key, $value, $array);
149
+		foreach ($array as $key => $value) {
150
+			if ($this->_callSetter($key, $key, $value, $array)===false) {
151
+				$this->_callSetter("set".ucfirst($key), $key, $value, $array);
152 152
 			}
153 153
 		}
154 154
 		return $array;
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
 	public function fromDatabaseObjects($objects, $function) {
158 158
 		if (isset($objects)) {
159
-			foreach ( $objects as $object ) {
159
+			foreach ($objects as $object) {
160 160
 				$this->fromDatabaseObject($object, $function);
161 161
 			}
162 162
 		}
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 
178 178
 
179 179
 	public function getElementById($identifier, $elements) {
180
-		return $this->_getElementBy(function(BaseWidget $element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements);
180
+		return $this->_getElementBy(function(BaseWidget $element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements);
181 181
 	}
182 182
 
183 183
 	public function getBsComponent() {
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 	}
191 191
 
192 192
 	protected function compile_once(JsUtils $js=NULL, &$view=NULL) {
193
-		if(!$this->_compiled){
194
-			if(isset($js)){
193
+		if (!$this->_compiled) {
194
+			if (isset($js)) {
195 195
 				$beforeCompile=$js->getParam("beforeCompileHtml");
196
-				if(\is_callable($beforeCompile)){
197
-					$beforeCompile($this,$js,$view);
196
+				if (\is_callable($beforeCompile)) {
197
+					$beforeCompile($this, $js, $view);
198 198
 				}
199 199
 			}
200
-			if(\is_callable($this->_preCompile)){
200
+			if (\is_callable($this->_preCompile)) {
201 201
 				$pc=$this->_preCompile;
202 202
 				$pc($this);
203 203
 			}
@@ -207,15 +207,15 @@  discard block
 block discarded – undo
207 207
 	}
208 208
 
209 209
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
210
-		$this->compile_once($js,$view);
210
+		$this->compile_once($js, $view);
211 211
 		$result=$this->getTemplate($js);
212
-		foreach ( $this as $key => $value ) {
213
-				if(\strstr($result, "%{$key}%")!==false){
212
+		foreach ($this as $key => $value) {
213
+				if (\strstr($result, "%{$key}%")!==false) {
214 214
 					if (\is_array($value)) {
215 215
 						$v=PropertyWrapper::wrap($value, $js);
216
-					}elseif($value instanceof \stdClass){
217
-							$v=\print_r($value,true);
218
-					}else{
216
+					}elseif ($value instanceof \stdClass) {
217
+							$v=\print_r($value, true);
218
+					} else {
219 219
 						$v=$value;
220 220
 					}
221 221
 					$result=str_replace("%{$key}%", $v, $result);
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
 		}
224 224
 		if (isset($js)===true) {
225 225
 			$this->run($js);
226
-			if (isset($view) === true) {
226
+			if (isset($view)===true) {
227 227
 				$js->addViewElement($this->_identifier, $result, $view);
228 228
 			}
229 229
 		}
230 230
 
231
-		if(\is_callable($this->_postCompile)){
231
+		if (\is_callable($this->_postCompile)) {
232 232
 			$pc=$this->_postCompile;
233 233
 			$pc($this);
234 234
 		}
@@ -242,13 +242,13 @@  discard block
 block discarded – undo
242 242
 	 * @param array $parameters default: ["jsCallback"=>"","jqueryDone"=>"append"]
243 243
 	 * @return \Ajax\common\html\BaseHtml
244 244
 	 */
245
-	public function setDraggable($attr="id",$dropZone=null,$parameters=[]){
245
+	public function setDraggable($attr="id", $dropZone=null, $parameters=[]) {
246 246
 		$this->setProperty("draggable", "true");
247
-		$this->addEvent("dragstart",Javascript::draggable($attr));
248
-		if(isset($dropZone)&& $dropZone instanceof BaseHtml){
249
-			$jqueryDone="append";$jsCallback="";
247
+		$this->addEvent("dragstart", Javascript::draggable($attr));
248
+		if (isset($dropZone) && $dropZone instanceof BaseHtml) {
249
+			$jqueryDone="append"; $jsCallback="";
250 250
 			extract($parameters);
251
-			$dropZone->asDropZone($jsCallback,$jqueryDone,$parameters);
251
+			$dropZone->asDropZone($jsCallback, $jqueryDone, $parameters);
252 252
 		}
253 253
 		return $this;
254 254
 	}
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 	 * @param array $parameters
261 261
 	 * @return \Ajax\common\html\BaseHtml
262 262
 	 */
263
-	public function asDropZone($jsCallback="",$jqueryDone="append",$parameters=[]){
263
+	public function asDropZone($jsCallback="", $jqueryDone="append", $parameters=[]) {
264 264
 		$stopPropagation=false;
265
-		$this->addEvent("dragover", '', $stopPropagation,true);
265
+		$this->addEvent("dragover", '', $stopPropagation, true);
266 266
 		extract($parameters);
267
-		$this->addEvent("drop",Javascript::dropZone($jqueryDone,$jsCallback),$stopPropagation,true);
267
+		$this->addEvent("drop", Javascript::dropZone($jqueryDone, $jsCallback), $stopPropagation, true);
268 268
 		return $this;
269 269
 	}
270 270
 
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 		return $this->compile();
273 273
 	}
274 274
 
275
-	public function onPostCompile($callback){
275
+	public function onPostCompile($callback) {
276 276
 		$this->_postCompile=$callback;
277 277
 	}
278 278
 
279
-	public function onPreCompile($callback){
279
+	public function onPreCompile($callback) {
280 280
 		$this->_preCompile=$callback;
281 281
 	}
282 282
 }
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
  * @property boolean $_visibleHover
15 15
  * @property InstanceViewer $_instanceViewer
16 16
  */
17
-trait DataTableFieldAsTrait{
18
-	protected $_buttons=["display","edit","delete"];
17
+trait DataTableFieldAsTrait {
18
+	protected $_buttons=["display", "edit", "delete"];
19 19
 	protected $_buttonsColumn;
20
-	abstract public function addField($field,$key=null);
21
-	abstract public function insertField($index,$field,$key=null);
22
-	abstract public function insertInField($index,$field,$key=null);
23
-	abstract public function fieldAs($index,$type,$attributes=NULL);
20
+	abstract public function addField($field, $key=null);
21
+	abstract public function insertField($index, $field, $key=null);
22
+	abstract public function insertInField($index, $field, $key=null);
23
+	abstract public function fieldAs($index, $type, $attributes=NULL);
24 24
 	abstract protected function cleanIdentifier($id);
25
-	abstract protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null);
25
+	abstract protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null);
26 26
 	
27 27
 	/**
28 28
 	 * @param string $caption
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	 * @param boolean $visibleHover
31 31
 	 * @return callable
32 32
 	 */
33
-	private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){
34
-		return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback);
33
+	private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) {
34
+		return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback);
35 35
 	}
36 36
 
37 37
 	/**
@@ -40,20 +40,20 @@  discard block
 block discarded – undo
40 40
 	 * @param callable $callback
41 41
 	 * @return callable
42 42
 	 */
43
-	private function getCallable($thisCallback,$parameters,$callback=null){
44
-		$result=function($instance) use($thisCallback,$parameters,$callback){
45
-			$object=call_user_func_array(array($this,$thisCallback), $parameters);
46
-			if(isset($callback)){
47
-				if(\is_callable($callback)){
48
-					$callback($object,$instance,$this->_instanceViewer->count()+1);
43
+	private function getCallable($thisCallback, $parameters, $callback=null) {
44
+		$result=function($instance) use($thisCallback, $parameters, $callback){
45
+			$object=call_user_func_array(array($this, $thisCallback), $parameters);
46
+			if (isset($callback)) {
47
+				if (\is_callable($callback)) {
48
+					$callback($object, $instance, $this->_instanceViewer->count()+1);
49 49
 				}
50 50
 			}
51
-			if($object instanceof HtmlSemDoubleElement){
51
+			if ($object instanceof HtmlSemDoubleElement) {
52 52
 				$id=$this->_instanceViewer->getIdentifier();
53
-				$object->setProperty("data-ajax",$id);
54
-				if($object->propertyContains("class","visibleover")){
53
+				$object->setProperty("data-ajax", $id);
54
+				if ($object->propertyContains("class", "visibleover")) {
55 55
 					$this->_visibleHover=true;
56
-					$object->setProperty("style","visibility:hidden;");
56
+					$object->setProperty("style", "visibility:hidden;");
57 57
 				}
58 58
 			}
59 59
 			return $object;
@@ -65,16 +65,16 @@  discard block
 block discarded – undo
65 65
 	 * @param string $caption
66 66
 	 * @return HtmlButton
67 67
 	 */
68
-	private function getFieldButton($caption,$visibleHover=true){
69
-		$bt= new HtmlButton($this->cleanIdentifier($caption),$caption);
70
-		if($visibleHover)
68
+	private function getFieldButton($caption, $visibleHover=true) {
69
+		$bt=new HtmlButton($this->cleanIdentifier($caption), $caption);
70
+		if ($visibleHover)
71 71
 			$this->_visibleOver($bt);
72 72
 		return $bt;
73 73
 	}
74 74
 
75
-	private function getFieldButtons($buttons,$visibleHover=true){
76
-		$bts=new HtmlButtonGroups("",$buttons);
77
-		if($visibleHover)
75
+	private function getFieldButtons($buttons, $visibleHover=true) {
76
+		$bts=new HtmlButtonGroups("", $buttons);
77
+		if ($visibleHover)
78 78
 			$this->_visibleOver($bts);
79 79
 		return $bts;
80 80
 	}
@@ -88,19 +88,19 @@  discard block
 block discarded – undo
88 88
 	 * @param array $attributes associative array (<b>ajax</b> key is for ajax post)
89 89
 	 * @return DataTable
90 90
 	 */
91
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
92
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){
93
-			$button=new HtmlButton($id,$value,$cssStyle);
94
-			$button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]);
95
-			if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
91
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
92
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){
93
+			$button=new HtmlButton($id, $value, $cssStyle);
94
+			$button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]);
95
+			if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
96 96
 				$this->_visibleOver($button);
97 97
 				return $button;
98
-		}, $index,$attributes);
98
+		}, $index, $attributes);
99 99
 	}
100 100
 
101
-	protected function _visibleOver(BaseHtml $element){
101
+	protected function _visibleOver(BaseHtml $element) {
102 102
 		$this->_visibleHover=true;
103
-		return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;");
103
+		return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;");
104 104
 	}
105 105
 
106 106
 	/**
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	 * @param boolean $visibleHover
111 111
 	 * @return DataTable
112 112
 	 */
113
-	public function addFieldButton($caption,$visibleHover=true,$callback=null){
114
-		$this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback));
113
+	public function addFieldButton($caption, $visibleHover=true, $callback=null) {
114
+		$this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback));
115 115
 		return $this;
116 116
 	}
117 117
 
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @param boolean $visibleHover
123 123
 	 * @return DataTable
124 124
 	 */
125
-	public function addFieldButtons($buttons,$visibleHover=true,$callback=null){
126
-		$this->addField($this->getCallable("getFieldButtons",[$buttons,$visibleHover],$callback));
125
+	public function addFieldButtons($buttons, $visibleHover=true, $callback=null) {
126
+		$this->addField($this->getCallable("getFieldButtons", [$buttons, $visibleHover], $callback));
127 127
 		return $this;
128 128
 	}
129 129
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 * @param callable $callback
135 135
 	 * @return DataTable
136 136
 	 */
137
-	public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){
138
-		$this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
137
+	public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) {
138
+		$this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback));
139 139
 		return $this;
140 140
 	}
141 141
 
@@ -146,25 +146,25 @@  discard block
 block discarded – undo
146 146
 	 * @param callable $callback
147 147
 	 * @return DataTable
148 148
 	 */
149
-	public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null,$key=null){
150
-		$this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback),$key);
149
+	public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null, $key=null) {
150
+		$this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback), $key);
151 151
 		return $this;
152 152
 	}
153 153
 
154
-	private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null,$key=null){
155
-		$this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback),$key);
154
+	private function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null, $key=null) {
155
+		$this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback), $key);
156 156
 		return $this;
157 157
 	}
158 158
 
159
-	public function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null,$key=null){
160
-		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback),$key);
159
+	public function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null, $key=null) {
160
+		$this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback), $key);
161 161
 		return $this;
162 162
 	}
163 163
 
164
-	private function getDefaultButton($icon,$class=null,$visibleHover=true){
165
-		$bt=$this->getFieldButton("",$visibleHover);
164
+	private function getDefaultButton($icon, $class=null, $visibleHover=true) {
165
+		$bt=$this->getFieldButton("", $visibleHover);
166 166
 		$bt->asIcon($icon);
167
-		if(isset($class))
167
+		if (isset($class))
168 168
 			$bt->addClass($class);
169 169
 		return $bt;
170 170
 	}
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 	 * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
177 177
 	 * @return DataTable
178 178
 	 */
179
-	public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){
179
+	public function addDeleteButton($visibleHover=true, $deleteBehavior=[], $callback=null) {
180 180
 		$this->_deleteBehavior=$deleteBehavior;
181
-		return $this->addDefaultButton("remove","_delete red basic",$visibleHover,$callback,"delete");
181
+		return $this->addDefaultButton("remove", "_delete red basic", $visibleHover, $callback, "delete");
182 182
 	}
183 183
 
184 184
 	/**
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 	 * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
189 189
 	 * @return DataTable
190 190
 	 */
191
-	public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){
191
+	public function addEditButton($visibleHover=true, $editBehavior=[], $callback=null) {
192 192
 		$this->_editBehavior=$editBehavior;
193
-		return $this->addDefaultButton("edit","_edit basic",$visibleHover,$callback,"edit");
193
+		return $this->addDefaultButton("edit", "_edit basic", $visibleHover, $callback, "edit");
194 194
 	}
195 195
 	
196 196
 	/**
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 	 * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
201 201
 	 * @return DataTable
202 202
 	 */
203
-	public function addDisplayButton($visibleHover=true,$displayBehavior=[],$callback=null){
203
+	public function addDisplayButton($visibleHover=true, $displayBehavior=[], $callback=null) {
204 204
 		$this->_displayBehavior=$displayBehavior;
205
-		return $this->addDefaultButton("eye","_display basic",$visibleHover,$callback,"display");
205
+		return $this->addDefaultButton("eye", "_display basic", $visibleHover, $callback, "display");
206 206
 	}
207 207
 
208 208
 	/**
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
 	 * @param callable $callbackDelete this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
214 214
 	 * @return DataTable
215 215
 	 */
216
-	public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){
217
-		$this->addEditButton($visibleHover,$behavior,$callbackEdit);
216
+	public function addEditDeleteButtons($visibleHover=true, $behavior=[], $callbackEdit=null, $callbackDelete=null) {
217
+		$this->addEditButton($visibleHover, $behavior, $callbackEdit);
218 218
 		$index=$this->_instanceViewer->visiblePropertiesCount()-1;
219
-		$this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete);
219
+		$this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete);
220 220
 		return $this;
221 221
 	}
222 222
 	
@@ -229,35 +229,35 @@  discard block
 block discarded – undo
229 229
 	 * @param callable $callbackDelete this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
230 230
 	 * @return DataTable
231 231
 	 */
232
-	public function addAllButtons($visibleHover=true,$behavior=[],$callbackDisplay=null,$callbackEdit=null,$callbackDelete=null){
233
-		$this->addDisplayButton($visibleHover,$behavior,$callbackDisplay);
232
+	public function addAllButtons($visibleHover=true, $behavior=[], $callbackDisplay=null, $callbackEdit=null, $callbackDelete=null) {
233
+		$this->addDisplayButton($visibleHover, $behavior, $callbackDisplay);
234 234
 		$index=$this->_instanceViewer->visiblePropertiesCount()-1;
235 235
 		$this->_buttonsColumn=$index;
236
-		$this->insertEditButtonIn($index,$visibleHover,$behavior,$callbackEdit);
237
-		$this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete);
236
+		$this->insertEditButtonIn($index, $visibleHover, $behavior, $callbackEdit);
237
+		$this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete);
238 238
 		return $this;
239 239
 	}
240 240
 
241
-	public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){
241
+	public function insertDeleteButtonIn($index, $visibleHover=true, $deleteBehavior=[], $callback=null) {
242 242
 		$this->_deleteBehavior=$deleteBehavior;
243
-		return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback,"delete");
243
+		return $this->insertDefaultButtonIn($index, "remove", "_delete red basic", $visibleHover, $callback, "delete");
244 244
 	}
245 245
 
246
-	public function insertEditButtonIn($index,$visibleHover=true,$editBehavior=[],$callback=null){
246
+	public function insertEditButtonIn($index, $visibleHover=true, $editBehavior=[], $callback=null) {
247 247
 		$this->_editBehavior=$editBehavior;
248
-		return $this->insertDefaultButtonIn($index,"edit","_edit basic",$visibleHover,$callback,"edit");
248
+		return $this->insertDefaultButtonIn($index, "edit", "_edit basic", $visibleHover, $callback, "edit");
249 249
 	}
250 250
 	
251
-	public function insertDisplayButtonIn($index,$visibleHover=true,$displayBehavior=[],$callback=null){
251
+	public function insertDisplayButtonIn($index, $visibleHover=true, $displayBehavior=[], $callback=null) {
252 252
 		$this->_displayBehavior=$displayBehavior;
253
-		return $this->insertDefaultButtonIn($index,"eye","_display basic",$visibleHover,$callback,"display");
253
+		return $this->insertDefaultButtonIn($index, "eye", "_display basic", $visibleHover, $callback, "display");
254 254
 	}
255 255
 	
256 256
 	/**
257 257
 	 * @param multitype:string  $_buttons
258 258
 	 */
259 259
 	public function setButtons($_buttons) {
260
-		$this->_buttons = $_buttons;
260
+		$this->_buttons=$_buttons;
261 261
 		return $this;
262 262
 	}
263 263
 }
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/JsonDataTable.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -21,24 +21,24 @@  discard block
 block discarded – undo
21 21
 		$this->_rowClass="_json";
22 22
 	}
23 23
 
24
-	protected function _generateContent($table){
24
+	protected function _generateContent($table) {
25 25
 		$this->_addRowModel($table);
26 26
 		parent::_generateContent($table);
27 27
 	}
28 28
 
29
-	protected function _addRowModel($table){
29
+	protected function _addRowModel($table) {
30 30
 		$row=$this->_createRow($table, $this->_modelClass);
31
-		$row->setProperty("style","display:none;");
31
+		$row->setProperty("style", "display:none;");
32 32
 		$table->getBody()->_addRow($row);
33 33
 	}
34 34
 
35
-	protected function _createRow($table,$rowClass){
35
+	protected function _createRow($table, $rowClass) {
36 36
 		$object=JReflection::jsonObject($this->_model);
37
-		if(isset($this->_rowModelCallback)){
37
+		if (isset($this->_rowModelCallback)) {
38 38
 			$callback=$this->_rowModelCallback;
39 39
 			$callback($object);
40 40
 		}
41
-		$row=$this->_generateRow($object, $table,"_jsonArrayChecked");
41
+		$row=$this->_generateRow($object, $table, "_jsonArrayChecked");
42 42
 		$row->setClass($rowClass);
43 43
 		return $row;
44 44
 	}
@@ -47,22 +47,22 @@  discard block
 block discarded – undo
47 47
 	 * {@inheritDoc}
48 48
 	 * @see DataTable::_associatePaginationBehavior()
49 49
 	 */
50
-	protected function _associatePaginationBehavior(JsUtils $js=NULL,$offset=null){
50
+	protected function _associatePaginationBehavior(JsUtils $js=NULL, $offset=null) {
51 51
 		$callback=null;
52 52
 		$menu=$this->_pagination->getMenu();
53 53
 		
54
-		if(isset($js)){
54
+		if (isset($js)) {
55 55
 			$id=$this->identifier;
56 56
 			$callback=$js->getScript($offset).$this->getHtmlComponent()->getInnerScript();
57
-			$callback.=$js->trigger("#".$id." [name='selection[]']","change",false)."$('#".$id." tbody .ui.checkbox').checkbox();".$js->execOn("change", "#".$id." [name='selection[]']", $this->_getCheckedChange($js));
57
+			$callback.=$js->trigger("#".$id." [name='selection[]']", "change", false)."$('#".$id." tbody .ui.checkbox').checkbox();".$js->execOn("change", "#".$id." [name='selection[]']", $this->_getCheckedChange($js));
58 58
 			$callback.=$this->_generatePaginationScript($id);
59 59
 		}
60
-		if(isset($this->_urls["refresh"])){
61
-			$js->jsonArrayOn("click", "#".$menu->getIdentifier()." a","#".$this->_identifier." tr.".$this->_modelClass, $this->_urls["refresh"],"post",["params"=>"{'p':$(this).attr('data-page')}","jsCallback"=>$callback]);
60
+		if (isset($this->_urls["refresh"])) {
61
+			$js->jsonArrayOn("click", "#".$menu->getIdentifier()." a", "#".$this->_identifier." tr.".$this->_modelClass, $this->_urls["refresh"], "post", ["params"=>"{'p':$(this).attr('data-page')}", "jsCallback"=>$callback]);
62 62
 		}
63 63
 	}
64 64
 	
65
-	protected function _generatePaginationScript($id){
65
+	protected function _generatePaginationScript($id) {
66 66
 		return ";var page=parseInt($(self).attr('data-page')) || 1;var pages_visibles=$('#pagination-{$id} .item').length-2;
67 67
 			var lastPage=$('#pagination-{$id} ._lastPage');
68 68
 			var middle= Math.ceil((pages_visibles-1)/ 2);
@@ -82,17 +82,17 @@  discard block
 block discarded – undo
82 82
 			lastPage.attr('data-page',Math.min(lastPage.attr('data-max'),page+1));
83 83
 			$('#{$id}').trigger('pageChange');$('#pagination-{$id}').show();";
84 84
 	}
85
-	protected function _compileSearchFieldBehavior(JsUtils $js=NULL){
85
+	protected function _compileSearchFieldBehavior(JsUtils $js=NULL) {
86 86
 		
87 87
 	}
88
-	protected function _associateSearchFieldBehavior(JsUtils $js=NULL,$offset=null){
89
-		if(isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])){
88
+	protected function _associateSearchFieldBehavior(JsUtils $js=NULL, $offset=null) {
89
+		if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) {
90 90
 			$callback=null;
91 91
 			$id=$this->identifier;
92 92
 			$callback=$js->getScript($offset).$this->getHtmlComponent()->getInnerScript();
93
-			$callback.=$js->trigger("#".$id." [name='selection[]']","change",false)."$('#".$id." tbody .ui.checkbox').checkbox();".$js->execOn("change", "#".$id." [name='selection[]']", $this->_getCheckedChange($js));
93
+			$callback.=$js->trigger("#".$id." [name='selection[]']", "change", false)."$('#".$id." tbody .ui.checkbox').checkbox();".$js->execOn("change", "#".$id." [name='selection[]']", $this->_getCheckedChange($js));
94 94
 			$callback.="$('#pagination-{$id}').hide();$('#".$this->identifier."').trigger('searchTerminate',[$(self).val()]);";
95
-			$js->jsonArrayOn("change", "#".$this->_searchField->getDataField()->getIdentifier(),"#".$this->_identifier." tr.".$this->_modelClass, $this->_urls["refresh"],"post",["params"=>"{'s':$(self).val()}","jsCallback"=>$callback]);
95
+			$js->jsonArrayOn("change", "#".$this->_searchField->getDataField()->getIdentifier(), "#".$this->_identifier." tr.".$this->_modelClass, $this->_urls["refresh"], "post", ["params"=>"{'s':$(self).val()}", "jsCallback"=>$callback]);
96 96
 		}
97 97
 	}
98 98
 	
@@ -106,29 +106,29 @@  discard block
 block discarded – undo
106 106
 	 * @param string $jsCallback
107 107
 	 * @return AjaxCall
108 108
 	 */
109
-	public function jsJsonArray($url, $method="get", $params="{}", $jsCallback=NULL,$parameters=[]){
110
-		$parameters=\array_merge($parameters,["modelSelector"=>"#".$this->_identifier." tr.".$this->_modelClass,"url"=>$url,"method"=>$method,"params"=>$params,"jsCallback"=>$jsCallback]);
109
+	public function jsJsonArray($url, $method="get", $params="{}", $jsCallback=NULL, $parameters=[]) {
110
+		$parameters=\array_merge($parameters, ["modelSelector"=>"#".$this->_identifier." tr.".$this->_modelClass, "url"=>$url, "method"=>$method, "params"=>$params, "jsCallback"=>$jsCallback]);
111 111
 		return new AjaxCall("jsonArray", $parameters);
112 112
 	}
113 113
 
114
-	public function jsClear(){
114
+	public function jsClear() {
115 115
 		return "$('#{$this->identifier} tbody').find('._json').remove();";
116 116
 	}
117 117
 
118
-	public function clearOn(BaseHtml $element,$event, $stopPropagation=false, $preventDefault=false){
119
-		return $element->addEvent($event, $this->jsClear(),$stopPropagation,$preventDefault);
118
+	public function clearOn(BaseHtml $element, $event, $stopPropagation=false, $preventDefault=false) {
119
+		return $element->addEvent($event, $this->jsClear(), $stopPropagation, $preventDefault);
120 120
 	}
121 121
 
122
-	public function clearOnClick(BaseHtml $element,$stopPropagation=false, $preventDefault=false){
123
-		return $this->clearOn($element, "click",$stopPropagation,$preventDefault);
122
+	public function clearOnClick(BaseHtml $element, $stopPropagation=false, $preventDefault=false) {
123
+		return $this->clearOn($element, "click", $stopPropagation, $preventDefault);
124 124
 	}
125 125
 
126
-	public function jsonArrayOn(BaseHtml $element,$event,$url, $method="get", $params="{}", $jsCallback=NULL,$parameters=[]){
127
-		return $element->_addEvent($event, $this->jsJsonArray($url,$method,$params,$jsCallback,$parameters));
126
+	public function jsonArrayOn(BaseHtml $element, $event, $url, $method="get", $params="{}", $jsCallback=NULL, $parameters=[]) {
127
+		return $element->_addEvent($event, $this->jsJsonArray($url, $method, $params, $jsCallback, $parameters));
128 128
 	}
129 129
 
130
-	public function jsonArrayOnClick(BaseHtml $element,$url, $method="get", $params="{}", $jsCallback=NULL,$parameters=[]){
131
-		return $this->jsonArrayOn($element, "click", $url,$method,$params,$jsCallback,$parameters);
130
+	public function jsonArrayOnClick(BaseHtml $element, $url, $method="get", $params="{}", $jsCallback=NULL, $parameters=[]) {
131
+		return $this->jsonArrayOn($element, "click", $url, $method, $params, $jsCallback, $parameters);
132 132
 	}
133 133
 
134 134
 	/**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
140 140
 	 * @return DataTable
141 141
 	 */
142
-	public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){
143
-		return parent::paginate($page, $total_rowcount,$items_per_page,$pages_visibles);
142
+	public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) {
143
+		return parent::paginate($page, $total_rowcount, $items_per_page, $pages_visibles);
144 144
 	}
145 145
 
146 146
 	public function setRowModelCallback($_rowModelCallback) {
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/Pagination.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	private $row_count;
13 13
 	private $menu;
14 14
 
15
-	public function __construct($items_per_page=10,$pages_visibles=null,$page=1,$row_count=null){
15
+	public function __construct($items_per_page=10, $pages_visibles=null, $page=1, $row_count=null) {
16 16
 		$this->items_per_page=$items_per_page;
17 17
 		$this->row_count=$row_count;
18 18
 		$this->page=$page;
@@ -20,30 +20,30 @@  discard block
 block discarded – undo
20 20
 		$this->visible=true;
21 21
 	}
22 22
 
23
-	public function getObjects($objects){
23
+	public function getObjects($objects) {
24 24
 		$auto=(!isset($this->row_count));
25 25
 		$os=$objects;
26
-		if(!\is_array($os)){
26
+		if (!\is_array($os)) {
27 27
 			$os=[];
28
-			foreach ($objects as $o){
28
+			foreach ($objects as $o) {
29 29
 				$os[]=$o;
30 30
 			}
31 31
 		}
32
-		$this->page_count = 0;
33
-		$row_count=($auto)?\sizeof($os):$this->row_count;
34
-		if (0 === $row_count) {
32
+		$this->page_count=0;
33
+		$row_count=($auto) ?\sizeof($os) : $this->row_count;
34
+		if (0===$row_count) {
35 35
 			$this->visible=false;
36 36
 		} else {
37 37
 
38
-			$this->page_count = (int)ceil($row_count / $this->items_per_page);
38
+			$this->page_count=(int)ceil($row_count/$this->items_per_page);
39 39
 			$this->visible=$this->page_count>1;
40
-			if($this->page > $this->page_count+1) {
41
-				$this->page = 1;
40
+			if ($this->page>$this->page_count+1) {
41
+				$this->page=1;
42 42
 			}
43 43
 		}
44
-		if($auto){
45
-			$offset = ($this->page - 1) * $this->items_per_page;
46
-			return array_slice($os, $offset,$this->items_per_page);
44
+		if ($auto) {
45
+			$offset=($this->page-1)*$this->items_per_page;
46
+			return array_slice($os, $offset, $this->items_per_page);
47 47
 		}
48 48
 		return $os;
49 49
 	}
@@ -79,28 +79,28 @@  discard block
 block discarded – undo
79 79
 		return $this->page_count;
80 80
 	}
81 81
 
82
-	public function getPagesNumbers(){
83
-		$middle= (int)ceil(($this->pages_visibles-1)/ 2);
82
+	public function getPagesNumbers() {
83
+		$middle=(int)ceil(($this->pages_visibles-1)/2);
84 84
 		$first=$this->page-$middle;
85
-		if($first<1){
85
+		if ($first<1) {
86 86
 			$first=1;
87 87
 		}
88 88
 		$last=$first+$this->pages_visibles-1;
89
-		if($last>$this->page_count){
89
+		if ($last>$this->page_count) {
90 90
 			$last=$this->page_count;
91 91
 		}
92 92
 		return \range($first, $last);
93 93
 	}
94 94
 
95 95
 	public function setPagesVisibles($pages_visibles) {
96
-		if(!isset($pages_visibles))
97
-			$pages_visibles=(int)ceil($this->row_count / $this->items_per_page)+1;
96
+		if (!isset($pages_visibles))
97
+			$pages_visibles=(int)ceil($this->row_count/$this->items_per_page)+1;
98 98
 		$this->pages_visibles=$pages_visibles;
99 99
 		return $this;
100 100
 	}
101 101
 	
102
-	public function generateMenu($identifier){
103
-		$menu=new HtmlPaginationMenu("pagination-".$identifier,$this->getPagesNumbers());
102
+	public function generateMenu($identifier) {
103
+		$menu=new HtmlPaginationMenu("pagination-".$identifier, $this->getPagesNumbers());
104 104
 		$menu->setMax($this->page_count);
105 105
 		$menu->floatRight();
106 106
 		$menu->setActivePage($this->getPage());
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 		return $this->menu;
115 115
 	}
116 116
 	
117
-	public static function getPageOfRow($rownum,$itemsPerPage=10){
118
-		$pageNum=0;$activeRow=0;
119
-		while($activeRow<$rownum){
117
+	public static function getPageOfRow($rownum, $itemsPerPage=10) {
118
+		$pageNum=0; $activeRow=0;
119
+		while ($activeRow<$rownum) {
120 120
 			$activeRow+=$itemsPerPage;
121 121
 			$pageNum++;
122 122
 		}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 1 patch
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *
23 23
  */
24 24
 class DataTable extends Widget {
25
-	use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait;
25
+	use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait;
26 26
 	protected $_searchField;
27 27
 	protected $_urls;
28 28
 	protected $_pagination;
@@ -41,41 +41,41 @@  discard block
 block discarded – undo
41 41
 	protected $_colWidths;
42 42
 
43 43
 
44
-	public function __construct($identifier,$model,$modelInstance=NULL) {
45
-		parent::__construct($identifier, $model,$modelInstance);
46
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
44
+	public function __construct($identifier, $model, $modelInstance=NULL) {
45
+		parent::__construct($identifier, $model, $modelInstance);
46
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
47 47
 		$this->_urls=[];
48
-		$this->_emptyMessage=new HtmlMessage("","nothing to display");
48
+		$this->_emptyMessage=new HtmlMessage("", "nothing to display");
49 49
 		$this->_emptyMessage->setIcon("info circle");
50 50
 	}
51 51
 
52
-	public function run(JsUtils $js){
52
+	public function run(JsUtils $js) {
53 53
 		$offset=$js->scriptCount();
54
-		if($this->_hasCheckboxes && isset($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);
65
-		if(\is_array($this->_displayBehavior)){
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
+		if (\is_array($this->_displayBehavior)) {
66 66
 			$this->_displayBehavior["jsCallback"]='$("#dataTable").hide();';
67
-			$this->_generateBehavior("display",$this->_displayBehavior,$js);
67
+			$this->_generateBehavior("display", $this->_displayBehavior, $js);
68 68
 		}
69 69
 		parent::run($js);
70
-		$this->_associateSearchFieldBehavior($js,$offset);
71
-		if(isset($this->_pagination))
72
-			$this->_associatePaginationBehavior($js,$offset);
70
+		$this->_associateSearchFieldBehavior($js, $offset);
71
+		if (isset($this->_pagination))
72
+			$this->_associatePaginationBehavior($js, $offset);
73 73
 	}
74 74
 
75
-	protected function _generateBehavior($op,$params,JsUtils $js){
76
-		if(isset($this->_urls[$op])){
77
-			$params=\array_merge($params,["attr"=>"data-ajax"]);
78
-			$js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector($op),$params);
75
+	protected function _generateBehavior($op, $params, JsUtils $js) {
76
+		if (isset($this->_urls[$op])) {
77
+			$params=\array_merge($params, ["attr"=>"data-ajax"]);
78
+			$js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params);
79 79
 		}
80 80
 	}
81 81
 
@@ -88,126 +88,126 @@  discard block
 block discarded – undo
88 88
 	}
89 89
 
90 90
 
91
-	public function compile(JsUtils $js=NULL,&$view=NULL){
92
-		if(!$this->_generated){
93
-			if(isset($this->_buttonsColumn)){
91
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
92
+		if (!$this->_generated) {
93
+			if (isset($this->_buttonsColumn)) {
94 94
 				$this->_instanceViewer->sortColumnContent($this->_buttonsColumn, $this->_buttons);
95 95
 			}
96 96
 			$this->_instanceViewer->setInstance($this->_model);
97 97
 			$captions=$this->_instanceViewer->getCaptions();
98 98
 			$table=$this->content["table"];
99
-			if($this->_hasCheckboxes){
99
+			if ($this->_hasCheckboxes) {
100 100
 				$this->_generateMainCheckbox($captions);
101 101
 			}
102 102
 			$table->setRowCount(0, \sizeof($captions));
103
-			$this->_generateHeader($table,$captions);
103
+			$this->_generateHeader($table, $captions);
104 104
 
105
-			if(isset($this->_compileParts))
105
+			if (isset($this->_compileParts))
106 106
 				$table->setCompileParts($this->_compileParts);
107 107
 
108 108
 			$this->_generateContent($table);
109 109
 
110
-			$this->compileExtraElements($table, $captions,$js);
110
+			$this->compileExtraElements($table, $captions, $js);
111 111
 			$this->_compileSearchFieldBehavior($js);
112 112
 
113
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
113
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
114 114
 			$this->_compileForm();
115 115
 			$this->_applyStyleAttributes($table);
116 116
 			$this->_generated=true;
117 117
 		}
118
-		return parent::compile($js,$view);
118
+		return parent::compile($js, $view);
119 119
 	}
120 120
 
121
-	protected function compileExtraElements($table,$captions,JsUtils $js=NULL){
121
+	protected function compileExtraElements($table, $captions, JsUtils $js=NULL) {
122 122
 
123
-		if($this->_hasCheckboxes && $table->hasPart("thead")){
123
+		if ($this->_hasCheckboxes && $table->hasPart("thead")) {
124 124
 			$table->getHeader()->getCell(0, 0)->addClass("no-sort");
125 125
 		}
126 126
 
127
-		if(isset($this->_toolbar)){
127
+		if (isset($this->_toolbar)) {
128 128
 			$this->_setToolbarPosition($table, $captions);
129 129
 		}
130
-		if(isset($this->_pagination) && $this->_pagination->getVisible()){
131
-			$this->_generatePagination($table,$js);
130
+		if (isset($this->_pagination) && $this->_pagination->getVisible()) {
131
+			$this->_generatePagination($table, $js);
132 132
 		}
133 133
 	}
134 134
 
135
-	protected function _applyStyleAttributes($table){
136
-		if(isset($this->_hiddenColumns))
135
+	protected function _applyStyleAttributes($table) {
136
+		if (isset($this->_hiddenColumns))
137 137
 			$this->_hideColumns();
138
-			if(isset($this->_colWidths)){
139
-				foreach ($this->_colWidths as $colIndex=>$width){
140
-					$table->setColWidth($colIndex,$width);
138
+			if (isset($this->_colWidths)) {
139
+				foreach ($this->_colWidths as $colIndex=>$width) {
140
+					$table->setColWidth($colIndex, $width);
141 141
 				}
142 142
 			}
143 143
 	}
144 144
 
145
-	protected function _hideColumns(){
146
-		foreach ($this->_hiddenColumns as $colIndex){
145
+	protected function _hideColumns() {
146
+		foreach ($this->_hiddenColumns as $colIndex) {
147 147
 			$this->_self->hideColumn($colIndex);
148 148
 		}
149 149
 		return $this;
150 150
 	}
151 151
 
152
-	protected function _generateHeader(HtmlTable $table,$captions){
152
+	protected function _generateHeader(HtmlTable $table, $captions) {
153 153
 		$table->setHeaderValues($captions);
154
-		if(isset($this->_sortable)){
154
+		if (isset($this->_sortable)) {
155 155
 			$table->setSortable($this->_sortable);
156 156
 		}
157 157
 	}
158 158
 
159 159
 
160 160
 
161
-	protected function _generateContent($table){
161
+	protected function _generateContent($table) {
162 162
 		$objects=$this->_modelInstance;
163
-		if(isset($this->_pagination)){
163
+		if (isset($this->_pagination)) {
164 164
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
165 165
 		}
166 166
 			InstanceViewer::setIndex(0);
167 167
 			$table->fromDatabaseObjects($objects, function($instance) use($table){
168 168
 				return $this->_generateRow($instance, $table);
169 169
 			});
170
-		if($table->getRowCount()==0){
170
+		if ($table->getRowCount()==0) {
171 171
 			$result=$table->addRow();
172 172
 			$result->mergeRow();
173 173
 			$result->setValues([$this->_emptyMessage]);
174 174
 		}
175 175
 	}
176 176
 
177
-	protected function _generateRow($instance,&$table,$checkedClass=null){
177
+	protected function _generateRow($instance, &$table, $checkedClass=null) {
178 178
 		$this->_instanceViewer->setInstance($instance);
179 179
 		InstanceViewer::$index++;
180
-		$values= $this->_instanceViewer->getValues();
180
+		$values=$this->_instanceViewer->getValues();
181 181
 		$id=$this->_instanceViewer->getIdentifier();
182 182
 		$dataAjax=$id;
183 183
 		$id=$this->cleanIdentifier($id);
184
-		if($this->_hasCheckboxes){
185
-			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,"");
184
+		if ($this->_hasCheckboxes) {
185
+			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, "");
186 186
 			$checked=false;
187
-			if(isset($this->_checkedCallback)){
187
+			if (isset($this->_checkedCallback)) {
188 188
 				$func=$this->_checkedCallback;
189 189
 				$checked=$func($instance);
190 190
 			}
191 191
 			$ck->setChecked($checked);
192 192
 			$ck->setOnChange("event.stopPropagation();");
193 193
 			$field=$ck->getField();
194
-			$field->setProperty("value",$dataAjax);
194
+			$field->setProperty("value", $dataAjax);
195 195
 			$field->setProperty("name", "selection[]");
196
-			if(isset($checkedClass))
196
+			if (isset($checkedClass))
197 197
 				$field->setClass($checkedClass);
198 198
 			\array_unshift($values, $ck);
199 199
 		}
200 200
 		$result=$table->newRow();
201 201
 		$result->setIdentifier($this->identifier."-tr-".$id);
202
-		$result->setProperty("data-ajax",$dataAjax);
202
+		$result->setProperty("data-ajax", $dataAjax);
203 203
 		$result->setValues($values);
204
-		$result->addToProperty("class",$this->_rowClass);
204
+		$result->addToProperty("class", $this->_rowClass);
205 205
 		return $result;
206 206
 	}
207 207
 
208
-	protected function _generatePagination($table,$js=NULL){
209
-		if(isset($this->_toolbar)){
210
-			if($this->_toolbarPosition==PositionInTable::FOOTER)
208
+	protected function _generatePagination($table, $js=NULL) {
209
+		if (isset($this->_toolbar)) {
210
+			if ($this->_toolbarPosition==PositionInTable::FOOTER)
211 211
 				$this->_toolbar->setFloated("left");
212 212
 		}
213 213
 		$footer=$table->getFooter();
@@ -215,44 +215,44 @@  discard block
 block discarded – undo
215 215
 		$footer->addValues($this->_pagination->generateMenu($this->identifier));
216 216
 	}
217 217
 
218
-	protected function _associatePaginationBehavior(JsUtils $js=NULL,$offset=null){
219
-		if(isset($this->_urls["refresh"])){
220
-			$this->_pagination->getMenu()->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith","hasLoader"=>false,"jsCallback"=>'$("#'.$this->identifier.'").trigger("pageChange");']);
218
+	protected function _associatePaginationBehavior(JsUtils $js=NULL, $offset=null) {
219
+		if (isset($this->_urls["refresh"])) {
220
+			$this->_pagination->getMenu()->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith", "hasLoader"=>false, "jsCallback"=>'$("#'.$this->identifier.'").trigger("pageChange");']);
221 221
 		}
222 222
 	}
223 223
 	
224
-	protected function _compileSearchFieldBehavior(JsUtils $js=NULL){
225
-		if(isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])){
226
-			$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(self).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith","hasLoader"=>"internal","jsCallback"=>'$("#'.$this->identifier.'").trigger("searchTerminate",[$(self).val()]);']);
224
+	protected function _compileSearchFieldBehavior(JsUtils $js=NULL) {
225
+		if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) {
226
+			$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith", "hasLoader"=>"internal", "jsCallback"=>'$("#'.$this->identifier.'").trigger("searchTerminate",[$(self).val()]);']);
227 227
 		}
228 228
 	}
229
-	protected function _associateSearchFieldBehavior(JsUtils $js=NULL,$offset=null){
229
+	protected function _associateSearchFieldBehavior(JsUtils $js=NULL, $offset=null) {
230 230
 		
231 231
 	}
232 232
 
233
-	protected function _getFieldName($index){
233
+	protected function _getFieldName($index) {
234 234
 		$fieldName=parent::_getFieldName($index);
235
-		if(\is_object($fieldName))
235
+		if (\is_object($fieldName))
236 236
 			$fieldName="field-".$index;
237 237
 		return $fieldName."[]";
238 238
 	}
239 239
 
240
-	protected function _getFieldCaption($index){
240
+	protected function _getFieldCaption($index) {
241 241
 		return null;
242 242
 	}
243 243
 
244
-	protected function _setToolbarPosition($table,$captions=NULL){
245
-		switch ($this->_toolbarPosition){
244
+	protected function _setToolbarPosition($table, $captions=NULL) {
245
+		switch ($this->_toolbarPosition) {
246 246
 			case PositionInTable::BEFORETABLE:
247 247
 			case PositionInTable::AFTERTABLE:
248
-				if(isset($this->_compileParts)===false){
248
+				if (isset($this->_compileParts)===false) {
249 249
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
250 250
 				}
251 251
 				break;
252 252
 			case PositionInTable::HEADER:
253 253
 			case PositionInTable::FOOTER:
254 254
 			case PositionInTable::BODY:
255
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
255
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
256 256
 				break;
257 257
 		}
258 258
 	}
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
 	 * @param callable $callback function called after the field compilation
265 265
 	 * @return DataTable
266 266
 	 */
267
-	public function afterCompile($index,$callback){
268
-		$this->_instanceViewer->afterCompile($index,$callback);
267
+	public function afterCompile($index, $callback) {
268
+		$this->_instanceViewer->afterCompile($index, $callback);
269 269
 		return $this;
270 270
 	}
271 271
 
272
-	private function addToolbarRow($part,$table,$captions){
272
+	private function addToolbarRow($part, $table, $captions) {
273 273
 		$hasPart=$table->hasPart($part);
274
-		if($hasPart){
274
+		if ($hasPart) {
275 275
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
276
-		}else{
276
+		} else {
277 277
 			$row=$table->getPart($part)->getRow(0);
278 278
 		}
279 279
 		$row->mergeCol();
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	 * @see Widget::getHtmlComponent()
286 286
 	 * @return HtmlTable
287 287
 	 */
288
-	public function getHtmlComponent(){
288
+	public function getHtmlComponent() {
289 289
 		return $this->content["table"];
290 290
 	}
291 291
 
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 	 * @return DataTable
301 301
 	 */
302 302
 	public function setUrls($urls) {
303
-		if(\is_array($urls)){
304
-			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
305
-			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
306
-			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
307
-			$this->_urls["display"]=JArray::getValue($urls, "display",3);
308
-		}else{
309
-			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls,"display"=>$urls];
303
+		if (\is_array($urls)) {
304
+			$this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0);
305
+			$this->_urls["edit"]=JArray::getValue($urls, "edit", 1);
306
+			$this->_urls["delete"]=JArray::getValue($urls, "delete", 2);
307
+			$this->_urls["display"]=JArray::getValue($urls, "display", 3);
308
+		} else {
309
+			$this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls, "display"=>$urls];
310 310
 		}
311 311
 		return $this;
312 312
 	}
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
320 320
 	 * @return DataTable
321 321
 	 */
322
-	public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){
323
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount);
322
+	public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) {
323
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
324 324
 		return $this;
325 325
 	}
326 326
 
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
332 332
 	 * @return DataTable
333 333
 	 */
334
-	public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){
335
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page);
334
+	public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) {
335
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page);
336 336
 		return $this;
337 337
 	}
338 338
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	 * @param array $compileParts
343 343
 	 * @return DataTable
344 344
 	 */
345
-	public function refresh($compileParts=["tbody"]){
345
+	public function refresh($compileParts=["tbody"]) {
346 346
 		$this->_compileParts=$compileParts;
347 347
 		return $this;
348 348
 	}
@@ -353,14 +353,14 @@  discard block
 block discarded – undo
353 353
 	 * @param string $position
354 354
 	 * @return \Ajax\common\html\HtmlDoubleElement
355 355
 	 */
356
-	public function addSearchInToolbar($position=Direction::RIGHT){
356
+	public function addSearchInToolbar($position=Direction::RIGHT) {
357 357
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
358 358
 	}
359 359
 
360
-	public function getSearchField(){
361
-		if(isset($this->_searchField)===false){
362
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
363
-			$this->_searchField->addIcon("search",Direction::RIGHT);
360
+	public function getSearchField() {
361
+		if (isset($this->_searchField)===false) {
362
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
363
+			$this->_searchField->addIcon("search", Direction::RIGHT);
364 364
 		}
365 365
 		return $this->_searchField;
366 366
 	}
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	 * Returns a form corresponding to the Datatable
381 381
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
382 382
 	 */
383
-	public function asForm(){
383
+	public function asForm() {
384 384
 		return $this->getForm();
385 385
 	}
386 386
 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 
389 389
 	protected function getTargetSelector($op) {
390 390
 		$result=$this->_targetSelector;
391
-		if(!isset($result[$op]))
391
+		if (!isset($result[$op]))
392 392
 			$result="#".$this->identifier;
393 393
 		return $result[$op];
394 394
 	}
@@ -399,15 +399,15 @@  discard block
 block discarded – undo
399 399
 	 * @return DataTable
400 400
 	 */
401 401
 	public function setTargetSelector($_targetSelector) {
402
-		if(!\is_array($_targetSelector)){
403
-			$_targetSelector=["edit"=>$_targetSelector,"delete"=>$_targetSelector];
402
+		if (!\is_array($_targetSelector)) {
403
+			$_targetSelector=["edit"=>$_targetSelector, "delete"=>$_targetSelector];
404 404
 		}
405 405
 		$this->_targetSelector=$_targetSelector;
406 406
 		return $this;
407 407
 	}
408 408
 
409 409
 	public function getRefreshSelector() {
410
-		if(isset($this->_refreshSelector))
410
+		if (isset($this->_refreshSelector))
411 411
 			return $this->_refreshSelector;
412 412
 		return "#".$this->identifier." tbody";
413 413
 	}
@@ -425,9 +425,9 @@  discard block
 block discarded – undo
425 425
 	 * {@inheritDoc}
426 426
 	 * @see \Ajax\common\Widget::show()
427 427
 	 */
428
-	public function show($modelInstance){
429
-		if(\is_array($modelInstance)){
430
-			if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
428
+	public function show($modelInstance) {
429
+		if (\is_array($modelInstance)) {
430
+			if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
431 431
 				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
432 432
 		}
433 433
 		$this->_modelInstance=$modelInstance;
@@ -462,29 +462,29 @@  discard block
 block discarded – undo
462 462
 		return $this;
463 463
 	}
464 464
 
465
-	public function setActiveRowSelector($class="active",$event="click",$multiple=false){
466
-		$this->_self->setActiveRowSelector($class,$event,$multiple);
465
+	public function setActiveRowSelector($class="active", $event="click", $multiple=false) {
466
+		$this->_self->setActiveRowSelector($class, $event, $multiple);
467 467
 		return $this;
468 468
 	}
469 469
 
470
-	public function hideColumn($colIndex){
471
-		if(!\is_array($this->_hiddenColumns))
470
+	public function hideColumn($colIndex) {
471
+		if (!\is_array($this->_hiddenColumns))
472 472
 			$this->_hiddenColumns=[];
473 473
 		$this->_hiddenColumns[]=$colIndex;
474 474
 		return $this;
475 475
 	}
476 476
 
477
-	public function setColWidth($colIndex,$width){
477
+	public function setColWidth($colIndex, $width) {
478 478
 		$this->_colWidths[$colIndex]=$width;
479 479
 		return $this;
480 480
 	}
481 481
 	public function setColWidths($_colWidths) {
482
-		$this->_colWidths = $_colWidths;
482
+		$this->_colWidths=$_colWidths;
483 483
 		return $this;
484 484
 	}
485 485
 
486
-	public function setColAlignment($colIndex,$alignment){
487
-		$this->content["table"]->setColAlignment($colIndex,$alignment);
486
+	public function setColAlignment($colIndex, $alignment) {
487
+		$this->content["table"]->setColAlignment($colIndex, $alignment);
488 488
 		return $this;
489 489
 	}
490 490
 }
Please login to merge, or discard this patch.