Completed
Push — master ( 0b3773...ca057c )
by Jean-Christophe
03:07
created
Ajax/semantic/widgets/datatable/DataTable.php 1 patch
Spacing   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -37,30 +37,30 @@  discard block
 block discarded – undo
37 37
 	protected $_targetSelector;
38 38
 	protected $_checkedMessage;
39 39
 
40
-	public function __construct($identifier,$model,$modelInstance=NULL) {
41
-		parent::__construct($identifier, $model,$modelInstance);
42
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
40
+	public function __construct($identifier, $model, $modelInstance=NULL) {
41
+		parent::__construct($identifier, $model, $modelInstance);
42
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
43 43
 		$this->_urls=[];
44 44
 	}
45 45
 
46
-	public function run(JsUtils $js){
47
-		if($this->_hasCheckboxes && isset($js)){
46
+	public function run(JsUtils $js) {
47
+		if ($this->_hasCheckboxes && isset($js)) {
48 48
 			$this->_runCheckboxes($js);
49 49
 		}
50
-		if($this->_visibleHover){
51
-			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
52
-			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
50
+		if ($this->_visibleHover) {
51
+			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]);
52
+			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]);
53 53
 		}
54
-		if($this->_hasDelete)
54
+		if ($this->_hasDelete)
55 55
 			$this->_generateBehavior("delete", $js);
56
-		if($this->_hasEdit)
56
+		if ($this->_hasEdit)
57 57
 			$this->_generateBehavior("edit", $js);
58 58
 		return parent::run($js);
59 59
 	}
60 60
 
61
-	protected function _runCheckboxes(JsUtils $js){
61
+	protected function _runCheckboxes(JsUtils $js) {
62 62
 		$checkedMessageCall="";
63
-		if($this->_hasCheckedMessage){
63
+		if ($this->_hasCheckedMessage) {
64 64
 			$msg=$this->getCheckedMessage();
65 65
 			$checkedMessageFunction="function updateChecked(){var msg='".$msg[0]."',count=\$('#{$this->identifier} [name=\"selection[]\"]:checked').length,all=\$('#{$this->identifier} [name=\"selection[]\"]').length;
66 66
 			if(count==1) msg='".$msg[1]."';
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 						\$('#checked-count-".$this->identifier."').contents().filter(function() {return this.nodeType == 3;}).each(function(){this.textContent = msg.replace('{count}',count);});
69 69
 								\$('#toolbar-{$this->identifier} .visibleOnChecked').toggle(count>0);}\$('#toolbar-".$this->identifier." .visibleOnChecked').hide();";
70 70
 			$checkedMessageCall="updateChecked();";
71
-			$js->exec($checkedMessageFunction,true);
71
+			$js->exec($checkedMessageFunction, true);
72 72
 		}
73 73
 		$js->execOn("change", "#".$this->identifier." [name='selection[]']", "
74 74
 				var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true;
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 				if(allChecked) {\$parentCheckbox.checkbox('set checked');}else if(allUnchecked){\$parentCheckbox.checkbox('set unchecked');}else{\$parentCheckbox.checkbox('set indeterminate');};".$checkedMessageCall);
77 77
 	}
78 78
 
79
-	protected function _generateBehavior($op,JsUtils $js){
80
-		if(isset($this->_urls[$op]))
81
-			$js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]);
79
+	protected function _generateBehavior($op, JsUtils $js) {
80
+		if (isset($this->_urls[$op]))
81
+			$js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op], $this->getTargetSelector(), ["preventDefault"=>false, "attr"=>"data-ajax"]);
82 82
 	}
83 83
 
