Passed
Push — master ( be8276...dfdbfa )
by Jean-Christophe
02:11
created
Ajax/semantic/components/Dropdown.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 	 * @param string $action one of "select","auto","activate","combo","nothing","hide"
17 17
 	 * @return \Ajax\semantic\components\Dropdown
18 18
 	 */
19
-	public function setAction($action){
20
-		return $this->setParamCtrl("action", $action,array("select","auto","activate","combo","nothing","hide"));
19
+	public function setAction($action) {
20
+		return $this->setParamCtrl("action", $action, array("select", "auto", "activate", "combo", "nothing", "hide"));
21 21
 	}
22 22
 
23 23
 	/**
@@ -25,23 +25,23 @@  discard block
 block discarded – undo
25 25
 	 * @param string $event Event used to trigger dropdown (Hover, Click, Custom Event)
26 26
 	 * @return \Ajax\semantic\components\Dropdown
27 27
 	 */
28
-	public function setOn($event){
28
+	public function setOn($event) {
29 29
 		return $this->setParam("on", $event);
30 30
 	}
31 31
 
32
-	public function setFullTextSearch($value){
32
+	public function setFullTextSearch($value) {
33 33
 		return $this->setParam("fullTextSearch", $value);
34 34
 	}
35 35
 
36
-	public function setShowOnFocus($value){
36
+	public function setShowOnFocus($value) {
37 37
 		return $this->setParam("showOnFocus", $value);
38 38
 	}
39 39
 	
40
-	public function setAllowAdditions($value){
40
+	public function setAllowAdditions($value) {
41 41
 		return $this->setParam("allowAdditions", $value);
42 42
 	}
43 43
 	
44
-	public function setClearable($value){
44
+	public function setClearable($value) {
45 45
 		return $this->setParam("clearable", $value);
46 46
 	}
47 47
 }
Please login to merge, or discard this patch.
Ajax/semantic/html/modules/HtmlDropdown.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -14,29 +14,29 @@  discard block
 block discarded – undo
14 14
 use Ajax\common\html\HtmlDoubleElement;
15 15
 
16 16
 class HtmlDropdown extends HtmlSemDoubleElement {
17
-	use FieldTrait,LabeledIconTrait {
17
+	use FieldTrait, LabeledIconTrait {
18 18
 		addIcon as addIconP;
19 19
 	}
20 20
 	protected $mClass="menu";
21 21
 	protected $mTagName="div";
22
-	protected $items=array ();
23
-	protected $_params=array("action"=>"nothing","on"=>"hover","showOnFocus"=>false);
22
+	protected $items=array();
23
+	protected $_params=array("action"=>"nothing", "on"=>"hover", "showOnFocus"=>false);
24 24
 	protected $input;
25 25
 	protected $value;
26 26
 	protected $_associative;
27 27
 	protected $_multiple;
28 28
 
29
-	public function __construct($identifier, $value="", $items=array(),$associative=true) {
29
+	public function __construct($identifier, $value="", $items=array(), $associative=true) {
30 30
 		parent::__construct($identifier, "div");
31 31
 		$this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php';
32 32
 		$this->setProperty("class", "ui dropdown");
33 33
 		$this->_multiple=false;
34 34
 		$content=[];
35
-		if(isset($value)){
36
-			if($value instanceof HtmlSemDoubleElement){
35
+		if (isset($value)) {
36
+			if ($value instanceof HtmlSemDoubleElement) {
37 37
 				$text=$value;
38
-			}else{
39
-				$text=new HtmlSemDoubleElement("text-".$this->identifier,"div");
38
+			} else {
39
+				$text=new HtmlSemDoubleElement("text-".$this->identifier, "div");
40 40
 				$text->setClass("text");
41 41
 				$this->setValue($value);
42 42
 			}
@@ -49,33 +49,33 @@  discard block
 block discarded – undo
49 49
 		$this->addItems($items);
50 50
 	}
51 51
 
52
-	public function getField(){
52
+	public function getField() {
53 53
 		return $this->input;
54 54
 	}
55 55
 
56
-	public function getDataField(){
56
+	public function getDataField() {
57 57
 		return $this->input;
58 58
 	}
59 59
 
60
-	public function addItem($item,$value=NULL,$image=NULL,$description=NULL){
61
-		$itemO=$this->beforeAddItem($item,$value,$image,$description);
60
+	public function addItem($item, $value=NULL, $image=NULL, $description=NULL) {
61
+		$itemO=$this->beforeAddItem($item, $value, $image, $description);
62 62
 		$this->items[]=$itemO;
63 63
 		return $itemO;
64 64
 	}
65 65
 
66
-	public function addIcon($icon,$before=true,$labeled=false){
66
+	public function addIcon($icon, $before=true, $labeled=false) {
67 67
 		$this->removeArrow();
68
-		$this->addIconP($icon,$before,$labeled);
68
+		$this->addIconP($icon, $before, $labeled);
69 69
 		$elm=$this->getElementById("text-".$this->identifier, $this->content);
70
-		if(isset($elm)){
70
+		if (isset($elm)) {
71 71
 			$elm->setWrapAfter("");
72 72
 		}
73 73
 		return $this;
74 74
 	}
75 75
 
76
-	public function addIcons($icons){
76
+	public function addIcons($icons) {
77 77
 		$count=$this->count();
78
-		for ($i=0;$i<\sizeof($icons) && $i<$count;$i++){
78
+		for ($i=0; $i<\sizeof($icons) && $i<$count; $i++) {
79 79
 			$this->getItem($i)->addIcon($icons[$i]);
80 80
 		}
81 81
 	}
@@ -86,33 +86,33 @@  discard block
 block discarded – undo
86 86
 	 * @param int $position
87 87
 	 * @return HtmlDropdownItem
88 88
 	 */
89
-	public function insertItem($item,$position=0){
89
+	public function insertItem($item, $position=0) {
90 90
 		$itemO=$this->beforeAddItem($item);
91
-		 $start = array_slice($this->items, 0, $position);
92
-		 $end = array_slice($this->items, $position);
93
-		 $start[] = $item;
91
+		 $start=array_slice($this->items, 0, $position);
92
+		 $end=array_slice($this->items, $position);
93
+		 $start[]=$item;
94 94
 		 $this->items=array_merge($start, $end);
95 95
 		 return $itemO;
96 96
 	}
97 97
 
98
-	protected function removeArrow(){
99
-		if(\sizeof($this->content)>1){
98
+	protected function removeArrow() {
99
+		if (\sizeof($this->content)>1) {
100 100
 			unset($this->content["arrow"]);
101 101
 			$this->content=\array_values($this->content);
102 102
 		}
103 103
 	}
104 104
 
105
-	protected function beforeAddItem($item,$value=NULL,$image=NULL,$description=NULL){
105
+	protected function beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL) {
106 106
 		$itemO=$item;
107
-		if(\is_array($item)){
107
+		if (\is_array($item)) {
108 108
 			$description=JArray::getValue($item, "description", 3);
109 109
 			$value=JArray::getValue($item, "value", 1);
110 110
 			$image=JArray::getValue($item, "image", 2);
111 111
 			$item=JArray::getValue($item, "item", 0);
112 112
 		}
113
-		if(!$item instanceof HtmlDropdownItem){
114
-			$itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description);
115
-		}elseif($itemO instanceof HtmlDropdownItem){
113
+		if (!$item instanceof HtmlDropdownItem) {
114
+			$itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image, $description);
115
+		}elseif ($itemO instanceof HtmlDropdownItem) {
116 116
 			$this->addToProperty("class", "vertical");
117 117
 		}
118 118
 		return $itemO;
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 		$this->addItem($function($object));
126 126
 	}
127 127
 
128
-	public function addInput($name){
129
-		if(!isset($name))
128
+	public function addInput($name) {
129
+		if (!isset($name))
130 130
 			$name="input-".$this->identifier;
131 131
 		$this->setAction("activate");
132
-		$this->input=new HtmlInput($name,"hidden");
132
+		$this->input=new HtmlInput($name, "hidden");
133 133
 		$this->input->setIdentifier("input-".$this->identifier);
134 134
 		return $this->input;
135 135
 	}
@@ -140,15 +140,15 @@  discard block
 block discarded – undo
140 140
 	 * @param string $icon
141 141
 	 * @return HtmlDropdownItem
142 142
 	 */
143
-	public function addSearchInputItem($placeHolder=NULL,$icon=NULL){
144
-		return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon));
143
+	public function addSearchInputItem($placeHolder=NULL, $icon=NULL) {
144
+		return $this->addItem(HtmlDropdownItem::searchInput($placeHolder, $icon));
145 145
 	}
146 146
 
147 147
 	/**
148 148
 	 * Adds a divider item
149 149
 	 * @return HtmlDropdownItem
150 150
 	 */
151
-	public function addDividerItem(){
151
+	public function addDividerItem() {
152 152
 		return $this->addItem(HtmlDropdownItem::divider());
153 153
 	}
154 154
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @param string $icon
159 159
 	 * @return HtmlDropdownItem
160 160
 	 */
161
-	public function addHeaderItem($caption=NULL,$icon=NULL){
162
-		return $this->addItem(HtmlDropdownItem::header($caption,$icon));
161
+	public function addHeaderItem($caption=NULL, $icon=NULL) {
162
+		return $this->addItem(HtmlDropdownItem::header($caption, $icon));
163 163
 	}
164 164
 
165 165
 	/**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * @param string $color
169 169
 	 * @return HtmlDropdownItem
170 170
 	 */
171
-	public function addCircularLabelItem($caption,$color){
171
+	public function addCircularLabelItem($caption, $color) {
172 172
 		return $this->addItem(HtmlDropdownItem::circular($caption, $color));
173 173
 	}
174 174
 
@@ -177,17 +177,17 @@  discard block
 block discarded – undo
177 177
 	 * @param string $image
178 178
 	 * @return \Ajax\semantic\html\content\HtmlDropdownItem
179 179
 	 */
180
-	public function addMiniAvatarImageItem($caption,$image){
180
+	public function addMiniAvatarImageItem($caption, $image) {
181 181
 		return $this->addItem(HtmlDropdownItem::avatar($caption, $image));
182 182
 	}
183 183
 
184
-	public function addItems($items){
185
-		if(\is_array($items) && $this->_associative){
186
-			foreach ($items as $k=>$v){
184
+	public function addItems($items) {
185
+		if (\is_array($items) && $this->_associative) {
186
+			foreach ($items as $k=>$v) {
187 187
 				$this->addItem($v)->setData($k);
188 188
 			}
189
-		}else{
190
-			foreach ($items as $item){
189
+		} else {
190
+			foreach ($items as $item) {
191 191
 				$this->addItem($item);
192 192
 			}
193 193
 		}
@@ -199,99 +199,99 @@  discard block
 block discarded – undo
199 199
 	 * @param array|mixed $values
200 200
 	 * @return $this
201 201
 	 */
202
-	public function setPropertyValues($property,$values){
202
+	public function setPropertyValues($property, $values) {
203 203
 		$i=0;
204
-		if(\is_array($values)===false){
205
-			$values=\array_fill(0, $this->count(),$values);
204
+		if (\is_array($values)===false) {
205
+			$values=\array_fill(0, $this->count(), $values);
206 206
 		}
207
-		foreach ($values as $value){
207
+		foreach ($values as $value) {
208 208
 			$c=$this->items[$i++];
209
-			if(isset($c)){
210
-				$c->setProperty($property,$value);
209
+			if (isset($c)) {
210
+				$c->setProperty($property, $value);
211 211
 			}
212
-			else{
212
+			else {
213 213
 				return $this;
214 214
 			}
215 215
 		}
216 216
 		return $this;
217 217
 	}
218 218
 
219
-	public function each($callBack){
220
-		foreach ($this->items as $index=>$value){
221
-			$callBack($index,$value);
219
+	public function each($callBack) {
220
+		foreach ($this->items as $index=>$value) {
221
+			$callBack($index, $value);
222 222
 		}
223 223
 		return $this;
224 224
 	}
225 225
 
226
-	public function getItem($index){
226
+	public function getItem($index) {
227 227
 		return $this->items[$index];
228 228
 	}
229 229
 
230 230
 	/**
231 231
 	 * @return int
232 232
 	 */
233
-	public function count(){
233
+	public function count() {
234 234
 		return \sizeof($this->items);
235 235
 	}
236 236
 	/**
237 237
 	 * @param boolean $dropdown
238 238
 	 */
239
-	public function asDropdown($dropdown){
240
-		if($dropdown===false){
239
+	public function asDropdown($dropdown) {
240
+		if ($dropdown===false) {
241 241
 			$this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php';
242 242
 			$dropdown="menu";
243
-		}else{
243
+		} else {
244 244
 			$dropdown="dropdown";
245 245
 			$this->mClass="menu";
246 246
 		}
247
-		return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown"));
247
+		return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown"));
248 248
 	}
249 249
 
250
-	public function setVertical(){
251
-		return $this->addToPropertyCtrl("class", "vertical",array("vertical"));
250
+	public function setVertical() {
251
+		return $this->addToPropertyCtrl("class", "vertical", array("vertical"));
252 252
 	}
253 253
 
254
-	public function setInline(){
255
-		return $this->addToPropertyCtrl("class", "inline",["inline"]);
254
+	public function setInline() {
255
+		return $this->addToPropertyCtrl("class", "inline", ["inline"]);
256 256
 	}
257 257
 
258
-	public function setSimple(){
259
-		return $this->addToPropertyCtrl("class", "simple",array("simple"));
258
+	public function setSimple() {
259
+		return $this->addToPropertyCtrl("class", "simple", array("simple"));
260 260
 	}
261 261
 
262
-	public function asButton($floating=false){
262
+	public function asButton($floating=false) {
263 263
 		$this->removeArrow();
264
-		if($floating)
264
+		if ($floating)
265 265
 			$this->addToProperty("class", "floating");
266 266
 		$this->removePropertyValue("class", "selection");
267 267
 		return $this->addToProperty("class", "button");
268 268
 	}
269 269
 
270
-	public function asSelect($name=NULL,$multiple=false,$selection=true){
270
+	public function asSelect($name=NULL, $multiple=false, $selection=true) {
271 271
 		$this->_multiple=$multiple;
272
-		if(isset($name))
272
+		if (isset($name))
273 273
 			$this->addInput($name);
274
-		if($multiple){
274
+		if ($multiple) {
275 275
 			$this->addToProperty("class", "multiple");
276 276
 		}
277
-		if ($selection){
278
-			if($this->propertyContains("class", "button")===false)
279
-				$this->addToPropertyCtrl("class", "selection",array("selection"));
277
+		if ($selection) {
278
+			if ($this->propertyContains("class", "button")===false)
279
+				$this->addToPropertyCtrl("class", "selection", array("selection"));
280 280
 		}
281 281
 		return $this;
282 282
 	}
283 283
 
284
-	public function asSearch($name=NULL,$multiple=false,$selection=true){
285
-		$this->asSelect($name,$multiple,$selection);
284
+	public function asSearch($name=NULL, $multiple=false, $selection=true) {
285
+		$this->asSelect($name, $multiple, $selection);
286 286
 		return $this->addToProperty("class", "search");
287 287
 	}
288 288
 
289
-	public function setSelect($name=NULL,$multiple=false){
289
+	public function setSelect($name=NULL, $multiple=false) {
290 290
 		$this->_template='<%tagName% id="%identifier%" %properties%>%items%</%tagName%>';
291
-		if(!isset($name))
291
+		if (!isset($name))
292 292
 			$name="select-".$this->identifier;
293 293
 		$this->input=null;
294
-		if($multiple){
294
+		if ($multiple) {
295 295
 			$this->setProperty("multiple", true);
296 296
 			$this->addToProperty("class", "multiple");
297 297
 		}
@@ -299,42 +299,42 @@  discard block
 block discarded – undo
299 299
 		$this->tagName="select";
300 300
 		$this->setProperty("name", $name);
301 301
 		$this->content=null;
302
-		foreach ($this->items as $item){
302
+		foreach ($this->items as $item) {
303 303
 			$item->asOption();
304 304
 		}
305 305
 		return $this;
306 306
 	}
307 307
 
308
-	public function asSubmenu($pointing=NULL){
308
+	public function asSubmenu($pointing=NULL) {
309 309
 		$this->setClass("ui dropdown link item");
310
-		if(isset($pointing)){
310
+		if (isset($pointing)) {
311 311
 			$this->setPointing($pointing);
312 312
 		}
313 313
 		return $this;
314 314
 	}
315 315
 
316
-	public function setPointing($value=Direction::NONE){
317
-		return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing"));
316
+	public function setPointing($value=Direction::NONE) {
317
+		return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing"));
318 318
 	}
319 319
 
320
-	public function setValue($value){
320
+	public function setValue($value) {
321 321
 		$this->value=$value;
322 322
 		return $this;
323 323
 	}
324 324
 	
325
-	public function setDefaultText($text){
326
-		$this->content["text"]=new HtmlSemDoubleElement("","div","default text",$text);
325
+	public function setDefaultText($text) {
326
+		$this->content["text"]=new HtmlSemDoubleElement("", "div", "default text", $text);
327 327
 	}
328 328
 	
329
-	private function applyValue(){
329
+	private function applyValue() {
330 330
 		$value=$this->value;
331
-		if(isset($this->input) && isset($value)){
331
+		if (isset($this->input) && isset($value)) {
332 332
 			$this->input->setProperty("value", $value);
333
-		}else{
333
+		} else {
334 334
 			$this->setProperty("value", $value);
335 335
 		}
336 336
 			$textElement=$this->getElementById("text-".$this->identifier, $this->content);
337
-			if(isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple)
337
+			if (isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple)
338 338
 				$textElement->setContent($value);
339 339
 		return $this;
340 340
 	}
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
 	 * @see BaseHtml::run()
345 345
 	 */
346 346
 	public function run(JsUtils $js) {
347
-		if($this->propertyContains("class", "simple")===false){
348
-			if(isset($this->_bsComponent)===false){
349
-				$this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params);
347
+		if ($this->propertyContains("class", "simple")===false) {
348
+			if (isset($this->_bsComponent)===false) {
349
+				$this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params);
350 350
 				$this->_bsComponent->setItemSelector(".item");
351 351
 			}
352 352
 			$this->addEventsOnRun($js);
@@ -354,50 +354,50 @@  discard block
 block discarded – undo
354 354
 		}
355 355
 	}
356 356
 
357
-	public function setCompact(){
357
+	public function setCompact() {
358 358
 		return $this->addToPropertyCtrl("class", "compact", array("compact"));
359 359
 	}
360 360
 
361
-	public function setAction($action){
361
+	public function setAction($action) {
362 362
 		$this->_params["action"]=$action;
363 363
 	}
364 364
 
365
-	public function setOn($on){
365
+	public function setOn($on) {
366 366
 		$this->_params["on"]=$on;
367 367
 	}
368 368
 
369
-	public function setShowOnFocus($value){
369
+	public function setShowOnFocus($value) {
370 370
 		$this->_params["showOnFocus"]=$value;
371 371
 	}
372 372
 	
373
-	public function setAllowAdditions($value){
373
+	public function setAllowAdditions($value) {
374 374
 		$this->_params["allowAdditions"]=$value;
375 375
 	}
376 376
 
377
-	public function setFullTextSearch($value){
377
+	public function setFullTextSearch($value) {
378 378
 		$this->_params["fullTextSearch"]=$value;
379 379
 	}
380 380
 
381 381
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
382 382
 		$this->applyValue();
383
-		return parent::compile($js,$view);
383
+		return parent::compile($js, $view);
384 384
 	}
385 385
 
386 386
 	public function getInput() {
387 387
 		return $this->input;
388 388
 	}
389 389
 
390
-	public function setIcon($icon="dropdown"){
390
+	public function setIcon($icon="dropdown") {
391 391
 		$this->content["arrow"]=new HtmlIcon($this->identifier."-icon", $icon);
392 392
 		return $this;
393 393
 	}
394 394
 
395
-	public function jsAddItem($caption){
395
+	public function jsAddItem($caption) {
396 396
 		$js="var first=$('#{$this->identifier} .item').first();if(first!=undefined){var new =first.clone();first.parent().append(new);first.html('{$caption}};')";
397 397
 		return $js;
398 398
 	}
399 399
 	
400
-	public function setClearable($value){
400
+	public function setClearable($value) {
401 401
 		$this->_params["clearable"]=$value;
402 402
 	}
403 403
 }
Please login to merge, or discard this patch.