Completed
Push — master ( 41f0f3...f58e0b )
by Jean-Christophe
03:38
created
Ajax/semantic/html/collections/form/traits/FormTrait.php 2 patches
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
 
49 49
 	public function setAttached($value=true){
50 50
 		$form=$this->getForm();
51
-		if($value)
52
-			$form->addToPropertyCtrl("class", "attached", array ("attached" ));
51
+		if($value) {
52
+					$form->addToPropertyCtrl("class", "attached", array ("attached" ));
53
+		}
53 54
 		return $form;
54 55
 	}
55 56
 
@@ -91,8 +92,9 @@  discard block
 block discarded – undo
91 92
 		if(isset($url) && isset($responseElement)){
92 93
 			$button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true);
93 94
 			$params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true];
94
-			if(\is_array($parameters))
95
-				$params=\array_merge($params,$parameters);
95
+			if(\is_array($parameters)) {
96
+							$params=\array_merge($params,$parameters);
97
+			}
96 98
 			$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params));
97 99
 		}
98 100
 		return $button;
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -12,28 +12,28 @@  discard block
 block discarded – undo
12 12
  * @author jc
13 13
  *
14 14
  */
15
-trait FormTrait{
15
+trait FormTrait {
16 16
 
17 17
 	/**
18 18
 	 * @return HtmlForm
19 19
 	 */
20 20
 	abstract protected function getForm();
21 21
 
22
-	protected function addCompoValidation($compo,$field){
22
+	protected function addCompoValidation($compo, $field) {
23 23
 		$validation=$field->getValidation();
24
-		if(isset($validation)){
24
+		if (isset($validation)) {
25 25
 			$validation->setIdentifier($field->getDataField()->getIdentifier());
26 26
 			$compo->addFieldValidation($validation);
27 27
 		}
28 28
 		return $compo;
29 29
 	}
30 30
 
31
-	protected function _runValidationParams(&$compo,JsUtils $js=NULL){
31
+	protected function _runValidationParams(&$compo, JsUtils $js=NULL) {
32 32
 		$form=$this->getForm();
33 33
 		$params=$form->getValidationParams();
34
-		if(isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall){
34
+		if (isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall) {
35 35
 			$compilation=$params["_ajaxSubmit"]->compile($js);
36
-			$compilation=str_ireplace("\"","%quote%", $compilation);
36
+			$compilation=str_ireplace("\"", "%quote%", $compilation);
37 37
 			$this->onSuccess($compilation);
38 38
 			$form->removeValidationParam("_ajaxSubmit");
39 39
 		}
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 		return $this;
52 52
 	}
53 53
 
54
-	public function setAttached($value=true){
54
+	public function setAttached($value=true) {
55 55
 		$form=$this->getForm();
56
-		if($value)
57
-			$form->addToPropertyCtrl("class", "attached", array ("attached" ));
56
+		if ($value)
57
+			$form->addToPropertyCtrl("class", "attached", array("attached"));
58 58
 		return $form;
59 59
 	}
60 60
 
61
-	public function addErrorMessage(){
61
+	public function addErrorMessage() {
62 62
 		return $this->getForm()->addContent((new HtmlMessage(""))->setError());
63 63
 	}
64 64
 
@@ -73,38 +73,38 @@  discard block
 block discarded – undo
73 73
 	 * @param string $responseElement
74 74
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
75 75
 	 */
76
-	public function submitOn($event,$identifier,$url,$responseElement){
76
+	public function submitOn($event, $identifier, $url, $responseElement) {
77 77
 		$form=$this->getForm();
78 78
 		$elem=$form->getElementById($identifier, $form->getContent());
79
-		if(isset($elem)){
80
-			$this->_buttonAsSubmit($elem, $event,$url,$responseElement);
79
+		if (isset($elem)) {
80
+			$this->_buttonAsSubmit($elem, $event, $url, $responseElement);
81 81
 		}
82 82
 		return $form;
83 83
 	}
84 84
 
85
-	public function submitOnClick($identifier,$url,$responseElement){
85
+	public function submitOnClick($identifier, $url, $responseElement) {
86 86
 		return $this->submitOn("click", $identifier, $url, $responseElement);
87 87
 	}
88 88
 
89
-	public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){
90
-		$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
91
-		return $this->_buttonAsSubmit($bt, "click",$url,$responseElement);
89
+	public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) {
90
+		$bt=$this->getForm()->addButton($identifier, $value, $cssStyle);
91
+		return $this->_buttonAsSubmit($bt, "click", $url, $responseElement);
92 92
 	}
93 93
 
94
-	protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL){
94
+	protected function _buttonAsSubmit(HtmlButton&$button, $event, $url, $responseElement=NULL, $parameters=NULL) {
95 95
 		$form=$this->getForm();
96
-		if(isset($url) && isset($responseElement)){
97
-			$button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true);
98
-			$params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true];
99
-			if(\is_array($parameters))
100
-				$params=\array_merge($params,$parameters);
96
+		if (isset($url) && isset($responseElement)) {
97
+			$button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');", true, true);
98
+			$params=["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url, "stopPropagation"=>true];
99
+			if (\is_array($parameters))
100
+				$params=\array_merge($params, $parameters);
101 101
 			$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params));
102 102
 		}
103 103
 		return $button;
104 104
 	}
105 105
 
106
-	public function addReset($identifier,$value,$cssStyle=NULL){
107
-		$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
106
+	public function addReset($identifier, $value, $cssStyle=NULL) {
107
+		$bt=$this->getForm()->addButton($identifier, $value, $cssStyle);
108 108
 		$bt->setProperty("type", "reset");
109 109
 		return $bt;
110 110
 	}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @param string $jsCode
115 115
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
116 116
 	 */
117
-	public function onValid($jsCode){
117
+	public function onValid($jsCode) {
118 118
 		$form=$this->getForm();
119 119
 		$form->addValidationParam("onValid", "%function(){".$jsCode."}%");
120 120
 		return $form;
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 	 * @param string $jsCode can use event and fields parameters
126 126
 	 * @return HtmlForm
127 127
 	 */
128
-	public function onSuccess($jsCode){
128
+	public function onSuccess($jsCode) {
129 129
 		$form=$this->getForm();
130
-		$form->addValidationParam("onSuccess", $jsCode,"%function(event,fields){","}%");
130
+		$form->addValidationParam("onSuccess", $jsCode, "%function(event,fields){", "}%");
131 131
 		return $form;
132 132
 	}
133 133
 }
134 134
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/FieldAsTrait.php 3 patches
Doc Comments   +14 added lines patch added patch discarded remove patch
@@ -28,9 +28,17 @@  discard block
 block discarded – undo
28 28
 trait FieldAsTrait{
29 29
 
30 30
 	abstract protected function _getFieldIdentifier($prefix,$name="");
31
+
32
+	/**
33
+	 * @param \Closure $callback
34
+	 */
31 35
 	abstract public function setValueFunction($index,$callback);
32 36
 	abstract protected function _getFieldName($index);
33 37
 	abstract protected function _getFieldCaption($index);
38
+
39
+	/**
40
+	 * @param string $event
41
+	 */
34 42
 	abstract protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL);
35 43
 
36 44
 	/**
@@ -70,6 +78,9 @@  discard block
 block discarded – undo
70 78
 		}
71 79
 	}
72 80
 
81
+	/**
82
+	 * @param HtmlFormInput $field
83
+	 */
73 84
 	protected function _prepareFormFields(&$field,$name,&$attributes){
74 85
 		$field->setName($name);
75 86
 		$this->_addRules($field, $attributes);
@@ -235,6 +246,9 @@  discard block
 block discarded – undo
235 246
 		}
236 247
 	}
237 248
 
249
+	/**
250
+	 * @param integer $index
251
+	 */
238 252
 	public function fieldAs($index,$type,$attributes=NULL){
239 253
 		$method="fieldAs".\ucfirst($type);
240 254
 		if(\method_exists($this, $method)){
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.
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["jsCallback"])){
40
+	protected function _applyAttributes($element, &$attributes, $index) {
41
+		if (isset($attributes["jsCallback"])) {
42 42
 			$callback=$attributes["jsCallback"];
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["jsCallback"]);
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.
Ajax/semantic/widgets/dataelement/DeInstanceViewer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@
 block discarded – undo
12 12
 		parent::__construct($identifier, $instance, $captions);
13 13
 	}
14 14
 
15
-	public function getValue($index){
15
+	public function getValue($index) {
16 16
 		$result=parent::getValue($index);
17
-		if($result instanceof HtmlFormField){
18
-			$lbl=new HtmlSemDoubleElement("lbl-".$this->widgetIdentifier."-".$index,"label","",$this->getCaption($index));
17
+		if ($result instanceof HtmlFormField) {
18
+			$lbl=new HtmlSemDoubleElement("lbl-".$this->widgetIdentifier."-".$index, "label", "", $this->getCaption($index));
19 19
 			$lbl->setProperty("for", $result->getDataField()->getIdentifier());
20 20
 			$this->captions[$index]=$lbl;
21 21
 		}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/dataelement/DataElement.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -18,49 +18,49 @@  discard block
 block discarded – undo
18 18
 class DataElement extends Widget {
19 19
 
20 20
 	public function __construct($identifier, $modelInstance=NULL) {
21
-		parent::__construct($identifier, null,$modelInstance);
22
-		$this->_init(new DeInstanceViewer($identifier), "table", new HtmlTable($identifier, 0,2), false);
21
+		parent::__construct($identifier, null, $modelInstance);
22
+		$this->_init(new DeInstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 2), false);
23 23
 		$this->content["table"]->setDefinition();
24 24
 	}
25 25
 
26
-	public function compile(JsUtils $js=NULL,&$view=NULL){
27
-		if(!$this->_generated){
26
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
27
+		if (!$this->_generated) {
28 28
 			$this->_instanceViewer->setInstance($this->_modelInstance);
29 29
 
30 30
 			$table=$this->content["table"];
31 31
 			$this->_generateContent($table);
32 32
 
33
-			if(isset($this->_toolbar)){
33
+			if (isset($this->_toolbar)) {
34 34
 				$this->_setToolbarPosition($table);
35 35
 			}
36
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
36
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
37 37
 			$this->_compileForm();
38 38
 			$this->_generated=true;
39 39
 		}
40
-		return parent::compile($js,$view);
40
+		return parent::compile($js, $view);
41 41
 	}
42 42
 
43 43
 	/**
44 44
 	 * @param HtmlTable $table
45 45
 	 */
46
-	protected function _generateContent($table){
47
-		$values= $this->_instanceViewer->getValues();
46
+	protected function _generateContent($table) {
47
+		$values=$this->_instanceViewer->getValues();
48 48
 		$captions=$this->_instanceViewer->getCaptions();
49 49
 		$count=$this->_instanceViewer->count();
50
-		for($i=0;$i<$count;$i++){
51
-			$table->addRow([$captions[$i],$values[$i]]);
50
+		for ($i=0; $i<$count; $i++) {
51
+			$table->addRow([$captions[$i], $values[$i]]);
52 52
 		}
53 53
 	}
54 54
 
55
-	protected function _getFieldName($index){
55
+	protected function _getFieldName($index) {
56 56
 		return $this->_instanceViewer->getFieldName($index);
57 57
 	}
58 58
 
59
-	protected function _getFieldCaption($index){
59
+	protected function _getFieldCaption($index) {
60 60
 		return null;
61 61
 	}
62 62
 
63
-	protected function _getFieldIdentifier($prefix,$name=""){
63
+	protected function _getFieldIdentifier($prefix, $name="") {
64 64
 		return $this->identifier."-{$prefix}-".$name;
65 65
 	}
66 66
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		return $this;
93 93
 	}
94 94
 
95
-	public function asForm(){
95
+	public function asForm() {
96 96
 		return $this->getForm();
97 97
 	}
98 98
 }
99 99
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/widgets/business/BusinessForm.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -15,6 +15,7 @@
 block discarded – undo
15 15
 	 * {@inheritdoc}
16 16
 	 *
17 17
 	 * @see \Ajax\semantic\widgets\dataform\DataForm::__construct()
18
+	 * @param string $identifier
18 19
 	 */
19 20
 	public function __construct($identifier,$modelInstance=null,$fieldsOrder,$fieldsDefinition,$fields=[],$captions=[],$separators=[]) {
20 21
 		if(!isset($modelInstance)){
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -16,17 +16,17 @@  discard block
 block discarded – undo
16 16
 	 *
17 17
 	 * @see \Ajax\semantic\widgets\dataform\DataForm::__construct()
18 18
 	 */
19
-	public function __construct($identifier,$modelInstance=null,$fieldsOrder,$fieldsDefinition,$fields=[],$captions=[],$separators=[]) {
20
-		if(!isset($modelInstance)){
19
+	public function __construct($identifier, $modelInstance=null, $fieldsOrder, $fieldsDefinition, $fields=[], $captions=[], $separators=[]) {
20
+		if (!isset($modelInstance)) {
21 21
 			$modelInstance=$this->getDefaultModelInstance();
22 22
 		}
23
-		parent::__construct($identifier,$modelInstance);
24
-		$this->_initForm($fieldsOrder, $fieldsDefinition,$fields,$captions,$separators);
23
+		parent::__construct($identifier, $modelInstance);
24
+		$this->_initForm($fieldsOrder, $fieldsDefinition, $fields, $captions, $separators);
25 25
 	}
26 26
 
27 27
 	abstract protected function getDefaultModelInstance();
28 28
 
29
-	protected function _initForm($fieldsOrder,$fieldsDefinition,$fields=[],$captions=[],$separators=[]){
29
+	protected function _initForm($fieldsOrder, $fieldsDefinition, $fields=[], $captions=[], $separators=[]) {
30 30
 		$this->_fieldsOrder=$fieldsOrder;
31 31
 		$this->setFields($fields);
32 32
 		$this->setSeparators($separators);
@@ -34,26 +34,26 @@  discard block
 block discarded – undo
34 34
 		$this->setCaptions($captions);
35 35
 	}
36 36
 
37
-	protected function _getIndex($fieldName){
37
+	protected function _getIndex($fieldName) {
38 38
 		$index=$fieldName;
39
-		if(\is_string($fieldName)){
39
+		if (\is_string($fieldName)) {
40 40
 			$index=\array_search($fieldName, $this->_fieldsOrder);
41 41
 		}
42 42
 		return $index;
43 43
 	}
44
-	protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){
44
+	protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) {
45 45
 		$index=$this->_getIndex($index);
46
-		return parent::_fieldAs($elementCallback, $index,$attributes,$prefix);
46
+		return parent::_fieldAs($elementCallback, $index, $attributes, $prefix);
47 47
 	}
48 48
 
49 49
 
50
-	public function removeField($fieldName){
50
+	public function removeField($fieldName) {
51 51
 		parent::removeField($fieldName);
52
-		\array_splice($this->_fieldsOrder,$this->_getIndex($fieldName),1);
52
+		\array_splice($this->_fieldsOrder, $this->_getIndex($fieldName), 1);
53 53
 		return $this;
54 54
 	}
55 55
 
56
-	public function compile(JsUtils $js=NULL,&$view=NULL){
57
-		return parent::compile($js,$view);
56
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
57
+		return parent::compile($js, $view);
58 58
 	}
59 59
 }
60 60
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/service/JString.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -2,51 +2,51 @@
 block discarded – undo
2 2
 namespace Ajax\service;
3 3
 class JString {
4 4
 
5
-	public static function contains($hay,$needle){
6
-		return strpos($hay, $needle) !== false;
5
+	public static function contains($hay, $needle) {
6
+		return strpos($hay, $needle)!==false;
7 7
 	}
8 8
 	public static function startswith($hay, $needle) {
9
-		return substr($hay, 0, strlen($needle)) === $needle;
9
+		return substr($hay, 0, strlen($needle))===$needle;
10 10
 	}
11 11
 
12 12
 	public static function endswith($hay, $needle) {
13
-		return substr($hay, -strlen($needle)) === $needle;
13
+		return substr($hay, -strlen($needle))===$needle;
14 14
 	}
15 15
 
16
-	public static function isNull($s){
16
+	public static function isNull($s) {
17 17
 		return (!isset($s) || NULL===$s || ""===$s);
18 18
 	}
19
-	public static function isNotNull($s){
19
+	public static function isNotNull($s) {
20 20
 		return (isset($s) && NULL!==$s && ""!==$s);
21 21
 	}
22 22
 
23
-	public static function isBoolean($value){
23
+	public static function isBoolean($value) {
24 24
 		return \is_bool($value) || $value==1 || $value==0;
25 25
 	}
26 26
 
27
-	public static function isBooleanTrue($value){
27
+	public static function isBooleanTrue($value) {
28 28
 		return $value==1 || $value;
29 29
 	}
30 30
 
31
-	public static function isBooleanFalse($value){
31
+	public static function isBooleanFalse($value) {
32 32
 		return $value==0 || !$value;
33 33
 	}
34 34
 
35
-	public static function camelCaseToSeparated($input,$separator=" "){
35
+	public static function camelCaseToSeparated($input, $separator=" ") {
36 36
 		return strtolower(preg_replace('/(?<!^)[A-Z]/', $separator.'$0', $input));
37 37
 	}
38 38
 
39
-	public static function replaceAtFirst($subject,$from, $to){
40
-		$from = '/\A'.preg_quote($from, '/').'/';
39
+	public static function replaceAtFirst($subject, $from, $to) {
40
+		$from='/\A'.preg_quote($from, '/').'/';
41 41
 		return \preg_replace($from, $to, $subject, 1);
42 42
 	}
43 43
 
44
-	public static function replaceAtLast($subject,$from, $to){
45
-		$from = '/'.preg_quote($from, '/').'\z/';
44
+	public static function replaceAtLast($subject, $from, $to) {
45
+		$from='/'.preg_quote($from, '/').'\z/';
46 46
 		return \preg_replace($from, $to, $subject, 1);
47 47
 	}
48 48
 
49
-	public static function replaceAtFirstAndLast($subject,$fromFirst,$toFirst,$fromLast,$toLast){
49
+	public static function replaceAtFirstAndLast($subject, $fromFirst, $toFirst, $fromLast, $toLast) {
50 50
 		$s=self::replaceAtFirst($subject, $fromFirst, $toFirst);
51 51
 		return self::replaceAtLast($s, $fromLast, $toLast);
52 52
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/dataform/FormInstanceViewer.php 2 patches
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,15 +47,17 @@
 block discarded – undo
47 47
 
48 48
 
49 49
 	public function addSeparatorAfter($fieldNum){
50
-		if(\array_search($fieldNum, $this->separators)===false)
51
-			$this->separators[]=$fieldNum;
50
+		if(\array_search($fieldNum, $this->separators)===false) {
51
+					$this->separators[]=$fieldNum;
52
+		}
52 53
 		return $this;
53 54
 	}
54 55
 
55 56
 	public function addHeaderDividerBefore($fieldNum,$header){
56 57
 		$this->headers[$fieldNum]=$header;
57
-		if($fieldNum>0)
58
-			$this->addSeparatorAfter($fieldNum-1);
58
+		if($fieldNum>0) {
59
+					$this->addSeparatorAfter($fieldNum-1);
60
+		}
59 61
 		return $this;
60 62
 	}
61 63
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -11,58 +11,58 @@  discard block
 block discarded – undo
11 11
 	protected $headers;
12 12
 	protected $wrappers;
13 13
 
14
-	public function __construct($identifier,$instance=NULL, $captions=NULL) {
15
-		parent::__construct($identifier,$instance=NULL, $captions=NULL);
14
+	public function __construct($identifier, $instance=NULL, $captions=NULL) {
15
+		parent::__construct($identifier, $instance=NULL, $captions=NULL);
16 16
 		$this->separators=[-1];
17 17
 		$this->headers=[];
18 18
 		$this->wrappers=[];
19
-		$this->defaultValueFunction=function($name,$value,$index){
19
+		$this->defaultValueFunction=function($name, $value, $index) {
20 20
 			$caption=$this->getCaption($index);
21
-			$input=new HtmlFormInput($this->widgetIdentifier."-".$name,$caption,"text",$value);
21
+			$input=new HtmlFormInput($this->widgetIdentifier."-".$name, $caption, "text", $value);
22 22
 			$input->setName($name);
23 23
 			return $input;
24 24
 		};
25 25
 	}
26 26
 
27
-	protected function _beforeAddProperty($index,&$field){
28
-		if(JString::endswith($field, "\n")===true){
27
+	protected function _beforeAddProperty($index, &$field) {
28
+		if (JString::endswith($field, "\n")===true) {
29 29
 			$this->addSeparatorAfter($index);
30 30
 		}
31
-		if($index>1 && JString::startswith($field, "\n")===true){
31
+		if ($index>1 && JString::startswith($field, "\n")===true) {
32 32
 			$this->addSeparatorAfter($index-1);
33 33
 		}
34 34
 		$field=\str_replace("\n", "", $field);
35
-		if(($header=$this->hasHeader($field))!==false){
35
+		if (($header=$this->hasHeader($field))!==false) {
36 36
 			$this->addHeaderDividerBefore($index, $header);
37 37
 		}
38 38
 	}
39 39
 
40
-	protected function hasHeader(&$field){
41
-		$matches=[];$result=false;
42
-		if(\preg_match('/\{(.*?)\}/s', $field, $matches)===1){
40
+	protected function hasHeader(&$field) {
41
+		$matches=[]; $result=false;
42
+		if (\preg_match('/\{(.*?)\}/s', $field, $matches)===1) {
43 43
 			$result=$matches[1];
44
-			$field=\str_replace("{".$result."}","", $field);
44
+			$field=\str_replace("{".$result."}", "", $field);
45 45
 		}
46 46
 		return $result;
47 47
 	}
48 48
 
49 49
 
50 50
 
51
-	public function addSeparatorAfter($fieldNum){
52
-		if(\array_search($fieldNum, $this->separators)===false)
51
+	public function addSeparatorAfter($fieldNum) {
52
+		if (\array_search($fieldNum, $this->separators)===false)
53 53
 			$this->separators[]=$fieldNum;
54 54
 		return $this;
55 55
 	}
56 56
 
57
-	public function addHeaderDividerBefore($fieldNum,$header){
57
+	public function addHeaderDividerBefore($fieldNum, $header) {
58 58
 		$this->headers[$fieldNum]=$header;
59
-		if($fieldNum>0)
59
+		if ($fieldNum>0)
60 60
 			$this->addSeparatorAfter($fieldNum-1);
61 61
 		return $this;
62 62
 	}
63 63
 
64
-	public function addWrapper($fieldNum,$contentBefore,$contentAfter=null){
65
-		$this->wrappers[$fieldNum]=[$contentBefore,$contentAfter];
64
+	public function addWrapper($fieldNum, $contentBefore, $contentAfter=null) {
65
+		$this->wrappers[$fieldNum]=[$contentBefore, $contentAfter];
66 66
 			return $this;
67 67
 	}
68 68
 
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
 		return $this->separators;
71 71
 	}
72 72
 
73
-	public function removeSeparator($index){
74
-		\array_splice($this->separators,$index,1);
73
+	public function removeSeparator($index) {
74
+		\array_splice($this->separators, $index, 1);
75 75
 	}
76 76
 
77
-	public function removeField($index){
77
+	public function removeField($index) {
78 78
 		parent::removeField($index);
79 79
 		$pos=\array_search($index, $this->separators);
80
-		if($pos!==false){
81
-			for($i=$pos+1;$i<\sizeof($this->separators);$i++){
80
+		if ($pos!==false) {
81
+			for ($i=$pos+1; $i<\sizeof($this->separators); $i++) {
82 82
 				$this->separators[$i]--;
83 83
 			}
84 84
 			\array_splice($this->separators, $pos, 1);
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlFormField.php 2 patches
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -14,34 +14,34 @@  discard block
 block discarded – undo
14 14
 	use FieldTrait;
15 15
 	protected $_container;
16 16
 	protected $_validation;
17
-	public function __construct($identifier, $field,$label=NULL) {
18
-		parent::__construct($identifier, "div","field");
17
+	public function __construct($identifier, $field, $label=NULL) {
18
+		parent::__construct($identifier, "div", "field");
19 19
 		$this->content=array();
20
-		$this->_states=[State::ERROR,State::DISABLED];
21
-		if(isset($label) && $label!=="")
20
+		$this->_states=[State::ERROR, State::DISABLED];
21
+		if (isset($label) && $label!=="")
22 22
 			$this->setLabel($label);
23 23
 		$this->setField($field);
24 24
 		$this->_validation=NULL;
25 25
 	}
26 26
 
27
-	public function addPointingLabel($label,$pointing=Direction::NONE){
28
-		$labelO=new HtmlLabel("",$label);
27
+	public function addPointingLabel($label, $pointing=Direction::NONE) {
28
+		$labelO=new HtmlLabel("", $label);
29 29
 		$labelO->setPointing($pointing);
30
-		$this->addContent($labelO,$pointing==="below" || $pointing==="right");
30
+		$this->addContent($labelO, $pointing==="below" || $pointing==="right");
31 31
 		return $labelO;
32 32
 	}
33 33
 
34
-	public function setLabel($label){
34
+	public function setLabel($label) {
35 35
 		$labelO=$label;
36
-		if(\is_string($label)){
37
-			$labelO=new HtmlSemDoubleElement("","label","");
36
+		if (\is_string($label)) {
37
+			$labelO=new HtmlSemDoubleElement("", "label", "");
38 38
 			$labelO->setContent($label);
39
-			$labelO->setProperty("for", \str_replace("field-", "",$this->identifier));
39
+			$labelO->setProperty("for", \str_replace("field-", "", $this->identifier));
40 40
 		}
41 41
 		$this->content["label"]=$labelO;
42 42
 	}
43 43
 
44
-	public function setField($field){
44
+	public function setField($field) {
45 45
 		$this->content["field"]=$field;
46 46
 	}
47 47
 
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	 * Returns the label or null
50 50
 	 * @return mixed
51 51
 	 */
52
-	public function getLabel(){
53
-		if(\array_key_exists("label", $this->content))
52
+	public function getLabel() {
53
+		if (\array_key_exists("label", $this->content))
54 54
 			return $this->content["label"];
55 55
 	}
56 56
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 * Return the field
59 59
 	 * @return mixed
60 60
 	 */
61
-	public function getField(){
61
+	public function getField() {
62 62
 		return $this->content["field"];
63 63
 	}
64 64
 
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
 	 * Return the field with data
67 67
 	 * @return mixed
68 68
 	 */
69
-	public function getDataField(){
69
+	public function getDataField() {
70 70
 		return $this->content["field"];
71 71
 	}
72 72
 
73 73
 	/**
74 74
 	 * puts the label before or behind
75 75
 	 */
76
-	public function swapLabel(){
76
+	public function swapLabel() {
77 77
 		$label=$this->getLabel();
78 78
 		unset($this->content["label"]);
79 79
 		$this->content["label"]=$label;
@@ -84,31 +84,31 @@  discard block
 block discarded – undo
84 84
 	 * @param int $width
85 85
 	 * @return \Ajax\semantic\html\collections\form\HtmlFormField
86 86
 	 */
87
-	public function setWidth($width){
88
-		if(\is_int($width)){
87
+	public function setWidth($width) {
88
+		if (\is_int($width)) {
89 89
 			$width=Wide::getConstants()["W".$width];
90 90
 		}
91 91
 		$this->addToPropertyCtrl("class", $width, Wide::getConstants());
92
-		if(isset($this->_container)){
92
+		if (isset($this->_container)) {
93 93
 			$this->_container->setEqualWidth(false);
94 94
 		}
95
-		return $this->addToPropertyCtrl("class", "wide",array("wide"));
95
+		return $this->addToPropertyCtrl("class", "wide", array("wide"));
96 96
 	}
97 97
 
98 98
 	/**
99 99
 	 * Field displays an error state
100 100
 	 * @return \Ajax\semantic\html\collections\form\HtmlFormField
101 101
 	 */
102
-	public function setError(){
102
+	public function setError() {
103 103
 		return $this->addToProperty("class", "error");
104 104
 	}
105 105
 
106
-	public function setInline(){
106
+	public function setInline() {
107 107
 		return $this->addToProperty("class", "inline");
108 108
 	}
109 109
 
110
-	public function jsState($state){
111
-		return $this->jsDoJquery("addClass",$state);
110
+	public function jsState($state) {
111
+		return $this->jsDoJquery("addClass", $state);
112 112
 	}
113 113
 
114 114
 	public function setContainer($_container) {
@@ -116,39 +116,39 @@  discard block
 block discarded – undo
116 116
 		return $this;
117 117
 	}
118 118
 
119
-	public function setReadonly(){
119
+	public function setReadonly() {
120 120
 		$this->getField()->setProperty("readonly", "");
121 121
 	}
122 122
 
123
-	public function addRule($type,$prompt=NULL,$value=NULL){
123
+	public function addRule($type, $prompt=NULL, $value=NULL) {
124 124
 		$field=$this->getDataField();
125
-		if(isset($field)){
126
-			if(!isset($this->_validation)){
125
+		if (isset($field)) {
126
+			if (!isset($this->_validation)) {
127 127
 				$this->_validation=new FieldValidation($field->getIdentifier());
128 128
 			}
129
-			if($type==="empty"){
130
-				$this->addToProperty("class","required");
129
+			if ($type==="empty") {
130
+				$this->addToProperty("class", "required");
131 131
 			}
132
-			$this->_validation->addRule($type,$prompt,$value);
132
+			$this->_validation->addRule($type, $prompt, $value);
133 133
 		}
134 134
 		return $this;
135 135
 	}
136 136
 
137
-	public function addRules(array $rules){
138
-		foreach ($rules as $rule){
137
+	public function addRules(array $rules) {
138
+		foreach ($rules as $rule) {
139 139
 			$this->addRule($rule);
140 140
 		}
141 141
 		return $this;
142 142
 	}
143 143
 
144
-	public function setRules(array $rules){
144
+	public function setRules(array $rules) {
145 145
 		$this->_validation=null;
146 146
 		return $this->addRules($rules);
147 147
 	}
148 148
 
149
-	public function addIcon($icon,$direction=Direction::LEFT){
149
+	public function addIcon($icon, $direction=Direction::LEFT) {
150 150
 		$field=$this->getField();
151
-		return $field->addIcon($icon,$direction);
151
+		return $field->addIcon($icon, $direction);
152 152
 	}
153 153
 
154 154
 	public function getValidation() {
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,8 +18,9 @@  discard block
 block discarded – undo
18 18
 		parent::__construct($identifier, "div","field");
19 19
 		$this->content=array();
20 20
 		$this->_states=[State::ERROR,State::DISABLED];
21
-		if(isset($label) && $label!=="")
22
-			$this->setLabel($label);
21
+		if(isset($label) && $label!=="") {
22
+					$this->setLabel($label);
23
+		}
23 24
 		$this->setField($field);
24 25
 		$this->_validation=NULL;
25 26
 	}
@@ -50,8 +51,9 @@  discard block
 block discarded – undo
50 51
 	 * @return mixed
51 52
 	 */
52 53
 	public function getLabel(){
53
-		if(\array_key_exists("label", $this->content))
54
-			return $this->content["label"];
54
+		if(\array_key_exists("label", $this->content)) {
55
+					return $this->content["label"];
56
+		}
55 57
 	}
56 58
 
57 59
 	/**
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.