84 84
 	/**
@@ -90,70 +90,70 @@  discard block
 block discarded – undo
90 90
 	}
91 91
 
92 92
 
93
-	public function compile(JsUtils $js=NULL,&$view=NULL){
94
-		if(!$this->_generated){
93
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
94
+		if (!$this->_generated) {
95 95
 			$this->_instanceViewer->setInstance($this->_model);
96 96
 			$captions=$this->_instanceViewer->getCaptions();
97 97
 
98 98
 			$table=$this->content["table"];
99 99
 
100
-			if($this->_hasCheckboxes){
100
+			if ($this->_hasCheckboxes) {
101 101
 				$this->_generateMainCheckbox($captions);
102 102
 			}
103 103
 
104 104
 			$table->setRowCount(0, \sizeof($captions));
105 105
 			$table->setHeaderValues($captions);
106
-			if(isset($this->_compileParts))
106
+			if (isset($this->_compileParts))
107 107
 				$table->setCompileParts($this->_compileParts);
108 108
 
109
-			if(isset($this->_searchField) && isset($js)){
110
-				if(isset($this->_urls["refresh"]))
111
-					$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
109
+			if (isset($this->_searchField) && isset($js)) {
110
+				if (isset($this->_urls["refresh"]))
111
+					$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
112 112
 			}
113 113
 
114 114
 			$this->_generateContent($table);
115 115
 
116
-			if($this->_hasCheckboxes && $table->hasPart("thead")){
117
-					$table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort");
116
+			if ($this->_hasCheckboxes && $table->hasPart("thead")) {
117
+					$table->getHeader()->getCell(0, 0)->addToProperty("class", "no-sort");
118 118
 			}
119 119
 
120
-			if(isset($this->_pagination) && $this->_pagination->getVisible()){
120
+			if (isset($this->_pagination) && $this->_pagination->getVisible()) {
121 121
 				$this->_generatePagination($table);
122 122
 			}
123
-			if(isset($this->_toolbar)){
123
+			if (isset($this->_toolbar)) {
124 124
 				$this->_setToolbarPosition($table, $captions);
125 125
 			}
126
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
126
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
127 127
 			$this->_compileForm();
128 128
 			$this->_generated=true;
129 129
 		}
130
-		return parent::compile($js,$view);
130
+		return parent::compile($js, $view);
131 131
 	}
132 132
 
133
-	private function _generateMainCheckbox(&$captions){
134
-		$ck=new HtmlCheckbox("main-ck-".$this->identifier,"");
133
+	private function _generateMainCheckbox(&$captions) {
134
+		$ck=new HtmlCheckbox("main-ck-".$this->identifier, "");
135 135
 		$checkedMessageCall="";
136
-		if($this->_hasCheckedMessage)
136
+		if ($this->_hasCheckedMessage)
137 137
 			$checkedMessageCall="updateChecked();";
138 138
 		$ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);".$checkedMessageCall);
139 139
 		$ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);".$checkedMessageCall);
140 140
 		\array_unshift($captions, $ck);
141 141
 	}
142 142
 
143
-	protected function _generateContent($table){
143
+	protected function _generateContent($table) {
144 144
 		$objects=$this->_modelInstance;
145
-		if(isset($this->_pagination)){
145
+		if (isset($this->_pagination)) {
146 146
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
147 147
 		}
148 148
 		InstanceViewer::setIndex(0);
149 149
 		$table->fromDatabaseObjects($objects, function($instance) use($table){
150 150
 			$this->_instanceViewer->setInstance($instance);
151 151
 			InstanceViewer::$index++;
152
-			$values= $this->_instanceViewer->getValues();
153
-			if($this->_hasCheckboxes){
154
-				$ck=new HtmlCheckbox("ck-".$this->identifier,"");
152
+			$values=$this->_instanceViewer->getValues();
153
+			if ($this->_hasCheckboxes) {
154
+				$ck=new HtmlCheckbox("ck-".$this->identifier, "");
155 155
 				$field=$ck->getField();
156
-				$field->setProperty("value",$this->_instanceViewer->getIdentifier());
156
+				$field->setProperty("value", $this->_instanceViewer->getIdentifier());
157 157
 				$field->setProperty("name", "selection[]");
158 158
 				\array_unshift($values, $ck);
159 159
 			}
@@ -164,37 +164,37 @@  discard block
 block discarded – undo
164 164
 		});
165 165
 	}
166 166
 
167
-	private function _generatePagination($table){
167
+	private function _generatePagination($table) {
168 168
 		$footer=$table->getFooter();
169 169
 		$footer->mergeCol();
170
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
170
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
171 171
 		$menu->floatRight();
172 172
 		$menu->setActiveItem($this->_pagination->getPage()-1);
173 173
 		$footer->setValues($menu);
174
-		if(isset($this->_urls["refresh"]))
175
-			$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
174
+		if (isset($this->_urls["refresh"]))
175
+			$menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
176 176
 	}
177 177
 
178
-	protected function _getFieldName($index){
178
+	protected function _getFieldName($index) {
179 179
 		return parent::_getFieldName($index)."[]";
180 180
 	}
181 181
 
182
-	protected function _getFieldCaption($index){
182
+	protected function _getFieldCaption($index) {
183 183
 		return null;
184 184
 	}
185 185
 
186
-	protected function _setToolbarPosition($table,$captions=NULL){
187
-		switch ($this->_toolbarPosition){
186
+	protected function _setToolbarPosition($table, $captions=NULL) {
187
+		switch ($this->_toolbarPosition) {
188 188
 			case PositionInTable::BEFORETABLE:
189 189
 			case PositionInTable::AFTERTABLE:
190
-				if(isset($this->_compileParts)===false){
190
+				if (isset($this->_compileParts)===false) {
191 191
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
192 192
 				}
193 193
 				break;
194 194
 			case PositionInTable::HEADER:
195 195
 			case PositionInTable::FOOTER:
196 196
 			case PositionInTable::BODY:
197
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
197
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
198 198
 				break;
199 199
 		}
200 200
 	}
@@ -206,23 +206,23 @@  discard block
 block discarded – undo
206 206
 	 * @param callable $callback function called after the field compilation
207 207
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
208 208
 	 */
