Completed
Push — master ( ab500e...03e9d9 )
by Jean-Christophe
04:23
created
Ajax/semantic/widgets/base/FieldAsTrait.php 2 patches
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -25,23 +25,23 @@  discard block
 block discarded – undo
25 25
  * @property boolean $_edition
26 26
  * @property mixed _modelInstance
27 27
  */
28
-trait FieldAsTrait{
28
+trait FieldAsTrait {
29 29
 
30
-	abstract protected function _getFieldIdentifier($prefix,$name="");
31
-	abstract public function setValueFunction($index,$callback);
30
+	abstract protected function _getFieldIdentifier($prefix, $name="");
31
+	abstract public function setValueFunction($index, $callback);
32 32
 	abstract protected function _getFieldName($index);
33 33
 	abstract protected function _getFieldCaption($index);
34
-	abstract protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL);
34
+	abstract protected function _buttonAsSubmit(HtmlButton&$button, $event, $url, $responseElement=NULL, $parameters=NULL);
35 35
 
36 36
 	/**
37 37
 	 * @param HtmlFormField $element
38 38
 	 * @param array $attributes
39 39
 	 */
40
-	protected function _applyAttributes($element,&$attributes,$index){
41
-		if(isset($attributes["callback"])){
40
+	protected function _applyAttributes($element, &$attributes, $index) {
41
+		if (isset($attributes["callback"])) {
42 42
 			$callback=$attributes["callback"];
43
-			if(\is_callable($callback)){
44
-				$callback($element,$this->_modelInstance,$index);
43
+			if (\is_callable($callback)) {
44
+				$callback($element, $this->_modelInstance, $index);
45 45
 				unset($attributes["callback"]);
46 46
 			}
47 47
 		}
@@ -51,43 +51,43 @@  discard block
 block discarded – undo
51 51
 		$element->fromArray($attributes);
52 52
 	}
53 53
 
54
-	private function _getLabelField($caption,$icon=NULL){
55
-		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon);
54
+	private function _getLabelField($caption, $icon=NULL) {
55
+		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
56 56
 		return $label;
57 57
 	}
58 58
 
59 59
 
60
-	protected function _addRules($element,&$attributes){
61
-		if(isset($attributes["rules"])){
60
+	protected function _addRules($element, &$attributes) {
61
+		if (isset($attributes["rules"])) {
62 62
 			$rules=$attributes["rules"];
63
-			if(\is_array($rules)){
63
+			if (\is_array($rules)) {
64 64
 				$element->addRules($rules);
65 65
 			}
66
-			else{
66
+			else {
67 67
 				$element->addRule($rules);
68 68
 			}
69 69
 			unset($attributes["rules"]);
70 70
 		}
71 71
 	}
72 72
 
73
-	protected function _prepareFormFields(&$field,$name,&$attributes){
73
+	protected function _prepareFormFields(&$field, $name, &$attributes) {
74 74
 		$field->setName($name);
75 75
 		$this->_addRules($field, $attributes);
76 76
 		return $field;
77 77
 	}
78 78
 
79
-	protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){
80
-		$this->setValueFunction($index,function($value,$instance,$index) use (&$attributes,$elementCallback,$prefix){
79
+	protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) {
80
+		$this->setValueFunction($index, function($value, $instance, $index) use (&$attributes, $elementCallback, $prefix){
81 81
 			$caption=$this->_getFieldCaption($index);
82 82
 			$name=$this->_getFieldName($index);
83
-			$id=$this->_getFieldIdentifier($prefix,$name);
84
-			if(isset($attributes["name"])){
83
+			$id=$this->_getFieldIdentifier($prefix, $name);
84
+			if (isset($attributes["name"])) {
85 85
 				$name=$attributes["name"];
86 86
 				unset($attributes["name"]);
87 87
 			}
88
-			$element=$elementCallback($id,$name,$value,$caption);
89
-			if(\is_array($attributes)){
90
-				$this->_applyAttributes($element, $attributes,$index);
88
+			$element=$elementCallback($id, $name, $value, $caption);
89
+			if (\is_array($attributes)) {
90
+				$this->_applyAttributes($element, $attributes, $index);
91 91
 			}
92 92
 			$element->setDisabled(!$this->_edition);
93 93
 			return $element;
@@ -96,169 +96,169 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 
98 98
 
99
-	public function fieldAsProgress($index,$label=NULL, $attributes=array()){
100
-		$this->setValueFunction($index,function($value) use($label,$attributes){
101
-			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes);
99
+	public function fieldAsProgress($index, $label=NULL, $attributes=array()) {
100
+		$this->setValueFunction($index, function($value) use($label, $attributes){
101
+			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes);
102 102
 			return $pb;
103 103
 		});
104 104
 			return $this;
105 105
 	}
106 106
 
107
-	public function fieldAsRating($index,$max=5, $icon=""){
108
-		$this->setValueFunction($index,function($value) use($max,$icon){
109
-			$rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon);
107
+	public function fieldAsRating($index, $max=5, $icon="") {
108
+		$this->setValueFunction($index, function($value) use($max, $icon){
109
+			$rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon);
110 110
 			return $rating;
111 111
 		});
112 112
 			return $this;
113 113
 	}
114 114
 
115
-	public function fieldAsLabel($index,$icon=NULL){
116
-		$this->setValueFunction($index,function($caption) use($icon){
117
-			$lbl=$this->_getLabelField($caption,$icon);
115
+	public function fieldAsLabel($index, $icon=NULL) {
116
+		$this->setValueFunction($index, function($caption) use($icon){
117
+			$lbl=$this->_getLabelField($caption, $icon);
118 118
 			return $lbl;
119 119
 		});
120 120
 			return $this;
121 121
 	}
122 122
 
123
-	public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){
124
-		return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){
125
-			$header=new HtmlHeader($id,$niveau,$value);
126
-			if(isset($icon))
123
+	public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) {
124
+		return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){
125
+			$header=new HtmlHeader($id, $niveau, $value);
126
+			if (isset($icon))
127 127
 				$header->asIcon($icon, $value);
128 128
 			return $header;
129
-		}, $index,$attributes,"header");
129
+		}, $index, $attributes, "header");
130 130
 	}
131 131
 
132 132
 
133
-	public function fieldAsImage($index,$size=Size::MINI,$circular=false){
134
-		$this->setValueFunction($index,function($img) use($size,$circular){
135
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
133
+	public function fieldAsImage($index, $size=Size::MINI, $circular=false) {
134
+		$this->setValueFunction($index, function($img) use($size, $circular){
135
+			$image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular();
136 136
 			return $image;
137 137
 		});
138 138
 			return $this;
139 139
 	}
140 140
 
141
-	public function fieldAsAvatar($index,$attributes=NULL){
142
-		return $this->_fieldAs(function($id,$name,$value){
143
-			$img=new HtmlImage($id,$value);
141
+	public function fieldAsAvatar($index, $attributes=NULL) {
142
+		return $this->_fieldAs(function($id, $name, $value) {
143
+			$img=new HtmlImage($id, $value);
144 144
 			$img->asAvatar();
145 145
 			return $img;
146
-		}, $index,$attributes,"avatar");
146
+		}, $index, $attributes, "avatar");
147 147
 	}
148 148
 
149
-	public function fieldAsRadio($index,$attributes=NULL){
150
-		return $this->_fieldAs(function($id,$name,$value){
151
-			$input= new HtmlRadio($id,$name,$value,$value);
149
+	public function fieldAsRadio($index, $attributes=NULL) {
150
+		return $this->_fieldAs(function($id, $name, $value) {
151
+			$input=new HtmlRadio($id, $name, $value, $value);
152 152
 			return $input;
153
-		}, $index,$attributes,"radio");
153
+		}, $index, $attributes, "radio");
154 154
 	}
155 155
 
156
-	public function fieldAsRadios($index,$elements=[],$attributes=NULL){
157
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){
158
-			return HtmlFormFields::radios($name,$elements,$caption,$value);
159
-		}, $index,$attributes,"radios");
156
+	public function fieldAsRadios($index, $elements=[], $attributes=NULL) {
157
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){
158
+			return HtmlFormFields::radios($name, $elements, $caption, $value);
159
+		}, $index, $attributes, "radios");
160 160
 	}
161 161
 
162
-	public function fieldAsInput($index,$attributes=NULL){
163
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){
164
-			$input= new HtmlFormInput($id,$caption,"text",$value);
162
+	public function fieldAsInput($index, $attributes=NULL) {
163
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){
164
+			$input=new HtmlFormInput($id, $caption, "text", $value);
165 165
 			return $this->_prepareFormFields($input, $name, $attributes);
166
-		}, $index,$attributes,"input");
166
+		}, $index, $attributes, "input");
167 167
 	}
168 168
 
169
-	public function fieldAsTextarea($index,$attributes=NULL){
170
-		return $this->_fieldAs(function($id,$name,$value,$caption){
171
-			$textarea=new HtmlFormTextarea($id,$caption,$value);
169
+	public function fieldAsTextarea($index, $attributes=NULL) {
170
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
171
+			$textarea=new HtmlFormTextarea($id, $caption, $value);
172 172
 			$textarea->setName($name);
173 173
 			return $textarea;
174
-		}, $index,$attributes,"textarea");
174
+		}, $index, $attributes, "textarea");
175 175
 	}
176 176
 
177
-	public function fieldAsHidden($index,$attributes=NULL){
178
-		if(!\is_array($attributes)){
177
+	public function fieldAsHidden($index, $attributes=NULL) {
178
+		if (!\is_array($attributes)) {
179 179
 			$attributes=[];
180 180
 		}
181 181
 		$attributes["imputType"]="hidden";
182
-		return $this->fieldAsInput($index,$attributes);
182
+		return $this->fieldAsInput($index, $attributes);
183 183
 	}
184 184
 
185
-	public function fieldAsCheckbox($index,$attributes=NULL){
186
-		return $this->_fieldAs(function($id,$name,$value,$caption){
187
-			$input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier());
185
+	public function fieldAsCheckbox($index, $attributes=NULL) {
186
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
187
+			$input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier());
188 188
 			$input->setChecked(JString::isBooleanTrue($value));
189 189
 			$input->setName($name);
190 190
 			return $input;
191
-		}, $index,$attributes,"ck");
191
+		}, $index, $attributes, "ck");
192 192
 	}
193 193
 
194
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
195
-		return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple){
196
-			$dd=new HtmlFormDropdown($id,$elements,$caption,$value);
197
-			$dd->asSelect($name,$multiple);
194
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) {
195
+		return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple){
196
+			$dd=new HtmlFormDropdown($id, $elements, $caption, $value);
197
+			$dd->asSelect($name, $multiple);
198 198
 			return $dd;
199
-		}, $index,$attributes,"dd");
199
+		}, $index, $attributes, "dd");
200 200
 	}
201 201
 
202
-	public function fieldAsMessage($index,$attributes=NULL){
203
-		return $this->_fieldAs(function($id,$name,$value,$caption){
204
-			$mess= new HtmlMessage("message-".$id,$caption);
202
+	public function fieldAsMessage($index, $attributes=NULL) {
203
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
204
+			$mess=new HtmlMessage("message-".$id, $caption);
205 205
 			$mess->addHeader($value);
206 206
 			return $mess;
207
-		}, $index,$attributes,"message");
207
+		}, $index, $attributes, "message");
208 208
 	}
209 209
 
210
-	public function fieldAsLink($index,$attributes=NULL){
211
-		return $this->_fieldAs(function($id,$name,$value,$caption){
212
-			$lnk= new HtmlLink("message-".$id,"#",$caption);
210
+	public function fieldAsLink($index, $attributes=NULL) {
211
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
212
+			$lnk=new HtmlLink("message-".$id, "#", $caption);
213 213
 			return $lnk;
214
-		}, $index,$attributes,"link");
214
+		}, $index, $attributes, "link");
215 215
 	}
216 216
 
217 217
 	/**Change fields type
218 218
 	 * @param array $types an array or associative array $type=>$attributes
219 219
 	 */
220
-	public function fieldsAs(array $types){
220
+	public function fieldsAs(array $types) {
221 221
 		$i=0;
222
-		if(JArray::isAssociative($types)){
223
-			foreach ($types as $type=>$attributes){
224
-				if(\is_int($type))
225
-					$this->fieldAs($i++,$attributes,[]);
226
-				else{
227
-					$type=preg_replace('/\d/', '', $type );
228
-					$this->fieldAs($i++,$type,$attributes);
222
+		if (JArray::isAssociative($types)) {
223
+			foreach ($types as $type=>$attributes) {
224
+				if (\is_int($type))
225
+					$this->fieldAs($i++, $attributes, []);
226
+				else {
227
+					$type=preg_replace('/\d/', '', $type);
228
+					$this->fieldAs($i++, $type, $attributes);
229 229
 				}
230 230
 			}
231
-		}else{
232
-			foreach ($types as $type){
233
-				$this->fieldAs($i++,$type);
231
+		} else {
232
+			foreach ($types as $type) {
233
+				$this->fieldAs($i++, $type);
234 234
 			}
235 235
 		}
236 236
 	}
237 237
 
238
-	public function fieldAs($index,$type,$attributes=NULL){
238
+	public function fieldAs($index, $type, $attributes=NULL) {
239 239
 		$method="fieldAs".\ucfirst($type);
240
-		if(\method_exists($this, $method)){
241
-			if(!\is_array($attributes)){
240
+		if (\method_exists($this, $method)) {
241
+			if (!\is_array($attributes)) {
242 242
 				$attributes=[$index];
243
-			}else{
243
+			} else {
244 244
 				\array_unshift($attributes, $index);
245 245
 			}
246
-			\call_user_func_array([$this,$method], $attributes);
246
+			\call_user_func_array([$this, $method], $attributes);
247 247
 		}
248 248
 	}
249 249
 
250
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
251
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){
252
-			$button=new HtmlButton($id,$caption,$cssStyle);
253
-			$this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]);
250
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
251
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){
252
+			$button=new HtmlButton($id, $caption, $cssStyle);
253
+			$this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]);
254 254
 			return $button;
255
-		}, $index,$attributes,"submit");
255
+		}, $index, $attributes, "submit");
256 256
 	}
257 257
 
258
-	public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){
259
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){
260
-			$button=new HtmlButton($id,$value,$cssStyle);
258
+	public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) {
259
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){
260
+			$button=new HtmlButton($id, $value, $cssStyle);
261 261
 			return $button;
262
-		}, $index,$attributes,"button");
262
+		}, $index, $attributes, "button");
263 263
 	}
