Completed
Push — master ( c0f044...c6c18d )
by Jean-Christophe
03:25
created
Ajax/semantic/html/collections/form/HtmlForm.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -11,57 +11,57 @@  discard block
 block discarded – undo
11 11
  * @author jc
12 12
  * @version 1.001
13 13
  */
14
-class HtmlForm extends HtmlSemCollection{
14
+class HtmlForm extends HtmlSemCollection {
15 15
 
16 16
 	use FieldsTrait;
17 17
 
18 18
 	protected $_fields;
19 19
 
20
-	public function __construct( $identifier, $elements=array()){
21
-		parent::__construct( $identifier, "form", "ui form");
20
+	public function __construct($identifier, $elements=array()) {
21
+		parent::__construct($identifier, "form", "ui form");
22 22
 		$this->setProperty("name", $this->identifier);
23 23
 		$this->_fields=array();
24 24
 		$this->addItems($elements);
25 25
 	}
26 26
 
27
-	public function addHeader($title,$niveau=1,$dividing=true){
28
-		$header=new HtmlHeader("",$niveau,$title);
29
-		if($dividing)
27
+	public function addHeader($title, $niveau=1, $dividing=true) {
28
+		$header=new HtmlHeader("", $niveau, $title);
29
+		if ($dividing)
30 30
 			$header->setDividing();
31 31
 		return $this->addItem($header);
32 32
 	}
33 33
 
34
-	public function addFields($fields,$label=NULL){
35
-		if(!$fields instanceof HtmlFormFields){
36
-			if(\is_array($fields)===false){
37
-				$fields = \func_get_args();
34
+	public function addFields($fields, $label=NULL) {
35
+		if (!$fields instanceof HtmlFormFields) {
36
+			if (\is_array($fields)===false) {
37
+				$fields=\func_get_args();
38 38
 				$end=\end($fields);
39
-				if(\is_string($end)){
39
+				if (\is_string($end)) {
40 40
 					$label=$end;
41 41
 					\array_pop($fields);
42 42
 				}else $label=NULL;
43 43
 			}
44
-			$this->_fields=\array_merge($this->_fields,$fields);
45
-			$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(),$fields);
44
+			$this->_fields=\array_merge($this->_fields, $fields);
45
+			$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields);
46 46
 		}
47
-		if(isset($label))
48
-		 $fields=new HtmlFormField("", $fields,$label);
47
+		if (isset($label))
48
+		 $fields=new HtmlFormField("", $fields, $label);
49 49
 		$this->addItem($fields);
50 50
 		return $fields;
51 51
 	}
52 52
 
53
-	public function addItem($item){
53
+	public function addItem($item) {
54 54
 		$item=parent::addItem($item);
55
-		if(\is_subclass_of($item, HtmlFormField::class)===true){
55
+		if (\is_subclass_of($item, HtmlFormField::class)===true) {
56 56
 			$this->_fields[]=$item;
57 57
 		}
58 58
 		return $item;
59 59
 	}
60 60
 
61
-	public function getField($index){
62
-		if(\is_string($index)){
61
+	public function getField($index) {
62
+		if (\is_string($index)) {
63 63
 			$field=$this->getElementById($index, $this->_fields);
64
-		}else{
64
+		}else {
65 65
 			$field=$this->_fields[$index];
66 66
 		}
67 67
 		return $field;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * automatically divide fields to be equal width
72 72
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
73 73
 	 */
74
-	public function setEqualWidth(){
74
+	public function setEqualWidth() {
75 75
 		return $this->addToProperty("class", "equal width");
76 76
 	}
77 77
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @param HtmlFormField $field
81 81
 	 * @return \Ajax\common\html\HtmlDoubleElement
82 82
 	 */
83
-	public function addField($field){
83
+	public function addField($field) {
84 84
 		return $this->addItem($field);
85 85
 	}
86 86
 
@@ -91,23 +91,23 @@  discard block
 block discarded – undo
91 91
 	 * @param string $icon
92 92
 	 * @return \Ajax\semantic\html\collections\HtmlMessage
93 93
 	 */
94
-	public function addMessage($identifier,$content,$header=NULL,$icon=NULL){
95
-		$message=new HtmlMessage($identifier,$content);
96
-		if(isset($header))
94
+	public function addMessage($identifier, $content, $header=NULL, $icon=NULL) {
95
+		$message=new HtmlMessage($identifier, $content);
96
+		if (isset($header))
97 97
 			$message->addHeader($header);
98
-		if(isset($icon))
98
+		if (isset($icon))
99 99
 			$message->setIcon($icon);
100 100
 		return $this->addItem($message);
101 101
 	}
102 102
 
103
-	public function addInputs($inputs,$fieldslabel=null){
103
+	public function addInputs($inputs, $fieldslabel=null) {
104 104
 		$fields=array();
105
-		foreach ($inputs as $input){
105
+		foreach ($inputs as $input) {
106 106
 			\extract($input);
107
-			$f=new HtmlFormInput("","");
107
+			$f=new HtmlFormInput("", "");
108 108
 			$f->fromArray($input);
109 109
 			$fields[]=$f;
110 110
 		}
111
-		return $this->addFields($fields,$fieldslabel);
111
+		return $this->addFields($fields, $fieldslabel);
112 112
 	}
113 113
 }
114 114
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +16 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,8 +26,9 @@  discard block
 block discarded – undo
26 26
 
27 27
 	public function addHeader($title,$niveau=1,$dividing=true){
28 28
 		$header=new HtmlHeader("",$niveau,$title);
29
-		if($dividing)
30
-			$header->setDividing();
29
+		if($dividing) {
30
+					$header->setDividing();
31
+		}
31 32
 		return $this->addItem($header);
32 33
 	}
33 34
 
@@ -39,13 +40,16 @@  discard block
 block discarded – undo
39 40
 				if(\is_string($end)){
40 41
 					$label=$end;
41 42
 					\array_pop($fields);
42
-				}else $label=NULL;
43
+				} else {
44
+					$label=NULL;
45
+				}
43 46
 			}
44 47
 			$this->_fields=\array_merge($this->_fields,$fields);
45 48
 			$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(),$fields);
46 49
 		}
47
-		if(isset($label))
48
-		 $fields=new HtmlFormField("", $fields,$label);
50
+		if(isset($label)) {
51
+				 $fields=new HtmlFormField("", $fields,$label);
52
+		}
49 53
 		$this->addItem($fields);
50 54
 		return $fields;
51 55
 	}
@@ -61,7 +65,7 @@  discard block
 block discarded – undo
61 65
 	public function getField($index){
62 66
 		if(\is_string($index)){
63 67
 			$field=$this->getElementById($index, $this->_fields);
64
-		}else{
68
+		} else{
65 69
 			$field=$this->_fields[$index];
66 70
 		}
67 71
 		return $field;
@@ -93,10 +97,12 @@  discard block
 block discarded – undo
93 97
 	 */
94 98
 	public function addMessage($identifier,$content,$header=NULL,$icon=NULL){
95 99
 		$message=new HtmlMessage($identifier,$content);
96
-		if(isset($header))
97
-			$message->addHeader($header);
98
-		if(isset($icon))
99
-			$message->setIcon($icon);
100
+		if(isset($header)) {
101
+					$message->addHeader($header);
102
+		}
103
+		if(isset($icon)) {
104
+					$message->setIcon($icon);
105
+		}
100 106
 		return $this->addItem($message);
101 107
 	}
102 108
 
Please login to merge, or discard this patch.