209
-	public function afterCompile($index,$callback){
210
-		$this->_instanceViewer->afterCompile($index,$callback);
209
+	public function afterCompile($index, $callback) {
210
+		$this->_instanceViewer->afterCompile($index, $callback);
211 211
 		return $this;
212 212
 	}
213 213
 
214
-	private function addToolbarRow($part,$table,$captions){
214
+	private function addToolbarRow($part, $table, $captions) {
215 215
 		$hasPart=$table->hasPart($part);
216
-		if($hasPart){
216
+		if ($hasPart) {
217 217
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
218
-		}else{
218
+		} else {
219 219
 			$row=$table->getPart($part)->getRow(0);
220 220
 		}
221 221
 		$row->mergeCol();
222 222
 		$row->setValues([$this->_toolbar]);
223 223
 	}
224 224
 
225
-	public function getHtmlComponent(){
225
+	public function getHtmlComponent() {
226 226
 		return $this->content["table"];
227 227
 	}
228 228
 
@@ -236,18 +236,18 @@  discard block
 block discarded – undo
236 236
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
237 237
 	 */
238 238
 	public function setUrls($urls) {
239
-		if(\is_array($urls)){
240
-			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
241
-			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
242
-			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
243
-		}else{
244
-			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
239
+		if (\is_array($urls)) {
240
+			$this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0);
241
+			$this->_urls["edit"]=JArray::getValue($urls, "edit", 1);
242
+			$this->_urls["delete"]=JArray::getValue($urls, "delete", 2);
243
+		} else {
244
+			$this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls];
245 245
 		}
246 246
 		return $this;
247 247
 	}
248 248
 
249
-	public function paginate($items_per_page=10,$page=1){
250
-		$this->_pagination=new Pagination($items_per_page,4,$page);
249
+	public function paginate($items_per_page=10, $page=1) {
250
+		$this->_pagination=new Pagination($items_per_page, 4, $page);
251 251
 	}
252 252
 
253 253
 	public function getHasCheckboxes() {
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 		return $this;
260 260
 	}
261 261
 
262
-	public function refresh($compileParts=["tbody"]){
262
+	public function refresh($compileParts=["tbody"]) {
263 263
 		$this->_compileParts=$compileParts;
264 264
 		return $this;
265 265
 	}
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 	 * @param boolean $visibleHover
270 270
 	 * @return callable
271 271
 	 */
272
-	private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){
273
-		return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback);
272
+	private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) {
273
+		return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback);
274 274
 	}
275 275
 
276 276
 	/**
@@ -279,19 +279,19 @@  discard block
 block discarded – undo
279 279
 	 * @param callable $callback
280 280
 	 * @return callable
281 281
 	 */
282
-	private function getCallable($thisCallback,$parameters,$callback=null){
283
-		$result=function($instance) use($thisCallback,$parameters,$callback){
284
-			$object=call_user_func_array(array($this,$thisCallback), $parameters);
285
-			if(isset($callback)){
286
-				if(\is_callable($callback)){
287
-					$callback($object,$instance);
282
+	private function getCallable($thisCallback, $parameters, $callback=null) {
283
+		$result=function($instance) use($thisCallback, $parameters, $callback){
284
+			$object=call_user_func_array(array($this, $thisCallback), $parameters);
285
+			if (isset($callback)) {
286
+				if (\is_callable($callback)) {
287
+					$callback($object, $instance);
288 288
 				}
289 289
 			}
290
-			if($object instanceof HtmlSemDoubleElement){
291
-				$object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier());
292
-				if($object->propertyContains("class","visibleover")){
290
+			if ($object instanceof HtmlSemDoubleElement) {
291
+				$object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier());
292
+				if ($object->propertyContains("class", "visibleover")) {
293 293
 					$this->_visibleHover=true;
294
-					$object->setProperty("style","visibility:hidden;");
294
+					$object->setProperty("style", "visibility:hidden;");
295 295
 				}
296 296
 			}
297 297
 			return $object;
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
 	 * @param string $caption
304 304
 	 * @return HtmlButton
305 305
 	 */
306
-	private function getFieldButton($caption,$visibleHover=true){
307
-		$bt= new HtmlButton("",$caption);
308
-		if($visibleHover)
306
+	private function getFieldButton($caption, $visibleHover=true) {
307
+		$bt=new HtmlButton("", $caption);
308
+		if ($visibleHover)
309 309
 			$this->_visibleOver($bt);
310 310
 		return $bt;
311 311
 	}
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 	 * @param boolean $visibleHover
318 318
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
319 319
 	 */
320
-	public function addFieldButton($caption,$visibleHover=true,$callback=null){
321
-		$this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback));
320
+	public function addFieldButton($caption, $visibleHover=true, $callback=null) {
321
+		$this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback));
322 322
 		return $this;
323 323
 	}
324 324
 
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 	 * @param callable $callback
330 330
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
331 331
 	 */
332
-	public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){
333
-		$this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
332
+	public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) {
333
+		$this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback));
334 334
 		return $this;
335 335
 	}
336 336
 
@@ -341,64 +341,64 @@  discard block
 block discarded – undo
341 341
 	 * @param callable $callback
342 342
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
343 343
 	 */
344
-	public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){
345
-		$this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
344
+	public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null) {
345
+		$this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback));
346 346
 		return $this;
347 347
 	}
348 348
 
349
-	private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){
350
-		$this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
349
+	private function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null) {
350
+		$this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback));
351 351
 		return $this;
352 352
 	}
353 353
 
354
-	private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){
355
-		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
354
+	private function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null) {
355
+		$this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback));
356 356
 		return $this;
357 357
 	}
358 358
 
359
-	private function getDefaultButton($icon,$class=null,$visibleHover=true){
360
-		$bt=$this->getFieldButton("",$visibleHover);
359
+	private function getDefaultButton($icon, $class=null, $visibleHover=true) {
360
+		$bt=$this->getFieldButton("", $visibleHover);
361 361
 		$bt->asIcon($icon);
362
-		if(isset($class))
362
+		if (isset($class))
363 363
 			$bt->addToProperty("class", $class);
364 364
 		return $bt;
365 365
 	}
366 366
 
367
-	public function addDeleteButton($visibleHover=true,$generateBehavior=true,$callback=null){
367
+	public function addDeleteButton($visibleHover=true, $generateBehavior=true, $callback=null) {
368 368
 		$this->_hasDelete=$generateBehavior;
369
-		return $this->addDefaultButton("remove","delete red basic",$visibleHover,$callback);
369
+		return $this->addDefaultButton("remove", "delete red basic", $visibleHover, $callback);
370 370
 	}
371 371
 
372
-	public function addEditButton($visibleHover=true,$generateBehavior=true,$callback=null){
372
+	public function addEditButton($visibleHover=true, $generateBehavior=true, $callback=null) {
373 373
 		$this->_hasEdit=$generateBehavior;
374
-		return $this->addDefaultButton("edit","edit basic",$visibleHover,$callback);
374
+		return $this->addDefaultButton("edit", "edit basic", $visibleHover, $callback);
375 375
 	}
376 376
 
377
-	public function addEditDeleteButtons($visibleHover=true,$generateBehavior=true,$callbackEdit=null,$callbackDelete=null){
378
-		$this->addEditButton($visibleHover,$generateBehavior,$callbackEdit);
377
+	public function addEditDeleteButtons($visibleHover=true, $generateBehavior=true, $callbackEdit=null, $callbackDelete=null) {
378
+		$this->addEditButton($visibleHover, $generateBehavior, $callbackEdit);
379 379
 		$index=$this->_instanceViewer->visiblePropertiesCount()-1;
380
-		$this->insertDeleteButtonIn($index,$visibleHover,$generateBehavior,$callbackDelete);
380
+		$this->insertDeleteButtonIn($index, $visibleHover, $generateBehavior, $callbackDelete);
381 381
 		return $this;
382 382
 	}
383 383
 
384
-	public function insertDeleteButtonIn($index,$visibleHover=true,$generateBehavior=true,$callback=null){
384
+	public function insertDeleteButtonIn($index, $visibleHover=true, $generateBehavior=true, $callback=null) {
385 385
 		$this->_hasDelete=$generateBehavior;
386
-		return $this->insertDefaultButtonIn($index,"remove","delete red basic",$visibleHover,$callback);
386
+		return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $visibleHover, $callback);
387 387
 	}
388 388
 
389
-	public function insertEditButtonIn($index,$visibleHover=true,$generateBehavior=true,$callback=null){
389
+	public function insertEditButtonIn($index, $visibleHover=true, $generateBehavior=true, $callback=null) {
390 390
 		$this->_hasEdit=$generateBehavior;
391
-		return $this->insertDefaultButtonIn($index,"edit","edit basic",$visibleHover,$callback);
391
+		return $this->insertDefaultButtonIn($index, "edit", "edit basic", $visibleHover, $callback);
392 392
 	}
393 393
 
394
-	public function addSearchInToolbar($position=Direction::RIGHT){
394
+	public function addSearchInToolbar($position=Direction::RIGHT) {
395 395
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
396 396
 	}
397 397
 
398
-	public function getSearchField(){
399
-		if(isset($this->_searchField)===false){
400
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
401
-			$this->_searchField->addIcon("search",Direction::RIGHT);
398
+	public function getSearchField() {
399
+		if (isset($this->_searchField)===false) {
400
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
401
+			$this->_searchField->addIcon("search", Direction::RIGHT);
402 402
 		}
403 403
 		return $this->_searchField;
404 404
 	}
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 		return $this;
415 415
 	}
416 416
 
417
-	public function asForm(){
417
+	public function asForm() {
418 418
 		return $this->getForm();
419 419
 	}
420 420
 
@@ -427,24 +427,24 @@  discard block
 block discarded – undo
427 427
 	 * @param array $attributes
428 428
 	 * @return \Ajax\semantic\widgets\datatable\DataTable
429 429
 	 */
430
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
431
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){
432
-			$button=new HtmlButton($id,$value,$cssStyle);
433
-			$button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]);
434
-			if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
430
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
431
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $index, $attributes){
432
+			$button=new HtmlButton($id, $value, $cssStyle);
433
+			$button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]);
434
+			if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
435 435
 				$this->_visibleOver($button);
436 436
 			return $button;
437
-		}, $index,$attributes);
437
+		}, $index, $attributes);
438 438
 	}
