@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | * @property string $identifier |
14 | 14 | */ |
15 | 15 | trait BaseTrait { |
16 | - protected $_variations=[ ]; |
|
17 | - protected $_states=[ ]; |
|
16 | + protected $_variations=[]; |
|
17 | + protected $_states=[]; |
|
18 | 18 | protected $_baseClass; |
19 | 19 | |
20 | 20 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | abstract public function setProperty($name, $value); |
29 | 29 | |
30 | - abstract public function addContent($content,$before=false); |
|
30 | + abstract public function addContent($content, $before=false); |
|
31 | 31 | |
32 | 32 | abstract public function onCreate($jsCode); |
33 | 33 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $this->setProperty("class", $this->_baseClass); |
49 | 49 | if (\is_string($variations)) |
50 | 50 | $variations=\explode(" ", $variations); |
51 | - foreach ( $variations as $variation ) { |
|
51 | + foreach ($variations as $variation) { |
|
52 | 52 | $this->addVariation($variation); |
53 | 53 | } |
54 | 54 | return $this; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public function addVariations($variations=array()) { |
63 | 63 | if (\is_string($variations)) |
64 | 64 | $variations=\explode(" ", $variations); |
65 | - foreach ( $variations as $variation ) { |
|
65 | + foreach ($variations as $variation) { |
|
66 | 66 | $this->addVariation($variation); |
67 | 67 | } |
68 | 68 | return $this; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public function addStates($states=array()) { |
72 | 72 | if (\is_string($states)) |
73 | 73 | $states=\explode(" ", $states); |
74 | - foreach ( $states as $state ) { |
|
74 | + foreach ($states as $state) { |
|
75 | 75 | $this->addState($state); |
76 | 76 | } |
77 | 77 | return $this; |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | $this->setProperty("class", $this->_baseClass); |
82 | 82 | if (\is_string($states)) |
83 | 83 | $states=\explode(" ", $states); |
84 | - foreach ( $states as $state ) { |
|
84 | + foreach ($states as $state) { |
|
85 | 85 | $this->addState($state); |
86 | 86 | } |
87 | 87 | return $this; |
88 | 88 | } |
89 | 89 | |
90 | 90 | public function addIcon($icon, $before=true) { |
91 | - return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
91 | + return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before); |
|
92 | 92 | } |
93 | 93 | |
94 | - public function addSticky($context="body"){ |
|
94 | + public function addSticky($context="body") { |
|
95 | 95 | $this->onCreate("$('#".$this->identifier."').sticky({ context: '".$context."'});"); |
96 | 96 | return $this; |
97 | 97 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
113 | 113 | */ |
114 | 114 | public function setDisabled($disable=true) { |
115 | - if($disable) |
|
115 | + if ($disable) |
|
116 | 116 | $this->addToProperty("class", "disabled"); |
117 | 117 | return $this; |
118 | 118 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
140 | 140 | */ |
141 | - public function asHeader(){ |
|
141 | + public function asHeader() { |
|
142 | 142 | return $this->addToProperty("class", "header"); |
143 | 143 | } |
144 | 144 | |
@@ -146,15 +146,15 @@ discard block |
||
146 | 146 | * show it is currently the active user selection |
147 | 147 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
148 | 148 | */ |
149 | - public function setActive($value=true){ |
|
150 | - if($value) |
|
149 | + public function setActive($value=true) { |
|
150 | + if ($value) |
|
151 | 151 | $this->addToProperty("class", "active"); |
152 | 152 | return $this; |
153 | 153 | } |
154 | 154 | |
155 | - public function setAttached($value=true){ |
|
156 | - if($value) |
|
157 | - $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
155 | + public function setAttached($value=true) { |
|
156 | + if ($value) |
|
157 | + $this->addToPropertyCtrl("class", "attached", array("attached")); |
|
158 | 158 | return $this; |
159 | 159 | } |
160 | 160 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | public function setFloated($direction="right") { |
173 | - return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
173 | + return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | public function floatRight() { |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | return $this->_baseClass; |
186 | 186 | } |
187 | 187 | |
188 | - protected function addBehavior(&$array,$key,$value,$before="",$after=""){ |
|
189 | - if(\is_string($value)){ |
|
190 | - if(isset($array[$key])){ |
|
188 | + protected function addBehavior(&$array, $key, $value, $before="", $after="") { |
|
189 | + if (\is_string($value)) { |
|
190 | + if (isset($array[$key])) { |
|
191 | 191 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
192 | 192 | $array[$key]=$before.$p.$value.$after; |
193 | - }else |
|
193 | + } else |
|
194 | 194 | $array[$key]=$before.$value.$after; |
195 | - }else |
|
195 | + } else |
|
196 | 196 | $array[$key]=$value; |
197 | 197 | return $this; |
198 | 198 | } |
@@ -46,8 +46,9 @@ discard block |
||
46 | 46 | |
47 | 47 | public function setVariations($variations) { |
48 | 48 | $this->setProperty("class", $this->_baseClass); |
49 | - if (\is_string($variations)) |
|
50 | - $variations=\explode(" ", $variations); |
|
49 | + if (\is_string($variations)) { |
|
50 | + $variations=\explode(" ", $variations); |
|
51 | + } |
|
51 | 52 | foreach ( $variations as $variation ) { |
52 | 53 | $this->addVariation($variation); |
53 | 54 | } |
@@ -60,8 +61,9 @@ discard block |
||
60 | 61 | } |
61 | 62 | |
62 | 63 | public function addVariations($variations=array()) { |
63 | - if (\is_string($variations)) |
|
64 | - $variations=\explode(" ", $variations); |
|
64 | + if (\is_string($variations)) { |
|
65 | + $variations=\explode(" ", $variations); |
|
66 | + } |
|
65 | 67 | foreach ( $variations as $variation ) { |
66 | 68 | $this->addVariation($variation); |
67 | 69 | } |
@@ -69,8 +71,9 @@ discard block |
||
69 | 71 | } |
70 | 72 | |
71 | 73 | public function addStates($states=array()) { |
72 | - if (\is_string($states)) |
|
73 | - $states=\explode(" ", $states); |
|
74 | + if (\is_string($states)) { |
|
75 | + $states=\explode(" ", $states); |
|
76 | + } |
|
74 | 77 | foreach ( $states as $state ) { |
75 | 78 | $this->addState($state); |
76 | 79 | } |
@@ -79,8 +82,9 @@ discard block |
||
79 | 82 | |
80 | 83 | public function setStates($states) { |
81 | 84 | $this->setProperty("class", $this->_baseClass); |
82 | - if (\is_string($states)) |
|
83 | - $states=\explode(" ", $states); |
|
85 | + if (\is_string($states)) { |
|
86 | + $states=\explode(" ", $states); |
|
87 | + } |
|
84 | 88 | foreach ( $states as $state ) { |
85 | 89 | $this->addState($state); |
86 | 90 | } |
@@ -112,8 +116,9 @@ discard block |
||
112 | 116 | * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
113 | 117 | */ |
114 | 118 | public function setDisabled($disable=true) { |
115 | - if($disable) |
|
116 | - $this->addToProperty("class", "disabled"); |
|
119 | + if($disable) { |
|
120 | + $this->addToProperty("class", "disabled"); |
|
121 | + } |
|
117 | 122 | return $this; |
118 | 123 | } |
119 | 124 | |
@@ -147,14 +152,16 @@ discard block |
||
147 | 152 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
148 | 153 | */ |
149 | 154 | public function setActive($value=true){ |
150 | - if($value) |
|
151 | - $this->addToProperty("class", "active"); |
|
155 | + if($value) { |
|
156 | + $this->addToProperty("class", "active"); |
|
157 | + } |
|
152 | 158 | return $this; |
153 | 159 | } |
154 | 160 | |
155 | 161 | public function setAttached($value=true){ |
156 | - if($value) |
|
157 | - $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
162 | + if($value) { |
|
163 | + $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
164 | + } |
|
158 | 165 | return $this; |
159 | 166 | } |
160 | 167 | |
@@ -190,10 +197,12 @@ discard block |
||
190 | 197 | if(isset($array[$key])){ |
191 | 198 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
192 | 199 | $array[$key]=$before.$p.$value.$after; |
193 | - }else |
|
194 | - $array[$key]=$before.$value.$after; |
|
195 | - }else |
|
196 | - $array[$key]=$value; |
|
200 | + } else { |
|
201 | + $array[$key]=$before.$value.$after; |
|
202 | + } |
|
203 | + } else { |
|
204 | + $array[$key]=$value; |
|
205 | + } |
|
197 | 206 | return $this; |
198 | 207 | } |
199 | 208 | } |
200 | 209 | \ No newline at end of file |
@@ -14,34 +14,34 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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() { |
@@ -18,8 +18,9 @@ discard block |
||
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 |
||
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 | /** |
@@ -128,12 +128,20 @@ |
||
128 | 128 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
129 | 129 | } |
130 | 130 | |
131 | + /** |
|
132 | + * @param integer $index |
|
133 | + * @param string $title |
|
134 | + */ |
|
131 | 135 | public function addDividerBefore($index,$title){ |
132 | 136 | $index=$this->_getIndex($index); |
133 | 137 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
134 | 138 | return $this; |
135 | 139 | } |
136 | 140 | |
141 | + /** |
|
142 | + * @param string $index |
|
143 | + * @param string $contentAfter |
|
144 | + */ |
|
137 | 145 | public function addWrapper($index,$contentBefore,$contentAfter=null){ |
138 | 146 | $index=$this->_getIndex($index); |
139 | 147 | $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
@@ -19,64 +19,64 @@ discard block |
||
19 | 19 | class DataForm extends Widget { |
20 | 20 | |
21 | 21 | public function __construct($identifier, $modelInstance=NULL) { |
22 | - parent::__construct($identifier, null,$modelInstance); |
|
22 | + parent::__construct($identifier, null, $modelInstance); |
|
23 | 23 | $this->_form=new HtmlForm($identifier); |
24 | 24 | $this->_init(new FormInstanceViewer($identifier), "form", $this->_form, true); |
25 | 25 | } |
26 | 26 | |
27 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
27 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
28 | 28 | return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier(); |
29 | 29 | } |
30 | 30 | |
31 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
32 | - if(!$this->_generated){ |
|
31 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
32 | + if (!$this->_generated) { |
|
33 | 33 | $this->_instanceViewer->setInstance($this->_modelInstance); |
34 | 34 | |
35 | 35 | $form=$this->content["form"]; |
36 | 36 | $this->_generateContent($form); |
37 | 37 | |
38 | - if(isset($this->_toolbar)){ |
|
38 | + if (isset($this->_toolbar)) { |
|
39 | 39 | $this->_setToolbarPosition($form); |
40 | 40 | } |
41 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
41 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
42 | 42 | $this->_generated=true; |
43 | 43 | } |
44 | - return parent::compile($js,$view); |
|
44 | + return parent::compile($js, $view); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * @param HtmlForm $form |
49 | 49 | */ |
50 | - protected function _generateContent($form){ |
|
51 | - $values= $this->_instanceViewer->getValues(); |
|
50 | + protected function _generateContent($form) { |
|
51 | + $values=$this->_instanceViewer->getValues(); |
|
52 | 52 | $count=$this->_instanceViewer->count(); |
53 | 53 | $separators=$this->_instanceViewer->getSeparators(); |
54 | 54 | $headers=$this->_instanceViewer->getHeaders(); |
55 | 55 | $wrappers=$this->_instanceViewer->getWrappers(); |
56 | 56 | \sort($separators); |
57 | 57 | $size=\sizeof($separators); |
58 | - if($size===1){ |
|
59 | - foreach ($values as $v){ |
|
58 | + if ($size===1) { |
|
59 | + foreach ($values as $v) { |
|
60 | 60 | $form->addField($v); |
61 | 61 | } |
62 | - }else{ |
|
62 | + } else { |
|
63 | 63 | $separators[]=$count; |
64 | - for($i=0;$i<$size;$i++){ |
|
64 | + for ($i=0; $i<$size; $i++) { |
|
65 | 65 | $wrapper=null; |
66 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
67 | - if(isset($headers[$separators[$i]+1])) |
|
68 | - $form->addHeader($headers[$separators[$i]+1],4,true); |
|
69 | - if(isset($wrappers[$separators[$i]+1])){ |
|
66 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
67 | + if (isset($headers[$separators[$i]+1])) |
|
68 | + $form->addHeader($headers[$separators[$i]+1], 4, true); |
|
69 | + if (isset($wrappers[$separators[$i]+1])) { |
|
70 | 70 | $wrapper=$wrappers[$separators[$i]+1]; |
71 | 71 | } |
72 | 72 | //TODO check why $fields is empty |
73 | - if(\sizeof($fields)===1){ |
|
73 | + if (\sizeof($fields)===1) { |
|
74 | 74 | $added=$form->addField($fields[0]); |
75 | - }elseif(\sizeof($fields)>1){ |
|
75 | + }elseif (\sizeof($fields)>1) { |
|
76 | 76 | $added=$form->addFields($fields); |
77 | 77 | } |
78 | - if(isset($wrapper)) |
|
79 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
78 | + if (isset($wrapper)) |
|
79 | + $added->wrap($wrapper[0], $wrapper[1]); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | * {@inheritDoc} |
86 | 86 | * @see \Ajax\common\Widget::getForm() |
87 | 87 | */ |
88 | - public function getForm(){ |
|
88 | + public function getForm() { |
|
89 | 89 | return $this->content["form"]; |
90 | 90 | } |
91 | 91 | |
92 | - public function addSeparatorAfter($fieldNum){ |
|
92 | + public function addSeparatorAfter($fieldNum) { |
|
93 | 93 | $fieldNum=$this->_getIndex($fieldNum); |
94 | 94 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
95 | 95 | return $this; |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | return $this; |
105 | 105 | } |
106 | 106 | |
107 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
108 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
109 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
107 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
108 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
109 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
110 | 110 | $button->setProperty("type", "reset"); |
111 | 111 | return $button; |
112 | - }, $index,$attributes); |
|
112 | + }, $index, $attributes); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -128,19 +128,19 @@ discard block |
||
128 | 128 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
129 | 129 | } |
130 | 130 | |
131 | - public function addDividerBefore($index,$title){ |
|
131 | + public function addDividerBefore($index, $title) { |
|
132 | 132 | $index=$this->_getIndex($index); |
133 | 133 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
134 | 134 | return $this; |
135 | 135 | } |
136 | 136 | |
137 | - public function addWrapper($index,$contentBefore,$contentAfter=null){ |
|
137 | + public function addWrapper($index, $contentBefore, $contentAfter=null) { |
|
138 | 138 | $index=$this->_getIndex($index); |
139 | - $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
|
139 | + $this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter); |
|
140 | 140 | return $this; |
141 | 141 | } |
142 | 142 | |
143 | - public function run(JsUtils $js){ |
|
143 | + public function run(JsUtils $js) { |
|
144 | 144 | return parent::run($js); |
145 | 145 | } |
146 | 146 | } |
147 | 147 | \ No newline at end of file |
@@ -59,24 +59,26 @@ |
||
59 | 59 | foreach ($values as $v){ |
60 | 60 | $form->addField($v); |
61 | 61 | } |
62 | - }else{ |
|
62 | + } else{ |
|
63 | 63 | $separators[]=$count; |
64 | 64 | for($i=0;$i<$size;$i++){ |
65 | 65 | $wrapper=null; |
66 | 66 | $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
67 | - if(isset($headers[$separators[$i]+1])) |
|
68 | - $form->addHeader($headers[$separators[$i]+1],4,true); |
|
67 | + if(isset($headers[$separators[$i]+1])) { |
|
68 | + $form->addHeader($headers[$separators[$i]+1],4,true); |
|
69 | + } |
|
69 | 70 | if(isset($wrappers[$separators[$i]+1])){ |
70 | 71 | $wrapper=$wrappers[$separators[$i]+1]; |
71 | 72 | } |
72 | 73 | //TODO check why $fields is empty |
73 | 74 | if(\sizeof($fields)===1){ |
74 | 75 | $added=$form->addField($fields[0]); |
75 | - }elseif(\sizeof($fields)>1){ |
|
76 | + } elseif(\sizeof($fields)>1){ |
|
76 | 77 | $added=$form->addFields($fields); |
77 | 78 | } |
78 | - if(isset($wrapper)) |
|
79 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
79 | + if(isset($wrapper)) { |
|
80 | + $added->wrap($wrapper[0],$wrapper[1]); |
|
81 | + } |
|
80 | 82 | } |
81 | 83 | } |
82 | 84 | } |
@@ -10,50 +10,50 @@ |
||
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 |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | * @param array $instances |
17 | 17 | * @return DataTable |
18 | 18 | */ |
19 | - public function dataTable($identifier,$model, $instances){ |
|
20 | - return $this->addHtmlComponent(new DataTable($identifier,$model,$instances)); |
|
19 | + public function dataTable($identifier, $model, $instances) { |
|
20 | + return $this->addHtmlComponent(new DataTable($identifier, $model, $instances)); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | * @param object $instance |
26 | 26 | * @return DataElement |
27 | 27 | */ |
28 | - public function dataElement($identifier, $instance){ |
|
29 | - return $this->addHtmlComponent(new DataElement($identifier,$instance)); |
|
28 | + public function dataElement($identifier, $instance) { |
|
29 | + return $this->addHtmlComponent(new DataElement($identifier, $instance)); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | * @param object $instance |
35 | 35 | * @return DataForm |
36 | 36 | */ |
37 | - public function dataForm($identifier, $instance){ |
|
38 | - return $this->addHtmlComponent(new DataForm($identifier,$instance)); |
|
37 | + public function dataForm($identifier, $instance) { |
|
38 | + return $this->addHtmlComponent(new DataForm($identifier, $instance)); |
|
39 | 39 | } |
40 | 40 | |
41 | - public function defaultLogin($identifier,$instance=null){ |
|
42 | - return $this->addHtmlComponent(FormLogin::regular($identifier,$instance)); |
|
41 | + public function defaultLogin($identifier, $instance=null) { |
|
42 | + return $this->addHtmlComponent(FormLogin::regular($identifier, $instance)); |
|
43 | 43 | } |
44 | 44 | |
45 | - public function smallLogin($identifier,$instance=null){ |
|
46 | - return $this->addHtmlComponent(FormLogin::small($identifier,$instance)); |
|
45 | + public function smallLogin($identifier, $instance=null) { |
|
46 | + return $this->addHtmlComponent(FormLogin::small($identifier, $instance)); |
|
47 | 47 | } |
48 | 48 | |
49 | - public function segmentedLogin($identifier,$instance=null){ |
|
50 | - return $this->addHtmlComponent(FormLogin::attachedSegment($identifier,$instance)); |
|
49 | + public function segmentedLogin($identifier, $instance=null) { |
|
50 | + return $this->addHtmlComponent(FormLogin::attachedSegment($identifier, $instance)); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | \ No newline at end of file |
@@ -15,7 +15,7 @@ |
||
15 | 15 | class HtmlFormCheckbox extends HtmlFormField { |
16 | 16 | use CheckboxTrait; |
17 | 17 | public function __construct($identifier, $label=NULL, $value=NULL, $type=NULL) { |
18 | - parent::__construct("field-".$identifier, new HtmlCheckbox($identifier,$label,$value,$type)); |
|
18 | + parent::__construct("field-".$identifier, new HtmlCheckbox($identifier, $label, $value, $type)); |
|
19 | 19 | $this->_identifier=$identifier; |
20 | 20 | } |
21 | 21 |
@@ -8,17 +8,17 @@ |
||
8 | 8 | class HtmlFormInput extends HtmlFormField { |
9 | 9 | use TextFieldsTrait; |
10 | 10 | |
11 | - public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
|
12 | - if(!isset($placeholder) && $type==="text") |
|
11 | + public function __construct($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
12 | + if (!isset($placeholder) && $type==="text") |
|
13 | 13 | $placeholder=$label; |
14 | - parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
|
14 | + parent::__construct("field-".$identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label); |
|
15 | 15 | $this->_identifier=$identifier; |
16 | 16 | } |
17 | 17 | |
18 | - public function getDataField(){ |
|
19 | - $field= $this->getField(); |
|
18 | + public function getDataField() { |
|
19 | + $field=$this->getField(); |
|
20 | 20 | //TODO check getField |
21 | - if($field instanceof HtmlInput) |
|
21 | + if ($field instanceof HtmlInput) |
|
22 | 22 | $field=$field->getDataField(); |
23 | 23 | return $field; |
24 | 24 | } |
@@ -9,8 +9,9 @@ discard block |
||
9 | 9 | use TextFieldsTrait; |
10 | 10 | |
11 | 11 | public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
12 | - if(!isset($placeholder) && $type==="text") |
|
13 | - $placeholder=$label; |
|
12 | + if(!isset($placeholder) && $type==="text") { |
|
13 | + $placeholder=$label; |
|
14 | + } |
|
14 | 15 | parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
15 | 16 | $this->_identifier=$identifier; |
16 | 17 | } |
@@ -18,8 +19,9 @@ discard block |
||
18 | 19 | public function getDataField(){ |
19 | 20 | $field= $this->getField(); |
20 | 21 | //TODO check getField |
21 | - if($field instanceof HtmlInput) |
|
22 | - $field=$field->getDataField(); |
|
22 | + if($field instanceof HtmlInput) { |
|
23 | + $field=$field->getDataField(); |
|
24 | + } |
|
23 | 25 | return $field; |
24 | 26 | } |
25 | 27 | } |
26 | 28 | \ No newline at end of file |
@@ -9,10 +9,10 @@ discard block |
||
9 | 9 | class HtmlFormTextarea extends HtmlFormField { |
10 | 10 | use TextFieldsTrait; |
11 | 11 | |
12 | - public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) { |
|
13 | - if(!isset($placeholder)) |
|
12 | + public function __construct($identifier, $label=NULL, $value=NULL, $placeholder=NULL, $rows=NULL) { |
|
13 | + if (!isset($placeholder)) |
|
14 | 14 | $placeholder=$label; |
15 | - parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label); |
|
15 | + parent::__construct("field-".$identifier, new HtmlTextarea($identifier, $value, $placeholder, $rows), $label); |
|
16 | 16 | $this->_identifier=$identifier; |
17 | 17 | } |
18 | 18 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * Defines the textarea row count |
21 | 21 | * @param int $count |
22 | 22 | */ |
23 | - public function setRows($count){ |
|
23 | + public function setRows($count) { |
|
24 | 24 | $this->getField()->setRows($count); |
25 | 25 | } |
26 | 26 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | return $this->content["field"]; |
29 | 29 | } |
30 | 30 | |
31 | - public function setName($name){ |
|
32 | - $this->getDataField()->setProperty("name",$name); |
|
31 | + public function setName($name) { |
|
32 | + $this->getDataField()->setProperty("name", $name); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | \ No newline at end of file |
@@ -10,8 +10,9 @@ |
||
10 | 10 | use TextFieldsTrait; |
11 | 11 | |
12 | 12 | public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) { |
13 | - if(!isset($placeholder)) |
|
14 | - $placeholder=$label; |
|
13 | + if(!isset($placeholder)) { |
|
14 | + $placeholder=$label; |
|
15 | + } |
|
15 | 16 | parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label); |
16 | 17 | $this->_identifier=$identifier; |
17 | 18 | } |
@@ -7,26 +7,26 @@ |
||
7 | 7 | |
8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
9 | 9 | |
10 | - public function __construct($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false,$associative=true) { |
|
11 | - parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label); |
|
10 | + public function __construct($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false, $associative=true) { |
|
11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label); |
|
12 | 12 | $this->_identifier=$identifier; |
13 | 13 | } |
14 | 14 | |
15 | - public function setItems($items){ |
|
15 | + public function setItems($items) { |
|
16 | 16 | return $this->getField()->setItems($items); |
17 | 17 | } |
18 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
19 | - return $this->getField()->addItem($item,$value,$image); |
|
18 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
19 | + return $this->getField()->addItem($item, $value, $image); |
|
20 | 20 | } |
21 | - public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$associative=true){ |
|
22 | - return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative); |
|
21 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $associative=true) { |
|
22 | + return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative); |
|
23 | 23 | } |
24 | 24 | |
25 | - public function getDataField(){ |
|
25 | + public function getDataField() { |
|
26 | 26 | return $this->getField()->getInput(); |
27 | 27 | } |
28 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
29 | - $this->getField()->asSelect($name,$multiple,$selection); |
|
28 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
29 | + $this->getField()->asSelect($name, $multiple, $selection); |
|
30 | 30 | return $this; |
31 | 31 | } |
32 | 32 | } |
33 | 33 | \ No newline at end of file |