Passed
Push — master ( 858380...1fb59e )
by Jean-Christophe
01:48
created
Ajax/semantic/html/collections/form/HtmlForm.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class HtmlForm extends HtmlSemCollection {
25 25
 
26
-	use FieldsTrait,FormTrait;
26
+	use FieldsTrait, FormTrait;
27 27
 	/**
28 28
 	 * @var array
29 29
 	 */
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 
39 39
 	public function __construct($identifier, $elements=array()) {
40 40
 		parent::__construct($identifier, "form", "ui form");
41
-		$this->_states=[ State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED ];
41
+		$this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED];
42 42
 		$this->setProperty("name", $this->identifier);
43
-		$this->_fields=array ();
43
+		$this->_fields=array();
44 44
 		$this->addItems($elements);
45 45
 		$this->_validationParams=[];
46 46
 		$this->_extraFieldRules=[];
47 47
 	}
48 48
 
49
-	protected function getForm(){
49
+	protected function getForm() {
50 50
 		return $this;
51 51
 	}
52 52
 
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	 * @param string $caption
69 69
 	 * @return HtmlForm
70 70
 	 */
71
-	public function addDivider($caption=NULL){
72
-		return $this->addContent(new HtmlDivider("",$caption));
71
+	public function addDivider($caption=NULL) {
72
+		return $this->addContent(new HtmlDivider("", $caption));
73 73
 	}
74 74
 
75 75
 	/**
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 						$label=NULL;
92 92
 				}
93 93
 				$this->_fields=\array_merge($this->_fields, $fields);
94
-				$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields);
94
+				$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields);
95 95
 			}
96
-			if (isset($label)){
97
-				$fields->wrap("<div class='field'><label>{$label}</label>","</div>");
96
+			if (isset($label)) {
97
+				$fields->wrap("<div class='field'><label>{$label}</label>", "</div>");
98 98
 			}
99 99
 		} else {
100
-			$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count());
100
+			$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count());
101 101
 		}
102 102
 		$this->addItem($fields);
103 103
 		return $fields;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
 	public function addItem($item) {
107 107
 		$item=parent::addItem($item);
108
-		if (\is_subclass_of($item, HtmlFormField::class) === true) {
108
+		if (\is_subclass_of($item, HtmlFormField::class)===true) {
109 109
 			$this->_fields[]=$item;
110 110
 		}
111 111
 		return $item;
@@ -163,49 +163,49 @@  discard block
 block discarded – undo
163 163
 
164 164
 
165 165
 
166
-	public function compile(JsUtils $js=NULL,&$view=NULL){
167
-		if(\sizeof($this->_validationParams)>0)
166
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
167
+		if (\sizeof($this->_validationParams)>0)
168 168
 			$this->setProperty("novalidate", "");
169
-		return parent::compile($js,$view);
169
+		return parent::compile($js, $view);
170 170
 	}
171 171
 
172 172
 	public function run(JsUtils $js) {
173
-		if(isset($js)){
173
+		if (isset($js)) {
174 174
 			$compo=$js->semantic()->form("#".$this->identifier);
175
-		}else{
175
+		} else {
176 176
 			$compo=new Form();
177 177
 			$compo->attach("#".$this->identifier);
178 178
 		}
179
-		foreach ($this->_fields as $field){
180
-			if($field instanceof HtmlFormField){
179
+		foreach ($this->_fields as $field) {
180
+			if ($field instanceof HtmlFormField) {
181 181
 				$this->addCompoValidation($compo, $field);
182 182
 			}
183 183
 		}
184
-		foreach ($this->content as $field){
185
-			if($field instanceof HtmlFormFields){
184
+		foreach ($this->content as $field) {
185
+			if ($field instanceof HtmlFormFields) {
186 186
 				$items=$field->getItems();
187
-				foreach ($items as $_field){
188
-					if($_field instanceof HtmlFormField)
187
+				foreach ($items as $_field) {
188
+					if ($_field instanceof HtmlFormField)
189 189
 						$this->addCompoValidation($compo, $_field);
190 190
 				}
191 191
 			}
192 192
 		}
193
-		foreach ($this->_extraFieldRules as $field=>$fieldValidation){
193
+		foreach ($this->_extraFieldRules as $field=>$fieldValidation) {
194 194
 			$this->addExtraCompoValidation($compo, $fieldValidation);
195 195
 		}
196
-		$this->_runValidationParams($compo,$js);
196
+		$this->_runValidationParams($compo, $js);
197 197
 		return $this->_bsComponent;
198 198
 	}
199 199
 	
200
-	public function getExtraFieldValidation($fieldname){
201
-		if(!isset($this->_extraFieldRules[$fieldname])){
200
+	public function getExtraFieldValidation($fieldname) {
201
+		if (!isset($this->_extraFieldRules[$fieldname])) {
202 202
 			$this->_extraFieldRules[$fieldname]=new FieldValidation($fieldname);
203 203
 		}
204 204
 		return $this->_extraFieldRules[$fieldname];
205 205
 	}
206 206
 
207
-	public function addValidationParam($paramName,$paramValue,$before="",$after=""){
208
-		$this->addBehavior($this->_validationParams, $paramName, $paramValue,$before,$after);
207
+	public function addValidationParam($paramName, $paramValue, $before="", $after="") {
208
+		$this->addBehavior($this->_validationParams, $paramName, $paramValue, $before, $after);
209 209
 		return $this;
210 210
 	}
211 211
 
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		return $this;
215 215
 	}
216 216
 	
217
-	public function hasValidationParams(){
217
+	public function hasValidationParams() {
218 218
 		return sizeof($this->_validationParams)>0;
219 219
 	}
220 220
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		return $this->_validationParams;
223 223
 	}
224 224
 
225
-	public function removeValidationParam($param){
225
+	public function removeValidationParam($param) {
226 226
 		unset($this->_validationParams[$param]);
227 227
 		return $this;
228 228
 	}
Please login to merge, or discard this patch.
Braces   +22 added lines, -15 removed lines patch added patch discarded remove patch
@@ -58,8 +58,9 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function addHeader($title, $niveau=1, $dividing=true) {
60 60
 		$header=new HtmlHeader("", $niveau, $title);
61
-		if ($dividing)
62
-			$header->setDividing();
61
+		if ($dividing) {
62
+					$header->setDividing();
63
+		}
63 64
 		return $this->addItem($header);
64 65
 	}
65 66
 
@@ -87,8 +88,9 @@  discard block
 block discarded – undo
87 88
 					if (\is_string($end)) {
88 89
 						$label=$end;
89 90
 						\array_pop($fields);
90
-					} else
91
-						$label=NULL;
91
+					} else {
92
+											$label=NULL;
93
+					}
92 94
 				}
93 95
 				$this->_fields=\array_merge($this->_fields, $fields);
94 96
 				$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields);
@@ -152,27 +154,31 @@  discard block
 block discarded – undo
152 154
 	 */
153 155
 	public function addMessage($identifier, $content, $header=NULL, $icon=NULL, $type=NULL) {
154 156
 		$message=new HtmlMessage($identifier, $content);
155
-		if (isset($header))
156
-			$message->addHeader($header);
157
-		if (isset($icon))
158
-			$message->setIcon($icon);
159
-		if (isset($type))
160
-			$message->setStyle($type);
157
+		if (isset($header)) {
158
+					$message->addHeader($header);
159
+		}
160
+		if (isset($icon)) {
161
+					$message->setIcon($icon);
162
+		}
163
+		if (isset($type)) {
164
+					$message->setStyle($type);
165
+		}
161 166
 		return $this->addItem($message);
162 167
 	}
163 168
 
164 169
 
165 170
 
166 171
 	public function compile(JsUtils $js=NULL,&$view=NULL){
167
-		if(\sizeof($this->_validationParams)>0)
168
-			$this->setProperty("novalidate", "");
172
+		if(\sizeof($this->_validationParams)>0) {
173
+					$this->setProperty("novalidate", "");
174
+		}
169 175
 		return parent::compile($js,$view);
170 176
 	}
171 177
 
172 178
 	public function run(JsUtils $js) {
173 179
 		if(isset($js)){
174 180
 			$compo=$js->semantic()->form("#".$this->identifier);
175
-		}else{
181
+		} else{
176 182
 			$compo=new Form();
177 183
 			$compo->attach("#".$this->identifier);
178 184
 		}
@@ -185,8 +191,9 @@  discard block
 block discarded – undo
185 191
 			if($field instanceof HtmlFormFields){
186 192
 				$items=$field->getItems();
187 193
 				foreach ($items as $_field){
188
-					if($_field instanceof HtmlFormField)
189
-						$this->addCompoValidation($compo, $_field);
194
+					if($_field instanceof HtmlFormField) {
195
+											$this->addCompoValidation($compo, $_field);
196
+					}
190 197
 				}
191 198
 			}
192 199
 		}
Please login to merge, or discard this patch.