264 264
 }
265 265
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +12 added lines, -10 removed lines patch added patch discarded remove patch
@@ -62,8 +62,7 @@  discard block
 block discarded – undo
62 62
 			$rules=$attributes["rules"];
63 63
 			if(\is_array($rules)){
64 64
 				$element->addRules($rules);
65
-			}
66
-			else{
65
+			} else{
67 66
 				$element->addRule($rules);
68 67
 			}
69 68
 			unset($attributes["rules"]);
@@ -123,8 +122,9 @@  discard block
 block discarded – undo
123 122
 	public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){
124 123
 		return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){
125 124
 			$header=new HtmlHeader($id,$niveau,$value);
126
-			if(isset($icon))
127
-				$header->asIcon($icon, $value);
125
+			if(isset($icon)) {
126
+							$header->asIcon($icon, $value);
127
+			}
128 128
 			return $header;
129 129
 		}, $index,$attributes,"header");
130 130
 	}
@@ -132,7 +132,9 @@  discard block
 block discarded – undo
132 132
 
133 133
 	public function fieldAsImage($index,$size=Size::MINI,$circular=false){
134 134
 		$this->setValueFunction($index,function($img) use($size,$circular){
135
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
135
+			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) {
136
+				$image->setCircular();
137
+			}
136 138
 			return $image;
137 139
 		});