439 439
 
440
-	protected function _visibleOver($element){
440
+	protected function _visibleOver($element) {
441 441
 		$this->_visibleHover=true;
442
-		return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;");
442
+		return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;");
443 443
 	}
444 444
 
445 445
 	protected function getTargetSelector() {
446 446
 		$result=$this->_targetSelector;
447
-		if(!isset($result))
447
+		if (!isset($result))
448 448
 			$result="#".$this->identifier;
449 449
 		return $result;
450 450
 	}
@@ -460,9 +460,9 @@  discard block
 block discarded – undo
460 460
 	}
461 461
 
462 462
 	protected function getCheckedMessage() {
463
-		$result= $this->_checkedMessage;
464
-		if(!isset($result)){
465
-			$result=[0=>"none selected",1=>"one item selected","other"=>"{count} items selected"];
463
+		$result=$this->_checkedMessage;
464
+		if (!isset($result)) {
465
+			$result=[0=>"none selected", 1=>"one item selected", "other"=>"{count} items selected"];
466 466
 		}
467 467
 		return $result;
468 468
 	}
@@ -482,14 +482,14 @@  discard block
 block discarded – undo
482 482
 	 * @param array $checkedMessage
483 483
 	 * @param callable $callback
484 484
 	 */
485
-	public function addCountCheckedInToolbar(array $checkedMessage=null,$callback=null){
486
-		if(isset($checkedMessage))
485
+	public function addCountCheckedInToolbar(array $checkedMessage=null, $callback=null) {
486
+		if (isset($checkedMessage))
487 487
 			$this->_checkedMessage=$checkedMessage;
488 488
 		$checkedMessage=$this->getCheckedMessage();
489 489
 		$this->_hasCheckboxes=true;
490 490
 		$this->_hasCheckedMessage=true;
491
-		$element=new HtmlLabel("checked-count-".$this->identifier,$checkedMessage[0]);
492
-		$this->addInToolbar($element,$callback);
491
+		$element=new HtmlLabel("checked-count-".$this->identifier, $checkedMessage[0]);
492
+		$this->addInToolbar($element, $callback);
493 493
 	}
494 494
 
495 495
 
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/menus/HtmlMenu.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 	 * @return \Ajax\semantic\html\collections\HtmlMenu
41 41
 	 */
42 42
 	public function setType($type="") {
43
-		return $this->addToPropertyCtrl("class", $type, array ("","item","text" ));
43
+		return $this->addToPropertyCtrl("class", $type, array("", "item", "text"));
44 44
 	}
45 45
 
46 46
 	public function setActiveItem($index) {
47 47
 		$item=$this->getItem($index);
48
-		if ($item !== null) {
48
+		if ($item!==null) {
49 49
 			$item->addToProperty("class", "active");
50 50
 		}
51 51
 		return $this;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 	private function getItemToInsert($item) {
55 55
 		if ($item instanceof HtmlInput || $item instanceof HtmlImg || $item instanceof HtmlIcon || $item instanceof HtmlButtonGroups || $item instanceof HtmlButton || $item instanceof HtmlLabel) {
56
-			$itemO=new HtmlMenuItem("item-" . $this->identifier . "-" . \sizeof($this->content) , $item);
56
+			$itemO=new HtmlMenuItem("item-".$this->identifier."-".\sizeof($this->content), $item);
57 57
 			$item=$itemO;
58 58
 		}
59 59
 		return $item;
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
 	private function afterInsert($item) {
63 63
 		if (!$item instanceof HtmlMenu && $item->propertyContains("class", "header")===false)
64
-			$item->addToPropertyCtrl("class", "item", array ("item" ));
64
+			$item->addToPropertyCtrl("class", "item", array("item"));
65 65
 		else {
66 66
 			$this->setSecondary();
67 67
 		}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	public function addItem($item) {
78 78
 		$number=$item;
79 79
 		$item=parent::addItem($this->getItemToInsert($item));
80
-		if(\is_int($number))
80
+		if (\is_int($number))
81 81
 			$item->setProperty("data-page", $number);
82 82
 		return $this->afterInsert($item);
83 83
 	}
@@ -95,15 +95,15 @@  discard block
 block discarded – undo
95 95
 
96 96
 	public function generateMenuAsItem($menu, $header=null) {
97 97
 		$count=$this->count();
98
-		$item=new HtmlSemDoubleElement("item-" . $this->identifier . "-" . $count, "div");
98
+		$item=new HtmlSemDoubleElement("item-".$this->identifier."-".$count, "div");
99 99
 		if (isset($header)) {
100
-			$headerItem=new HtmlSemDoubleElement("item-header-" . $this->identifier . "-" . $count, "div", "header");
100
+			$headerItem=new HtmlSemDoubleElement("item-header-".$this->identifier."-".$count, "div", "header");
101 101
 			$headerItem->setContent($header);
102 102
 			$item->addContent($headerItem);
103 103
 			$this->_itemHeader=$headerItem;
104 104
 		}
105
-		if(\is_array($menu)){
106
-			$menu=new HtmlMenu("menu-" . $this->identifier . "-" . $count,$menu);
105
+		if (\is_array($menu)) {
106
+			$menu=new HtmlMenu("menu-".$this->identifier."-".$count, $menu);
107 107
 		}
108 108
 		$menu->setClass("menu");
109 109
 		$item->addContent($menu);
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		$value=new HtmlSemDoubleElement($identifier, "a", "browse item", $value);
119 119
 		$value->addContent(new HtmlIcon("", "dropdown"));
120 120
 		$value=$this->addItem($value);
121
-		$popup=new HtmlPopup($value, "popup-" . $this->identifier . "-" . $this->count(), $content);
121
+		$popup=new HtmlPopup($value, "popup-".$this->identifier."-".$this->count(), $content);
122 122
 		$popup->setFlowing()->setPosition("bottom left")->setOn("click");
123 123
 		$this->wrap("", $popup);
124 124
 		return $popup;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	public function addDropdownAsItem($value, $items=NULL) {
128 128
 		$dd=$value;
129 129
 		if (\is_string($value)) {
130
-			$dd=new HtmlDropdown("dropdown-" . $this->identifier . "-" . $this->count(), $value, $items);
130
+			$dd=new HtmlDropdown("dropdown-".$this->identifier."-".$this->count(), $value, $items);
131 131
 		}
132 132
 		$this->addItem($dd);
133 133
 		return $dd;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 * @see \Ajax\common\html\html5\HtmlCollection::createItem()
141 141
 	 */
142 142
 	protected function createItem($value) {
143
-		$itemO=new HtmlMenuItem($this->identifier."-item-" . \sizeof($this->content),"");
143
+		$itemO=new HtmlMenuItem($this->identifier."-item-".\sizeof($this->content), "");
144 144
 		$itemO->setTagName("a");
145 145
 		$itemO->setContent($value);
146 146
 		return $itemO;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	}
152 152
 
153 153
 	public function setSecondary($value=true) {
154
-		if($value)
154
+		if ($value)
155 155
 			$this->addToProperty("class", "secondary");
156 156
 		else
157 157
 			$this->removePropertyValue("class", "secondary");
@@ -159,28 +159,28 @@  discard block
 block discarded – undo
159 159
 	}
160 160
 
161 161
 	public function setVertical() {
162
-		return $this->addToPropertyCtrl("class", "vertical", array ("vertical" ));
162
+		return $this->addToPropertyCtrl("class", "vertical", array("vertical"));
163 163
 	}
164 164
 
165 165
 	public function setPosition($value="right") {
166
-		return $this->addToPropertyCtrl("class", $value, array ("right","left" ));
166
+		return $this->addToPropertyCtrl("class", $value, array("right", "left"));
167 167
 	}
168 168
 
169 169
 	public function setPointing($value=Direction::NONE) {
170
-		return $this->addToPropertyCtrl("class", $value . " pointing", Direction::getConstantValues("pointing"));
170
+		return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing"));
171 171
 	}
172 172
 
173 173
 	public function asTab($vertical=false) {
174
-		$this->apply(function (HtmlDoubleElement &$item) {
174
+		$this->apply(function(HtmlDoubleElement&$item) {
175 175
 			$item->setTagName("a");
176 176
 		});
177
-		if ($vertical === true)
177
+		if ($vertical===true)
178 178
 			$this->setVertical();
179 179
 		return $this->addToProperty("class", "tabular");
180 180
 	}
181 181
 
182 182
 	public function asPagination() {
183
-		$this->apply(function (HtmlDoubleElement &$item) {
183
+		$this->apply(function(HtmlDoubleElement&$item) {
184 184
 			$item->setTagName("a");
185 185
 		});
186 186
 		return $this->addToProperty("class", "pagination");
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
 	 */
218 218
 	public function setWidth($width) {
219 219
 		if (\is_int($width)) {
220
-			$width=Wide::getConstants()["W" . $width];
220
+			$width=Wide::getConstants()["W".$width];
221 221
 		}
222 222
 		$this->addToPropertyCtrl("class", $width, Wide::getConstants());
223
-		return $this->addToPropertyCtrl("class", "item", array ("item" ));
223
+		return $this->addToPropertyCtrl("class", "item", array("item"));
224 224
 	}
225 225
 
226 226
 	public function addImage($identifier, $src="", $alt="") {
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 		return $this->_itemHeader;
236 236
 	}
237 237
 
238
-	public function run(JsUtils $js){
239
-		$result= parent::run($js);
238
+	public function run(JsUtils $js) {
239
+		$result=parent::run($js);
240 240
 		return $result->setItemSelector(".item");
241 241
 	}
242 242
 }
243 243
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/html/elements/HtmlButtonGroups.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 
17 17
 	public function __construct($identifier, $elements=array(), $asIcons=false) {
18 18
 		parent::__construct($identifier, "div", "ui buttons");
19
-		if ($asIcons === true)
19
+		if ($asIcons===true)
20 20
 			$this->asIcons();
21 21
 		$this->addElements($elements, $asIcons);
22 22
 	}
23
-	protected function createItem($value){
24
-		return new HtmlButton("button-" . $this->identifier . "-" . \sizeof($this->content), $value);
23
+	protected function createItem($value) {
24
+		return new HtmlButton("button-".$this->identifier."-".\sizeof($this->content), $value);
25 25
 	}
26 26
 
27 27
 
28 28
 	public function addElement($element, $asIcon=false) {
29 29
 		$item=$this->addItem($element);
30
-		if($asIcon)
30
+		if ($asIcon)
31 31
 			$item->asIcon($element);
32 32
 		return $item;
33 33
 	}
34 34
 
35 35
 	public function addElements($elements, $asIcons=false) {
36
-		foreach ( $elements as $element ) {
36
+		foreach ($elements as $element) {
37 37
 			$this->addElement($element, $asIcons);
38 38
 		}
39 39
 		return $this;
40 40
 	}
41 41
 
42 42
 	public function insertOr($aferIndex=0, $or="or") {
43
-		$orElement=new HtmlSemDoubleElement("or-" . $this->identifier, "div", "or");
43
+		$orElement=new HtmlSemDoubleElement("or-".$this->identifier, "div", "or");
44 44
 		$orElement->setProperty("data-text", $or);
45
-		array_splice($this->content, $aferIndex + 1, 0, array ($orElement ));
45
+		array_splice($this->content, $aferIndex+1, 0, array($orElement));
46 46
 		return $this;
47 47
 	}
48 48
 
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 	}
56 56
 
57 57
 	public function asIcons() {
58
-		foreach ( $this->content as $item ) {
59
-			if($item instanceof HtmlButton)
58
+		foreach ($this->content as $item) {
59
+			if ($item instanceof HtmlButton)
60 60
 			$item->asIcon($item->getContent());
61 61
 		}
62 62
 		return $this->addToProperty("class", "icons");
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @see \Ajax\bootstrap\html\base\BaseHtml::on()
90 90
 	 */
91 91
 	public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
92
-		foreach ( $this->content as $element ) {
92
+		foreach ($this->content as $element) {
93 93
 			$element->on($event, $jsCode, $stopPropagation, $preventDefault);
94 94
 		}
95 95
 		return $this;
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
 
102 102
 	public function addClasses($classes=array()) {
103 103
 		$i=0;
104
-		if(!\is_array($classes)){
105
-			$classes=array_fill (0,$this->count(),$classes);
104
+		if (!\is_array($classes)) {
105
+			$classes=array_fill(0, $this->count(), $classes);
106 106
 		}
107
-		foreach ( $this->content as $button ) {
107
+		foreach ($this->content as $button) {
108 108
 			$button->addToProperty("class", $classes[$i++]);
109 109
 		}
110 110
 		return $this;
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 		$this->addElement($function($object));
119 119
 	}
120 120
 
121
-	public function run(JsUtils $js){
122
-		$result= parent::run($js);
121
+	public function run(JsUtils $js) {
122
+		$result=parent::run($js);
123 123
 		return $result->setItemSelector(".ui.button");
124 124
 	}
125 125
 }
126 126
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/common/Widget.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 use Ajax\semantic\html\collections\form\traits\FormTrait;
19 19
 
20 20
 abstract class Widget extends HtmlDoubleElement {
21
-	use FieldAsTrait,FormTrait;
21
+	use FieldAsTrait, FormTrait;
22 22
 
23 23
 	/**
24 24
 	 * @var string classname
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
 	protected $_generated;
52 52
 
53 53
 
54
-	public function __construct($identifier,$model,$modelInstance=NULL) {
54
+	public function __construct($identifier, $model, $modelInstance=NULL) {
55 55
 		parent::__construct($identifier);
56 56
 		$this->_template="%wrapContentBefore%%content%%wrapContentAfter%";
57 57
 		$this->setModel($model);
58
-		if(isset($modelInstance)){
59
-			if(\is_array($modelInstance)){
58
+		if (isset($modelInstance)) {
59
+			if (\is_array($modelInstance)) {
60 60
 				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
61 61
 			}
62 62
 			$this->show($modelInstance);
@@ -64,28 +64,28 @@  discard block
 block discarded – undo
64 64
 		$this->_generated=false;
65 65
 	}
66 66
 
67
-	protected function _init($instanceViewer,$contentKey,$content,$edition){
67
+	protected function _init($instanceViewer, $contentKey, $content, $edition) {
68 68
 		$this->_instanceViewer=$instanceViewer;
69 69
 		$this->content=[$contentKey=>$content];
70 70
 		$this->_toolbarPosition=PositionInTable::BEFORETABLE;
71 71
 		$this->_edition=$edition;
72 72
 	}
73 73
 
74
-	protected function _getFieldIdentifier($prefix,$name=""){
74
+	protected function _getFieldIdentifier($prefix, $name="") {
75 75
 		return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier();
76 76
 	}
77 77
 
78
-	protected function _getFieldName($index){
78
+	protected function _getFieldName($index) {
79 79
 		return $this->_instanceViewer->getFieldName($index);
80 80
 	}
81 81
 
82
-	protected function _getFieldCaption($index){
82
+	protected function _getFieldCaption($index) {
83 83
 		return $this->_instanceViewer->getCaption($index);
84 84
 	}
85 85
 
86
-	abstract protected  function _setToolbarPosition($table,$captions=NULL);
86
+	abstract protected  function _setToolbarPosition($table, $captions=NULL);
87 87
 
88
-	public function show($modelInstance){
88
+	public function show($modelInstance) {
89 89
 		$this->_modelInstance=$modelInstance;
90 90
 	}
91 91
 
@@ -109,56 +109,56 @@  discard block
 block discarded – undo
109 109
 
110 110
 	abstract public function getHtmlComponent();
111 111
 
112
-	public function setAttached($value=true){
112
+	public function setAttached($value=true) {
113 113
 		return $this->getHtmlComponent()->setAttached($value);
114 114
 	}
115 115
 
116
-	public function setColor($color){
116
+	public function setColor($color) {
117 117
 		return $this->getHtmlComponent()->setColor($color);
118 118
 	}
119 119
 
120 120
 
121
-	public function setCaptions($captions){
121
+	public function setCaptions($captions) {
122 122
 		$this->_instanceViewer->setCaptions($captions);
123 123
 		return $this;
124 124
 	}
125 125
 
126
-	public function setFields($fields){
126
+	public function setFields($fields) {
127 127
 		$this->_instanceViewer->setVisibleProperties($fields);
128 128
 		return $this;
129 129
 	}
130 130
 
131
-	public function addField($field){
131
+	public function addField($field) {
132 132
 		$this->_instanceViewer->addField($field);
133 133
 		return $this;
134 134
 	}
135 135
 
136
-	public function addMessage($attributes=NULL,$fieldName="message"){
136
+	public function addMessage($attributes=NULL, $fieldName="message") {
137 137
 		$this->_instanceViewer->addField($fieldName);
138 138
 		$count=$this->_instanceViewer->visiblePropertiesCount();
139
-		return $this->fieldAsMessage($count-1,$attributes);
139
+		return $this->fieldAsMessage($count-1, $attributes);
140 140
 	}
141 141
 
142
-	public function addErrorMessage(){
143
-		return $this->addMessage(["error"=>true],"message");
142
+	public function addErrorMessage() {
143
+		return $this->addMessage(["error"=>true], "message");
144 144
 	}
145 145
 
146
-	public function insertField($index,$field){
146
+	public function insertField($index, $field) {
147 147
 		$this->_instanceViewer->insertField($index, $field);
148 148
 		return $this;
149 149
 	}
150 150
 
151
-	public function insertInField($index,$field){
151
+	public function insertInField($index, $field) {
152 152
 		$this->_instanceViewer->insertInField($index, $field);
153 153
 		return $this;
154 154
 	}
155 155
 
156
-	public function setValueFunction($index,$callback){
156
+	public function setValueFunction($index, $callback) {
157 157
 		$this->_instanceViewer->setValueFunction($index, $callback);
158 158
 		return $this;
159 159
 	}
160 160
 
161
-	public function setIdentifierFunction($callback){
161
+	public function setIdentifierFunction($callback) {
162 162
 		$this->_instanceViewer->setIdentifierFunction($callback);
163 163
 		return $this;
164 164
 	}
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 	/**
167 167
 	 * @return \Ajax\semantic\html\collections\menus\HtmlMenu
168 168
 	 */
169
-	public function getToolbar(){
170
-		if(isset($this->_toolbar)===false){
169
+	public function getToolbar() {
170
+		if (isset($this->_toolbar)===false) {
171 171
 			$this->_toolbar=new HtmlMenu("toolbar-".$this->identifier);
172 172
 		}
173 173
 		return $this->_toolbar;
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 	 * @param callable $callback function to call on $element
180 180
 	 * @return \Ajax\common\html\HtmlDoubleElement
181 181
 	 */
182
-	public function addInToolbar($element,$callback=NULL){
182
+	public function addInToolbar($element, $callback=NULL) {
183 183
 		$tb=$this->getToolbar();
184
-		if(isset($callback)){
185
-			if(\is_callable($callback)){
184
+		if (isset($callback)) {
185
+			if (\is_callable($callback)) {
186 186
 				$callback($element);
187 187
 			}
188 188
 		}
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 	 * @param callable $callback function($element)
196 196
 	 * @return \Ajax\common\html\HtmlDoubleElement
197 197
 	 */
198
-	public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){
199
-		$result=$this->addInToolbar($caption,$callback);
200
-		if(isset($icon))
198
+	public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) {
199
+		$result=$this->addInToolbar($caption, $callback);
200
+		if (isset($icon))
201 201
 			$result->addIcon($icon);
202 202
 		return $result;
203 203
 	}
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
 	 * @param callable $callback function($element)
208 208
 	 * @return \Ajax\common\Widget
209 209
 	 */
210
-	public function addItemsInToolbar(array $items,$callback=NULL){
211
-		if(JArray::isAssociative($items)){
212
-			foreach ($items as $icon=>$item){
213
-				$this->addItemInToolbar($item,$icon,$callback);
210
+	public function addItemsInToolbar(array $items, $callback=NULL) {
211
+		if (JArray::isAssociative($items)) {
212
+			foreach ($items as $icon=>$item) {
213
+				$this->addItemInToolbar($item, $icon, $callback);
214 214
 			}
215
-		}else{
216
-			foreach ($items as $item){
217
-				$this->addItemInToolbar($item,null,$callback);
215
+		} else {
216
+			foreach ($items as $item) {
217
+				$this->addItemInToolbar($item, null, $callback);
218 218
 			}
219 219
 		}
220 220
 		return $this;
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
 	 * @param callable $callback function($element)
227 227
 	 * @return \Ajax\common\html\HtmlDoubleElement
228 228
 	 */
229
-	public function addDropdownInToolbar($value,$items,$callback=NULL){
229
+	public function addDropdownInToolbar($value, $items, $callback=NULL) {
230 230
 		$dd=$value;
231 231
 		if (\is_string($value)) {
232
-			$dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items);
232
+			$dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items);
233 233
 		}
234
-		return $this->addInToolbar($dd,$callback);
234
+		return $this->addInToolbar($dd, $callback);
235 235
 	}
236 236
 
237 237
 	/**
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 	 * @param callable $callback function($element)
241 241
 	 * @return \Ajax\common\html\HtmlDoubleElement
242 242
 	 */
243
-	public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){
244
-		$bt=new HtmlButton("bt-".$caption,$caption,$cssStyle);
245
-		return $this->addInToolbar($bt,$callback);
243
+	public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) {
244
+		$bt=new HtmlButton("bt-".$caption, $caption, $cssStyle);
245
+		return $this->addInToolbar($bt, $callback);
246 246
 	}
247 247
 
248 248
 	/**
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 	 * @param callable $callback function($element)
252 252
 	 * @return \Ajax\common\html\HtmlDoubleElement
253 253
 	 */
254
-	public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){
255
-		$bts=new HtmlButtonGroups("",$captions,$asIcon);
256
-		return $this->addInToolbar($bts,$callback);
254
+	public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) {
255
+		$bts=new HtmlButtonGroups("", $captions, $asIcon);
256
+		return $this->addInToolbar($bts, $callback);
257 257
 	}
258 258
 
259 259
 	/**
@@ -263,15 +263,15 @@  discard block
 block discarded – undo
263 263
 	 * @param boolean $labeled
264 264
 	 * @return \Ajax\common\html\HtmlDoubleElement
265 265
 	 */
266
-	public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){
267
-		$bt=new HtmlButton("",$caption);
268
-		$bt->addIcon($icon,$before,$labeled);
266
+	public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) {
267
+		$bt=new HtmlButton("", $caption);
268
+		$bt->addIcon($icon, $before, $labeled);
269 269
 		return $this->addInToolbar($bt);
270 270
 	}
271 271
 
272
-	public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){
273
-		$button=new HtmlButton($identifier,$value,$cssStyle);
274
-		$this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters);
272
+	public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) {
273
+		$button=new HtmlButton($identifier, $value, $cssStyle);
274
+		$this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters);
275 275
 		return $this->addInToolbar($button);
276 276
 	}
277 277
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	 * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model
302 302
 	 * @return \Ajax\common\Widget
303 303
 	 */
304
-	public function setDefaultValueFunction($defaultValueFunction){
304
+	public function setDefaultValueFunction($defaultValueFunction) {
305 305
 		$this->_instanceViewer->setDefaultValueFunction($defaultValueFunction);
306 306
 		return $this;
307 307
 	}
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	 * @param string|boolean $disable
311 311
 	 * @return string
312 312
 	 */
313
-	public function jsDisabled($disable=true){
313
+	public function jsDisabled($disable=true) {
314 314
 		return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");";
315 315
 	}
316 316
 
@@ -319,12 +319,12 @@  discard block
 block discarded – undo
319 319
 	 * @param callable $callback function($element)
320 320
 	 * @return \Ajax\common\html\HtmlDoubleElement
321 321
 	 */
322
-	public function addEditButtonInToolbar($caption,$callback=NULL){
323
-		$bt=new HtmlButton($this->identifier."-editBtn",$caption);
322
+	public function addEditButtonInToolbar($caption, $callback=NULL) {
323
+		$bt=new HtmlButton($this->identifier."-editBtn", $caption);
324 324
 		$bt->setToggle();
325 325
 		$bt->setActive($this->_edition);
326 326
 		$bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')")));
327
-		return $this->addInToolbar($bt,$callback);
327
+		return $this->addInToolbar($bt, $callback);
328 328
 	}
329 329
 
330 330
 	public function setToolbar(HtmlMenu $_toolbar) {
@@ -338,35 +338,35 @@  discard block
 block discarded – undo
338 338
 	}
339 339
 
340 340
 	public function getForm() {
341
-		if(!isset($this->_form)){
341
+		if (!isset($this->_form)) {
342 342
 			$this->_form=new HtmlForm("frm-".$this->identifier);
343 343
 			$this->setEdition(true);
344 344
 		}
345 345
 		return $this->_form;
346 346
 	}
347 347
 
348
-	public function run(JsUtils $js){
348
+	public function run(JsUtils $js) {
349 349
 		$result=parent::run($js);
350
-		if(isset($this->_form)){
350
+		if (isset($this->_form)) {
351 351
 			$result=$this->runForm($js);
352 352
 		}
353 353
 		return $result;
354 354
 	}
355 355
 
356
-	protected function runForm(JsUtils $js){
356
+	protected function runForm(JsUtils $js) {
357 357
 		$fields=$this->getContentInstances(HtmlFormField::class);
358
-		foreach ($fields as $field){
358
+		foreach ($fields as $field) {
359 359
 			$this->_form->addField($field);
360 360
 		}
361 361
 		return $this->_form->run($js);
362 362
 	}
363 363
 
364
-	protected function _compileForm(){
365
-		if(isset($this->_form)){
364
+	protected function _compileForm() {
365
+		if (isset($this->_form)) {
366 366
 			$noValidate="";
367
-			if(\sizeof($this->_form->getValidationParams())>0)
367
+			if (\sizeof($this->_form->getValidationParams())>0)
368 368
 				$noValidate="novalidate";
369
-			$this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>");
369
+			$this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>");
370 370
 		}
371 371
 	}
372 372
 
Please login to merge, or discard this patch.
Ajax/common/html/HtmlSingleElement.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	}
14 14
 
15 15
 	public function setClass($classNames) {
16
-		if(\is_array($classNames)){
16
+		if (\is_array($classNames)) {
17 17
 			$classNames=implode(" ", $classNames);
18 18
 		}
19 19
 		$this->setProperty("class", $classNames);
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	}
22 22
 
23 23
 	public function addClass($classNames) {
24
-		if(\is_array($classNames)){
24
+		if (\is_array($classNames)) {
25 25
 			$classNames=implode(" ", $classNames);
26 26
 		}
27 27
 		$this->addToProperty("class", $classNames);
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function fromArray($array) {
54 54
 		$array=parent::fromArray($array);
55
-		foreach ( $array as $key => $value ) {
55
+		foreach ($array as $key => $value) {
56 56
 			$this->setProperty($key, $value);
57 57
 		}
58 58
 		return $array;
Please login to merge, or discard this patch.