Completed
Push — master ( 79b035...e37d9a )
by Jean-Christophe
03:44
created
Ajax/semantic/html/collections/form/HtmlFormFields.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -15,26 +15,26 @@  discard block
 block discarded – undo
15 15
 	protected $_equalWidth;
16 16
 	protected $_name;
17 17
 
18
-	public function __construct($identifier, $fields=array(),$equalWidth=true) {
18
+	public function __construct($identifier, $fields=array(), $equalWidth=true) {
19 19
 		parent::__construct($identifier, "div");
20 20
 		$this->_equalWidth=$equalWidth;
21 21
 		$this->addItems($fields);
22 22
 	}
23 23
 
24
-	public function addFields($fields=NULL,$label=NULL){
25
-		if(!$fields instanceof HtmlFormFields){
26
-			if(\is_array($fields)===false){
27
-				$fields = \func_get_args();
24
+	public function addFields($fields=NULL, $label=NULL) {
25
+		if (!$fields instanceof HtmlFormFields) {
26
+			if (\is_array($fields)===false) {
27
+				$fields=\func_get_args();
28 28
 				$end=\end($fields);
29
-				if(\is_string($end)){
29
+				if (\is_string($end)) {
30 30
 					$label=$end;
31 31
 					\array_pop($fields);
32 32
 				}else $label=NULL;
33 33
 			}
34 34
 		}
35
-		if(isset($label))
35
+		if (isset($label))
36 36
 			$this->setLabel($label);
37
-		foreach ($fields as $field){
37
+		foreach ($fields as $field) {
38 38
 			$this->addItem($field);
39 39
 		}
40 40
 		return $this;
@@ -44,39 +44,39 @@  discard block
 block discarded – undo
44 44
 	 * @param string|HtmlSemDoubleElement $label
45 45
 	 * @return \Ajax\semantic\html\base\HtmlSemDoubleElement
46 46
 	 */
47
-	public function setLabel($label){
47
+	public function setLabel($label) {
48 48
 		$labelO=$label;
49
-		if(\is_string($label)){
50
-			$labelO=new HtmlSemDoubleElement("","label","",$label);
49
+		if (\is_string($label)) {
50
+			$labelO=new HtmlSemDoubleElement("", "label", "", $label);
51 51
 		}
52
-		$this->insertItem($labelO,0);
52
+		$this->insertItem($labelO, 0);
53 53
 		return $labelO;
54 54
 	}
55
-	public function addItem($item){
55
+	public function addItem($item) {
56 56
 		$item=parent::addItem($item);
57 57
 		$item->setContainer($this);
58 58
 		return $item;
59 59
 	}
60
-	public function compile(JsUtils $js=NULL,View $view=NULL){
61
-		if($this->_equalWidth){
60
+	public function compile(JsUtils $js=NULL, View $view=NULL) {
61
+		if ($this->_equalWidth) {
62 62
 			$count=$this->count();
63 63
 			$this->addToProperty("class", Wide::getConstants()["W".$count]." fields");
64 64
 		}else
65
-			$this->addToProperty("class","fields");
66
-		return parent::compile($js,$view);
65
+			$this->addToProperty("class", "fields");
66
+		return parent::compile($js, $view);
67 67
 	}
68 68
 
69
-	public function setWidth($index,$width){
69
+	public function setWidth($index, $width) {
70 70
 		$this->_equalWidth=false;
71 71
 		return $this->getItem($index)->setWidth($width);
72 72
 	}
73 73
 
74
-	public function setInline(){
74
+	public function setInline() {
75 75
 		$this->_equalWidth=false;
76 76
 		$this->addToProperty("class", "inline");
77 77
 	}
78 78
 
79
-	public function setGrouped(){
79
+	public function setGrouped() {
80 80
 		$this->_equalWidth=false;
81 81
 		$this->addToProperty("class", "grouped");
82 82
 	}
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
 		return $this;
91 91
 	}
92 92
 
93
-	public static function radios($name,$items=array(),$label=NULL){
93
+	public static function radios($name, $items=array(), $label=NULL) {
94 94
 		$fields=array();
95 95
 		$i=0;
96
-		foreach ($items as $item){
97
-			$fields[]=new HtmlFormRadio($name."-".$i++,$name,$item,$item);
96
+		foreach ($items as $item) {
97
+			$fields[]=new HtmlFormRadio($name."-".$i++, $name, $item, $item);
98 98
 		}
99
-		$radios=new HtmlFormFields("fields-".$name,$fields);
100
-		if(isset($label))
99
+		$radios=new HtmlFormFields("fields-".$name, $fields);
100
+		if (isset($label))
101 101
 			$radios->setLabel($label)->setProperty("for", $name);
102 102
 		return $radios;
103 103
 	}
Please login to merge, or discard this patch.
Braces   +12 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,11 +29,14 @@  discard block
 block discarded – undo
29 29
 				if(\is_string($end)){
30 30
 					$label=$end;
31 31
 					\array_pop($fields);
32
-				}else $label=NULL;
32
+				} else {
33
+					$label=NULL;
34
+				}
33 35
 			}
34 36
 		}
35
-		if(isset($label))
36
-			$this->setLabel($label);
37
+		if(isset($label)) {
38
+					$this->setLabel($label);
39
+		}
37 40
 		foreach ($fields as $field){
38 41
 			$this->addItem($field);
39 42
 		}
@@ -61,8 +64,9 @@  discard block
 block discarded – undo
61 64
 		if($this->_equalWidth){
62 65
 			$count=$this->count();
63 66
 			$this->addToProperty("class", Wide::getConstants()["W".$count]." fields");
64
-		}else
65
-			$this->addToProperty("class","fields");
67
+		} else {
68
+					$this->addToProperty("class","fields");
69
+		}
66 70
 		return parent::compile($js,$view);
67 71
 	}
68 72
 
@@ -97,8 +101,9 @@  discard block
 block discarded – undo
97 101
 			$fields[]=new HtmlFormRadio($name."-".$i++,$name,$item,$item);
98 102
 		}
99 103
 		$radios=new HtmlFormFields("fields-".$name,$fields);
100
-		if(isset($label))
101
-			$radios->setLabel($label)->setProperty("for", $name);
104
+		if(isset($label)) {
105
+					$radios->setLabel($label)->setProperty("for", $name);
106
+		}
102 107
 		return $radios;
103 108
 	}
104 109
 
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlForm.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -13,62 +13,62 @@  discard block
 block discarded – undo
13 13
  * @author jc
14 14
  * @version 1.001
15 15
  */
16
-class HtmlForm extends HtmlSemCollection{
16
+class HtmlForm extends HtmlSemCollection {
17 17
 
18 18
 	use FieldsTrait;
19 19
 
20 20
 	protected $_fields;
21 21
 
22
-	public function __construct( $identifier, $elements=array()){
23
-		parent::__construct( $identifier, "form", "ui form");
24
-		$this->_states=[State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED];
22
+	public function __construct($identifier, $elements=array()) {
23
+		parent::__construct($identifier, "form", "ui form");
24
+		$this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED];
25 25
 		$this->setProperty("name", $this->identifier);
26 26
 		$this->_fields=array();
27 27
 		$this->addItems($elements);
28 28
 	}
29 29
 
30
-	public function addHeader($title,$niveau=1,$dividing=true){
31
-		$header=new HtmlHeader("",$niveau,$title);
32
-		if($dividing)
30
+	public function addHeader($title, $niveau=1, $dividing=true) {
31
+		$header=new HtmlHeader("", $niveau, $title);
32
+		if ($dividing)
33 33
 			$header->setDividing();
34 34
 		return $this->addItem($header);
35 35
 	}
36 36
 
37
-	public function addFields($fields=NULL,$label=NULL){
38
-		if(isset($fields)){
39
-			if(!$fields instanceof HtmlFormFields){
40
-				if(\is_array($fields)===false){
41
-					$fields = \func_get_args();
37
+	public function addFields($fields=NULL, $label=NULL) {
38
+		if (isset($fields)) {
39
+			if (!$fields instanceof HtmlFormFields) {
40
+				if (\is_array($fields)===false) {
41
+					$fields=\func_get_args();
42 42
 					$end=\end($fields);
43
-					if(\is_string($end)){
43
+					if (\is_string($end)) {
44 44
 						$label=$end;
45 45
 						\array_pop($fields);
46 46
 					}else $label=NULL;
47 47
 				}
48
-				$this->_fields=\array_merge($this->_fields,$fields);
49
-				$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(),$fields);
48
+				$this->_fields=\array_merge($this->_fields, $fields);
49
+				$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields);
50 50
 			}
51
-			if(isset($label))
52
-			 $fields=new HtmlFormField("", $fields,$label);
53
-		}else{
51
+			if (isset($label))
52
+			 $fields=new HtmlFormField("", $fields, $label);
53
+		}else {
54 54
 			$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count());
55 55
 		}
56 56
 		$this->addItem($fields);
57 57
 		return $fields;
58 58
 	}
59 59
 
60
-	public function addItem($item){
60
+	public function addItem($item) {
61 61
 		$item=parent::addItem($item);
62
-		if(\is_subclass_of($item, HtmlFormField::class)===true){
62
+		if (\is_subclass_of($item, HtmlFormField::class)===true) {
63 63
 			$this->_fields[]=$item;
64 64
 		}
65 65
 		return $item;
66 66
 	}
67 67
 
68
-	public function getField($index){
69
-		if(\is_string($index)){
68
+	public function getField($index) {
69
+		if (\is_string($index)) {
70 70
 			$field=$this->getElementById($index, $this->_fields);
71
-		}else{
71
+		}else {
72 72
 			$field=$this->_fields[$index];
73 73
 		}
74 74
 		return $field;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * automatically divide fields to be equal width
79 79
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
80 80
 	 */
81
-	public function setEqualWidth(){
81
+	public function setEqualWidth() {
82 82
 		return $this->addToProperty("class", "equal width");
83 83
 	}
84 84
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param HtmlFormField $field
88 88
 	 * @return \Ajax\common\html\HtmlDoubleElement
89 89
 	 */
90
-	public function addField($field){
90
+	public function addField($field) {
91 91
 		return $this->addItem($field);
92 92
 	}
93 93
 
@@ -99,22 +99,22 @@  discard block
 block discarded – undo
99 99
 	 * @param string $type
100 100
 	 * @return \Ajax\semantic\html\collections\HtmlMessage
101 101
 	 */
102
-	public function addMessage($identifier,$content,$header=NULL,$icon=NULL,$type=NULL){
103
-		$message=new HtmlMessage($identifier,$content);
104
-		if(isset($header))
102
+	public function addMessage($identifier, $content, $header=NULL, $icon=NULL, $type=NULL) {
103
+		$message=new HtmlMessage($identifier, $content);
104
+		if (isset($header))
105 105
 			$message->addHeader($header);
106
-		if(isset($icon))
106
+		if (isset($icon))
107 107
 			$message->setIcon($icon);
108
-		if(isset($type))
108
+		if (isset($type))
109 109
 			$message->setStyle($type);
110 110
 		return $this->addItem($message);
111 111
 	}
112 112
 
113
-	public function setLoading(){
113
+	public function setLoading() {
114 114
 		return $this->addToProperty("class", "loading");
115 115
 	}
116 116
 
117
-	public function jsState($state){
118
-		return $this->jsDoJquery("addClass",$state);
117
+	public function jsState($state) {
118
+		return $this->jsDoJquery("addClass", $state);
119 119
 	}
120 120
 }
121 121
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +20 added lines, -13 removed lines patch added patch discarded remove patch
@@ -29,8 +29,9 @@  discard block
 block discarded – undo
29 29
 
30 30
 	public function addHeader($title,$niveau=1,$dividing=true){
31 31
 		$header=new HtmlHeader("",$niveau,$title);
32
-		if($dividing)
33
-			$header->setDividing();
32
+		if($dividing) {
33
+					$header->setDividing();
34
+		}
34 35
 		return $this->addItem($header);
35 36
 	}
36 37
 
@@ -43,14 +44,17 @@  discard block
 block discarded – undo
43 44
 					if(\is_string($end)){
44 45
 						$label=$end;
45 46
 						\array_pop($fields);
46
-					}else $label=NULL;
47
+					} else {
48
+						$label=NULL;
49
+					}
47 50
 				}
48 51
 				$this->_fields=\array_merge($this->_fields,$fields);
49 52
 				$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(),$fields);
50 53
 			}
51
-			if(isset($label))
52
-			 $fields=new HtmlFormField("", $fields,$label);
53
-		}else{
54
+			if(isset($label)) {
55
+						 $fields=new HtmlFormField("", $fields,$label);
56
+			}
57
+		} else{
54 58
 			$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count());
55 59
 		}
56 60
 		$this->addItem($fields);
@@ -68,7 +72,7 @@  discard block
 block discarded – undo
68 72
 	public function getField($index){
69 73
 		if(\is_string($index)){
70 74
 			$field=$this->getElementById($index, $this->_fields);
71
-		}else{
75
+		} else{
72 76
 			$field=$this->_fields[$index];
73 77
 		}
74 78
 		return $field;
@@ -101,12 +105,15 @@  discard block
 block discarded – undo
101 105
 	 */
102 106
 	public function addMessage($identifier,$content,$header=NULL,$icon=NULL,$type=NULL){
103 107
 		$message=new HtmlMessage($identifier,$content);
104
-		if(isset($header))
105
-			$message->addHeader($header);
106
-		if(isset($icon))
107
-			$message->setIcon($icon);
108
-		if(isset($type))
109
-			$message->setStyle($type);
108
+		if(isset($header)) {
109
+					$message->addHeader($header);
110
+		}
111
+		if(isset($icon)) {
112
+					$message->setIcon($icon);
113
+		}
114
+		if(isset($type)) {
115
+					$message->setStyle($type);
116
+		}
110 117
 		return $this->addItem($message);
111 118
 	}
112 119
 
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlFormField.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -8,26 +8,26 @@  discard block
 block discarded – undo
8 8
 
9 9
 class HtmlFormField extends HtmlSemDoubleElement {
10 10
 	protected $_container;
11
-	public function __construct($identifier, $field,$label=NULL) {
12
-		parent::__construct($identifier, "div","field");
11
+	public function __construct($identifier, $field, $label=NULL) {
12
+		parent::__construct($identifier, "div", "field");
13 13
 		$this->content=array();
14
-		$this->_states=[State::ERROR,State::DISABLED];
15
-		if(isset($label))
14
+		$this->_states=[State::ERROR, State::DISABLED];
15
+		if (isset($label))
16 16
 			$this->setLabel($label);
17 17
 		$this->setField($field);
18 18
 	}
19 19
 
20
-	public function setLabel($label){
20
+	public function setLabel($label) {
21 21
 		$labelO=$label;
22
-		if(\is_string($label)){
23
-			$labelO=new HtmlSemDoubleElement("","label");
22
+		if (\is_string($label)) {
23
+			$labelO=new HtmlSemDoubleElement("", "label");
24 24
 			$labelO->setContent($label);
25
-			$labelO->setProperty("for", \str_replace("field-", "",$this->identifier));
25
+			$labelO->setProperty("for", \str_replace("field-", "", $this->identifier));
26 26
 		}
27 27
 		$this->content["label"]=$labelO;
28 28
 	}
29 29
 
30
-	public function setField($field){
30
+	public function setField($field) {
31 31
 		$this->content["field"]=$field;
32 32
 	}
33 33
 
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 	 * Returns the label or null
36 36
 	 * @return mixed
37 37
 	 */
38
-	public function getLabel(){
39
-		if(\array_key_exists("label", $this->content))
38
+	public function getLabel() {
39
+		if (\array_key_exists("label", $this->content))
40 40
 			return $this->content["label"];
41 41
 	}
42 42
 
@@ -44,14 +44,14 @@  discard block
 block discarded – undo
44 44
 	 * Return the field
45 45
 	 * @return mixed
46 46
 	 */
47
-	public function getField(){
47
+	public function getField() {
48 48
 		return $this->content["field"];
49 49
 	}
50 50
 
51 51
 	/**
52 52
 	 * puts the label before or behind
53 53
 	 */
54
-	public function swapLabel(){
54
+	public function swapLabel() {
55 55
 		$label=$this->getLabel();
56 56
 		unset($this->content["label"]);
57 57
 		$this->content["label"]=$label;
@@ -62,27 +62,27 @@  discard block
 block discarded – undo
62 62
 	 * @param int $width
63 63
 	 * @return \Ajax\semantic\html\collections\form\HtmlFormField
64 64
 	 */
65
-	public function setWidth($width){
66
-		if(\is_int($width)){
65
+	public function setWidth($width) {
66
+		if (\is_int($width)) {
67 67
 			$width=Wide::getConstants()["W".$width];
68 68
 		}
69 69
 		$this->addToPropertyCtrl("class", $width, Wide::getConstants());
70
-		if(isset($this->_container)){
70
+		if (isset($this->_container)) {
71 71
 			$this->_container->setEqualWidth(false);
72 72
 		}
73
-		return $this->addToPropertyCtrl("class", "wide",array("wide"));
73
+		return $this->addToPropertyCtrl("class", "wide", array("wide"));
74 74
 	}
75 75
 
76 76
 	/**
77 77
 	 * Field displays an error state
78 78
 	 * @return \Ajax\semantic\html\collections\form\HtmlFormField
79 79
 	 */
80
-	public function setError(){
80
+	public function setError() {
81 81
 		return $this->addToProperty("class", "error");
82 82
 	}
83 83
 
84
-	public function jsState($state){
85
-		return $this->jsDoJquery("addClass",$state);
84
+	public function jsState($state) {
85
+		return $this->jsDoJquery("addClass", $state);
86 86
 	}
87 87
 
88 88
 	public function setContainer($_container) {
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/traits/FieldsTrait.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -9,23 +9,23 @@  discard block
 block discarded – undo
9 9
 use Ajax\semantic\html\collections\form\HtmlFormCheckbox;
10 10
 use Ajax\semantic\html\collections\form\HtmlFormRadio;
11 11
 trait FieldsTrait {
12
-	protected function createItem($value){
13
-		if(\is_array($value)){
14
-			$itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null)));
12
+	protected function createItem($value) {
13
+		if (\is_array($value)) {
14
+			$itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id", ""), JArray::getDefaultValue($value, "label", null), JArray::getDefaultValue($value, "type", "text"), JArray::getDefaultValue($value, "value", ""), JArray::getDefaultValue($value, "placeholder", JArray::getDefaultValue($value, "label", null)));
15 15
 			return $itemO;
16 16
 		}else
17 17
 			return new HtmlFormInput($value);
18 18
 	}
19 19
 
20
-	public function addInputs($inputs,$fieldslabel=null){
20
+	public function addInputs($inputs, $fieldslabel=null) {
21 21
 		$fields=array();
22
-		foreach ($inputs as $input){
22
+		foreach ($inputs as $input) {
23 23
 			\extract($input);
24
-			$f=new HtmlFormInput("","");
24
+			$f=new HtmlFormInput("", "");
25 25
 			$f->fromArray($input);
26 26
 			$fields[]=$f;
27 27
 		}
28
-		return $this->addFields($fields,$fieldslabel);
28
+		return $this->addFields($fields, $fieldslabel);
29 29
 	}
30 30
 
31 31
 	/**
@@ -36,23 +36,23 @@  discard block
 block discarded – undo
36 36
 	 * @param string $multiple
37 37
 	 * @return \Ajax\common\html\HtmlDoubleElement
38 38
 	 */
39
-	public function addDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false){
40
-		return $this->addItem(new HtmlFormDropdown($identifier,$items,$label,$value,$multiple));
39
+	public function addDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) {
40
+		return $this->addItem(new HtmlFormDropdown($identifier, $items, $label, $value, $multiple));
41 41
 	}
42 42
 
43
-	public function addInput($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL){
44
-		return $this->addItem(new HtmlFormInput($identifier,$label,$type,$value,$placeholder));
43
+	public function addInput($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) {
44
+		return $this->addItem(new HtmlFormInput($identifier, $label, $type, $value, $placeholder));
45 45
 	}
46 46
 
47
-	public function addButton($identifier,$value,$cssStyle=NULL,$onClick=NULL){
48
-		return $this->addItem(new HtmlButton($identifier,$value,$cssStyle,$onClick));
47
+	public function addButton($identifier, $value, $cssStyle=NULL, $onClick=NULL) {
48
+		return $this->addItem(new HtmlButton($identifier, $value, $cssStyle, $onClick));
49 49
 	}
50 50
 
51
-	public function addCheckbox($identifier, $label=NULL,$value=NULL,$type=NULL){
52
-		return $this->addItem(new HtmlFormCheckbox($identifier,$label,$value,$type));
51
+	public function addCheckbox($identifier, $label=NULL, $value=NULL, $type=NULL) {
52
+		return $this->addItem(new HtmlFormCheckbox($identifier, $label, $value, $type));
53 53
 	}
54 54
 
55
-	public function addRadio($identifier, $name,$label=NULL,$value=NULL){
56
-		return $this->addItem(new HtmlFormRadio($identifier,$name,$label,$value));
55
+	public function addRadio($identifier, $name, $label=NULL, $value=NULL) {
56
+		return $this->addItem(new HtmlFormRadio($identifier, $name, $label, $value));
57 57
 	}
58 58
 }
59 59
\ 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
@@ -13,8 +13,9 @@
 block discarded – undo
13 13
 		if(\is_array($value)){
14 14
 			$itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null)));
15 15
 			return $itemO;
16
-		}else
17
-			return new HtmlFormInput($value);
16
+		} else {
17
+					return new HtmlFormInput($value);
18
+		}
18 19
 	}
19 20
 
20 21
 	public function addInputs($inputs,$fieldslabel=null){
Please login to merge, or discard this patch.