138 140
 			return $this;
@@ -221,14 +223,14 @@  discard block
 block discarded – undo
221 223
 		$i=0;
222 224
 		if(JArray::isAssociative($types)){
223 225
 			foreach ($types as $type=>$attributes){
224
-				if(\is_int($type))
225
-					$this->fieldAs($i++,$attributes,[]);
226
-				else{
226
+				if(\is_int($type)) {
227
+									$this->fieldAs($i++,$attributes,[]);
228
+				} else{
227 229
 					$type=preg_replace('/\d/', '', $type );
228 230
 					$this->fieldAs($i++,$type,$attributes);
229 231
 				}
230 232
 			}
231
-		}else{
233
+		} else{
232 234
 			foreach ($types as $type){
233 235
 				$this->fieldAs($i++,$type);
234 236
 			}
@@ -240,7 +242,7 @@  discard block
 block discarded – undo
240 242
 		if(\method_exists($this, $method)){
241 243
 			if(!\is_array($attributes)){
242 244
 				$attributes=[$index];
243
-			}else{
245
+			} else{
244 246
 				\array_unshift($attributes, $index);
245 247
 			}
246 248
 			\call_user_func_array([$this,$method], $attributes);
Please login to merge, or discard this patch.
Ajax/semantic/widgets/dataform/DataForm.php 2 patches
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -19,64 +19,64 @@  discard block
 block discarded – undo
19 19
 class DataForm extends Widget {
20 20
 
21 21
 	public function __construct($identifier, $modelInstance=NULL) {
22
-		parent::__construct($identifier, null,$modelInstance);
22
+		parent::__construct($identifier, null, $modelInstance);
23 23
 		$this->_form=new HtmlForm($identifier);
24 24
 		$this->_init(new FormInstanceViewer($identifier), "form", $this->_form, true);
25 25
 	}
26 26
 
27
-	protected function _getFieldIdentifier($prefix,$name=""){
27
+	protected function _getFieldIdentifier($prefix, $name="") {
28 28
 		return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier();
29 29
 	}
30 30
 
31
-	public function compile(JsUtils $js=NULL,&$view=NULL){
32
-		if(!$this->_generated){
31
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
32
+		if (!$this->_generated) {
33 33
 			$this->_instanceViewer->setInstance($this->_modelInstance);
34 34
 
35 35
 			$form=$this->content["form"];
36 36
 			$this->_generateContent($form);
37 37
 
38
-			if(isset($this->_toolbar)){
38
+			if (isset($this->_toolbar)) {
39 39
 				$this->_setToolbarPosition($form);
40 40
 			}
41
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]);
41
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]);
42 42
 			$this->_generated=true;
43 43
 		}
44
-		return parent::compile($js,$view);
44
+		return parent::compile($js, $view);
45 45
 	}
46 46
 
47 47
 	/**
48 48
 	 * @param HtmlForm $form
49 49
 	 */
50
-	protected function _generateContent($form){
51
-		$values= $this->_instanceViewer->getValues();
50
+	protected function _generateContent($form) {
51
+		$values=$this->_instanceViewer->getValues();
52 52
 		$count=$this->_instanceViewer->count();
53 53
 		$separators=$this->_instanceViewer->getSeparators();
54 54
 		$headers=$this->_instanceViewer->getHeaders();
55 55
 		$wrappers=$this->_instanceViewer->getWrappers();
56 56
 		\sort($separators);
57 57
 		$size=\sizeof($separators);
58
-		if($size===1){
59
-			foreach ($values as $v){
58
+		if ($size===1) {
59
+			foreach ($values as $v) {
60 60
 				$form->addField($v);
61 61
 			}
62
-		}else{
62
+		} else {
63 63
 			$separators[]=$count;
64
-			for($i=0;$i<$size;$i++){
64
+			for ($i=0; $i<$size; $i++) {
65 65
 				$wrapper=null;
66
-				$fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]);
67
-				if(isset($headers[$separators[$i]+1]))
68
-					$form->addHeader($headers[$separators[$i]+1],4,true);
69
-				if(isset($wrappers[$separators[$i]+1])){
66
+				$fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]);
67
+				if (isset($headers[$separators[$i]+1]))
68
+					$form->addHeader($headers[$separators[$i]+1], 4, true);
69
+				if (isset($wrappers[$separators[$i]+1])) {
70 70
 					$wrapper=$wrappers[$separators[$i]+1];
71 71
 				}
72 72
 				//TODO check why $fields is empty
73
-				if(\sizeof($fields)===1){
73
+				if (\sizeof($fields)===1) {
74 74
 					$added=$form->addField($fields[0]);
75
-				}elseif(\sizeof($fields)>1){
75
+				}elseif (\sizeof($fields)>1) {
76 76
 					$added=$form->addFields($fields);
77 77
 				}
78
-				if(isset($wrapper))
79
-					$added->wrap($wrapper[0],$wrapper[1]);
78
+				if (isset($wrapper))
79
+					$added->wrap($wrapper[0], $wrapper[1]);
80 80
 			}
81 81
 		}
82 82
 	}
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 	 * {@inheritDoc}
86 86
 	 * @see \Ajax\common\Widget::getForm()
87 87
 	 */
88
-	public function getForm(){
88
+	public function getForm() {
89 89
 		return $this->content["form"];
90 90
 	}
91 91
 
92
-	public function addSeparatorAfter($fieldNum){
92
+	public function addSeparatorAfter($fieldNum) {
93 93
 		$fieldNum=$this->_getIndex($fieldNum);
94 94
 		$this->_instanceViewer->addSeparatorAfter($fieldNum);
95 95
 		return $this;
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 		return $this;
105 105
 	}
106 106
 
107
-	public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){
108
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){
109
-			$button=new HtmlButton($id,$value,$cssStyle);
107
+	public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) {
108
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){
109
+			$button=new HtmlButton($id, $value, $cssStyle);
110 110
 			$button->setProperty("type", "reset");
111 111
 			return $button;
112
-		}, $index,$attributes);
112
+		}, $index, $attributes);
113 113
 	}
114 114
 
115 115
 	/**
@@ -128,19 +128,19 @@  discard block
 block discarded – undo
128 128
 		$this->content[$this->_toolbarPosition]=$this->_toolbar;
129 129
 	}
130 130
 
131
-	public function addDividerBefore($index,$title){
131
+	public function addDividerBefore($index, $title) {
132 132
 		$index=$this->_getIndex($index);
133 133
 		$this->_instanceViewer->addHeaderDividerBefore($index, $title);
134 134
 		return $this;
135 135
 	}
136 136
 
137
-	public function addWrapper($index,$contentBefore,$contentAfter=null){
137
+	public function addWrapper($index, $contentBefore, $contentAfter=null) {
138 138
 		$index=$this->_getIndex($index);
139
-		$this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter);
139
+		$this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter);
140 140
 		return $this;
141 141
 	}
142 142
 
143
-	public function run(JsUtils $js){
143
+	public function run(JsUtils $js) {
144 144
 		return parent::run($js);
145 145
 	}
146 146
 }
147 147
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -59,24 +59,26 @@
 block discarded – undo
59 59
 			foreach ($values as $v){
60 60
 				$form->addField($v);
61 61
 			}
62
-		}else{
62
+		} else{
63 63
 			$separators[]=$count;
64 64
 			for($i=0;$i<$size;$i++){
65 65
 				$wrapper=null;
66 66
 				$fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]);
67
-				if(isset($headers[$separators[$i]+1]))
68
-					$form->addHeader($headers[$separators[$i]+1],4,true);
67
+				if(isset($headers[$separators[$i]+1])) {
68
+									$form->addHeader($headers[$separators[$i]+1],4,true);
69
+				}
69 70
 				if(isset($wrappers[$separators[$i]+1])){
70 71
 					$wrapper=$wrappers[$separators[$i]+1];
71 72
 				}
72 73
 				//TODO check why $fields is empty
73 74
 				if(\sizeof($fields)===1){
74 75
 					$added=$form->addField($fields[0]);
75
-				}elseif(\sizeof($fields)>1){
76
+				} elseif(\sizeof($fields)>1){
76 77
 					$added=$form->addFields($fields);
77 78
 				}
78
-				if(isset($wrapper))
79
-					$added->wrap($wrapper[0],$wrapper[1]);
79
+				if(isset($wrapper)) {
80
+									$added->wrap($wrapper[0],$wrapper[1]);
81
+				}
80 82
 			}
81 83
 		}
82 84
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/business/user/FormLogin.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -10,50 +10,50 @@
 block discarded – undo
10 10
 	 * @param string $identifier
11 11
 	 * @param object $modelInstance
12 12
 	 */
13
-	public function __construct($identifier,$modelInstance=null,$fieldsOrder=[],$fieldsDefinition=[],$fields=[],$captions=[],$separators=[]) {
14
-		parent::__construct($identifier,$modelInstance,$fieldsOrder,$fieldsDefinition,$fields,$captions,$separators);
13
+	public function __construct($identifier, $modelInstance=null, $fieldsOrder=[], $fieldsDefinition=[], $fields=[], $captions=[], $separators=[]) {
14
+		parent::__construct($identifier, $modelInstance, $fieldsOrder, $fieldsDefinition, $fields, $captions, $separators);
15 15
 	}
16 16
 
17
-	protected function getDefaultModelInstance(){
17
+	protected function getDefaultModelInstance() {
18 18
 		return new UserModel();
19 19
 	}
20 20
 
21
-	public static function regular($identifier,$modelInstance=null){
22
-		return new FormLogin($identifier,$modelInstance,
23
-				["message","login","password","remember","forget","submit","error"],
24
-				["message"=>[["icon"=>"sign in"]],"input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"checkbox","link","submit"=>["green fluid"],"message2"=>[["error"=>true]]],
25
-				["Connection","login","password","remember","forget","submit","error"],
26
-				["Please enter login and password to connect","Login","Password","Remember me.","Forgot your password?","Connection"],
27
-				[0,2,4,5,6]);
21
+	public static function regular($identifier, $modelInstance=null) {
22
+		return new FormLogin($identifier, $modelInstance,
23
+				["message", "login", "password", "remember", "forget", "submit", "error"],
24
+				["message"=>[["icon"=>"sign in"]], "input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "checkbox", "link", "submit"=>["green fluid"], "message2"=>[["error"=>true]]],
25
+				["Connection", "login", "password", "remember", "forget", "submit", "error"],
26
+				["Please enter login and password to connect", "Login", "Password", "Remember me.", "Forgot your password?", "Connection"],
27
+				[0, 2, 4, 5, 6]);
28 28
 	}
29 29
 
30
-	public static function smallInline($identifier,$modelInstance=null){
31
-		$result=new FormLogin($identifier,$modelInstance,
32
-				["login","password","submit"],
33
-				["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]],
34
-				["login","password","submit"],
35
-				["","","Connection"],
30
+	public static function smallInline($identifier, $modelInstance=null) {
31
+		$result=new FormLogin($identifier, $modelInstance,
32
+				["login", "password", "submit"],
33
+				["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]],
34
+				["login", "password", "submit"],
35
+				["", "", "Connection"],
36 36
 				[2]);
37 37
 			$result->addDividerBefore(0, "Connection");
38 38
 		return $result;
39 39
 	}
40 40
 
41
-	public static function small($identifier,$modelInstance=null){
42
-		$result=new FormLogin($identifier,$modelInstance,
43
-				["login","password","submit"],
44
-				["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]],
45
-				["login","password","submit"],
46
-				["Login","Password","Connection"],
47
-				[1,2]);
41
+	public static function small($identifier, $modelInstance=null) {
42
+		$result=new FormLogin($identifier, $modelInstance,
43
+				["login", "password", "submit"],
44
+				["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]],
45
+				["login", "password", "submit"],
46
+				["Login", "Password", "Connection"],
47
+				[1, 2]);
48 48
 		$result->addDividerBefore(0, "Connection");
49 49
 		return $result;
50 50
 	}
51 51
 
52
-	public static function attachedSegment($identifier,$modelInstance=null){
53
-		$result=self::regular($identifier,$modelInstance);
54
-		$result->fieldAsMessage("message",["icon"=>"sign in","attached"=>true]);
55
-		$result->addWrapper("message",null,"<div class='ui attached segment'>");
56
-		$result->addWrapper("error", null,"</div>");
52
+	public static function attachedSegment($identifier, $modelInstance=null) {
53
+		$result=self::regular($identifier, $modelInstance);
54
+		$result->fieldAsMessage("message", ["icon"=>"sign in", "attached"=>true]);
55
+		$result->addWrapper("message", null, "<div class='ui attached segment'>");
56
+		$result->addWrapper("error", null, "</div>");
57 57
 		return $result;
58 58
 	}
59 59
 }
60 60
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/traits/SemanticWidgetsTrait.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 	 * @param array $instances
17 17
 	 * @return DataTable
18 18
 	 */
19
-	public function dataTable($identifier,$model, $instances){
20
-		return $this->addHtmlComponent(new DataTable($identifier,$model,$instances));
19
+	public function dataTable($identifier, $model, $instances) {
20
+		return $this->addHtmlComponent(new DataTable($identifier, $model, $instances));
21 21
 	}
22 22
 
23 23
 	/**
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 	 * @param object $instance
26 26
 	 * @return DataElement
27 27
 	 */
28
-	public function dataElement($identifier, $instance){
29
-		return $this->addHtmlComponent(new DataElement($identifier,$instance));
28
+	public function dataElement($identifier, $instance) {
29
+		return $this->addHtmlComponent(new DataElement($identifier, $instance));
30 30
 	}
31 31
 
32 32
 	/**
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 	 * @param object $instance
35 35
 	 * @return DataForm
36 36
 	 */
37
-	public function dataForm($identifier, $instance){
38
-		return $this->addHtmlComponent(new DataForm($identifier,$instance));
37
+	public function dataForm($identifier, $instance) {
38
+		return $this->addHtmlComponent(new DataForm($identifier, $instance));
39 39
 	}
40 40
 
41
-	public function defaultLogin($identifier,$instance=null){
42
-		return $this->addHtmlComponent(FormLogin::regular($identifier,$instance));
41
+	public function defaultLogin($identifier, $instance=null) {
42
+		return $this->addHtmlComponent(FormLogin::regular($identifier, $instance));
43 43
 	}
44 44
 
45
-	public function smallLogin($identifier,$instance=null){
46
-		return $this->addHtmlComponent(FormLogin::small($identifier,$instance));
45
+	public function smallLogin($identifier, $instance=null) {
46
+		return $this->addHtmlComponent(FormLogin::small($identifier, $instance));
47 47
 	}
48 48
 
49
-	public function segmentedLogin($identifier,$instance=null){
50
-		return $this->addHtmlComponent(FormLogin::attachedSegment($identifier,$instance));
49
+	public function segmentedLogin($identifier, $instance=null) {
50
+		return $this->addHtmlComponent(FormLogin::attachedSegment($identifier, $instance));
51 51
 	}
52 52
 }
53 53
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlFormCheckbox.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 class HtmlFormCheckbox extends HtmlFormField {
16 16
 	use CheckboxTrait;
17 17
 	public function __construct($identifier, $label=NULL, $value=NULL, $type=NULL) {
18
-		parent::__construct("field-".$identifier, new HtmlCheckbox($identifier,$label,$value,$type));
18
+		parent::__construct("field-".$identifier, new HtmlCheckbox($identifier, $label, $value, $type));
19 19
 		$this->_identifier=$identifier;
20 20
 	}
21 21
 
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlFormInput.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,17 +8,17 @@
 block discarded – undo
8 8
 class HtmlFormInput extends HtmlFormField {
9 9
 	use TextFieldsTrait;
10 10
 
11
-	public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) {
12
-		if(!isset($placeholder) && $type==="text")
11
+	public function __construct($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) {
12
+		if (!isset($placeholder) && $type==="text")
13 13
 			$placeholder=$label;
14
-		parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label);
14
+		parent::__construct("field-".$identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label);
15 15
 		$this->_identifier=$identifier;
16 16
 	}
17 17
 
18
-	public function getDataField(){
19
-		$field= $this->getField();
18
+	public function getDataField() {
19
+		$field=$this->getField();
20 20
 		//TODO check getField
21
-		if($field instanceof HtmlInput)
21
+		if ($field instanceof HtmlInput)
22 22
 			$field=$field->getDataField();
23 23
 		return $field;
24 24
 	}
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,8 +9,9 @@  discard block
 block discarded – undo
9 9
 	use TextFieldsTrait;
10 10
 
11 11
 	public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) {
12
-		if(!isset($placeholder) && $type==="text")
13
-			$placeholder=$label;
12
+		if(!isset($placeholder) && $type==="text") {
13
+					$placeholder=$label;
14
+		}
14 15
 		parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label);
15 16
 		$this->_identifier=$identifier;
16 17
 	}
@@ -18,8 +19,9 @@  discard block
 block discarded – undo
18 19
 	public function getDataField(){
19 20
 		$field= $this->getField();
20 21
 		//TODO check getField
21
-		if($field instanceof HtmlInput)
22
-			$field=$field->getDataField();
22
+		if($field instanceof HtmlInput) {
23
+					$field=$field->getDataField();
24
+		}
23 25
 		return $field;
24 26
 	}
25 27
 }
26 28
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlFormTextarea.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 class HtmlFormTextarea extends HtmlFormField {
10 10
 	use TextFieldsTrait;
11 11
 
12
-	public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) {
13
-		if(!isset($placeholder))
12
+	public function __construct($identifier, $label=NULL, $value=NULL, $placeholder=NULL, $rows=NULL) {
13
+		if (!isset($placeholder))
14 14
 			$placeholder=$label;
15
-		parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label);
15
+		parent::__construct("field-".$identifier, new HtmlTextarea($identifier, $value, $placeholder, $rows), $label);
16 16
 		$this->_identifier=$identifier;
17 17
 	}
18 18
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * Defines the textarea row count
21 21
 	 * @param int $count
22 22
 	 */
23
-	public function setRows($count){
23
+	public function setRows($count) {
24 24
 		$this->getField()->setRows($count);
25 25
 	}
26 26
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		return $this->content["field"];
29 29
 	}
30 30
 
31
-	public function setName($name){
32
-		$this->getDataField()->setProperty("name",$name);
31
+	public function setName($name) {
32
+		$this->getDataField()->setProperty("name", $name);
33 33
 	}
34 34
 }
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,9 @@
 block discarded – undo
10 10
 	use TextFieldsTrait;
11 11
 
12 12
 	public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) {
13
-		if(!isset($placeholder))
14
-			$placeholder=$label;
13
+		if(!isset($placeholder)) {
14
+					$placeholder=$label;
15
+		}
15 16
 		parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label);
16 17
 		$this->_identifier=$identifier;
17 18
 	}
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlFormDropdown.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,26 +7,26 @@
 block discarded – undo
7 7
 
8 8
 class HtmlFormDropdown extends HtmlFormField {
9 9
 
10
-	public function __construct($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false,$associative=true) {
11
-		parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label);
10
+	public function __construct($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false, $associative=true) {
11
+		parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label);
12 12
 		$this->_identifier=$identifier;
13 13
 	}
14 14
 
15
-	public function setItems($items){
15
+	public function setItems($items) {
16 16
 		return $this->getField()->setItems($items);
17 17
 	}
18
-	public function addItem($item,$value=NULL,$image=NULL){
19
-		return $this->getField()->addItem($item,$value,$image);
18
+	public function addItem($item, $value=NULL, $image=NULL) {
19
+		return $this->getField()->addItem($item, $value, $image);
20 20
 	}
21
-	public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$associative=true){
22
-		return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative);
21
+	public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $associative=true) {
22
+		return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative);
23 23
 	}
24 24
 
25
-	public function getDataField(){
25
+	public function getDataField() {
26 26
 		return $this->getField()->getInput();
27 27
 	}
28
-	public function asSelect($name=NULL,$multiple=false,$selection=true){
29
-		$this->getField()->asSelect($name,$multiple,$selection);
28
+	public function asSelect($name=NULL, $multiple=false, $selection=true) {
29
+		$this->getField()->asSelect($name, $multiple, $selection);
30 30
 		return $this;
31 31
 	}
32 32
 }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/html/elements/HtmlInput.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,14 +10,14 @@  discard block
 block discarded – undo
10 10
 use Ajax\JsUtils;
11 11
 
12 12
 class HtmlInput extends HtmlSemDoubleElement {
13
-	use IconTrait,TextFieldsTrait,FieldTrait;
13
+	use IconTrait, TextFieldsTrait, FieldTrait;
14 14
 
15 15
 	public function __construct($identifier, $type="text", $value="", $placeholder="") {
16
-		parent::__construct("div-" . $identifier, "div", "ui input");
16
+		parent::__construct("div-".$identifier, "div", "ui input");
17 17
 		$this->_identifier=$identifier;
18
-		$this->content=[ "field" => new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder) ];
19
-		$this->_states=[ State::DISABLED,State::FOCUS,State::ERROR ];
20
-		$this->_variations=[ Variation::TRANSPARENT ];
18
+		$this->content=["field" => new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder)];
19
+		$this->_states=[State::DISABLED, State::FOCUS, State::ERROR];
20
+		$this->_variations=[Variation::TRANSPARENT];
21 21
 	}
22 22
 
23 23
 	public function getField() {
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 
38 38
 	public function run(JsUtils $js) {
39 39
 		$result=parent::run($js);
40
-		$result->attach("#" . $this->getDataField()->getIdentifier());
40
+		$result->attach("#".$this->getDataField()->getIdentifier());
41 41
 		return $result;
42 42
 	}
43 43
 
44
-	public function setTransparent(){
44
+	public function setTransparent() {
45 45
 		return $this->addToProperty("class", "transparent");
46 46
 	}
47 47
 }
48 48
\ No newline at end of file
Please login to merge, or discard this patch.