@@ -5,12 +5,12 @@ |
||
5 | 5 | trait TextFieldsTrait { |
6 | 6 | |
7 | 7 | public abstract function getField(); |
8 | - public function setPlaceholder($value){ |
|
8 | + public function setPlaceholder($value) { |
|
9 | 9 | $this->getField()->setPlaceholder($value); |
10 | 10 | return $this; |
11 | 11 | } |
12 | 12 | |
13 | - public function setValue($value){ |
|
13 | + public function setValue($value) { |
|
14 | 14 | $this->getField()->setValue($value); |
15 | 15 | return $this; |
16 | 16 | } |
@@ -9,13 +9,13 @@ |
||
9 | 9 | use Ajax\semantic\html\collections\form\traits\FieldTrait; |
10 | 10 | |
11 | 11 | class HtmlInput extends HtmlSemDoubleElement { |
12 | - use IconTrait,TextFieldsTrait,FieldTrait; |
|
12 | + use IconTrait, TextFieldsTrait, FieldTrait; |
|
13 | 13 | |
14 | 14 | public function __construct($identifier, $type="text", $value="", $placeholder="") { |
15 | - parent::__construct("div-" . $identifier, "div", "ui input"); |
|
16 | - $this->content=[ "field" => new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder) ]; |
|
17 | - $this->_states=[ State::DISABLED,State::FOCUS,State::ERROR ]; |
|
18 | - $this->_variations=[ Variation::TRANSPARENT ]; |
|
15 | + parent::__construct("div-".$identifier, "div", "ui input"); |
|
16 | + $this->content=["field" => new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder)]; |
|
17 | + $this->_states=[State::DISABLED, State::FOCUS, State::ERROR]; |
|
18 | + $this->_variations=[Variation::TRANSPARENT]; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function getField() { |
@@ -7,17 +7,17 @@ |
||
7 | 7 | use Ajax\semantic\html\elements\HtmlInput; |
8 | 8 | |
9 | 9 | class HtmlFormInput extends HtmlFormField { |
10 | - use TextFieldsTrait,FieldTrait; |
|
10 | + use TextFieldsTrait, FieldTrait; |
|
11 | 11 | |
12 | - public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
|
13 | - if(!isset($placeholder) && $type==="text") |
|
12 | + public function __construct($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
13 | + if (!isset($placeholder) && $type==="text") |
|
14 | 14 | $placeholder=$label; |
15 | - parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
|
15 | + parent::__construct("field-".$identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label); |
|
16 | 16 | } |
17 | 17 | |
18 | - public function getDataField(){ |
|
19 | - $field= $this->getField(); |
|
20 | - if($field instanceof HtmlInput) |
|
18 | + public function getDataField() { |
|
19 | + $field=$this->getField(); |
|
20 | + if ($field instanceof HtmlInput) |
|
21 | 21 | $field=$field->getField(); |
22 | 22 | return $field; |
23 | 23 | } |
@@ -10,15 +10,17 @@ |
||
10 | 10 | use TextFieldsTrait,FieldTrait; |
11 | 11 | |
12 | 12 | public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
13 | - if(!isset($placeholder) && $type==="text") |
|
14 | - $placeholder=$label; |
|
13 | + if(!isset($placeholder) && $type==="text") { |
|
14 | + $placeholder=$label; |
|
15 | + } |
|
15 | 16 | parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
16 | 17 | } |
17 | 18 | |
18 | 19 | public function getDataField(){ |
19 | 20 | $field= $this->getField(); |
20 | - if($field instanceof HtmlInput) |
|
21 | - $field=$field->getField(); |
|
21 | + if($field instanceof HtmlInput) { |
|
22 | + $field=$field->getField(); |
|
23 | + } |
|
22 | 24 | return $field; |
23 | 25 | } |
24 | 26 | } |
25 | 27 | \ No newline at end of file |
@@ -18,11 +18,12 @@ |
||
18 | 18 | if(\is_array($value)){ |
19 | 19 | $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))); |
20 | 20 | return $itemO; |
21 | - }elseif(\is_object($value)){ |
|
21 | + } elseif(\is_object($value)){ |
|
22 | 22 | $itemO=new HtmlFormField("field-".$this->identifier, $value); |
23 | 23 | return $itemO; |
24 | - }else |
|
25 | - return new HtmlFormInput($value); |
|
24 | + } else { |
|
25 | + return new HtmlFormInput($value); |
|
26 | + } |
|
26 | 27 | } |
27 | 28 | |
28 | 29 | protected function createCondition($value){ |
@@ -11,46 +11,46 @@ discard block |
||
11 | 11 | use Ajax\semantic\html\collections\form\HtmlFormField; |
12 | 12 | |
13 | 13 | trait FieldsTrait { |
14 | - public abstract function addFields($fields=NULL,$label=NULL); |
|
14 | + public abstract function addFields($fields=NULL, $label=NULL); |
|
15 | 15 | public abstract function addItem($item); |
16 | 16 | |
17 | - protected function createItem($value){ |
|
18 | - if(\is_array($value)){ |
|
19 | - $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))); |
|
17 | + protected function createItem($value) { |
|
18 | + if (\is_array($value)) { |
|
19 | + $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))); |
|
20 | 20 | return $itemO; |
21 | - }elseif(\is_object($value)){ |
|
21 | + }elseif (\is_object($value)) { |
|
22 | 22 | $itemO=new HtmlFormField("field-".$this->identifier, $value); |
23 | 23 | return $itemO; |
24 | - }else |
|
24 | + } else |
|
25 | 25 | return new HtmlFormInput($value); |
26 | 26 | } |
27 | 27 | |
28 | - protected function createCondition($value){ |
|
28 | + protected function createCondition($value) { |
|
29 | 29 | return \is_object($value)===false || $value instanceof \Ajax\semantic\html\elements\HtmlInput; |
30 | 30 | } |
31 | 31 | |
32 | - public function addInputs($inputs,$fieldslabel=null){ |
|
32 | + public function addInputs($inputs, $fieldslabel=null) { |
|
33 | 33 | $fields=array(); |
34 | - foreach ($inputs as $input){ |
|
34 | + foreach ($inputs as $input) { |
|
35 | 35 | \extract($input); |
36 | - $f=new HtmlFormInput("",""); |
|
36 | + $f=new HtmlFormInput("", ""); |
|
37 | 37 | $f->fromArray($input); |
38 | 38 | $fields[]=$f; |
39 | 39 | } |
40 | - return $this->addFields($fields,$fieldslabel); |
|
40 | + return $this->addFields($fields, $fieldslabel); |
|
41 | 41 | } |
42 | 42 | |
43 | - public function addFieldRule($index,$type,$prompt=NULL,$value=NULL){ |
|
43 | + public function addFieldRule($index, $type, $prompt=NULL, $value=NULL) { |
|
44 | 44 | $field=$this->getItem($index); |
45 | - if(isset($field)){ |
|
46 | - $field->addRule($type,$prompt,$value); |
|
45 | + if (isset($field)) { |
|
46 | + $field->addRule($type, $prompt, $value); |
|
47 | 47 | } |
48 | 48 | return $this; |
49 | 49 | } |
50 | 50 | |
51 | - public function addFieldRules($index,$rules){ |
|
51 | + public function addFieldRules($index, $rules) { |
|
52 | 52 | $field=$this->getItem($index); |
53 | - if(isset($field)){ |
|
53 | + if (isset($field)) { |
|
54 | 54 | $field->addRules($rules); |
55 | 55 | } |
56 | 56 | return $this; |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | * @param boolean $multiple |
65 | 65 | * @return \Ajax\common\html\HtmlDoubleElement |
66 | 66 | */ |
67 | - public function addDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false){ |
|
68 | - return $this->addItem(new HtmlFormDropdown($identifier,$items,$label,$value,$multiple)); |
|
67 | + public function addDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) { |
|
68 | + return $this->addItem(new HtmlFormDropdown($identifier, $items, $label, $value, $multiple)); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -76,23 +76,23 @@ discard block |
||
76 | 76 | * @param string $placeholder |
77 | 77 | * @return HtmlFormInput |
78 | 78 | */ |
79 | - public function addInput($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL){ |
|
80 | - return $this->addItem(new HtmlFormInput($identifier,$label,$type,$value,$placeholder)); |
|
79 | + public function addInput($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
80 | + return $this->addItem(new HtmlFormInput($identifier, $label, $type, $value, $placeholder)); |
|
81 | 81 | } |
82 | 82 | |
83 | - public function addPassword($identifier, $label=NULL){ |
|
84 | - return $this->addItem(new HtmlFormInput($identifier,$label,"password","","")); |
|
83 | + public function addPassword($identifier, $label=NULL) { |
|
84 | + return $this->addItem(new HtmlFormInput($identifier, $label, "password", "", "")); |
|
85 | 85 | } |
86 | 86 | |
87 | - public function addButton($identifier,$value,$cssStyle=NULL,$onClick=NULL){ |
|
88 | - return $this->addItem(new HtmlButton($identifier,$value,$cssStyle,$onClick)); |
|
87 | + public function addButton($identifier, $value, $cssStyle=NULL, $onClick=NULL) { |
|
88 | + return $this->addItem(new HtmlButton($identifier, $value, $cssStyle, $onClick)); |
|
89 | 89 | } |
90 | 90 | |
91 | - public function addCheckbox($identifier, $label=NULL,$value=NULL,$type=NULL){ |
|
92 | - return $this->addItem(new HtmlFormCheckbox($identifier,$label,$value,$type)); |
|
91 | + public function addCheckbox($identifier, $label=NULL, $value=NULL, $type=NULL) { |
|
92 | + return $this->addItem(new HtmlFormCheckbox($identifier, $label, $value, $type)); |
|
93 | 93 | } |
94 | 94 | |
95 | - public function addRadio($identifier, $name,$label=NULL,$value=NULL){ |
|
96 | - return $this->addItem(new HtmlFormRadio($identifier,$name,$label,$value)); |
|
95 | + public function addRadio($identifier, $name, $label=NULL, $value=NULL) { |
|
96 | + return $this->addItem(new HtmlFormRadio($identifier, $name, $label, $value)); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | \ No newline at end of file |
@@ -33,17 +33,17 @@ discard block |
||
33 | 33 | return $this->getHtmlCk()->attachEvents($events); |
34 | 34 | } |
35 | 35 | |
36 | - public function getField(){ |
|
36 | + public function getField() { |
|
37 | 37 | return $this->content["field"]->getField(); |
38 | 38 | } |
39 | 39 | |
40 | - public function getHtmlCk(){ |
|
40 | + public function getHtmlCk() { |
|
41 | 41 | return $this->content["field"]; |
42 | 42 | } |
43 | 43 | |
44 | - public function getDataField(){ |
|
45 | - $field= $this->getField(); |
|
46 | - if($field instanceof AbstractCheckbox) |
|
44 | + public function getDataField() { |
|
45 | + $field=$this->getField(); |
|
46 | + if ($field instanceof AbstractCheckbox) |
|
47 | 47 | $field=$field->getField(); |
48 | 48 | return $field; |
49 | 49 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * @param boolean $value |
54 | 54 | * @return \Ajax\semantic\html\collections\form\traits\CheckboxTrait |
55 | 55 | */ |
56 | - public function setChecked($value=true){ |
|
57 | - if($value===true){ |
|
56 | + public function setChecked($value=true) { |
|
57 | + if ($value===true) { |
|
58 | 58 | $this->getDataField()->setProperty("checked", "checked"); |
59 | - }else{ |
|
59 | + } else { |
|
60 | 60 | $this->getDataField()->removeProperty("checked"); |
61 | 61 | } |
62 | 62 | return $this; |
@@ -43,8 +43,9 @@ discard block |
||
43 | 43 | |
44 | 44 | public function getDataField(){ |
45 | 45 | $field= $this->getField(); |
46 | - if($field instanceof AbstractCheckbox) |
|
47 | - $field=$field->getField(); |
|
46 | + if($field instanceof AbstractCheckbox) { |
|
47 | + $field=$field->getField(); |
|
48 | + } |
|
48 | 49 | return $field; |
49 | 50 | } |
50 | 51 | |
@@ -56,7 +57,7 @@ discard block |
||
56 | 57 | public function setChecked($value=true){ |
57 | 58 | if($value===true){ |
58 | 59 | $this->getDataField()->setProperty("checked", "checked"); |
59 | - }else{ |
|
60 | + } else{ |
|
60 | 61 | $this->getDataField()->removeProperty("checked"); |
61 | 62 | } |
62 | 63 | return $this; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use Ajax\semantic\html\base\constants\CheckboxType; |
7 | 7 | |
8 | 8 | abstract class AbstractCheckbox extends HtmlSemDoubleElement { |
9 | - protected $_params=array (); |
|
9 | + protected $_params=array(); |
|
10 | 10 | |
11 | 11 | public function __construct($identifier, $name=NULL, $label=NULL, $value=NULL, $inputType="checkbox", $type="checkbox") { |
12 | 12 | parent::__construct("ck-".$identifier, "div", "ui ".$type); |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | $this->setLabel($label); |
18 | 18 | } |
19 | 19 | |
20 | - public function setChecked($value=true){ |
|
21 | - if($value===true){ |
|
20 | + public function setChecked($value=true) { |
|
21 | + if ($value===true) { |
|
22 | 22 | $this->getField()->setProperty("checked", "checked"); |
23 | - }else{ |
|
23 | + } else { |
|
24 | 24 | $this->getField()->removeProperty("checked"); |
25 | 25 | } |
26 | 26 | return $this; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @return \Ajax\semantic\html\collections\form\AbstractHtmlFormRadioCheckbox |
83 | 83 | */ |
84 | 84 | public function attachEvent($selector, $action=NULL) { |
85 | - if (isset($action)!==false||\is_numeric($action)===true) { |
|
85 | + if (isset($action)!==false || \is_numeric($action)===true) { |
|
86 | 86 | $js='$("#%identifier%").checkbox("attach events", "'.$selector.'", "'.$action.'");'; |
87 | 87 | } else { |
88 | 88 | $js='$("#%identifier%").checkbox("attach events", "'.$selector.'");'; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function attachEvents($events=array()) { |
100 | 100 | if (\is_array($events)) { |
101 | - foreach ( $events as $action => $selector ) { |
|
101 | + foreach ($events as $action => $selector) { |
|
102 | 102 | $this->attachEvent($selector, $action); |
103 | 103 | } |
104 | 104 | } |
@@ -13,14 +13,15 @@ discard block |
||
13 | 13 | $field=new \Ajax\common\html\html5\HtmlInput($identifier, $inputType, $value); |
14 | 14 | $field->setProperty("name", $name); |
15 | 15 | $this->setField($field); |
16 | - if (isset($label)) |
|
17 | - $this->setLabel($label); |
|
16 | + if (isset($label)) { |
|
17 | + $this->setLabel($label); |
|
18 | + } |
|
18 | 19 | } |
19 | 20 | |
20 | 21 | public function setChecked($value=true){ |
21 | 22 | if($value===true){ |
22 | 23 | $this->getField()->setProperty("checked", "checked"); |
23 | - }else{ |
|
24 | + } else{ |
|
24 | 25 | $this->getField()->removeProperty("checked"); |
25 | 26 | } |
26 | 27 | return $this; |
@@ -49,8 +50,9 @@ discard block |
||
49 | 50 | * @return mixed |
50 | 51 | */ |
51 | 52 | public function getLabel() { |
52 | - if (\array_key_exists("label", $this->content)) |
|
53 | - return $this->content["label"]; |
|
53 | + if (\array_key_exists("label", $this->content)) { |
|
54 | + return $this->content["label"]; |
|
55 | + } |
|
54 | 56 | } |
55 | 57 | |
56 | 58 | /** |