Passed
Push — master ( 727fe8...731c7d )
by Jean-Christophe
02:56
created
Ajax/semantic/html/collections/menus/HtmlMenu.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 	 * @return HtmlMenu
42 42
 	 */
43 43
 	public function setType($type="") {
44
-		return $this->addToPropertyCtrl("class", $type, array ("","item","text" ));
44
+		return $this->addToPropertyCtrl("class", $type, array("", "item", "text"));
45 45
 	}
46 46
 
47 47
 	public function setActiveItem($index) {
48 48
 		$item=$this->getItem($index);
49
-		if ($item !== null) {
49
+		if ($item!==null) {
50 50
 			$item->addToProperty("class", "active");
51 51
 		}
52 52
 		return $this;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 	private function getItemToInsert($item) {
56 56
 		if ($item instanceof HtmlInput || $item instanceof HtmlImg || $item instanceof HtmlIcon || $item instanceof HtmlButtonGroups || $item instanceof HtmlButton || $item instanceof HtmlLabel) {
57
-			$itemO=new HtmlMenuItem("item-" . $this->identifier . "-" . \sizeof($this->content) , $item);
57
+			$itemO=new HtmlMenuItem("item-".$this->identifier."-".\sizeof($this->content), $item);
58 58
 			$itemO->addClass("no-active");
59 59
 			$item=$itemO;
60 60
 		}
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
 	private function afterInsert($item) {
65 65
 		if (!$item instanceof HtmlMenu && $item->propertyContains("class", "header")===false)
66
-			$item->addToPropertyCtrl("class", "item", array ("item" ));
66
+			$item->addToPropertyCtrl("class", "item", array("item"));
67 67
 		else {
68 68
 			$this->setSecondary();
69 69
 		}
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	public function addItem($item) {
80 80
 		$number=$item;
81 81
 		$item=parent::addItem($this->getItemToInsert($item));
82
-		if(\is_int($number))
82
+		if (\is_int($number))
83 83
 			$item->setProperty("data-page", $number);
84 84
 		return $this->afterInsert($item);
85 85
 	}
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
 
98 98
 	public function generateMenuAsItem($menu, $header=null) {
99 99
 		$count=$this->count();
100
-		$item=new HtmlSemDoubleElement("item-" . $this->identifier . "-" . $count, "div");
100
+		$item=new HtmlSemDoubleElement("item-".$this->identifier."-".$count, "div");
101 101
 		if (isset($header)) {
102
-			$headerItem=new HtmlSemDoubleElement("item-header-" . $this->identifier . "-" . $count, "div", "header");
102
+			$headerItem=new HtmlSemDoubleElement("item-header-".$this->identifier."-".$count, "div", "header");
103 103
 			$headerItem->setContent($header);
104 104
 			$item->addContent($headerItem);
105 105
 			$this->_itemHeader=$headerItem;
106 106
 		}
107
-		if(\is_array($menu)){
108
-			$menu=new HtmlMenu("menu-" . $this->identifier . "-" . $count,$menu);
107
+		if (\is_array($menu)) {
108
+			$menu=new HtmlMenu("menu-".$this->identifier."-".$count, $menu);
109 109
 		}
110 110
 		$menu->setClass("menu");
111 111
 		$item->addContent($menu);
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		$value=new HtmlSemDoubleElement($identifier, "a", "browse item", $value);
121 121
 		$value->addContent(new HtmlIcon("", "dropdown"));
122 122
 		$value=$this->addItem($value);
123
-		$popup=new HtmlPopup($value, "popup-" . $this->identifier . "-" . $this->count(), $content);
123
+		$popup=new HtmlPopup($value, "popup-".$this->identifier."-".$this->count(), $content);
124 124
 		$popup->setFlowing()->setPosition("bottom left")->setOn("click");
125 125
 		$this->wrap("", $popup);
126 126
 		return $popup;
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	public function addDropdownAsItem($value, $items=NULL) {
130 130
 		$dd=$value;
131 131
 		if (\is_string($value)) {
132
-			$dd=new HtmlDropdown("dropdown-" . $this->identifier . "-" . $this->count(), $value, $items);
132
+			$dd=new HtmlDropdown("dropdown-".$this->identifier."-".$this->count(), $value, $items);
133 133
 		}
134 134
 		$this->addItem($dd);
135 135
 		return $dd;
@@ -142,14 +142,14 @@  discard block
 block discarded – undo
142 142
 	 * @see HtmlCollection::createItem()
143 143
 	 */
144 144
 	protected function createItem($value) {
145
-		$itemO=new HtmlMenuItem($this->identifier."-item-" . \sizeof($this->content),"");
145
+		$itemO=new HtmlMenuItem($this->identifier."-item-".\sizeof($this->content), "");
146 146
 		$itemO->setTagName("a");
147 147
 		$itemO->setContent($value);
148 148
 		return $itemO;
149 149
 	}
150 150
 
151 151
 	public function setSecondary($value=true) {
152
-		if($value)
152
+		if ($value)
153 153
 			$this->addToProperty("class", "secondary");
154 154
 		else
155 155
 			$this->removePropertyValue("class", "secondary");
@@ -157,28 +157,28 @@  discard block
 block discarded – undo
157 157
 	}
158 158
 
159 159
 	public function setVertical() {
160
-		return $this->addToPropertyCtrl("class", "vertical", array ("vertical" ));
160
+		return $this->addToPropertyCtrl("class", "vertical", array("vertical"));
161 161
 	}
162 162
 
163 163
 	public function setPosition($value="right") {
164
-		return $this->addToPropertyCtrl("class", $value, array ("right","left" ));
164
+		return $this->addToPropertyCtrl("class", $value, array("right", "left"));
165 165
 	}
166 166
 
167 167
 	public function setPointing($value=Direction::NONE) {
168
-		return $this->addToPropertyCtrl("class", $value . " pointing", Direction::getConstantValues("pointing"));
168
+		return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing"));
169 169
 	}
170 170
 
171 171
 	public function asTab($vertical=false) {
172
-		$this->apply(function (HtmlDoubleElement &$item) {
172
+		$this->apply(function(HtmlDoubleElement &$item) {
173 173
 			$item->setTagName("a");
174 174
 		});
175
-		if ($vertical === true)
175
+		if ($vertical===true)
176 176
 			$this->setVertical();
177 177
 		return $this->addToProperty("class", "tabular");
178 178
 	}
179 179
 
180 180
 	public function asPagination() {
181
-		$this->apply(function (HtmlDoubleElement &$item) {
181
+		$this->apply(function(HtmlDoubleElement &$item) {
182 182
 			$item->setTagName("a");
183 183
 		});
184 184
 		return $this->addToProperty("class", "pagination");
@@ -215,10 +215,10 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	public function setWidth($width) {
217 217
 		if (\is_int($width)) {
218
-			$width=Wide::getConstants()["W" . $width];
218
+			$width=Wide::getConstants()["W".$width];
219 219
 		}
220 220
 		$this->addToPropertyCtrl("class", $width, Wide::getConstants());
221
-		return $this->addToPropertyCtrl("class", "item", array ("item" ));
221
+		return $this->addToPropertyCtrl("class", "item", array("item"));
222 222
 	}
223 223
 
224 224
 	public function addImage($identifier, $src="", $alt="") {
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
 		return $this->_itemHeader;
234 234
 	}
235 235
 
236
-	public function setHasContainer(){
237
-		return $this->wrapContent("<div class='ui container'>","</div>");
236
+	public function setHasContainer() {
237
+		return $this->wrapContent("<div class='ui container'>", "</div>");
238 238
 	}
239 239
 
240
-	public function run(JsUtils $js){
241
-		if($this->identifier!=="" && !isset($this->_bsComponent))
242
-			$this->onClick('if(!$(this).hasClass("dropdown")&&!$(this).hasClass("no-active")){$(this).addClass("active").siblings().removeClass("active");}',false,false);
243
-		$result= parent::run($js);
240
+	public function run(JsUtils $js) {
241
+		if ($this->identifier!=="" && !isset($this->_bsComponent))
242
+			$this->onClick('if(!$(this).hasClass("dropdown")&&!$(this).hasClass("no-active")){$(this).addClass("active").siblings().removeClass("active");}', false, false);
243
+		$result=parent::run($js);
244 244
 		return $result->setItemSelector(".item");
245 245
 	}
246 246
 }
Please login to merge, or discard this patch.
Ajax/semantic/html/elements/html5/HtmlDatalist.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -5,20 +5,20 @@
 block discarded – undo
5 5
 use Ajax\common\html\HtmlDoubleElement;
6 6
 use Ajax\common\html\HtmlCollection;
7 7
 
8
-class HtmlDatalist extends HtmlCollection{
8
+class HtmlDatalist extends HtmlCollection {
9 9
 	
10
-	public function __construct($identifier){
11
-		parent::__construct($identifier,"datalist");
10
+	public function __construct($identifier) {
11
+		parent::__construct($identifier, "datalist");
12 12
 	}
13 13
 	
14 14
 	protected function createItem($value) {
15
-		$elm= new HtmlDoubleElement("","option");
15
+		$elm=new HtmlDoubleElement("", "option");
16 16
 		$elm->setProperty("value", $value->getContent());
17 17
 		$elm->setContent($value);
18 18
 		return $elm;
19 19
 	}
20 20
 	
21
-	protected function createCondition($value){
21
+	protected function createCondition($value) {
22 22
 		return true;
23 23
 	}
24 24
 }
Please login to merge, or discard this patch.
Ajax/semantic/html/elements/HtmlButton.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 	 * @return HtmlButton
43 43
 	 */
44 44
 	public function setValue($value) {
45
-		if(is_array($this->content)){
46
-			foreach ($this->content as $i=>$content){
47
-				if(is_string($content)){
45
+		if (is_array($this->content)) {
46
+			foreach ($this->content as $i=>$content) {
47
+				if (is_string($content)) {
48 48
 					$this->content[$i]=$value;
49 49
 					return $this;
50 50
 				}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	}
65 65
 
66 66
 	public function setFocusable($value=true) {
67
-		if ($value === true)
67
+		if ($value===true)
68 68
 			$this->setProperty("tabindex", "0");
69 69
 		else {
70 70
 			$this->removeProperty("tabindex");
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 
75 75
 	public function setAnimated($content, $animation="") {
76 76
 		$this->setTagName("div");
77
-		$this->addToProperty("class", "animated " . $animation);
78
-		$visible=new HtmlSemDoubleElement("visible-" . $this->identifier, "div");
77
+		$this->addToProperty("class", "animated ".$animation);
78
+		$visible=new HtmlSemDoubleElement("visible-".$this->identifier, "div");
79 79
 		$visible->setClass("visible content");
80 80
 		$visible->setContent($this->content);
81
-		$hidden=new HtmlSemDoubleElement("hidden-" . $this->identifier, "div");
81
+		$hidden=new HtmlSemDoubleElement("hidden-".$this->identifier, "div");
82 82
 		$hidden->setClass("hidden content");
83 83
 		$hidden->setContent($content);
84
-		$this->content=array ($visible,$hidden );
84
+		$this->content=array($visible, $hidden);
85 85
 		return $hidden;
86 86
 	}
87 87
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	public function asIcon($icon) {
94 94
 		$iconO=$icon;
95 95
 		if (\is_string($icon)) {
96
-			$iconO=new HtmlIcon("icon-" . $this->identifier, $icon);
96
+			$iconO=new HtmlIcon("icon-".$this->identifier, $icon);
97 97
 		}
98 98
 		$this->addToProperty("class", "icon");
99 99
 		$this->content=$iconO;
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
 	 * @return HtmlLabel
114 114
 	 */
115 115
 	public function addLabel($label, $before=false, $icon=NULL) {
116
-		$this->tagName="div";$prefix="";
117
-		if($before)
116
+		$this->tagName="div"; $prefix="";
117
+		if ($before)
118 118
 			$prefix="left ";
119 119
 		$this->addToProperty("class", $prefix."labeled");
120 120
 		$isIcon=(isset($this->content[0]) && $this->content[0] instanceof HtmlIcon);
121
-		$this->content=new HtmlButton("button-" . $this->identifier, $this->content);
122
-		if($isIcon){
121
+		$this->content=new HtmlButton("button-".$this->identifier, $this->content);
122
+		if ($isIcon) {
123 123
 			$this->content->addClass("icon");
124 124
 		}
125 125
 		$this->content->setTagName("div");
126
-		$label=new HtmlLabel("label-" . $this->identifier, $label, $icon,"a");
126
+		$label=new HtmlLabel("label-".$this->identifier, $label, $icon, "a");
127 127
 		$label->setBasic();
128 128
 		$this->addContent($label, $before);
129 129
 		return $label;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	public function fromArray($array) {
137 137
 		$array=parent::fromArray($array);
138
-		foreach ( $array as $key => $value ) {
138
+		foreach ($array as $key => $value) {
139 139
 			$this->setProperty($key, $value);
140 140
 		}
141 141
 		return $array;
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
 		return $this->addToProperty("class", "positive");
150 150
 	}
151 151
 
152
-	public function setColor($color){
153
-		if(\is_array($this->content)){
154
-			foreach ($this->content as $content){
155
-				if($content instanceof HtmlButton)
152
+	public function setColor($color) {
153
+		if (\is_array($this->content)) {
154
+			foreach ($this->content as $content) {
155
+				if ($content instanceof HtmlButton)
156 156
 					$content->setColor($color);
157 157
 			}
158 158
 		}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * @return HtmlButton
211 211
 	 */
212 212
 	public static function social($identifier, $social, $value=NULL) {
213
-		if ($value === NULL)
213
+		if ($value===NULL)
214 214
 			$value=\ucfirst($social);
215 215
 		$return=new HtmlButton($identifier, $value);
216 216
 		$return->addIcon($social);
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 	 * {@inheritDoc}
248 248
 	 * @see HtmlSemDoubleElement::asLink()
249 249
 	 */
250
-	public function asLink($href=NULL,$target=NULL) {
251
-		parent::asLink($href,$target);
250
+	public function asLink($href=NULL, $target=NULL) {
251
+		parent::asLink($href, $target);
252 252
 		return $this;
253 253
 	}
254 254
 
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
 	 * @param string $icon
262 262
 	 * @return HtmlButtonGroups
263 263
 	 */
264
-	public static function dropdown($identifier,$value,$items=[],$asCombo=false,$icon=null){
265
-		$result=new HtmlButtonGroups($identifier,[$value]);
266
-		$dd=$result->addDropdown($items,$asCombo);
267
-		if(isset($icon) && $dd instanceof HtmlDropdown)
264
+	public static function dropdown($identifier, $value, $items=[], $asCombo=false, $icon=null) {
265
+		$result=new HtmlButtonGroups($identifier, [$value]);
266
+		$dd=$result->addDropdown($items, $asCombo);
267
+		if (isset($icon) && $dd instanceof HtmlDropdown)
268 268
 			$dd->setIcon($icon);
269 269
 		return $result;
270 270
 	}
Please login to merge, or discard this patch.
Ajax/semantic/html/modules/HtmlDropdown.php 1 patch
Spacing   +100 added lines, -100 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,29 +49,29 @@  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
 		return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter("");
70 70
 	}
71 71
 
72
-	public function addIcons($icons){
72
+	public function addIcons($icons) {
73 73
 		$count=$this->count();
74
-		for ($i=0;$i<\sizeof($icons) && $i<$count;$i++){
74
+		for ($i=0; $i<\sizeof($icons) && $i<$count; $i++) {
75 75
 			$this->getItem($i)->addIcon($icons[$i]);
76 76
 		}
77 77
 	}
@@ -82,33 +82,33 @@  discard block
 block discarded – undo
82 82
 	 * @param int $position
83 83
 	 * @return HtmlDropdownItem
84 84
 	 */
85
-	public function insertItem($item,$position=0){
85
+	public function insertItem($item, $position=0) {
86 86
 		$itemO=$this->beforeAddItem($item);
87
-		 $start = array_slice($this->items, 0, $position);
88
-		 $end = array_slice($this->items, $position);
89
-		 $start[] = $item;
87
+		 $start=array_slice($this->items, 0, $position);
88
+		 $end=array_slice($this->items, $position);
89
+		 $start[]=$item;
90 90
 		 $this->items=array_merge($start, $end);
91 91
 		 return $itemO;
92 92
 	}
93 93
 
94
-	protected function removeArrow(){
95
-		if(\sizeof($this->content)>1){
94
+	protected function removeArrow() {
95
+		if (\sizeof($this->content)>1) {
96 96
 			unset($this->content["arrow"]);
97 97
 			$this->content=\array_values($this->content);
98 98
 		}
99 99
 	}
100 100
 
101
-	protected function beforeAddItem($item,$value=NULL,$image=NULL,$description=NULL){
101
+	protected function beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL) {
102 102
 		$itemO=$item;
103
-		if(\is_array($item)){
103
+		if (\is_array($item)) {
104 104
 			$description=JArray::getValue($item, "description", 3);
105 105
 			$value=JArray::getValue($item, "value", 1);
106 106
 			$image=JArray::getValue($item, "image", 2);
107 107
 			$item=JArray::getValue($item, "item", 0);
108 108
 		}
109
-		if(!$item instanceof HtmlDropdownItem){
110
-			$itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description);
111
-		}elseif($itemO instanceof HtmlDropdownItem){
109
+		if (!$item instanceof HtmlDropdownItem) {
110
+			$itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image, $description);
111
+		}elseif ($itemO instanceof HtmlDropdownItem) {
112 112
 			$this->addToProperty("class", "vertical");
113 113
 		}
114 114
 		return $itemO;
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
 		$this->addItem($function($object));
122 122
 	}
123 123
 
124
-	public function addInput($name){
125
-		if(!isset($name))
124
+	public function addInput($name) {
125
+		if (!isset($name))
126 126
 			$name="input-".$this->identifier;
127 127
 		$this->setAction("activate");
128
-		$this->input=new HtmlInput($name,"hidden");
128
+		$this->input=new HtmlInput($name, "hidden");
129 129
 		$this->input->setIdentifier("input-".$this->identifier);
130 130
 		return $this->input;
131 131
 	}
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
 	 * @param string $icon
137 137
 	 * @return HtmlDropdownItem
138 138
 	 */
139
-	public function addSearchInputItem($placeHolder=NULL,$icon=NULL){
140
-		return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon));
139
+	public function addSearchInputItem($placeHolder=NULL, $icon=NULL) {
140
+		return $this->addItem(HtmlDropdownItem::searchInput($placeHolder, $icon));
141 141
 	}
142 142
 
143 143
 	/**
144 144
 	 * Adds a divider item
145 145
 	 * @return HtmlDropdownItem
146 146
 	 */
147
-	public function addDividerItem(){
147
+	public function addDividerItem() {
148 148
 		return $this->addItem(HtmlDropdownItem::divider());
149 149
 	}
150 150
 
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 	 * @param string $icon
155 155
 	 * @return HtmlDropdownItem
156 156
 	 */
157
-	public function addHeaderItem($caption=NULL,$icon=NULL){
158
-		return $this->addItem(HtmlDropdownItem::header($caption,$icon));
157
+	public function addHeaderItem($caption=NULL, $icon=NULL) {
158
+		return $this->addItem(HtmlDropdownItem::header($caption, $icon));
159 159
 	}
160 160
 
161 161
 	/**
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 * @param string $color
165 165
 	 * @return HtmlDropdownItem
166 166
 	 */
167
-	public function addCircularLabelItem($caption,$color){
167
+	public function addCircularLabelItem($caption, $color) {
168 168
 		return $this->addItem(HtmlDropdownItem::circular($caption, $color));
169 169
 	}
170 170
 
@@ -173,17 +173,17 @@  discard block
 block discarded – undo
173 173
 	 * @param string $image
174 174
 	 * @return \Ajax\semantic\html\content\HtmlDropdownItem
175 175
 	 */
176
-	public function addMiniAvatarImageItem($caption,$image){
176
+	public function addMiniAvatarImageItem($caption, $image) {
177 177
 		return $this->addItem(HtmlDropdownItem::avatar($caption, $image));
178 178
 	}
179 179
 
180
-	public function addItems($items){
181
-		if(\is_array($items) && $this->_associative){
182
-			foreach ($items as $k=>$v){
180
+	public function addItems($items) {
181
+		if (\is_array($items) && $this->_associative) {
182
+			foreach ($items as $k=>$v) {
183 183
 				$this->addItem($v)->setData($k);
184 184
 			}
185
-		}else{
186
-			foreach ($items as $item){
185
+		} else {
186
+			foreach ($items as $item) {
187 187
 				$this->addItem($item);
188 188
 			}
189 189
 		}
@@ -195,98 +195,98 @@  discard block
 block discarded – undo
195 195
 	 * @param array|mixed $values
196 196
 	 * @return $this
197 197
 	 */
198
-	public function setPropertyValues($property,$values){
198
+	public function setPropertyValues($property, $values) {
199 199
 		$i=0;
200
-		if(\is_array($values)===false){
201
-			$values=\array_fill(0, $this->count(),$values);
200
+		if (\is_array($values)===false) {
201
+			$values=\array_fill(0, $this->count(), $values);
202 202
 		}
203
-		foreach ($values as $value){
203
+		foreach ($values as $value) {
204 204
 			$c=$this->items[$i++];
205
-			if(isset($c)){
206
-				$c->setProperty($property,$value);
205
+			if (isset($c)) {
206
+				$c->setProperty($property, $value);
207 207
 			}
208
-			else{
208
+			else {
209 209
 				return $this;
210 210
 			}
211 211
 		}
212 212
 		return $this;
213 213
 	}
214 214
 
215
-	public function each($callBack){
216
-		foreach ($this->items as $index=>$value){
217
-			$callBack($index,$value);
215
+	public function each($callBack) {
216
+		foreach ($this->items as $index=>$value) {
217
+			$callBack($index, $value);
218 218
 		}
219 219
 		return $this;
220 220
 	}
221 221
 
222
-	public function getItem($index){
222
+	public function getItem($index) {
223 223
 		return $this->items[$index];
224 224
 	}
225 225
 
226 226
 	/**
227 227
 	 * @return int
228 228
 	 */
229
-	public function count(){
229
+	public function count() {
230 230
 		return \sizeof($this->items);
231 231
 	}
232 232
 	/**
233 233
 	 * @param boolean $dropdown
234 234
 	 */
235
-	public function asDropdown($dropdown){
236
-		if($dropdown===false){
235
+	public function asDropdown($dropdown) {
236
+		if ($dropdown===false) {
237 237
 			$this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php';
238 238
 			$dropdown="menu";
239
-		}else{
239
+		} else {
240 240
 			$dropdown="dropdown";
241 241
 			$this->mClass="menu";
242 242
 		}
243
-		return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown"));
243
+		return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown"));
244 244
 	}
245 245
 
246
-	public function setVertical(){
247
-		return $this->addToPropertyCtrl("class", "vertical",array("vertical"));
246
+	public function setVertical() {
247
+		return $this->addToPropertyCtrl("class", "vertical", array("vertical"));
248 248
 	}
249 249
 
250
-	public function setInline(){
251
-		return $this->addToPropertyCtrl("class", "inline",["inline"]);
250
+	public function setInline() {
251
+		return $this->addToPropertyCtrl("class", "inline", ["inline"]);
252 252
 	}
253 253
 
254
-	public function setSimple(){
255
-		return $this->addToPropertyCtrl("class", "simple",array("simple"));
254
+	public function setSimple() {
255
+		return $this->addToPropertyCtrl("class", "simple", array("simple"));
256 256
 	}
257 257
 
258
-	public function asButton($floating=false){
258
+	public function asButton($floating=false) {
259 259
 		$this->removeArrow();
260
-		if($floating)
260
+		if ($floating)
261 261
 			$this->addToProperty("class", "floating");
262 262
 		$this->removePropertyValue("class", "selection");
263 263
 		return $this->addToProperty("class", "button");
264 264
 	}
265 265
 
266
-	public function asSelect($name=NULL,$multiple=false,$selection=true){
266
+	public function asSelect($name=NULL, $multiple=false, $selection=true) {
267 267
 		$this->_multiple=$multiple;
268
-		if(isset($name))
268
+		if (isset($name))
269 269
 			$this->addInput($name);
270
-		if($multiple){
270
+		if ($multiple) {
271 271
 			$this->addToProperty("class", "multiple");
272 272
 		}
273
-		if ($selection){
274
-			if($this->propertyContains("class", "button")===false)
275
-				$this->addToPropertyCtrl("class", "selection",array("selection"));
273
+		if ($selection) {
274
+			if ($this->propertyContains("class", "button")===false)
275
+				$this->addToPropertyCtrl("class", "selection", array("selection"));
276 276
 		}
277 277
 		return $this;
278 278
 	}
279 279
 
280
-	public function asSearch($name=NULL,$multiple=false,$selection=true){
281
-		$this->asSelect($name,$multiple,$selection);
280
+	public function asSearch($name=NULL, $multiple=false, $selection=true) {
281
+		$this->asSelect($name, $multiple, $selection);
282 282
 		return $this->addToProperty("class", "search");
283 283
 	}
284 284
 
285
-	public function setSelect($name=NULL,$multiple=false){
286
-		if(!isset($name))
285
+	public function setSelect($name=NULL, $multiple=false) {
286
+		if (!isset($name))
287 287
 			$name="select-".$this->identifier;
288 288
 		$this->input=null;
289
-		if($multiple){
289
+		if ($multiple) {
290 290
 			$this->setProperty("multiple", true);
291 291
 			$this->addToProperty("class", "multiple");
292 292
 		}
@@ -294,42 +294,42 @@  discard block
 block discarded – undo
294 294
 		$this->tagName="select";
295 295
 		$this->setProperty("name", $name);
296 296
 		$this->content=null;
297
-		foreach ($this->items as $item){
297
+		foreach ($this->items as $item) {
298 298
 			$item->asOption();
299 299
 		}
300 300
 		return $this;
301 301
 	}
302 302
 
303
-	public function asSubmenu($pointing=NULL){
303
+	public function asSubmenu($pointing=NULL) {
304 304
 		$this->setClass("ui dropdown link item");
305
-		if(isset($pointing)){
305
+		if (isset($pointing)) {
306 306
 			$this->setPointing($pointing);
307 307
 		}
308 308
 		return $this;
309 309
 	}
310 310
 
311
-	public function setPointing($value=Direction::NONE){
312
-		return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing"));
311
+	public function setPointing($value=Direction::NONE) {
312
+		return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing"));
313 313
 	}
314 314
 
315
-	public function setValue($value){
315
+	public function setValue($value) {
316 316
 		$this->value=$value;
317 317
 		return $this;
318 318
 	}
319 319
 	
320
-	public function setDefaultText($text){
321
-		$this->content["text"]=new HtmlSemDoubleElement("","div","default text",$text);
320
+	public function setDefaultText($text) {
321
+		$this->content["text"]=new HtmlSemDoubleElement("", "div", "default text", $text);
322 322
 	}
323 323
 	
324
-	private function applyValue(){
324
+	private function applyValue() {
325 325
 		$value=$this->value;
326
-		if(isset($this->input) && isset($value)){
326
+		if (isset($this->input) && isset($value)) {
327 327
 			$this->input->setProperty("value", $value);
328
-		}else{
328
+		} else {
329 329
 			$this->setProperty("value", $value);
330 330
 		}
331 331
 			$textElement=$this->getElementById("text-".$this->identifier, $this->content);
332
-			if(isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple)
332
+			if (isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple)
333 333
 				$textElement->setContent($value);
334 334
 		return $this;
335 335
 	}
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
 	 * @see BaseHtml::run()
340 340
 	 */
341 341
 	public function run(JsUtils $js) {
342
-		if($this->propertyContains("class", "simple")===false){
343
-			if(isset($this->_bsComponent)===false){
344
-				$this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params);
342
+		if ($this->propertyContains("class", "simple")===false) {
343
+			if (isset($this->_bsComponent)===false) {
344
+				$this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params);
345 345
 				$this->_bsComponent->setItemSelector(".item");
346 346
 			}
347 347
 			$this->addEventsOnRun($js);
@@ -349,41 +349,41 @@  discard block
 block discarded – undo
349 349
 		}
350 350
 	}
351 351
 
352
-	public function setCompact(){
352
+	public function setCompact() {
353 353
 		return $this->addToPropertyCtrl("class", "compact", array("compact"));
354 354
 	}
355 355
 
356
-	public function setAction($action){
356
+	public function setAction($action) {
357 357
 		$this->_params["action"]=$action;
358 358
 	}
359 359
 
360
-	public function setOn($on){
360
+	public function setOn($on) {
361 361
 		$this->_params["on"]=$on;
362 362
 	}
363 363
 
364
-	public function setShowOnFocus($value){
364
+	public function setShowOnFocus($value) {
365 365
 		$this->_params["showOnFocus"]=$value;
366 366
 	}
367 367
 
368
-	public function setFullTextSearch($value){
368
+	public function setFullTextSearch($value) {
369 369
 		$this->_params["fullTextSearch"]=$value;
370 370
 	}
371 371
 
372 372
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
373 373
 		$this->applyValue();
374
-		return parent::compile($js,$view);
374
+		return parent::compile($js, $view);
375 375
 	}
376 376
 
377 377
 	public function getInput() {
378 378
 		return $this->input;
379 379
 	}
380 380
 
381
-	public function setIcon($icon="dropdown"){
381
+	public function setIcon($icon="dropdown") {
382 382
 		$this->content["arrow"]=new HtmlIcon($this->identifier."-icon", $icon);
383 383
 		return $this;
384 384
 	}
385 385
 
386
-	public function jsAddItem($caption){
386
+	public function jsAddItem($caption) {
387 387
 		$js="var first=$('#{$this->identifier} .item').first();if(first!=undefined){var new =first.clone();first.parent().append(new);first.html('{$caption}};')";
388 388
 		return $js;
389 389
 	}
Please login to merge, or discard this patch.
Ajax/common/html/BaseHtml.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
  * @version 1.3
16 16
  */
17 17
 abstract class BaseHtml extends BaseWidget {
18
-	use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait;
18
+	use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait;
19 19
 	protected $_template;
20 20
 	protected $tagName;
21
-	protected $_wrapBefore=array ();
22
-	protected $_wrapAfter=array ();
21
+	protected $_wrapBefore=array();
22
+	protected $_wrapAfter=array();
23 23
 	protected $_bsComponent;
24 24
 	protected $_compiled=false;
25 25
 	protected $_runned=false;
@@ -33,32 +33,32 @@  discard block
 block discarded – undo
33 33
 	 */
34 34
 	abstract public function run(JsUtils $js);
35 35
 
36
-	private function _callSetter($setter,$key,$value,&$array){
36
+	private function _callSetter($setter, $key, $value, &$array) {
37 37
 		$result=false;
38
-		if (method_exists($this, $setter) && substr($setter, 0, 1) !== "_") {
38
+		if (method_exists($this, $setter) && substr($setter, 0, 1)!=="_") {
39 39
 			try {
40 40
 				$this->$setter($value);
41 41
 				unset($array[$key]);
42 42
 				$result=true;
43
-			} catch ( \Exception $e ) {
43
+			}catch (\Exception $e) {
44 44
 				$result=false;
45 45
 			}
46 46
 		}
47 47
 		return $result;
48 48
 	}
49 49
 
50
-	protected function getTemplate(JsUtils $js=NULL,$view=null) {
51
-		return PropertyWrapper::wrap($this->_wrapBefore, $js,$view) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js,$view);
50
+	protected function getTemplate(JsUtils $js=NULL, $view=null) {
51
+		return PropertyWrapper::wrap($this->_wrapBefore, $js, $view).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js, $view);
52 52
 	}
53 53
 
54 54
 	protected function ctrl($name, $value, $typeCtrl) {
55 55
 		if (\is_array($typeCtrl)) {
56
-			if (array_search($value, $typeCtrl) === false) {
57
-				throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}");
56
+			if (array_search($value, $typeCtrl)===false) {
57
+				throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
58 58
 			}
59 59
 		} else {
60 60
 			if (!$typeCtrl($value)) {
61
-				throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name);
61
+				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name);
62 62
 			}
63 63
 		}
64 64
 		return true;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") {
76 76
 		if (\is_array($typeCtrl)) {
77 77
 			$this->removeOldValues($name, $typeCtrl);
78
-			$name.=$separator . $value;
78
+			$name.=$separator.$value;
79 79
 		}
80 80
 		return $this;
81 81
 	}
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 		if (\is_array($typeCtrl)) {
88 88
 			$this->removeOldValues($name, $typeCtrl);
89 89
 		}
90
-		$name.=$separator . $value;
90
+		$name.=$separator.$value;
91 91
 		return $this;
92 92
 	}
93 93
 
94 94
 	protected function addToMember(&$name, $value, $separator=" ") {
95
-		$name=str_ireplace($value, "", $name) . $separator . $value;
95
+		$name=str_ireplace($value, "", $name).$separator.$value;
96 96
 		return $this;
97 97
 	}
98 98
 
@@ -103,18 +103,18 @@  discard block
 block discarded – undo
103 103
 		$oldValue=trim($oldValue);
104 104
 	}
105 105
 
106
-	protected function _getElementBy($callback,$elements){
106
+	protected function _getElementBy($callback, $elements) {
107 107
 		if (\is_array($elements)) {
108 108
 			$elements=\array_values($elements);
109 109
 			$flag=false;
110 110
 			$index=0;
111
-			while ( !$flag && $index < sizeof($elements) ) {
111
+			while (!$flag && $index<sizeof($elements)) {
112 112
 				if ($elements[$index] instanceof BaseHtml)
113 113
 					$flag=($callback($elements[$index]));
114 114
 					$index++;
115 115
 			}
116
-			if ($flag === true)
117
-				return $elements[$index - 1];
116
+			if ($flag===true)
117
+				return $elements[$index-1];
118 118
 		} elseif ($elements instanceof BaseHtml) {
119 119
 			if ($callback($elements))
120 120
 				return $elements;
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
 	}
143 143
 
144 144
 	public function fromArray($array) {
145
-		foreach ( $this as $key => $value ) {
146
-			if(array_key_exists($key, $array)===true)
147
-				$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
145
+		foreach ($this as $key => $value) {
146
+			if (array_key_exists($key, $array)===true)
147
+				$this->_callSetter("set".ucfirst($key), $key, $array[$key], $array);
148 148
 		}
149
-		foreach ( $array as $key => $value ) {
150
-			if($this->_callSetter($key, $key, $value, $array)===false){
151
-				$this->_callSetter("set" . ucfirst($key), $key, $value, $array);
149
+		foreach ($array as $key => $value) {
150
+			if ($this->_callSetter($key, $key, $value, $array)===false) {
151
+				$this->_callSetter("set".ucfirst($key), $key, $value, $array);
152 152
 			}
153 153
 		}
154 154
 		return $array;
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
 	public function fromDatabaseObjects($objects, $function) {
158 158
 		if (isset($objects)) {
159
-			foreach ( $objects as $object ) {
159
+			foreach ($objects as $object) {
160 160
 				$this->fromDatabaseObject($object, $function);
161 161
 			}
162 162
 		}
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 
178 178
 
179 179
 	public function getElementById($identifier, $elements) {
180
-		return $this->_getElementBy(function(BaseWidget $element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements);
180
+		return $this->_getElementBy(function(BaseWidget $element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements);
181 181
 	}
182 182
 
183 183
 	public function getBsComponent() {
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 	}
191 191
 
192 192
 	protected function compile_once(JsUtils $js=NULL, &$view=NULL) {
193
-		if(!$this->_compiled){
194
-			if(isset($js)){
193
+		if (!$this->_compiled) {
194
+			if (isset($js)) {
195 195
 				$beforeCompile=$js->getParam("beforeCompileHtml");
196
-				if(\is_callable($beforeCompile)){
197
-					$beforeCompile($this,$js,$view);
196
+				if (\is_callable($beforeCompile)) {
197
+					$beforeCompile($this, $js, $view);
198 198
 				}
199 199
 			}
200
-			if(\is_callable($this->_preCompile)){
200
+			if (\is_callable($this->_preCompile)) {
201 201
 				$pc=$this->_preCompile;
202 202
 				$pc($this);
203 203
 			}
@@ -207,17 +207,17 @@  discard block
 block discarded – undo
207 207
 	}
208 208
 
209 209
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
210
-		$this->compile_once($js,$view);
211
-		$result=$this->getTemplate($js,$view);
212
-		foreach ( $this as $key => $value ) {
213
-				if(\strstr($result, "%{$key}%")!==false){
210
+		$this->compile_once($js, $view);
211
+		$result=$this->getTemplate($js, $view);
212
+		foreach ($this as $key => $value) {
213
+				if (\strstr($result, "%{$key}%")!==false) {
214 214
 					if (\is_array($value)) {
215
-						$v=PropertyWrapper::wrap($value, $js,$view);
216
-					}elseif($value instanceof \stdClass){
217
-							$v=\print_r($value,true);
218
-					}elseif ($value instanceof BaseHtml){
219
-						$v=$value->compile($js,$view);
220
-					}else{
215
+						$v=PropertyWrapper::wrap($value, $js, $view);
216
+					}elseif ($value instanceof \stdClass) {
217
+							$v=\print_r($value, true);
218
+					}elseif ($value instanceof BaseHtml) {
219
+						$v=$value->compile($js, $view);
220
+					} else {
221 221
 						$v=$value;
222 222
 					}
223 223
 					$result=str_replace("%{$key}%", $v, $result);
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
 		}
226 226
 		if (isset($js)===true) {
227 227
 			$this->run($js);
228
-			if (isset($view) === true) {
228
+			if (isset($view)===true) {
229 229
 				$js->addViewElement($this->_identifier, $result, $view);
230 230
 			}
231 231
 		}
232 232
 
233
-		if(\is_callable($this->_postCompile)){
233
+		if (\is_callable($this->_postCompile)) {
234 234
 			$pc=$this->_postCompile;
235 235
 			$pc($this);
236 236
 		}
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 	 * @param array $parameters default: ["jsCallback"=>"","jqueryDone"=>"append"]
245 245
 	 * @return \Ajax\common\html\BaseHtml
246 246
 	 */
247
-	public function setDraggable($attr="id",$dropZone=null,$parameters=[]){
247
+	public function setDraggable($attr="id", $dropZone=null, $parameters=[]) {
248 248
 		$this->setProperty("draggable", "true");
249
-		$this->addEvent("dragstart",Javascript::draggable($attr));
250
-		if(isset($dropZone)&& $dropZone instanceof BaseHtml){
251
-			$jqueryDone="append";$jsCallback="";
249
+		$this->addEvent("dragstart", Javascript::draggable($attr));
250
+		if (isset($dropZone) && $dropZone instanceof BaseHtml) {
251
+			$jqueryDone="append"; $jsCallback="";
252 252
 			extract($parameters);
253
-			$dropZone->asDropZone($jsCallback,$jqueryDone,$parameters);
253
+			$dropZone->asDropZone($jsCallback, $jqueryDone, $parameters);
254 254
 		}
255 255
 		return $this;
256 256
 	}
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
 	 * @param array $parameters
263 263
 	 * @return \Ajax\common\html\BaseHtml
264 264
 	 */
265
-	public function asDropZone($jsCallback="",$jqueryDone="append",$parameters=[]){
265
+	public function asDropZone($jsCallback="", $jqueryDone="append", $parameters=[]) {
266 266
 		$stopPropagation=false;
267
-		$this->addEvent("dragover", '', $stopPropagation,true);
267
+		$this->addEvent("dragover", '', $stopPropagation, true);
268 268
 		extract($parameters);
269
-		$this->addEvent("drop",Javascript::dropZone($jqueryDone,$jsCallback),$stopPropagation,true);
269
+		$this->addEvent("drop", Javascript::dropZone($jqueryDone, $jsCallback), $stopPropagation, true);
270 270
 		return $this;
271 271
 	}
272 272
 
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
 		return $this->compile();
275 275
 	}
276 276
 
277
-	public function onPostCompile($callback){
277
+	public function onPostCompile($callback) {
278 278
 		$this->_postCompile=$callback;
279 279
 	}
280 280
 
281
-	public function onPreCompile($callback){
281
+	public function onPreCompile($callback) {
282 282
 		$this->_preCompile=$callback;
283 283
 	}
284 284
 }
Please login to merge, or discard this patch.
Ajax/common/html/PropertyWrapper.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 		}
13 13
 		$output="";
14 14
 		if (\is_array($input)) {
15
-			if (sizeof($input) > 0) {
16
-				if (self::containsElement($input) === false) {
15
+			if (sizeof($input)>0) {
16
+				if (self::containsElement($input)===false) {
17 17
 					$output=self::wrapStrings($input, $separator=' ', $valueQuote='"');
18 18
 				} else {
19 19
 					$output=self::wrapObjects($input, $js, $view, $separator, $valueQuote);
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	}
25 25
 
26 26
 	private static function containsElement($input) {
27
-		foreach ( $input as $v ) {
27
+		foreach ($input as $v) {
28 28
 			if (\is_object($v) || \is_array($v))
29 29
 				return true;
30 30
 		}
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 	}
33 33
 
34 34
 	public static function wrapStrings($input, $separator=' ', $valueQuote='"') {
35
-		if (JArray::isAssociative($input) === true) {
36
-			$result=implode($separator, array_map(function ($v, $k) use($valueQuote) {
37
-				return $k . '=' . $valueQuote . $v . $valueQuote;
35
+		if (JArray::isAssociative($input)===true) {
36
+			$result=implode($separator, array_map(function($v, $k) use($valueQuote) {
37
+				return $k.'='.$valueQuote.$v.$valueQuote;
38 38
 			}, $input, array_keys($input)));
39 39
 		} else {
40 40
 			$result=implode($separator, $input);
@@ -43,30 +43,30 @@  discard block
 block discarded – undo
43 43
 	}
44 44
 
45 45
 	public static function wrapObjects($input, $js=NULL, $view=null, $separator=' ', $valueQuote='"') {
46
-		return implode($separator, array_map(function ($v) use($js, $view,$separator, $valueQuote) {
47
-			if(\is_string($v)){
46
+		return implode($separator, array_map(function($v) use($js, $view, $separator, $valueQuote) {
47
+			if (\is_string($v)) {
48 48
 				return $v;
49 49
 			}
50
-			if ($v instanceof BaseHtml){
51
-				return $v->compile($js,$view);
50
+			if ($v instanceof BaseHtml) {
51
+				return $v->compile($js, $view);
52 52
 			}
53 53
 			if (\is_array($v)) {
54
-				return self::wrap($v, $js, $view,$separator, $valueQuote);
54
+				return self::wrap($v, $js, $view, $separator, $valueQuote);
55 55
 			}
56
-			if(!\is_callable($v)){
56
+			if (!\is_callable($v)) {
57 57
 				return $v;
58 58
 			}
59 59
 		}, $input));
60 60
 	}
61 61
 
62
-	protected static function wrapValue($value,$js=NULL, $separator=' ', $valueQuote='"'){
62
+	protected static function wrapValue($value, $js=NULL, $separator=' ', $valueQuote='"') {
63 63
 		if (\is_array($value)) {
64 64
 			return self::wrap($value, $js, $separator, $valueQuote);
65 65
 		}
66
-		if ($value instanceof BaseHtml){
66
+		if ($value instanceof BaseHtml) {
67 67
 			return $value->compile($js);
68 68
 		}
69
-		if(!\is_callable($value)){
69
+		if (!\is_callable($value)) {
70 70
 			return $value;
71 71
 		}
72 72
 		return '';
Please login to merge, or discard this patch.
Ajax/common/html/traits/BaseHtmlEventsTrait.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
  * @property string identifier
12 12
  * @property BaseHtml _self
13 13
  */
14
-trait BaseHtmlEventsTrait{
14
+trait BaseHtmlEventsTrait {
15 15
 
16
-	protected $_events=array ();
16
+	protected $_events=array();
17 17
 
18 18
 	/**
19 19
 	 * @param string $event
@@ -23,21 +23,21 @@  discard block
 block discarded – undo
23 23
 	 * @return BaseHtml
24 24
 	 */
25 25
 	public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
26
-		if ($stopPropagation === true) {
27
-			$jsCode=Javascript::$stopPropagation . $jsCode;
26
+		if ($stopPropagation===true) {
27
+			$jsCode=Javascript::$stopPropagation.$jsCode;
28 28
 		}
29
-		if ($preventDefault === true) {
30
-			$jsCode=Javascript::$preventDefault . $jsCode;
29
+		if ($preventDefault===true) {
30
+			$jsCode=Javascript::$preventDefault.$jsCode;
31 31
 		}
32 32
 		return $this->_addEvent($event, $jsCode);
33 33
 	}
34 34
 	
35
-	public function trigger($event,$params="[]"){
35
+	public function trigger($event, $params="[]") {
36 36
 		$this->executeOnRun('$("#'.$this->identifier.'").trigger("'.$event.'",'.$params.');');
37 37
 	}
38 38
 	
39
-	public function jsTrigger($event,$params="[this]"){
40
-		return $this->jsDoJquery("trigger",["'".$event."'",$params]);
39
+	public function jsTrigger($event, $params="[this]") {
40
+		return $this->jsDoJquery("trigger", ["'".$event."'", $params]);
41 41
 	}
42 42
 
43 43
 	/**
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
 	public function _addEvent($event, $jsCode) {
49 49
 		if (array_key_exists($event, $this->_events)) {
50 50
 			if (\is_array($this->_events[$event])) {
51
-				if(array_search($jsCode, $this->_events[$event])===false){
51
+				if (array_search($jsCode, $this->_events[$event])===false) {
52 52
 					$this->_events[$event][]=$jsCode;
53 53
 				}
54 54
 			} else {
55
-				$this->_events[$event]=array ($this->_events[$event],$jsCode );
55
+				$this->_events[$event]=array($this->_events[$event], $jsCode);
56 56
 			}
57 57
 		} else {
58 58
 			$this->_events[$event]=$jsCode;
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 		return $this->onClick($jsCode);
80 80
 	}
81 81
 
82
-	public function onCreate($jsCode){
83
-		if(isset($this->_events["_create"])){
82
+	public function onCreate($jsCode) {
83
+		if (isset($this->_events["_create"])) {
84 84
 			$this->_events["_create"][]=$jsCode;
85
-		}else{
85
+		} else {
86 86
 			$this->_events["_create"]=[$jsCode];
87 87
 		}
88 88
 		return $this;
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
 	public function addEventsOnRun(JsUtils $js=NULL) {
92 92
 		$this->_eventsOnCreate($js);
93 93
 		if (isset($this->_bsComponent)) {
94
-			foreach ( $this->_events as $event => $jsCode ) {
94
+			foreach ($this->_events as $event => $jsCode) {
95 95
 				$code=$jsCode;
96 96
 				if (\is_array($jsCode)) {
97 97
 					$code="";
98
-					foreach ( $jsCode as $jsC ) {
98
+					foreach ($jsCode as $jsC) {
99 99
 						if ($jsC instanceof AjaxCall) {
100
-							$code.="\n" . $jsC->compile($js);
100
+							$code.="\n".$jsC->compile($js);
101 101
 						} else {
102
-							$code.="\n" . $jsC;
102
+							$code.="\n".$jsC;
103 103
 						}
104 104
 					}
105 105
 				} elseif ($jsCode instanceof AjaxCall) {
@@ -107,20 +107,20 @@  discard block
 block discarded – undo
107 107
 				}
108 108
 				$this->_bsComponent->addEvent($event, $code);
109 109
 			}
110
-			$this->_events=array ();
110
+			$this->_events=array();
111 111
 			return $this->_bsComponent->getScript();
112 112
 		}
113 113
 		return "";
114 114
 	}
115 115
 
116
-	protected function _eventsOnCreate(JsUtils $js=NULL){
117
-		if(isset($this->_events["_create"])){
116
+	protected function _eventsOnCreate(JsUtils $js=NULL) {
117
+		if (isset($this->_events["_create"])) {
118 118
 			$create=$this->_events["_create"];
119
-			if(\is_array($create)){
119
+			if (\is_array($create)) {
120 120
 				$create=\implode("", $create);
121 121
 			}
122
-			if(isset($js) && $create!=="")
123
-				$js->exec($create,true);
122
+			if (isset($js) && $create!=="")
123
+				$js->exec($create, true);
124 124
 			unset($this->_events["_create"]);
125 125
 		}
126 126
 	}
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @return $this
135 135
 	 */
136 136
 	public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) {
137
-		$params=array ("url" => $url,"responseElement" => $responseElement );
137
+		$params=array("url" => $url, "responseElement" => $responseElement);
138 138
 		$params=array_merge($params, $parameters);
139 139
 		$this->_addEvent($event, new AjaxCall($operation, $params));
140 140
 		return $this;
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 	 **/
178 178
 	public function postOn($event, $url, $params="{}", $responseElement="", $parameters=array()) {
179 179
 		$allParameters=[];
180
-		if(isset($parameters["params"])){
180
+		if (isset($parameters["params"])) {
181 181
 			$allParameters[]=JsUtils::_correctParams($parameters["params"]);
182 182
 		}
183
-		if(isset($params)){
183
+		if (isset($params)) {
184 184
 			$allParameters[]=JsUtils::_correctParams($params);
185 185
 		}
186 186
 		$parameters["params"]=\implode("+'&'+", $allParameters);
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	}
228 228
 
229 229
 	public function jsDoJquery($jqueryCall, $param="") {
230
-		return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . Javascript::prep_value($param) . ");";
230
+		return "$('#".$this->identifier."').".$jqueryCall."(".Javascript::prep_value($param).");";
231 231
 	}
232 232
 
233 233
 	public function executeOnRun($jsCode) {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	}
248 248
 
249 249
 	public function jsToggle($value) {
250
-		return $this->jsDoJquery("toggle",$value);
250
+		return $this->jsDoJquery("toggle", $value);
251 251
 	}
252 252
 	/**
253 253
 	 * @return array
Please login to merge, or discard this patch.
Ajax/common/traits/JsUtilsAjaxTrait.php 1 patch
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 	protected $ajaxLoader="<div class=\"ui active centered inline text loader\">Loading</div>";
18 18
 
19 19
 	abstract public function getUrl($url);
20
-	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
20
+	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true);
21 21
 
22
-	protected function _ajax($method,$url,$responseElement="",$parameters=[]) {
23
-		if(isset($this->params["ajax"])){
22
+	protected function _ajax($method, $url, $responseElement="", $parameters=[]) {
23
+		if (isset($this->params["ajax"])) {
24 24
 			extract($this->params["ajax"]);
25 25
 		}
26 26
 		extract($parameters);
@@ -30,109 +30,109 @@  discard block
 block discarded – undo
30 30
 		$originalSelector=$responseElement;
31 31
 		$responseElement=$this->_getResponseElement($responseElement);
32 32
 		$retour.="var self=this;\n";
33
-		if($hasLoader===true && JString::isNotNull($responseElement)){
34
-			$this->addLoading($retour, $responseElement,$ajaxLoader);
35
-		}elseif($hasLoader==="internal"){
33
+		if ($hasLoader===true && JString::isNotNull($responseElement)) {
34
+			$this->addLoading($retour, $responseElement, $ajaxLoader);
35
+		}elseif ($hasLoader==="internal") {
36 36
 			$retour.="\n$(this).addClass('loading');";
37 37
 		}
38
-		$ajaxParameters=["url"=>"url","method"=>"'".\strtoupper($method)."'"];
38
+		$ajaxParameters=["url"=>"url", "method"=>"'".\strtoupper($method)."'"];
39 39
 		
40
-		$ajaxParameters["async"]=($async?"true":"false");
40
+		$ajaxParameters["async"]=($async ? "true" : "false");
41 41
 		
42
-		if(isset($params)){
42
+		if (isset($params)) {
43 43
 			$ajaxParameters["data"]=self::_correctParams($params);
44 44
 		}
45
-		if(isset($headers)){
45
+		if (isset($headers)) {
46 46
 			$ajaxParameters["headers"]=$headers;
47 47
 		}
48 48
 		$this->createAjaxParameters($ajaxParameters, $parameters);
49 49
 		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n";
50
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback,$hasLoader,($historize?$originalSelector:null))."});\n";
51
-		$retour=$this->_addJsCondition($jsCondition,$retour);
50
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null))."});\n";
51
+		$retour=$this->_addJsCondition($jsCondition, $retour);
52 52
 		if ($immediatly)
53 53
 			$this->jquery_code_for_compile[]=$retour;
54 54
 		return $retour;
55 55
 	}
56 56
 
57
-	protected function createAjaxParameters(&$original,$parameters){
58
-		$validParameters=["dataType"=>"'%value%'","beforeSend"=>"function(jqXHR,settings){%value%}","complete"=>"function(jqXHR){%value%}"];
59
-		foreach ($validParameters as $param=>$mask){
60
-			if(isset($parameters[$param])){
57
+	protected function createAjaxParameters(&$original, $parameters) {
58
+		$validParameters=["dataType"=>"'%value%'", "beforeSend"=>"function(jqXHR,settings){%value%}", "complete"=>"function(jqXHR){%value%}"];
59
+		foreach ($validParameters as $param=>$mask) {
60
+			if (isset($parameters[$param])) {
61 61
 				$original[$param]=\str_replace("%value%", $parameters[$param], $mask);
62 62
 			}
63 63
 		}
64 64
 	}
65 65
 
66
-	protected function implodeAjaxParameters($ajaxParameters){
67
-		$s = ''; foreach ($ajaxParameters as $k=>$v) { if ($s !== '') { $s .= ','; } $s .= "'{$k}':{$v}"; }
66
+	protected function implodeAjaxParameters($ajaxParameters) {
67
+		$s=''; foreach ($ajaxParameters as $k=>$v) { if ($s!=='') { $s.=','; } $s.="'{$k}':{$v}"; }
68 68
 		return $s;
69 69
 	}
70 70
 
71
-	protected function _addJsCondition($jsCondition,$jsSource){
72
-		if(isset($jsCondition)){
71
+	protected function _addJsCondition($jsCondition, $jsSource) {
72
+		if (isset($jsCondition)) {
73 73
 			return "if(".$jsCondition."){\n".$jsSource."\n}";
74 74
 		}
75 75
 		return $jsSource;
76 76
 	}
77 77
 
78 78
 
79
-	protected function _getAjaxUrl($url,$attr){
79
+	protected function _getAjaxUrl($url, $attr) {
80 80
 		$url=$this->_correctAjaxUrl($url);
81 81
 		$retour="url='".$url."';";
82 82
 		$slash="/";
83
-		if(JString::endswith($url, "/")===true){
83
+		if (JString::endswith($url, "/")===true) {
84 84
 			$slash="";
85 85
 		}
86
-		if(JString::isNotNull($attr)){
87
-			if ($attr==="value"){
86
+		if (JString::isNotNull($attr)) {
87
+			if ($attr==="value") {
88 88
 				$retour.="url=url+'".$slash."'+$(this).val();\n";
89
-			}elseif ($attr==="html"){
89
+			}elseif ($attr==="html") {
90 90
 				$retour.="url=url+'".$slash."'+$(this).html();\n";
91
-			}elseif(\substr($attr, 0,3)==="js:"){
91
+			}elseif (\substr($attr, 0, 3)==="js:") {
92 92
 				$retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n";
93
-			}elseif($attr!==null && $attr!=="")
93
+			}elseif ($attr!==null && $attr!=="")
94 94
 				$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
95 95
 		}
96 96
 		return $retour;
97 97
 	}
98 98
 	
99
-	protected function onPopstate(){
99
+	protected function onPopstate() {
100 100
 		return "window.onpopstate = function(e){if(e.state){var target=e.state.jqueryDone;$(e.state.selector)[target](e.state.html);}};";
101 101
 	}
102 102
 	
103
-	protected function autoActiveLinks($previousURL="window.location.href"){
104
-		$result= "\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}";
103
+	protected function autoActiveLinks($previousURL="window.location.href") {
104
+		$result="\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}";
105 105
 		$result.="\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;";
106 106
 		return $result;
107 107
 	}
108 108
 
109
-	protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback,$hasLoader=false,$history=null){
110
-		$retour="";$call=null;
109
+	protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader=false, $history=null) {
110
+		$retour=""; $call=null;
111 111
 		if (JString::isNotNull($responseElement)) {
112
-			if(isset($ajaxTransition)){
112
+			if (isset($ajaxTransition)) {
113 113
 				$call=$this->setAjaxDataCall($ajaxTransition);
114
-			}elseif(isset($this->ajaxTransition)){
114
+			}elseif (isset($this->ajaxTransition)) {
115 115
 				$call=$this->ajaxTransition;
116 116
 			}
117
-			if(\is_callable($call))
118
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
117
+			if (\is_callable($call))
118
+				$retour="\t".$call($responseElement, $jqueryDone).";\n";
119 119
 			else
120 120
 				$retour="\t{$responseElement}.{$jqueryDone}( data );\n";
121 121
 		}
122
-		if(isset($history)){
123
-			if($this->params["autoActiveLinks"]){
122
+		if (isset($history)) {
123
+			if ($this->params["autoActiveLinks"]) {
124 124
 				$retour.=$this->autoActiveLinks("url");
125 125
 			}
126 126
 			$retour.="\nwindow.history.pushState({'html':data,'selector':".Javascript::prep_value($history).",'jqueryDone':'{$jqueryDone}'},'', url);";
127 127
 		}
128
-		if($hasLoader==="internal"){
128
+		if ($hasLoader==="internal") {
129 129
 			$retour.="\n$(self).removeClass('loading');";
130 130
 		}
131 131
 		$retour.="\t".$jsCallback."\n";
132 132
 		return $retour;
133 133
 	}
134 134
 
135
-	protected function _getResponseElement($responseElement){
135
+	protected function _getResponseElement($responseElement) {
136 136
 		if (JString::isNotNull($responseElement)) {
137 137
 			$responseElement=Javascript::prep_jquery_selector($responseElement);
138 138
 		}
@@ -142,33 +142,33 @@  discard block
 block discarded – undo
142 142
 	protected function _correctAjaxUrl($url) {
143 143
 		if ($url!=="/" && JString::endsWith($url, "/")===true)
144 144
 			$url=substr($url, 0, strlen($url)-1);
145
-			if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
145
+			if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) {
146 146
 				$url=$this->getUrl($url);
147 147
 			}
148 148
 			return $url;
149 149
 	}
150 150
 
151
-	public static function _correctParams($params){
152
-		if(JString::isNull($params)){
151
+	public static function _correctParams($params) {
152
+		if (JString::isNull($params)) {
153 153
 			return "";
154 154
 		}
155
-		if(\preg_match("@^\{.*?\}$@", $params)){
155
+		if (\preg_match("@^\{.*?\}$@", $params)) {
156 156
 			return '$.param('.$params.')';
157 157
 		}
158 158
 		return $params;
159 159
 	}
160 160
 
161
-	public static function _implodeParams($parameters){
161
+	public static function _implodeParams($parameters) {
162 162
 		$allParameters=[];
163
-		foreach ($parameters as $params){
164
-			if(isset($params))
163
+		foreach ($parameters as $params) {
164
+			if (isset($params))
165 165
 				$allParameters[]=self::_correctParams($params);
166 166
 		}
167 167
 		return \implode("+'&'+", $allParameters);
168 168
 	}
169 169
 
170
-	protected function addLoading(&$retour, $responseElement,$ajaxLoader=null) {
171
-		if(!isset($ajaxLoader)){
170
+	protected function addLoading(&$retour, $responseElement, $ajaxLoader=null) {
171
+		if (!isset($ajaxLoader)) {
172 172
 			$ajaxLoader=$this->ajaxLoader;
173 173
 		}
174 174
 		$loading_notifier='<div class="ajax-loader">'.$ajaxLoader.'</div>';
@@ -176,19 +176,19 @@  discard block
 block discarded – undo
176 176
 		$retour.="\t\t{$responseElement}.prepend('{$loading_notifier}');\n";
177 177
 	}
178 178
 
179
-	protected function setAjaxDataCall($params){
179
+	protected function setAjaxDataCall($params) {
180 180
 		$result=null;
181
-		if(!\is_callable($params)){
182
-			$result=function ($responseElement,$jqueryDone="html") use($params){
183
-				return AjaxTransition::{$params}($responseElement,$jqueryDone);
181
+		if (!\is_callable($params)) {
182
+			$result=function($responseElement, $jqueryDone="html") use($params){
183
+				return AjaxTransition::{$params}($responseElement, $jqueryDone);
184 184
 			};
185 185
 		}
186 186
 		return $result;
187 187
 	}
188 188
 
189
-	protected function setDefaultParameters(&$parameters,$default){
190
-		foreach ($default as $k=>$v){
191
-			if(!isset($parameters[$k]))
189
+	protected function setDefaultParameters(&$parameters, $default) {
190
+		foreach ($default as $k=>$v) {
191
+			if (!isset($parameters[$k]))
192 192
 				$parameters[$k]=$v;
193 193
 		}
194 194
 	}
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 	 * @param string $url The url of the request
203 203
 	 * @param string $responseElement selector of the HTML element displaying the answer
204 204
 	 */
205
-	private function _get($url, $responseElement="",$parameters=[]) {
206
-		return $this->_ajax("get", $url,$responseElement,$parameters);
205
+	private function _get($url, $responseElement="", $parameters=[]) {
206
+		return $this->_ajax("get", $url, $responseElement, $parameters);
207 207
 	}
208 208
 
209 209
 	/**
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
 	 * @param string $responseElement selector of the HTML element displaying the answer
213 213
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
214 214
 	 */
215
-	public function get($url, $responseElement="",$parameters=[]) {
215
+	public function get($url, $responseElement="", $parameters=[]) {
216 216
 		$parameters["immediatly"]=true;
217
-		return $this->_get($url,$responseElement,$parameters);
217
+		return $this->_get($url, $responseElement, $parameters);
218 218
 	}
219 219
 
220 220
 	/**
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 	 * @param string $responseElement selector of the HTML element displaying the answer
225 225
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
226 226
 	 */
227
-	public function ajax($method,$url, $responseElement="", $parameters=[]) {
227
+	public function ajax($method, $url, $responseElement="", $parameters=[]) {
228 228
 		$parameters["immediatly"]=true;
229
-		return $this->_ajax($method,$url,$responseElement,$parameters);
229
+		return $this->_ajax($method, $url, $responseElement, $parameters);
230 230
 	}
231 231
 
232 232
 	/**
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 	 * @param string $responseElement selector of the HTML element displaying the answer
237 237
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
238 238
 	 */
239
-	public function ajaxDeferred($method,$url, $responseElement="", $parameters=[]) {
239
+	public function ajaxDeferred($method, $url, $responseElement="", $parameters=[]) {
240 240
 		$parameters["immediatly"]=false;
241
-		return $this->_ajax($method,$url,$responseElement,$parameters);
241
+		return $this->_ajax($method, $url, $responseElement, $parameters);
242 242
 	}
243 243
 
244 244
 	/**
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 	 * @param string $method Method used
248 248
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false)
249 249
 	 */
250
-	private function _json($url, $method="get",$parameters=[]) {
251
-		$parameters=\array_merge($parameters,["hasLoader"=>false]);
250
+	private function _json($url, $method="get", $parameters=[]) {
251
+		$parameters=\array_merge($parameters, ["hasLoader"=>false]);
252 252
 		$jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : "";
253 253
 		$context=isset($parameters['context']) ? $parameters['context'] : "document";
254 254
 		$retour="\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t".$jsCallback.";"
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 				."if($('#'+key,".$context.").length){ if($('#'+key,".$context.").is('[value]')) { $('#'+key,".$context.").val(data[key]);} else { $('#'+key,".$context.").html(data[key]); }}};\n";
257 257
 				$retour.="\t$(document).trigger('jsonReady',[data]);\n";
258 258
 		$parameters["jsCallback"]=$retour;
259
-		return $this->_ajax($method, $url,null,$parameters);
259
+		return $this->_ajax($method, $url, null, $parameters);
260 260
 	}
261 261
 	
262 262
 	/**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false)
267 267
 	 */
268 268
 	public function json($url, $method="get", $parameters=[]) {
269
-		return $this->_json($url,$method,$parameters);
269
+		return $this->_json($url, $method, $parameters);
270 270
 	}
271 271
 
272 272
 	/**
@@ -277,9 +277,9 @@  discard block
 block discarded – undo
277 277
 	 * @param string $method default get
278 278
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
279 279
 	 */
280
-	public function jsonOn($event,$element, $url,$method="get",$parameters=array()) {
281
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
282
-		return $this->_add_event($element, $this->jsonDeferred($url,$method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
280
+	public function jsonOn($event, $element, $url, $method="get", $parameters=array()) {
281
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
282
+		return $this->_add_event($element, $this->jsonDeferred($url, $method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
283 283
 	}
284 284
 
285 285
 	/**
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 */
291 291
 	public function jsonDeferred($url, $method="get", $parameters=[]) {
292 292
 		$parameters["immediatly"]=false;
293
-		return $this->_json($url,$method,$parameters);
293
+		return $this->_json($url, $method, $parameters);
294 294
 	}
295 295
 
296 296
 	/**
@@ -301,27 +301,27 @@  discard block
 block discarded – undo
301 301
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json")
302 302
 	 */
303 303
 	private function _jsonArray($maskSelector, $url, $method="get", $parameters=[]) {
304
-		$parameters=\array_merge($parameters,["hasLoader"=>false]);
304
+		$parameters=\array_merge($parameters, ["hasLoader"=>false]);
305 305
 		$rowClass=isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json";
306 306
 		$jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : "";
307 307
 		$context=isset($parameters['context']) ? $parameters['context'] : null;
308
-		if($context===null){
308
+		if ($context===null) {
309 309
 			$parent="$('".$maskSelector."').parent()";
310
-			$newElm = "$('#'+newId)";
311
-		}else{
310
+			$newElm="$('#'+newId)";
311
+		} else {
312 312
 			$parent=$context;
313
-			$newElm = $context.".find('#'+newId)";
313
+			$newElm=$context.".find('#'+newId)";
314 314
 		}
315 315
 		$appendTo="\t\tnewElm.appendTo(".$parent.");\n";
316 316
 		$retour=$parent.".find('.{$rowClass}').remove();";
317 317
 		$retour.="\tdata=($.isPlainObject(data)||$.isArray(data))?data:JSON.parse(data);\n$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone();
318 318
 		newElm.attr('id',newId);\n;newElm.addClass('{$rowClass}').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n";
319
-		$retour.= $appendTo;
319
+		$retour.=$appendTo;
320 320
 		$retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('__'+key+'__')>-1){\n"."\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n";
321 321
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
322 322
 		$retour.="\t".$jsCallback;
323 323
 		$parameters["jsCallback"]=$retour;
324
-		return $this->_ajax($method, $url,null,$parameters);
324
+		return $this->_ajax($method, $url, null, $parameters);
325 325
 	}
326 326
 
327 327
 	/**
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json")
333 333
 	 */
334 334
 	public function jsonArray($maskSelector, $url, $method="get", $parameters=[]) {
335
-		return $this->_jsonArray($maskSelector, $url,$method,$parameters);
335
+		return $this->_jsonArray($maskSelector, $url, $method, $parameters);
336 336
 	}
337 337
 
338 338
 	/**
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 	 * @param string $method Method used, default : get
356 356
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true)
357 357
 	 */
358
-	public function jsonArrayOn($event,$element,$maskSelector, $url,$method="get",$parameters=array()) {
359
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
360
-		return $this->_add_event($element, $this->jsonArrayDeferred($maskSelector,$url,$method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
358
+	public function jsonArrayOn($event, $element, $maskSelector, $url, $method="get", $parameters=array()) {
359
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
360
+		return $this->_add_event($element, $this->jsonArrayDeferred($maskSelector, $url, $method, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
361 361
 	}
362 362
 
363 363
 	/**
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 */
370 370
 	public function getDeferred($url, $responseElement="", $parameters=[]) {
371 371
 		$parameters["immediatly"]=false;
372
-		return $this->_get($url, $responseElement,$parameters);
372
+		return $this->_get($url, $responseElement, $parameters);
373 373
 	}
374 374
 
375 375
 	/**
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false)
383 383
 	 */
384 384
 	public function getOn($event, $element, $url, $responseElement="", $parameters=array()) {
385
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
386
-		return $this->_add_event($element, $this->getDeferred($url,$responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
385
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
386
+		return $this->_add_event($element, $this->getDeferred($url, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
387 387
 	}
388 388
 
389 389
 	/**
@@ -396,8 +396,8 @@  discard block
 block discarded – undo
396 396
 	 * @param array $parameters default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false)
397 397
 	 */
398 398
 	public function ajaxOn($event, $element, $url, $responseElement="", $parameters=array()) {
399
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true,"method"=>"get"]);
400
-		return $this->_add_event($element, $this->ajaxDeferred($parameters["method"],$url,$responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
399
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true, "method"=>"get"]);
400
+		return $this->_add_event($element, $this->ajaxDeferred($parameters["method"], $url, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
401 401
 	}
402 402
 
403 403
 	/**
@@ -431,15 +431,15 @@  discard block
 block discarded – undo
431 431
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true)
432 432
 	 * @return $this
433 433
 	 */
434
-	public function getHref($element,$responseElement="",$parameters=array()){
434
+	public function getHref($element, $responseElement="", $parameters=array()) {
435 435
 		$parameters["attr"]="href";
436
-		if(JString::isNull($responseElement)){
436
+		if (JString::isNull($responseElement)) {
437 437
 			$responseElement='%$(self).attr("data-target")%';
438 438
 		}
439
-		if(!isset($parameters["historize"])){
439
+		if (!isset($parameters["historize"])) {
440 440
 			$parameters["historize"]=true;
441 441
 		}
442
-		return $this->getOnClick($element, "",$responseElement,$parameters);
442
+		return $this->getOnClick($element, "", $responseElement, $parameters);
443 443
 	}
444 444
 	
445 445
 	/**
@@ -449,20 +449,20 @@  discard block
 block discarded – undo
449 449
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false)
450 450
 	 * @return $this
451 451
 	 */
452
-	public function postHref($element,$responseElement="",$parameters=array()){
452
+	public function postHref($element, $responseElement="", $parameters=array()) {
453 453
 		$parameters["attr"]="href";
454
-		if(JString::isNull($responseElement)){
454
+		if (JString::isNull($responseElement)) {
455 455
 			$responseElement='%$(this).attr("data-target")%';
456 456
 		}
457
-		if(!isset($parameters["historize"])){
457
+		if (!isset($parameters["historize"])) {
458 458
 			$parameters["historize"]=true;
459 459
 		}
460
-		return $this->postOnClick($element, "","{}",$responseElement,$parameters);
460
+		return $this->postOnClick($element, "", "{}", $responseElement, $parameters);
461 461
 	}
462 462
 
463
-	private function _post($url, $params="{}",$responseElement="", $parameters=[]) {
463
+	private function _post($url, $params="{}", $responseElement="", $parameters=[]) {
464 464
 		$parameters["params"]=$params;
465
-		return $this->_ajax("POST", $url,$responseElement,$parameters);
465
+		return $this->_ajax("POST", $url, $responseElement, $parameters);
466 466
 	}
467 467
 
468 468
 	/**
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 	 * @param string $params JSON parameters
473 473
 	 * @param array $parameters default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
474 474
 	 */
475
-	public function post($url, $params="{}",$responseElement="", $parameters=[]) {
476
-		return $this->_post($url, $params,$responseElement, $parameters);
475
+	public function post($url, $params="{}", $responseElement="", $parameters=[]) {
476
+		return $this->_post($url, $params, $responseElement, $parameters);
477 477
 	}
478 478
 
479 479
 	/**
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 	 * @param string $responseElement selector of the HTML element displaying the answer
485 485
 	 * @param array $parameters default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
486 486
 	 */
487
-	public function postDeferred($url, $params="{}",$responseElement="", $parameters=[]) {
487
+	public function postDeferred($url, $params="{}", $responseElement="", $parameters=[]) {
488 488
 		$parameters["immediatly"]=false;
489 489
 		return $this->_post($url, $params, $responseElement, $parameters);
490 490
 	}
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
501 501
 	 */
502 502
 	public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
503
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
504
-		return $this->_add_event($element, $this->postDeferred($url, $params, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
503
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
504
+		return $this->_add_event($element, $this->postDeferred($url, $params, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
505 505
 	}
506 506
 
507 507
 	/**
@@ -518,33 +518,33 @@  discard block
 block discarded – undo
518 518
 	}
519 519
 
520 520
 	private function _postForm($url, $form, $responseElement, $parameters=[]) {
521
-		if(isset($this->params["ajax"])){
521
+		if (isset($this->params["ajax"])) {
522 522
 			extract($this->params["ajax"]);
523 523
 		}
524
-		$params="{}";$validation=false;
524
+		$params="{}"; $validation=false;
525 525
 		\extract($parameters);
526
-		$async=($async)?"true":"false";
526
+		$async=($async) ? "true" : "false";
527 527
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
528 528
 		$retour=$this->_getAjaxUrl($url, $attr);
529 529
 		$retour.="\n$('#".$form."').trigger('ajaxSubmit');";
530 530
 		$retour.="\nvar params=$('#".$form."').serialize();\n";
531
-		if(isset($params)){
531
+		if (isset($params)) {
532 532
 			$retour.="params+='&'+".self::_correctParams($params).";\n";
533 533
 		}
534 534
 		$responseElement=$this->_getResponseElement($responseElement);
535 535
 		$retour.="var self=this;\n";
536
-		if($hasLoader===true){
537
-			$this->addLoading($retour, $responseElement,$ajaxLoader);
538
-		}elseif($hasLoader==="internal"){
536
+		if ($hasLoader===true) {
537
+			$this->addLoading($retour, $responseElement, $ajaxLoader);
538
+		}elseif ($hasLoader==="internal") {
539 539
 			$retour.="\n$(this).addClass('loading');";
540 540
 		}
541
-		$ajaxParameters=["url"=>"url","method"=>"'POST'","data"=>"params","async"=>$async];
542
-		if(isset($headers)){
541
+		$ajaxParameters=["url"=>"url", "method"=>"'POST'", "data"=>"params", "async"=>$async];
542
+		if (isset($headers)) {
543 543
 			$ajaxParameters["headers"]=$headers;
544 544
 		}
545 545
 		$this->createAjaxParameters($ajaxParameters, $parameters);
546 546
 		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data ) {\n";
547
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback,$hasLoader)."});\n";
547
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader)."});\n";
548 548
 
549 549
 		if ($validation) {
550 550
 			$retour="$('#".$form."').validate({submitHandler: function(form) {
@@ -594,8 +594,8 @@  discard block
 block discarded – undo
594 594
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false)
595 595
 	 */
596 596
 	public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) {
597
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
598
-		return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
597
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
598
+		return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
599 599
 	}
600 600
 
601 601
 	/**
Please login to merge, or discard this patch.
Ajax/common/traits/JsUtilsActionsTrait.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 trait JsUtilsActionsTrait {
13 13
 
14
-	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
14
+	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true);
15 15
 	/**
16 16
 	 * show or hide with effect
17 17
 	 *
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * @param boolean $immediatly defers the execution if set to false
23 23
 	 * @return string
24 24
 	 */
25
-	protected function _showHideWithEffect($action,$element='this', $speed='', $callback='', $immediatly=false) {
25
+	protected function _showHideWithEffect($action, $element='this', $speed='', $callback='', $immediatly=false) {
26 26
 		$element=Javascript::prep_element($element);
27 27
 		$speed=$this->_validate_speed($speed);
28 28
 		if ($callback!='') {
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 	 * @return string
40 40
 	 */
41 41
 	private function _validate_speed($speed) {
42
-		if (in_array($speed, array (
43
-				'slow','normal','fast'
42
+		if (in_array($speed, array(
43
+				'slow', 'normal', 'fast'
44 44
 		))) {
45 45
 			$speed='"'.$speed.'"';
46 46
 		} elseif (preg_match("/[^0-9]/", $speed)) {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 * @param string $param
58 58
 	 * @param boolean $immediatly delayed if false
59 59
 	 */
60
-	public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) {
60
+	public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) {
61 61
 		$element=Javascript::prep_element($element);
62 62
 		if (isset($param)) {
63 63
 			$param=Javascript::prep_value($param);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @param boolean $immediatly delayed if false
78 78
 	 * @return string
79 79
 	 */
80
-	public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) {
80
+	public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) {
81 81
 		$to=Javascript::prep_element($to);
82 82
 		$element=Javascript::prep_element($element);
83 83
 		$str="$({$to}).{$jQueryCall}({$element});";
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 * @return string
95 95
 	 */
96 96
 	public function addClass($element='this', $class='', $immediatly=false) {
97
-		return $this->_genericCallValue('addClass',$element, $class, $immediatly);
97
+		return $this->_genericCallValue('addClass', $element, $class, $immediatly);
98 98
 	}
99 99
 
100 100
 	/**
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * @param boolean $immediatly defers the execution if set to false
105 105
 	 * @return string
106 106
 	 */
107
-	public function after($to, $element, $immediatly=false){
108
-		return $this->_genericCallElement('after',$to, $element, $immediatly);
107
+	public function after($to, $element, $immediatly=false) {
108
+		return $this->_genericCallElement('after', $to, $element, $immediatly);
109 109
 	}
110 110
 
111 111
 	/**
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 * @param boolean $immediatly defers the execution if set to false
116 116
 	 * @return string
117 117
 	 */
118
-	public function before($to, $element, $immediatly=false){
119
-		return $this->_genericCallElement('before',$to, $element, $immediatly);
118
+	public function before($to, $element, $immediatly=false) {
119
+		return $this->_genericCallElement('before', $to, $element, $immediatly);
120 120
 	}
121 121
 
122 122
 	/**
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 	 * @param string $value
145 145
 	 * @param boolean $immediatly defers the execution if set to false
146 146
 	 */
147
-	public function val($element='this',$value='',$immediatly=false){
148
-		return $this->_genericCallValue('val',$element,$value,$immediatly);
147
+	public function val($element='this', $value='', $immediatly=false) {
148
+		return $this->_genericCallValue('val', $element, $value, $immediatly);
149 149
 	}
150 150
 
151 151
 	/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @param boolean $immediatly defers the execution if set to false
156 156
 	 */
157 157
 	public function html($element='this', $value='', $immediatly=false) {
158
-		return $this->_genericCallValue('html',$element, $value, $immediatly);
158
+		return $this->_genericCallValue('html', $element, $value, $immediatly);
159 159
 	}
160 160
 
161 161
 	/**
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
 		$animations="\t\t\t";
176 176
 		if (\is_array($params)) {
177
-			foreach ( $params as $param => $value ) {
177
+			foreach ($params as $param => $value) {
178 178
 				$animations.=$param.': \''.$value.'\', ';
179 179
 			}
180 180
 		}
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @return string
204 204
 	 */
205 205
 	public function append($to, $element, $immediatly=false) {
206
-		return $this->_genericCallElement('append',$to, $element, $immediatly);
206
+		return $this->_genericCallElement('append', $to, $element, $immediatly);
207 207
 	}
208 208
 
209 209
 	/**
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 * @return string
215 215
 	 */
216 216
 	public function prepend($to, $element, $immediatly=false) {
217
-		return $this->_genericCallElement('prepend',$to, $element, $immediatly);
217
+		return $this->_genericCallElement('prepend', $to, $element, $immediatly);
218 218
 	}
219 219
 
220 220
 	/**
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 * @return string
228 228
 	 */
229 229
 	public function fadeIn($element='this', $speed='', $callback='', $immediatly=false) {
230
-		return $this->_showHideWithEffect("fadeIn",$element,$speed,$callback,$immediatly);
230
+		return $this->_showHideWithEffect("fadeIn", $element, $speed, $callback, $immediatly);
231 231
 	}
232 232
 
233 233
 	/**
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 * @return string
241 241
 	 */
242 242
 	public function fadeOut($element='this', $speed='', $callback='', $immediatly=false) {
243
-		return $this->_showHideWithEffect("fadeOut",$element,$speed,$callback,$immediatly);
243
+		return $this->_showHideWithEffect("fadeOut", $element, $speed, $callback, $immediatly);
244 244
 	}
245 245
 
246 246
 	/**
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 * @return string
254 254
 	 */
255 255
 	public function slideUp($element='this', $speed='', $callback='', $immediatly=false) {
256
-		return $this->_showHideWithEffect("slideUp",$element,$speed,$callback,$immediatly);
256
+		return $this->_showHideWithEffect("slideUp", $element, $speed, $callback, $immediatly);
257 257
 	}
258 258
 
259 259
 	/**
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 	 * @return string
266 266
 	 */
267 267
 	public function removeClass($element='this', $class='', $immediatly=false) {
268
-		return $this->_genericCallValue('removeClass',$element, $class, $immediatly);
268
+		return $this->_genericCallValue('removeClass', $element, $class, $immediatly);
269 269
 	}
270 270
 
271 271
 	/**
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * @return string
279 279
 	 */
280 280
 	public function slideDown($element='this', $speed='', $callback='', $immediatly=false) {
281
-		return $this->_showHideWithEffect("slideDown",$element,$speed,$callback,$immediatly);
281
+		return $this->_showHideWithEffect("slideDown", $element, $speed, $callback, $immediatly);
282 282
 	}
283 283
 
284 284
 	/**
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @return string
292 292
 	 */
293 293
 	public function slideToggle($element='this', $speed='', $callback='', $immediatly=false) {
294
-		return $this->_showHideWithEffect("slideToggle",$element,$speed,$callback,$immediatly);
294
+		return $this->_showHideWithEffect("slideToggle", $element, $speed, $callback, $immediatly);
295 295
 	}
296 296
 
297 297
 	/**
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	 * @return string
305 305
 	 */
306 306
 	public function hide($element='this', $speed='', $callback='', $immediatly=false) {
307
-		return $this->_showHideWithEffect("hide",$element,$speed,$callback,$immediatly);
307
+		return $this->_showHideWithEffect("hide", $element, $speed, $callback, $immediatly);
308 308
 	}
309 309
 
310 310
 	/**
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 * @return string
318 318
 	 */
319 319
 	public function toggle($element='this', $speed='', $callback='', $immediatly=false) {
320
-		return $this->_showHideWithEffect("toggle",$element,$speed,$callback,$immediatly);
320
+		return $this->_showHideWithEffect("toggle", $element, $speed, $callback, $immediatly);
321 321
 	}
322 322
 
323 323
 	/**
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 	 * @return string
330 330
 	 */
331 331
 	public function toggleClass($element='this', $class='', $immediatly=false) {
332
-		return $this->_genericCallValue('toggleClass',$element, $class, $immediatly);
332
+		return $this->_genericCallValue('toggleClass', $element, $class, $immediatly);
333 333
 	}
334 334
 
335 335
 	/**
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 	 * @return string
358 358
 	 */
359 359
 	public function show($element='this', $speed='', $callback='', $immediatly=false) {
360
-		return $this->_showHideWithEffect("show",$element,$speed,$callback,$immediatly);
360
+		return $this->_showHideWithEffect("show", $element, $speed, $callback, $immediatly);
361 361
 	}
362 362
 
363 363
 	/**
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
 	 */
370 370
 	public function sortable($element, $options=array()) {
371 371
 		if (count($options)>0) {
372
-			$sort_options=array ();
373
-			foreach ( $options as $k => $v ) {
372
+			$sort_options=array();
373
+			foreach ($options as $k => $v) {
374 374
 				$sort_options[]="\n\t\t".$k.': '.$v."";
375 375
 			}
376 376
 			$sort_options=implode(",", $sort_options);
@@ -467,8 +467,8 @@  discard block
 block discarded – undo
467 467
 	 * @param boolean $immediatly
468 468
 	 * @return string
469 469
 	 */
470
-	private function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="",$immediatly=true) {
471
-		return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation,$immediatly);
470
+	private function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="", $immediatly=true) {
471
+		return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation, $immediatly);
472 472
 	}
473 473
 
474 474
 	/**
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 		$preventDefault=false;
487 487
 		$immediatly=true;
488 488
 		extract($parameters);
489
-		return $this->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback,$immediatly);
489
+		return $this->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback, $immediatly);
490 490
 	}
491 491
 
492 492
 	/**
@@ -527,11 +527,11 @@  discard block
 block discarded – undo
527 527
 		$preventDefault=false;
528 528
 		$immediatly=true;
529 529
 		extract($parameters);
530
-		$script=$this->_add_event($element, $this->exec($js), $event, $preventDefault, $stopPropagation,$immediatly);
530
+		$script=$this->_add_event($element, $this->exec($js), $event, $preventDefault, $stopPropagation, $immediatly);
531 531
 		return $script;
532 532
 	}
533 533
 	
534
-	public function setJsonToElement($json,$elementClass="_element",$immediatly=true){
534
+	public function setJsonToElement($json, $elementClass="_element", $immediatly=true) {
535 535
 		$retour="var data={$json};"
536 536
 				."\n\tdata=($.isPlainObject(data))?data:JSON.parse(data);"
537 537
 				."\n\tvar pk=data['pk'];var object=data['object'];"
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 				."\n\t});"
543 543
 				."\n}};\n";
544 544
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
545
-		return $this->exec($retour,$immediatly);
545
+		return $this->exec($retour, $immediatly);
546 546
 	}
547 547
 	
548 548
 	/**
@@ -550,10 +550,10 @@  discard block
 block discarded – undo
550 550
 	 * @param string $element The element selector
551 551
 	 * @param array $parameters default : array("attr"=>"id","preventDefault"=>false,"stopPropagation"=>false,"immediatly"=>true)
552 552
 	 */
553
-	public function setDraggable($element,$parameters=[]){
553
+	public function setDraggable($element, $parameters=[]) {
554 554
 		$attr="id";
555 555
 		extract($parameters);
556
-		$script=$this->_add_event($element, Javascript::draggable($attr), "dragstart",$parameters);
556
+		$script=$this->_add_event($element, Javascript::draggable($attr), "dragstart", $parameters);
557 557
 		return $script;
558 558
 	}
559 559
 	
@@ -563,13 +563,13 @@  discard block
 block discarded – undo
563 563
 	 * @param array $parameters default : array("attr"=>"id","stopPropagation"=>false,"immediatly"=>true,"jqueryDone"=>"append")
564 564
 	 * @param string $jsCallback the js script to call when element is dropped
565 565
 	 */
566
-	public function asDropZone($element,$jsCallback="",$parameters=[]){
566
+	public function asDropZone($element, $jsCallback="", $parameters=[]) {
567 567
 		$stopPropagation=false;
568 568
 		$immediatly=true;
569 569
 		$jqueryDone="append";
570
-		$script=$this->_add_event($element, '', "dragover",true,$stopPropagation,$immediatly);
570
+		$script=$this->_add_event($element, '', "dragover", true, $stopPropagation, $immediatly);
571 571
 		extract($parameters);
572
-		$script.=$this->_add_event($element, Javascript::dropZone($jqueryDone,$jsCallback), "drop",true,$stopPropagation,$immediatly);
572
+		$script.=$this->_add_event($element, Javascript::dropZone($jqueryDone, $jsCallback), "drop", true, $stopPropagation, $immediatly);
573 573
 		return $script;
574 574
 	}
575 575
 }
Please login to merge, or discard this patch.