Passed
Push — master ( 468e47...0bebef )
by Jean-Christophe
02:09
created
Ajax/semantic/widgets/datatable/DataTable.php 2 patches
Spacing   +117 added lines, -117 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,21 +88,21 @@  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);
@@ -110,106 +110,106 @@  discard block
 block discarded – undo
110 110
 			$this->compileExtraElements($table, $captions);
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){
121
+	protected function compileExtraElements($table, $captions) {
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()){
130
+		if (isset($this->_pagination) && $this->_pagination->getVisible()) {
131 131
 			$this->_generatePagination($table);
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
 			$fields=$this->_instanceViewer->getSimpleProperties();
168
-			$table->fromDatabaseObjects($objects, function($instance) use($table,$fields){
169
-				return $this->_generateRow($instance, $fields,$table);
168
+			$table->fromDatabaseObjects($objects, function($instance) use($table, $fields){
169
+				return $this->_generateRow($instance, $fields, $table);
170 170
 			});
171
-		if($table->getRowCount()==0){
171
+		if ($table->getRowCount()==0) {
172 172
 			$result=$table->addRow();
173 173
 			$result->mergeRow();
174 174
 			$result->setValues([$this->_emptyMessage]);
175 175
 		}
176 176
 	}
177 177
 
178
-	protected function _generateRow($instance,$fields,&$table,$checkedClass=null){
178
+	protected function _generateRow($instance, $fields, &$table, $checkedClass=null) {
179 179
 		$this->_instanceViewer->setInstance($instance);
180 180
 		InstanceViewer::$index++;
181
-		$values= $this->_instanceViewer->getValues();
181
+		$values=$this->_instanceViewer->getValues();
182 182
 		$id=$this->_instanceViewer->getIdentifier();
183 183
 		$dataAjax=$id;
184 184
 		$id=$this->cleanIdentifier($id);
185
-		if($this->_hasCheckboxes){
186
-			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,"");
185
+		if ($this->_hasCheckboxes) {
186
+			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, "");
187 187
 			$checked=false;
188
-			if(isset($this->_checkedCallback)){
188
+			if (isset($this->_checkedCallback)) {
189 189
 				$func=$this->_checkedCallback;
190 190
 				$checked=$func($instance);
191 191
 			}
192 192
 			$ck->setChecked($checked);
193 193
 			$ck->setOnChange("event.stopPropagation();");
194 194
 			$field=$ck->getField();
195
-			$field->setProperty("value",$dataAjax);
195
+			$field->setProperty("value", $dataAjax);
196 196
 			$field->setProperty("name", "selection[]");
197
-			if(isset($checkedClass))
197
+			if (isset($checkedClass))
198 198
 				$field->setClass($checkedClass);
199 199
 			\array_unshift($values, $ck);
200 200
 		}
201 201
 		$result=$table->newRow();
202 202
 		$result->setIdentifier($this->identifier."-tr-".$id);
203
-		$result->setProperty("data-ajax",$dataAjax);
203
+		$result->setProperty("data-ajax", $dataAjax);
204 204
 		$result->setValues($values);
205
-		$result->addToProperty("class",$this->_rowClass);
205
+		$result->addToProperty("class", $this->_rowClass);
206 206
 		$result->setPropertyValues("data-field", $fields);
207 207
 		return $result;
208 208
 	}
209 209
 
210
-	protected function _generatePagination($table){
211
-		if(isset($this->_toolbar)){
212
-			if($this->_toolbarPosition==PositionInTable::FOOTER)
210
+	protected function _generatePagination($table) {
211
+		if (isset($this->_toolbar)) {
212
+			if ($this->_toolbarPosition==PositionInTable::FOOTER)
213 213
 				$this->_toolbar->setFloated("left");
214 214
 		}
215 215
 		$footer=$table->getFooter();
@@ -217,44 +217,44 @@  discard block
 block discarded – undo
217 217
 		$footer->addValues($this->_pagination->generateMenu($this->identifier));
218 218
 	}
219 219
 
220
-	protected function _associatePaginationBehavior(JsUtils $js=NULL,$offset=null){
221
-		if(isset($this->_urls["refresh"])){
222
-			$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");$("#'.$this->identifier.'").trigger("activeRowChange");']);
220
+	protected function _associatePaginationBehavior(JsUtils $js=NULL, $offset=null) {
221
+		if (isset($this->_urls["refresh"])) {
222
+			$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");$("#'.$this->identifier.'").trigger("activeRowChange");']);
223 223
 		}
224 224
 	}
225 225
 	
226
-	protected function _compileSearchFieldBehavior(JsUtils $js=NULL){
227
-		if(isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])){
228
-			$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()]);']);
226
+	protected function _compileSearchFieldBehavior(JsUtils $js=NULL) {
227
+		if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) {
228
+			$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()]);']);
229 229
 		}
230 230
 	}
231
-	protected function _associateSearchFieldBehavior(JsUtils $js=NULL,$offset=null){
231
+	protected function _associateSearchFieldBehavior(JsUtils $js=NULL, $offset=null) {
232 232
 		
233 233
 	}
234 234
 
235
-	protected function _getFieldName($index){
235
+	protected function _getFieldName($index) {
236 236
 		$fieldName=parent::_getFieldName($index);
237
-		if(\is_object($fieldName))
237
+		if (\is_object($fieldName))
238 238
 			$fieldName="field-".$index;
239 239
 		return $fieldName."[]";
240 240
 	}
241 241
 
242
-	protected function _getFieldCaption($index){
242
+	protected function _getFieldCaption($index) {
243 243
 		return null;
244 244
 	}
245 245
 
246
-	protected function _setToolbarPosition($table,$captions=NULL){
247
-		switch ($this->_toolbarPosition){
246
+	protected function _setToolbarPosition($table, $captions=NULL) {
247
+		switch ($this->_toolbarPosition) {
248 248
 			case PositionInTable::BEFORETABLE:
249 249
 			case PositionInTable::AFTERTABLE:
250
-				if(isset($this->_compileParts)===false){
250
+				if (isset($this->_compileParts)===false) {
251 251
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
252 252
 				}
253 253
 				break;
254 254
 			case PositionInTable::HEADER:
255 255
 			case PositionInTable::FOOTER:
256 256
 			case PositionInTable::BODY:
257
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
257
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
258 258
 				break;
259 259
 		}
260 260
 	}
@@ -266,16 +266,16 @@  discard block
 block discarded – undo
266 266
 	 * @param callable $callback function called after the field compilation
267 267
 	 * @return DataTable
268 268
 	 */
269
-	public function afterCompile($index,$callback){
270
-		$this->_instanceViewer->afterCompile($index,$callback);
269
+	public function afterCompile($index, $callback) {
270
+		$this->_instanceViewer->afterCompile($index, $callback);
271 271
 		return $this;
272 272
 	}
273 273
 
274
-	private function addToolbarRow($part,$table,$captions){
274
+	private function addToolbarRow($part, $table, $captions) {
275 275
 		$hasPart=$table->hasPart($part);
276
-		if($hasPart){
276
+		if ($hasPart) {
277 277
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
278
-		}else{
278
+		} else {
279 279
 			$row=$table->getPart($part)->getRow(0);
280 280
 		}
281 281
 		$row->mergeCol();
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	 * @see Widget::getHtmlComponent()
288 288
 	 * @return HtmlTable
289 289
 	 */
290
-	public function getHtmlComponent(){
290
+	public function getHtmlComponent() {
291 291
 		return $this->content["table"];
292 292
 	}
293 293
 
@@ -302,13 +302,13 @@  discard block
 block discarded – undo
302 302
 	 * @return DataTable
303 303
 	 */
304 304
 	public function setUrls($urls) {
305
-		if(\is_array($urls)){
306
-			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
307
-			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
308
-			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
309
-			$this->_urls["display"]=JArray::getValue($urls, "display",3);
310
-		}else{
311
-			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls,"display"=>$urls];
305
+		if (\is_array($urls)) {
306
+			$this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0);
307
+			$this->_urls["edit"]=JArray::getValue($urls, "edit", 1);
308
+			$this->_urls["delete"]=JArray::getValue($urls, "delete", 2);
309
+			$this->_urls["display"]=JArray::getValue($urls, "display", 3);
310
+		} else {
311
+			$this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls, "display"=>$urls];
312 312
 		}
313 313
 		return $this;
314 314
 	}
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
322 322
 	 * @return DataTable
323 323
 	 */
324
-	public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){
325
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount);
324
+	public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) {
325
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
326 326
 		return $this;
327 327
 	}
328 328
 
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
334 334
 	 * @return DataTable
335 335
 	 */
336
-	public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){
337
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page);
336
+	public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) {
337
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page);
338 338
 		return $this;
339 339
 	}
340 340
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 	 * @param array $compileParts
345 345
 	 * @return DataTable
346 346
 	 */
347
-	public function refresh($compileParts=["tbody"]){
347
+	public function refresh($compileParts=["tbody"]) {
348 348
 		$this->_compileParts=$compileParts;
349 349
 		return $this;
350 350
 	}
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
 	 * @param string $position
356 356
 	 * @return \Ajax\common\html\HtmlDoubleElement
357 357
 	 */
358
-	public function addSearchInToolbar($position=Direction::RIGHT){
358
+	public function addSearchInToolbar($position=Direction::RIGHT) {
359 359
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
360 360
 	}
361 361
 
362
-	public function getSearchField(){
363
-		if(isset($this->_searchField)===false){
364
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
365
-			$this->_searchField->addIcon("search",Direction::RIGHT);
362
+	public function getSearchField() {
363
+		if (isset($this->_searchField)===false) {
364
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
365
+			$this->_searchField->addIcon("search", Direction::RIGHT);
366 366
 		}
367 367
 		return $this->_searchField;
368 368
 	}
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 	 * Returns a form corresponding to the Datatable
383 383
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
384 384
 	 */
385
-	public function asForm(){
385
+	public function asForm() {
386 386
 		return $this->getForm();
387 387
 	}
388 388
 
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 
391 391
 	protected function getTargetSelector($op) {
392 392
 		$result=$this->_targetSelector;
393
-		if(!isset($result[$op]))
393
+		if (!isset($result[$op]))
394 394
 			$result="#".$this->identifier;
395 395
 		return $result[$op];
396 396
 	}
@@ -401,15 +401,15 @@  discard block
 block discarded – undo
401 401
 	 * @return DataTable
402 402
 	 */
403 403
 	public function setTargetSelector($_targetSelector) {
404
-		if(!\is_array($_targetSelector)){
405
-			$_targetSelector=["edit"=>$_targetSelector,"delete"=>$_targetSelector];
404
+		if (!\is_array($_targetSelector)) {
405
+			$_targetSelector=["edit"=>$_targetSelector, "delete"=>$_targetSelector];
406 406
 		}
407 407
 		$this->_targetSelector=$_targetSelector;
408 408
 		return $this;
409 409
 	}
410 410
 
411 411
 	public function getRefreshSelector() {
412
-		if(isset($this->_refreshSelector))
412
+		if (isset($this->_refreshSelector))
413 413
 			return $this->_refreshSelector;
414 414
 		return "#".$this->identifier." tbody";
415 415
 	}
@@ -427,9 +427,9 @@  discard block
 block discarded – undo
427 427
 	 * {@inheritDoc}
428 428
 	 * @see \Ajax\common\Widget::show()
429 429
 	 */
430
-	public function show($modelInstance){
431
-		if(\is_array($modelInstance)){
432
-			if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
430
+	public function show($modelInstance) {
431
+		if (\is_array($modelInstance)) {
432
+			if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
433 433
 				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
434 434
 		}
435 435
 		$this->_modelInstance=$modelInstance;
@@ -464,37 +464,37 @@  discard block
 block discarded – undo
464 464
 		return $this;
465 465
 	}
466 466
 
467
-	public function setActiveRowSelector($class="active",$event="click",$multiple=false){
468
-		$this->_self->setActiveRowSelector($class,$event,$multiple);
467
+	public function setActiveRowSelector($class="active", $event="click", $multiple=false) {
468
+		$this->_self->setActiveRowSelector($class, $event, $multiple);
469 469
 		return $this;
470 470
 	}
471 471
 
472
-	public function hideColumn($colIndex){
473
-		if(!\is_array($this->_hiddenColumns))
472
+	public function hideColumn($colIndex) {
473
+		if (!\is_array($this->_hiddenColumns))
474 474
 			$this->_hiddenColumns=[];
475 475
 		$this->_hiddenColumns[]=$colIndex;
476 476
 		return $this;
477 477
 	}
478 478
 
479
-	public function setColWidth($colIndex,$width){
479
+	public function setColWidth($colIndex, $width) {
480 480
 		$this->_colWidths[$colIndex]=$width;
481 481
 		return $this;
482 482
 	}
483 483
 	public function setColWidths($_colWidths) {
484
-		$this->_colWidths = $_colWidths;
484
+		$this->_colWidths=$_colWidths;
485 485
 		return $this;
486 486
 	}
487 487
 
488
-	public function setColAlignment($colIndex,$alignment){
489
-		$this->content["table"]->setColAlignment($colIndex,$alignment);
488
+	public function setColAlignment($colIndex, $alignment) {
489
+		$this->content["table"]->setColAlignment($colIndex, $alignment);
490 490
 		return $this;
491 491
 	}
492 492
 	
493
-	public function trigger($event,$params="[]"){
494
-		return $this->getHtmlComponent()->trigger($event,$params);
493
+	public function trigger($event, $params="[]") {
494
+		return $this->getHtmlComponent()->trigger($event, $params);
495 495
 	}
496 496
 	
497
-	public function onActiveRowChange($jsCode){
497
+	public function onActiveRowChange($jsCode) {
498 498
 		$this->getHtmlComponent()->onActiveRowChange($jsCode);
499 499
 		return $this;
500 500
 	}
Please login to merge, or discard this patch.
Braces   +38 added lines, -26 removed lines patch added patch discarded remove patch
@@ -58,18 +58,21 @@  discard block
 block discarded – undo
58 58
 			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
59 59
 			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
60 60
 		}
61
-		if(\is_array($this->_deleteBehavior))
62
-			$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
63
-		if(\is_array($this->_editBehavior))
64
-			$this->_generateBehavior("edit",$this->_editBehavior,$js);
61
+		if(\is_array($this->_deleteBehavior)) {
62
+					$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
63
+		}
64
+		if(\is_array($this->_editBehavior)) {
65
+					$this->_generateBehavior("edit",$this->_editBehavior,$js);
66
+		}
65 67
 		if(\is_array($this->_displayBehavior)){
66 68
 			$this->_displayBehavior["jsCallback"]='$("#dataTable").hide();';
67 69
 			$this->_generateBehavior("display",$this->_displayBehavior,$js);
68 70
 		}
69 71
 		parent::run($js);
70 72
 		$this->_associateSearchFieldBehavior($js,$offset);
71
-		if(isset($this->_pagination))
72
-			$this->_associatePaginationBehavior($js,$offset);
73
+		if(isset($this->_pagination)) {
74
+					$this->_associatePaginationBehavior($js,$offset);
75
+		}
73 76
 	}
74 77
 
75 78
 	protected function _generateBehavior($op,$params,JsUtils $js){
@@ -102,8 +105,9 @@  discard block
 block discarded – undo
102 105
 			$table->setRowCount(0, \sizeof($captions));
103 106
 			$this->_generateHeader($table,$captions);
104 107
 
105
-			if(isset($this->_compileParts))
106
-				$table->setCompileParts($this->_compileParts);
108
+			if(isset($this->_compileParts)) {
109
+							$table->setCompileParts($this->_compileParts);
110
+			}
107 111
 
108 112
 			$this->_generateContent($table);
109 113
 
@@ -133,8 +137,9 @@  discard block
 block discarded – undo
133 137
 	}
134 138
 
135 139
 	protected function _applyStyleAttributes($table){
136
-		if(isset($this->_hiddenColumns))
137
-			$this->_hideColumns();
140
+		if(isset($this->_hiddenColumns)) {
141
+					$this->_hideColumns();
142
+		}
138 143
 			if(isset($this->_colWidths)){
139 144
 				foreach ($this->_colWidths as $colIndex=>$width){
140 145
 					$table->setColWidth($colIndex,$width);
@@ -194,8 +199,9 @@  discard block
 block discarded – undo
194 199
 			$field=$ck->getField();
195 200
 			$field->setProperty("value",$dataAjax);
196 201
 			$field->setProperty("name", "selection[]");
197
-			if(isset($checkedClass))
198
-				$field->setClass($checkedClass);
202
+			if(isset($checkedClass)) {
203
+							$field->setClass($checkedClass);
204
+			}
199 205
 			\array_unshift($values, $ck);
200 206
 		}
201 207
 		$result=$table->newRow();
@@ -209,8 +215,9 @@  discard block
 block discarded – undo
209 215
 
210 216
 	protected function _generatePagination($table){
211 217
 		if(isset($this->_toolbar)){
212
-			if($this->_toolbarPosition==PositionInTable::FOOTER)
213
-				$this->_toolbar->setFloated("left");
218
+			if($this->_toolbarPosition==PositionInTable::FOOTER) {
219
+							$this->_toolbar->setFloated("left");
220
+			}
214 221
 		}
215 222
 		$footer=$table->getFooter();
216 223
 		$footer->mergeCol();
@@ -234,8 +241,9 @@  discard block
 block discarded – undo
234 241
 
235 242
 	protected function _getFieldName($index){
236 243
 		$fieldName=parent::_getFieldName($index);
237
-		if(\is_object($fieldName))
238
-			$fieldName="field-".$index;
244
+		if(\is_object($fieldName)) {
245
+					$fieldName="field-".$index;
246
+		}
239 247
 		return $fieldName."[]";
240 248
 	}
241 249
 
@@ -275,7 +283,7 @@  discard block
 block discarded – undo
275 283
 		$hasPart=$table->hasPart($part);
276 284
 		if($hasPart){
277 285
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
278
-		}else{
286
+		} else{
279 287
 			$row=$table->getPart($part)->getRow(0);
280 288
 		}
281 289
 		$row->mergeCol();
@@ -307,7 +315,7 @@  discard block
 block discarded – undo
307 315
 			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
308 316
 			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
309 317
 			$this->_urls["display"]=JArray::getValue($urls, "display",3);
310
-		}else{
318
+		} else{
311 319
 			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls,"display"=>$urls];
312 320
 		}
313 321
 		return $this;
@@ -390,8 +398,9 @@  discard block
 block discarded – undo
390 398
 
391 399
 	protected function getTargetSelector($op) {
392 400
 		$result=$this->_targetSelector;
393
-		if(!isset($result[$op]))
394
-			$result="#".$this->identifier;
401
+		if(!isset($result[$op])) {
402
+					$result="#".$this->identifier;
403
+		}
395 404
 		return $result[$op];
396 405
 	}
397 406
 
@@ -409,8 +418,9 @@  discard block
 block discarded – undo
409 418
 	}
410 419
 
411 420
 	public function getRefreshSelector() {
412
-		if(isset($this->_refreshSelector))
413
-			return $this->_refreshSelector;
421
+		if(isset($this->_refreshSelector)) {
422
+					return $this->_refreshSelector;
423
+		}
414 424
 		return "#".$this->identifier." tbody";
415 425
 	}
416 426
 
@@ -429,8 +439,9 @@  discard block
 block discarded – undo
429 439
 	 */
430 440
 	public function show($modelInstance){
431 441
 		if(\is_array($modelInstance)){
432
-			if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
433
-				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
442
+			if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) {
443
+							$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
444
+			}
434 445
 		}
435 446
 		$this->_modelInstance=$modelInstance;
436 447
 	}
@@ -470,8 +481,9 @@  discard block
 block discarded – undo
470 481
 	}
471 482
 
472 483
 	public function hideColumn($colIndex){
473
-		if(!\is_array($this->_hiddenColumns))
474
-			$this->_hiddenColumns=[];
484
+		if(!\is_array($this->_hiddenColumns)) {
485
+					$this->_hiddenColumns=[];
486
+		}
475 487
 		$this->_hiddenColumns[]=$colIndex;
476 488
 		return $this;
477 489
 	}
Please login to merge, or discard this patch.