@@ -16,34 +16,34 @@ discard block |
||
16 | 16 | use FieldTrait; |
17 | 17 | protected $_container; |
18 | 18 | protected $_validation; |
19 | - public function __construct($identifier, $field,$label=NULL) { |
|
20 | - parent::__construct($identifier, "div","field"); |
|
19 | + public function __construct($identifier, $field, $label=NULL) { |
|
20 | + parent::__construct($identifier, "div", "field"); |
|
21 | 21 | $this->content=array(); |
22 | - $this->_states=[State::ERROR,State::DISABLED]; |
|
23 | - if(isset($label) && $label!=="") |
|
22 | + $this->_states=[State::ERROR, State::DISABLED]; |
|
23 | + if (isset($label) && $label!=="") |
|
24 | 24 | $this->setLabel($label); |
25 | 25 | $this->setField($field); |
26 | 26 | $this->_validation=NULL; |
27 | 27 | } |
28 | 28 | |
29 | - public function addPointingLabel($label,$pointing=Direction::NONE){ |
|
30 | - $labelO=new HtmlLabel("",$label); |
|
29 | + public function addPointingLabel($label, $pointing=Direction::NONE) { |
|
30 | + $labelO=new HtmlLabel("", $label); |
|
31 | 31 | $labelO->setPointing($pointing); |
32 | - $this->addContent($labelO,$pointing==="below" || $pointing==="right"); |
|
32 | + $this->addContent($labelO, $pointing==="below" || $pointing==="right"); |
|
33 | 33 | return $labelO; |
34 | 34 | } |
35 | 35 | |
36 | - public function setLabel($label){ |
|
36 | + public function setLabel($label) { |
|
37 | 37 | $labelO=$label; |
38 | - if(\is_string($label)){ |
|
39 | - $labelO=new HtmlSemDoubleElement("","label",""); |
|
38 | + if (\is_string($label)) { |
|
39 | + $labelO=new HtmlSemDoubleElement("", "label", ""); |
|
40 | 40 | $labelO->setContent($label); |
41 | - $labelO->setProperty("for", \str_replace("field-", "",$this->identifier)); |
|
41 | + $labelO->setProperty("for", \str_replace("field-", "", $this->identifier)); |
|
42 | 42 | } |
43 | 43 | $this->content["label"]=$labelO; |
44 | 44 | } |
45 | 45 | |
46 | - public function setField($field){ |
|
46 | + public function setField($field) { |
|
47 | 47 | $this->content["field"]=$field; |
48 | 48 | } |
49 | 49 | |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * Returns the label or null |
52 | 52 | * @return mixed |
53 | 53 | */ |
54 | - public function getLabel(){ |
|
55 | - if(\array_key_exists("label", $this->content)) |
|
54 | + public function getLabel() { |
|
55 | + if (\array_key_exists("label", $this->content)) |
|
56 | 56 | return $this->content["label"]; |
57 | 57 | } |
58 | 58 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * Return the field |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | - public function getField(){ |
|
63 | + public function getField() { |
|
64 | 64 | return $this->content["field"]; |
65 | 65 | } |
66 | 66 | |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | * Return the field with data |
69 | 69 | * @return mixed |
70 | 70 | */ |
71 | - public function getDataField(){ |
|
71 | + public function getDataField() { |
|
72 | 72 | return $this->content["field"]; |
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | 76 | * puts the label before or behind |
77 | 77 | */ |
78 | - public function swapLabel(){ |
|
78 | + public function swapLabel() { |
|
79 | 79 | $label=$this->getLabel(); |
80 | 80 | unset($this->content["label"]); |
81 | 81 | $this->content["label"]=$label; |
@@ -86,31 +86,31 @@ discard block |
||
86 | 86 | * @param int $width |
87 | 87 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
88 | 88 | */ |
89 | - public function setWidth($width){ |
|
90 | - if(\is_int($width)){ |
|
89 | + public function setWidth($width) { |
|
90 | + if (\is_int($width)) { |
|
91 | 91 | $width=Wide::getConstants()["W".$width]; |
92 | 92 | } |
93 | 93 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
94 | - if(isset($this->_container)){ |
|
94 | + if (isset($this->_container)) { |
|
95 | 95 | $this->_container->setEqualWidth(false); |
96 | 96 | } |
97 | - return $this->addToPropertyCtrl("class", "wide",array("wide")); |
|
97 | + return $this->addToPropertyCtrl("class", "wide", array("wide")); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Field displays an error state |
102 | 102 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
103 | 103 | */ |
104 | - public function setError(){ |
|
104 | + public function setError() { |
|
105 | 105 | return $this->addToProperty("class", "error"); |
106 | 106 | } |
107 | 107 | |
108 | - public function setInline(){ |
|
108 | + public function setInline() { |
|
109 | 109 | return $this->addToProperty("class", "inline"); |
110 | 110 | } |
111 | 111 | |
112 | - public function jsState($state){ |
|
113 | - return $this->jsDoJquery("addClass",$state); |
|
112 | + public function jsState($state) { |
|
113 | + return $this->jsDoJquery("addClass", $state); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | public function setContainer($_container) { |
@@ -118,49 +118,49 @@ discard block |
||
118 | 118 | return $this; |
119 | 119 | } |
120 | 120 | |
121 | - public function setReadonly(){ |
|
121 | + public function setReadonly() { |
|
122 | 122 | $this->getDataField()->setProperty("readonly", ""); |
123 | 123 | } |
124 | 124 | |
125 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
125 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
126 | 126 | $field=$this->getDataField(); |
127 | - if(isset($field)){ |
|
128 | - if(!isset($this->_validation)){ |
|
127 | + if (isset($field)) { |
|
128 | + if (!isset($this->_validation)) { |
|
129 | 129 | $this->_validation=new FieldValidation($field->getIdentifier()); |
130 | 130 | } |
131 | - if($type==="empty"){ |
|
132 | - $this->addToProperty("class","required"); |
|
131 | + if ($type==="empty") { |
|
132 | + $this->addToProperty("class", "required"); |
|
133 | 133 | } |
134 | - $this->_validation->addRule($type,$prompt,$value); |
|
134 | + $this->_validation->addRule($type, $prompt, $value); |
|
135 | 135 | } |
136 | 136 | return $this; |
137 | 137 | } |
138 | 138 | |
139 | - public function setOptional($optional=true){ |
|
139 | + public function setOptional($optional=true) { |
|
140 | 140 | $field=$this->getDataField(); |
141 | - if(isset($field)){ |
|
142 | - if(!isset($this->_validation)){ |
|
141 | + if (isset($field)) { |
|
142 | + if (!isset($this->_validation)) { |
|
143 | 143 | $this->_validation=new FieldValidation($field->getIdentifier()); |
144 | 144 | } |
145 | 145 | $this->_validation->setOptional($optional); |
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - public function addRules(array $rules){ |
|
150 | - foreach ($rules as $rule){ |
|
149 | + public function addRules(array $rules) { |
|
150 | + foreach ($rules as $rule) { |
|
151 | 151 | $this->addRule($rule); |
152 | 152 | } |
153 | 153 | return $this; |
154 | 154 | } |
155 | 155 | |
156 | - public function setRules(array $rules){ |
|
156 | + public function setRules(array $rules) { |
|
157 | 157 | $this->_validation=null; |
158 | 158 | return $this->addRules($rules); |
159 | 159 | } |
160 | 160 | |
161 | - public function addIcon($icon,$direction=Direction::LEFT){ |
|
161 | + public function addIcon($icon, $direction=Direction::LEFT) { |
|
162 | 162 | $field=$this->getField(); |
163 | - return $field->addIcon($icon,$direction); |
|
163 | + return $field->addIcon($icon, $direction); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | public function getValidation() { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | } |
173 | 173 | |
174 | 174 | public function run(JsUtils $js) { |
175 | - if(isset($this->_validation)){ |
|
175 | + if (isset($this->_validation)) { |
|
176 | 176 | $this->_validation->compile($js); |
177 | 177 | } |
178 | 178 | return parent::run($js); |
@@ -10,7 +10,7 @@ |
||
10 | 10 | */ |
11 | 11 | class HtmlRail extends HtmlSemDoubleElement { |
12 | 12 | |
13 | - public function __construct($identifier, $content = NULL) { |
|
13 | + public function __construct($identifier, $content=NULL) { |
|
14 | 14 | parent::__construct($identifier, 'div', 'ui rail', $content); |
15 | 15 | } |
16 | 16 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param string $onClick |
46 | 46 | * @return HtmlButton |
47 | 47 | */ |
48 | - public function htmlButton($identifier, $value = null, $cssStyle = null, $onClick = null) { |
|
48 | + public function htmlButton($identifier, $value=null, $cssStyle=null, $onClick=null) { |
|
49 | 49 | return $this->addHtmlComponent(new HtmlButton($identifier, $value, $cssStyle, $onClick)); |
50 | 50 | } |
51 | 51 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param boolean $asIcons |
60 | 60 | * @return HtmlButtonGroups |
61 | 61 | */ |
62 | - public function htmlButtonGroups($identifier, $elements = array(), $asIcons = false) { |
|
62 | + public function htmlButtonGroups($identifier, $elements=array(), $asIcons=false) { |
|
63 | 63 | return $this->addHtmlComponent(new HtmlButtonGroups($identifier, $elements, $asIcons)); |
64 | 64 | } |
65 | 65 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param string $content |
73 | 73 | * @return HtmlContainer |
74 | 74 | */ |
75 | - public function htmlContainer($identifier, $content = "") { |
|
75 | + public function htmlContainer($identifier, $content="") { |
|
76 | 76 | return $this->addHtmlComponent(new HtmlContainer($identifier, $content)); |
77 | 77 | } |
78 | 78 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param string $content |
86 | 86 | * @return HtmlDivider |
87 | 87 | */ |
88 | - public function htmlDivider($identifier, $content = "", $tagName = "div") { |
|
88 | + public function htmlDivider($identifier, $content="", $tagName="div") { |
|
89 | 89 | return $this->addHtmlComponent(new HtmlDivider($identifier, $content, $tagName)); |
90 | 90 | } |
91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param string $type |
101 | 101 | * @return HtmlHeader |
102 | 102 | */ |
103 | - public function htmlHeader($identifier, $niveau = 1, $content = NULL, $type = "page") { |
|
103 | + public function htmlHeader($identifier, $niveau=1, $content=NULL, $type="page") { |
|
104 | 104 | return $this->addHtmlComponent(new HtmlHeader($identifier, $niveau, $content, $type)); |
105 | 105 | } |
106 | 106 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param string $size |
129 | 129 | * @return HtmlImage |
130 | 130 | */ |
131 | - public function htmlImage($identifier, $src = "", $alt = "", $size = NULL) { |
|
131 | + public function htmlImage($identifier, $src="", $alt="", $size=NULL) { |
|
132 | 132 | return $this->addHtmlComponent(new HtmlImage($identifier, $src, $alt, $size)); |
133 | 133 | } |
134 | 134 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param string $size |
143 | 143 | * @return HtmlIconGroups |
144 | 144 | */ |
145 | - public function htmlIconGroups($identifier, $icons = array(), $size = "") { |
|
145 | + public function htmlIconGroups($identifier, $icons=array(), $size="") { |
|
146 | 146 | return $this->addHtmlComponent(new HtmlIconGroups($identifier, $icons, $size)); |
147 | 147 | } |
148 | 148 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param string $placeholder |
158 | 158 | * @return HtmlInput |
159 | 159 | */ |
160 | - public function htmlInput($identifier, $type = "text", $value = "", $placeholder = "") { |
|
160 | + public function htmlInput($identifier, $type="text", $value="", $placeholder="") { |
|
161 | 161 | return $this->addHtmlComponent(new HtmlInput($identifier, $type, $value, $placeholder)); |
162 | 162 | } |
163 | 163 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @param string $tagName |
172 | 172 | * @return HtmlLabel |
173 | 173 | */ |
174 | - public function htmlLabel($identifier, $content = "", $icon = NULL, $tagName = "div") { |
|
174 | + public function htmlLabel($identifier, $content="", $icon=NULL, $tagName="div") { |
|
175 | 175 | return $this->addHtmlComponent(new HtmlLabel($identifier, $content, $icon, $tagName)); |
176 | 176 | } |
177 | 177 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @param array $attributes |
183 | 183 | * @return HtmlLabelGroups |
184 | 184 | */ |
185 | - public function htmlLabelGroups($identifier, $labels = array(), $attributes = array()) { |
|
185 | + public function htmlLabelGroups($identifier, $labels=array(), $attributes=array()) { |
|
186 | 186 | return $this->addHtmlComponent(new HtmlLabelGroups($identifier, $labels, $attributes)); |
187 | 187 | } |
188 | 188 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @param array $items |
194 | 194 | * @return HtmlList |
195 | 195 | */ |
196 | - public function htmlList($identifier, $items = array()) { |
|
196 | + public function htmlList($identifier, $items=array()) { |
|
197 | 197 | return $this->addHtmlComponent(new HtmlList($identifier, $items)); |
198 | 198 | } |
199 | 199 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @param string $content |
205 | 205 | * @return HtmlSegment |
206 | 206 | */ |
207 | - public function htmlSegment($identifier, $content = "") { |
|
207 | + public function htmlSegment($identifier, $content="") { |
|
208 | 208 | return $this->addHtmlComponent(new HtmlSegment($identifier, $content)); |
209 | 209 | } |
210 | 210 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * the segments |
217 | 217 | * @return HtmlSegmentGroups |
218 | 218 | */ |
219 | - public function htmlSegmentGroups($identifier, $items = array()) { |
|
219 | + public function htmlSegmentGroups($identifier, $items=array()) { |
|
220 | 220 | return $this->addHtmlComponent(new HtmlSegmentGroups($identifier, $items)); |
221 | 221 | } |
222 | 222 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @param Direction|string $attributeType |
231 | 231 | * @return HtmlReveal |
232 | 232 | */ |
233 | - public function htmlReveal($identifier, $visibleContent, $hiddenContent, $type = RevealType::FADE, $attributeType = NULL) { |
|
233 | + public function htmlReveal($identifier, $visibleContent, $hiddenContent, $type=RevealType::FADE, $attributeType=NULL) { |
|
234 | 234 | return $this->addHtmlComponent(new HtmlReveal($identifier, $visibleContent, $hiddenContent, $type, $attributeType)); |
235 | 235 | } |
236 | 236 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @param array $steps |
242 | 242 | * @return HtmlStep |
243 | 243 | */ |
244 | - public function htmlStep($identifier, $steps = array()) { |
|
244 | + public function htmlStep($identifier, $steps=array()) { |
|
245 | 245 | return $this->addHtmlComponent(new HtmlStep($identifier, $steps)); |
246 | 246 | } |
247 | 247 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * @param mixed $content |
276 | 276 | * @return HtmlRail |
277 | 277 | */ |
278 | - public function htmlRail($identifier, $content = null) { |
|
278 | + public function htmlRail($identifier, $content=null) { |
|
279 | 279 | return $this->addHtmlComponent(new HtmlRail($identifier, $content)); |
280 | 280 | } |
281 | 281 | } |
@@ -13,19 +13,19 @@ discard block |
||
13 | 13 | */ |
14 | 14 | protected $content; |
15 | 15 | |
16 | - protected $wrapContentBefore = ""; |
|
16 | + protected $wrapContentBefore=""; |
|
17 | 17 | |
18 | - protected $wrapContentAfter = ""; |
|
18 | + protected $wrapContentAfter=""; |
|
19 | 19 | |
20 | 20 | protected $_editableContent; |
21 | 21 | |
22 | - public function __construct($identifier, $tagName = "p") { |
|
22 | + public function __construct($identifier, $tagName="p") { |
|
23 | 23 | parent::__construct($identifier, $tagName); |
24 | - $this->_template = '<%tagName% id="%identifier%" %properties%>%wrapContentBefore%%content%%wrapContentAfter%</%tagName%>'; |
|
24 | + $this->_template='<%tagName% id="%identifier%" %properties%>%wrapContentBefore%%content%%wrapContentAfter%</%tagName%>'; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function setContent($content) { |
28 | - $this->content = $content; |
|
28 | + $this->content=$content; |
|
29 | 29 | return $this; |
30 | 30 | } |
31 | 31 | |
@@ -33,19 +33,19 @@ discard block |
||
33 | 33 | return $this->content; |
34 | 34 | } |
35 | 35 | |
36 | - public function addContent($content, $before = false) { |
|
37 | - if (! \is_array($this->content)) { |
|
36 | + public function addContent($content, $before=false) { |
|
37 | + if (!\is_array($this->content)) { |
|
38 | 38 | if (isset($this->content)) |
39 | - $this->content = array( |
|
39 | + $this->content=array( |
|
40 | 40 | $this->content |
41 | 41 | ); |
42 | 42 | else |
43 | - $this->content = array(); |
|
43 | + $this->content=array(); |
|
44 | 44 | } |
45 | 45 | if ($before) |
46 | 46 | \array_unshift($this->content, $content); |
47 | 47 | else |
48 | - $this->content[] = $content; |
|
48 | + $this->content[]=$content; |
|
49 | 49 | return $this; |
50 | 50 | } |
51 | 51 | |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | |
69 | 69 | public function setValue($value) {} |
70 | 70 | |
71 | - public function wrapContent($before, $after = "") { |
|
72 | - $this->wrapContentBefore .= $before; |
|
73 | - $this->wrapContentAfter = $after . $this->wrapContentAfter; |
|
71 | + public function wrapContent($before, $after="") { |
|
72 | + $this->wrapContentBefore.=$before; |
|
73 | + $this->wrapContentAfter=$after.$this->wrapContentAfter; |
|
74 | 74 | return $this; |
75 | 75 | } |
76 | 76 | |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | protected function _getContentInstances($class, $content) { |
92 | - $instances = []; |
|
92 | + $instances=[]; |
|
93 | 93 | if ($content instanceof $class) { |
94 | - $instances[] = $content; |
|
94 | + $instances[]=$content; |
|
95 | 95 | } elseif ($content instanceof HtmlDoubleElement) { |
96 | - $instances = \array_merge($instances, $content->getContentInstances($class)); |
|
96 | + $instances=\array_merge($instances, $content->getContentInstances($class)); |
|
97 | 97 | } elseif (\is_array($content)) { |
98 | 98 | foreach ($content as $element) { |
99 | - $instances = \array_merge($instances, $this->_getContentInstances($class, $element)); |
|
99 | + $instances=\array_merge($instances, $this->_getContentInstances($class, $element)); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | return $instances; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return HtmlDoubleElement |
109 | 109 | */ |
110 | - public function asLink($href = NULL, $target = NULL) { |
|
110 | + public function asLink($href=NULL, $target=NULL) { |
|
111 | 111 | if (isset($href)) |
112 | 112 | $this->setProperty("href", $href); |
113 | 113 | if (isset($target)) |
@@ -122,28 +122,28 @@ discard block |
||
122 | 122 | return \strip_tags($this->content); |
123 | 123 | } |
124 | 124 | |
125 | - public function asEditable(HtmlFormField $field, $asForm = false, $setValueProperty = "val()") { |
|
126 | - $idF = $field->getIdentifier(); |
|
127 | - $idE = $idF; |
|
125 | + public function asEditable(HtmlFormField $field, $asForm=false, $setValueProperty="val()") { |
|
126 | + $idF=$field->getIdentifier(); |
|
127 | + $idE=$idF; |
|
128 | 128 | if ($asForm) { |
129 | - $frm = new HtmlForm("frm-" . $field->getIdentifier()); |
|
129 | + $frm=new HtmlForm("frm-".$field->getIdentifier()); |
|
130 | 130 | $frm->setProperty("onsubmit", "return false;"); |
131 | - $fields = $frm->addFields(); |
|
132 | - $idE = $frm->getIdentifier(); |
|
131 | + $fields=$frm->addFields(); |
|
132 | + $idE=$frm->getIdentifier(); |
|
133 | 133 | $fields->addItem($field); |
134 | - $fields->addButtonIcon("bt-okay", "check", "green mini", "\$('#" . $idE . "').trigger('validate',{value: $('#'+idF+' input').val()});"); |
|
135 | - $fields->addButtonIcon("bt-cancel", "close", "mini", "\$('#" . $idE . "').trigger('endEdit');"); |
|
136 | - $this->_editableContent = $frm; |
|
137 | - $keypress = ""; |
|
138 | - $focusOut = ""; |
|
134 | + $fields->addButtonIcon("bt-okay", "check", "green mini", "\$('#".$idE."').trigger('validate',{value: $('#'+idF+' input').val()});"); |
|
135 | + $fields->addButtonIcon("bt-cancel", "close", "mini", "\$('#".$idE."').trigger('endEdit');"); |
|
136 | + $this->_editableContent=$frm; |
|
137 | + $keypress=""; |
|
138 | + $focusOut=""; |
|
139 | 139 | } else { |
140 | - $focusOut = "if(e.relatedTarget==null)elm.trigger('endEdit');"; |
|
141 | - $this->_editableContent = $field; |
|
142 | - $keypress = "$('#" . $idF . "').keyup(function(e){if(e.which == 13) {\$('#" . $idE . "').trigger('validate',{value: $('#'+idF+' input').val()});}if(e.keyCode===27) {\$('#" . $idE . "').trigger('endEdit');}});"; |
|
140 | + $focusOut="if(e.relatedTarget==null)elm.trigger('endEdit');"; |
|
141 | + $this->_editableContent=$field; |
|
142 | + $keypress="$('#".$idF."').keyup(function(e){if(e.which == 13) {\$('#".$idE."').trigger('validate',{value: $('#'+idF+' input').val()});}if(e.keyCode===27) {\$('#".$idE."').trigger('endEdit');}});"; |
|
143 | 143 | } |
144 | 144 | $this->_editableContent->setProperty("style", "display:none;"); |
145 | - $this->onCreate("let idF='" . $idF . "';let idE='" . $idE . "';let elm=$('#'+idE);let self=$('#" . $this->getIdentifier() . "');" . $keypress . "elm.on('validate',function(){self.html($('#'+idE+' input')." . $setValueProperty . ");elm.trigger('endEdit');});elm.on('endEdit',function(){self.show();$(this).hide();});elm.focusout(function(e){" . $focusOut . "});"); |
|
146 | - $this->onClick("let self=$(this);self.hide();" . $field->setJsContent("self.html()") . ";$('#" . $idF . " input').trigger('change');elm.show();$('#'+idE+' input').focus();"); |
|
145 | + $this->onCreate("let idF='".$idF."';let idE='".$idE."';let elm=$('#'+idE);let self=$('#".$this->getIdentifier()."');".$keypress."elm.on('validate',function(){self.html($('#'+idE+' input').".$setValueProperty.");elm.trigger('endEdit');});elm.on('endEdit',function(){self.show();$(this).hide();});elm.focusout(function(e){".$focusOut."});"); |
|
146 | + $this->onClick("let self=$(this);self.hide();".$field->setJsContent("self.html()").";$('#".$idF." input').trigger('change');elm.show();$('#'+idE+' input').focus();"); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | * {@inheritdoc} |
152 | 152 | * @see \Ajax\common\html\BaseHtml::compile_once() |
153 | 153 | */ |
154 | - protected function compile_once(\Ajax\JsUtils $js = NULL, &$view = NULL) { |
|
155 | - if (! $this->_compiled && isset($this->_editableContent)) { |
|
154 | + protected function compile_once(\Ajax\JsUtils $js=NULL, &$view=NULL) { |
|
155 | + if (!$this->_compiled && isset($this->_editableContent)) { |
|
156 | 156 | $this->wrap("", $this->_editableContent); |
157 | 157 | } |
158 | 158 | parent::compile_once($js, $view); |
@@ -14,44 +14,44 @@ discard block |
||
14 | 14 | */ |
15 | 15 | abstract class HtmlCollection extends HtmlDoubleElement { |
16 | 16 | |
17 | - public function __construct($identifier,$tagName="div"){ |
|
18 | - parent::__construct($identifier,$tagName); |
|
17 | + public function __construct($identifier, $tagName="div") { |
|
18 | + parent::__construct($identifier, $tagName); |
|
19 | 19 | $this->content=array(); |
20 | 20 | } |
21 | 21 | |
22 | - public function addItems($items){ |
|
23 | - if(JArray::isAssociative($items)){ |
|
24 | - foreach ($items as $k=>$v){ |
|
25 | - $this->addItem([$k,$v]); |
|
22 | + public function addItems($items) { |
|
23 | + if (JArray::isAssociative($items)) { |
|
24 | + foreach ($items as $k=>$v) { |
|
25 | + $this->addItem([$k, $v]); |
|
26 | 26 | } |
27 | - }else{ |
|
28 | - foreach ($items as $item){ |
|
27 | + } else { |
|
28 | + foreach ($items as $item) { |
|
29 | 29 | $this->addItem($item); |
30 | 30 | } |
31 | 31 | } |
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
35 | - public function setItems($items){ |
|
35 | + public function setItems($items) { |
|
36 | 36 | $this->content=$items; |
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | - public function getItems(){ |
|
40 | + public function getItems() { |
|
41 | 41 | return $this->content; |
42 | 42 | } |
43 | 43 | |
44 | - protected function getItemToAdd($item){ |
|
44 | + protected function getItemToAdd($item) { |
|
45 | 45 | $itemO=$item; |
46 | - if($this->createCondition($item)===true){ |
|
46 | + if ($this->createCondition($item)===true) { |
|
47 | 47 | $itemO=$this->createItem($item); |
48 | 48 | } |
49 | 49 | return $itemO; |
50 | 50 | } |
51 | 51 | |
52 | - protected function setItemIdentifier($item,$classname,$index){ |
|
53 | - if($item instanceof BaseWidget){ |
|
54 | - if(JString::isNull($item->getIdentifier())){ |
|
52 | + protected function setItemIdentifier($item, $classname, $index) { |
|
53 | + if ($item instanceof BaseWidget) { |
|
54 | + if (JString::isNull($item->getIdentifier())) { |
|
55 | 55 | $item->setIdentifier($classname."-".$this->identifier."-".$index); |
56 | 56 | } |
57 | 57 | } |
@@ -62,15 +62,15 @@ discard block |
||
62 | 62 | * @param HtmlDoubleElement|string|array $item |
63 | 63 | * @return \Ajax\common\html\HtmlDoubleElement |
64 | 64 | */ |
65 | - public function addItem($item){ |
|
65 | + public function addItem($item) { |
|
66 | 66 | $itemO=$this->getItemToAdd($item); |
67 | 67 | $this->addContent($itemO); |
68 | 68 | return $itemO; |
69 | 69 | } |
70 | 70 | |
71 | - public function insertItem($item,$position=0){ |
|
71 | + public function insertItem($item, $position=0) { |
|
72 | 72 | $itemO=$this->getItemToAdd($item); |
73 | - \array_splice( $this->content, $position, 0, array($itemO)); |
|
73 | + \array_splice($this->content, $position, 0, array($itemO)); |
|
74 | 74 | return $itemO; |
75 | 75 | } |
76 | 76 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @return \Ajax\common\html\HtmlDoubleElement |
81 | 81 | */ |
82 | 82 | public function getItem($index) { |
83 | - if (is_int($index)&& isset($this->content[$index])) |
|
83 | + if (is_int($index) && isset($this->content[$index])) |
|
84 | 84 | return $this->content[$index]; |
85 | 85 | else { |
86 | 86 | $elm=$this->getElementById($index, $this->content); |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | return $this; |
94 | 94 | } |
95 | 95 | |
96 | - public function removeItem($index){ |
|
96 | + public function removeItem($index) { |
|
97 | 97 | return array_splice($this->content, $index, 1); |
98 | 98 | } |
99 | 99 | |
100 | - public function count(){ |
|
100 | + public function count() { |
|
101 | 101 | return \sizeof($this->content); |
102 | 102 | } |
103 | 103 | |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | return $this->addItem($function($object)); |
109 | 109 | } |
110 | 110 | |
111 | - public function apply($callBack){ |
|
112 | - foreach ($this->content as $item){ |
|
111 | + public function apply($callBack) { |
|
112 | + foreach ($this->content as $item) { |
|
113 | 113 | $callBack($item); |
114 | 114 | } |
115 | 115 | return $this; |
@@ -129,23 +129,23 @@ discard block |
||
129 | 129 | */ |
130 | 130 | abstract protected function createItem($value); |
131 | 131 | |
132 | - protected function createCondition($value){ |
|
132 | + protected function createCondition($value) { |
|
133 | 133 | return !($value instanceof BaseHtml); |
134 | 134 | } |
135 | 135 | |
136 | - protected function contentAs($tagName){ |
|
137 | - foreach ($this->content as $item){ |
|
136 | + protected function contentAs($tagName) { |
|
137 | + foreach ($this->content as $item) { |
|
138 | 138 | $item->setTagName($tagName); |
139 | 139 | } |
140 | 140 | return $this; |
141 | 141 | } |
142 | 142 | |
143 | - public function setProperties($properties){ |
|
143 | + public function setProperties($properties) { |
|
144 | 144 | $i=0; |
145 | - foreach ($properties as $k=>$v){ |
|
145 | + foreach ($properties as $k=>$v) { |
|
146 | 146 | $c=$this->content[$i++]; |
147 | - if(isset($c)) |
|
148 | - $c->setProperty($k,$v); |
|
147 | + if (isset($c)) |
|
148 | + $c->setProperty($k, $v); |
|
149 | 149 | else |
150 | 150 | return $this; |
151 | 151 | } |
@@ -158,15 +158,15 @@ discard block |
||
158 | 158 | * @param array|mixed $values |
159 | 159 | * @return $this |
160 | 160 | */ |
161 | - public function setPropertyValues($property,$values){ |
|
162 | - if(\is_array($values)===false){ |
|
163 | - $values=\array_fill(0, $this->count(),$values); |
|
161 | + public function setPropertyValues($property, $values) { |
|
162 | + if (\is_array($values)===false) { |
|
163 | + $values=\array_fill(0, $this->count(), $values); |
|
164 | 164 | } |
165 | - foreach ($values as $i=>$value){ |
|
166 | - if(isset($this->content[$i])){ |
|
167 | - $this->content[$i]->setProperty($property,$value); |
|
165 | + foreach ($values as $i=>$value) { |
|
166 | + if (isset($this->content[$i])) { |
|
167 | + $this->content[$i]->setProperty($property, $value); |
|
168 | 168 | } |
169 | - else{ |
|
169 | + else { |
|
170 | 170 | return $this; |
171 | 171 | } |
172 | 172 | } |
@@ -179,15 +179,15 @@ discard block |
||
179 | 179 | * @param array|mixed $values |
180 | 180 | * @return $this |
181 | 181 | */ |
182 | - public function addPropertyValues($property,$values){ |
|
183 | - if(\is_array($values)===false){ |
|
184 | - $values=\array_fill(0, $this->count(),$values); |
|
182 | + public function addPropertyValues($property, $values) { |
|
183 | + if (\is_array($values)===false) { |
|
184 | + $values=\array_fill(0, $this->count(), $values); |
|
185 | 185 | } |
186 | - foreach ($values as $i=>$value){ |
|
187 | - if(isset($this->content[$i])){ |
|
188 | - $this->content[$i++]->addToProperty($property,$value); |
|
186 | + foreach ($values as $i=>$value) { |
|
187 | + if (isset($this->content[$i])) { |
|
188 | + $this->content[$i++]->addToProperty($property, $value); |
|
189 | 189 | } |
190 | - else{ |
|
190 | + else { |
|
191 | 191 | return $this; |
192 | 192 | } |
193 | 193 | } |
@@ -197,13 +197,13 @@ discard block |
||
197 | 197 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
198 | 198 | $index=0; |
199 | 199 | $classname=\strtolower(JReflection::shortClassName($this)); |
200 | - foreach ($this->content as $item){ |
|
201 | - $this->setItemIdentifier($item,$classname,$index++); |
|
200 | + foreach ($this->content as $item) { |
|
201 | + $this->setItemIdentifier($item, $classname, $index++); |
|
202 | 202 | } |
203 | - return parent::compile($js,$view); |
|
203 | + return parent::compile($js, $view); |
|
204 | 204 | } |
205 | 205 | |
206 | - public function getItemById($identifier){ |
|
206 | + public function getItemById($identifier) { |
|
207 | 207 | return $this->getElementById($identifier, $this->content); |
208 | 208 | } |
209 | 209 | |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | * @param string $target |
213 | 213 | * @return HtmlCollection |
214 | 214 | */ |
215 | - public function asLinks($hrefs=[],$target=NUll) { |
|
216 | - foreach ( $this->content as $index=>$item ) { |
|
217 | - if($item instanceof HtmlDoubleElement){ |
|
215 | + public function asLinks($hrefs=[], $target=NUll) { |
|
216 | + foreach ($this->content as $index=>$item) { |
|
217 | + if ($item instanceof HtmlDoubleElement) { |
|
218 | 218 | $href=""; |
219 | - if(isset($hrefs[$index])) |
|
219 | + if (isset($hrefs[$index])) |
|
220 | 220 | $href=$hrefs[$index]; |
221 | - $item->asLink($href,$target); |
|
221 | + $item->asLink($href, $target); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | return $this; |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | * @param int $length If length is omitted, removes everything from offset to the end of the array. If length is specified and is positive, then that many elements will be removed. If length is specified and is negative then the end of the removed portion will be that many elements from the end of the array. If length is specified and is zero, no elements will be removed. Tip: to remove everything from offset to the end of the array when replacement is also specified, use count($input) for length. |
231 | 231 | * @return $this |
232 | 232 | */ |
233 | - public function splice($offset,$length=null){ |
|
234 | - $this->content=array_slice($this->content, $offset,$length); |
|
233 | + public function splice($offset, $length=null) { |
|
234 | + $this->content=array_slice($this->content, $offset, $length); |
|
235 | 235 | return $this; |
236 | 236 | } |
237 | 237 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @author jc |
16 | 16 | * |
17 | 17 | */ |
18 | -trait FormTrait{ |
|
18 | +trait FormTrait { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @return HtmlForm |
@@ -23,23 +23,23 @@ discard block |
||
23 | 23 | abstract protected function getForm(); |
24 | 24 | |
25 | 25 | |
26 | - protected function addCompoValidation(Form $compo,HtmlFormField $field){ |
|
26 | + protected function addCompoValidation(Form $compo, HtmlFormField $field) { |
|
27 | 27 | $validation=$field->getValidation(); |
28 | - if(isset($validation)){ |
|
28 | + if (isset($validation)) { |
|
29 | 29 | $validation->setIdentifier($field->getDataField()->getIdentifier()); |
30 | 30 | $compo->addFieldValidation($validation); |
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | - protected function addExtraCompoValidation(Form $compo,FieldValidation $validation){ |
|
34 | + protected function addExtraCompoValidation(Form $compo, FieldValidation $validation) { |
|
35 | 35 | $compo->addFieldValidation($validation); |
36 | 36 | } |
37 | 37 | |
38 | - protected function _runValidationParams(Form &$compo,JsUtils $js=NULL){ |
|
38 | + protected function _runValidationParams(Form &$compo, JsUtils $js=NULL) { |
|
39 | 39 | $form=$this->getForm(); |
40 | 40 | $params=$form->getValidationParams(); |
41 | - if(isset($params["_ajaxSubmit"])){ |
|
42 | - $compilation=$this->_compileAjaxSubmit($params["_ajaxSubmit"],$js); |
|
41 | + if (isset($params["_ajaxSubmit"])) { |
|
42 | + $compilation=$this->_compileAjaxSubmit($params["_ajaxSubmit"], $js); |
|
43 | 43 | $this->onSuccess($compilation); |
44 | 44 | $form->removeValidationParam("_ajaxSubmit"); |
45 | 45 | } |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | $form->addEventsOnRun($js); |
49 | 49 | } |
50 | 50 | |
51 | - protected function _compileAjaxSubmit($ajaxSubmit,JsUtils $js=null){ |
|
51 | + protected function _compileAjaxSubmit($ajaxSubmit, JsUtils $js=null) { |
|
52 | 52 | $compilation=""; |
53 | - if(\is_array($ajaxSubmit)){ |
|
54 | - foreach ($ajaxSubmit as $ajaxSubmitItem){ |
|
53 | + if (\is_array($ajaxSubmit)) { |
|
54 | + foreach ($ajaxSubmit as $ajaxSubmitItem) { |
|
55 | 55 | $compilation.=$ajaxSubmitItem->compile($js); |
56 | 56 | } |
57 | - }elseif($ajaxSubmit instanceof AjaxCall){ |
|
57 | + }elseif ($ajaxSubmit instanceof AjaxCall) { |
|
58 | 58 | $compilation=$ajaxSubmit->compile($js); |
59 | 59 | } |
60 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
60 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
61 | 61 | return $compilation; |
62 | 62 | } |
63 | 63 | |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | return $this; |
71 | 71 | } |
72 | 72 | |
73 | - public function setAttached($value=true){ |
|
73 | + public function setAttached($value=true) { |
|
74 | 74 | $form=$this->getForm(); |
75 | - if($value) |
|
76 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
75 | + if ($value) |
|
76 | + $form->addToPropertyCtrl("class", "attached", array("attached")); |
|
77 | 77 | return $form; |
78 | 78 | } |
79 | 79 | |
80 | - public function addErrorMessage(){ |
|
80 | + public function addErrorMessage() { |
|
81 | 81 | return $this->getForm()->addContent((new HtmlMessage(""))->setError()); |
82 | 82 | } |
83 | 83 | |
@@ -93,48 +93,48 @@ discard block |
||
93 | 93 | * @param array $parameters |
94 | 94 | * @return HtmlForm |
95 | 95 | */ |
96 | - public function submitOn($event,$identifierOrElement,$url,$responseElement,$parameters=NULL){ |
|
96 | + public function submitOn($event, $identifierOrElement, $url, $responseElement, $parameters=NULL) { |
|
97 | 97 | $form=$this->getForm(); |
98 | - if($identifierOrElement instanceof BaseHtml) |
|
98 | + if ($identifierOrElement instanceof BaseHtml) |
|
99 | 99 | $elem=$identifierOrElement; |
100 | 100 | else |
101 | 101 | $elem=$form->getElementById($identifierOrElement, $form->getContent()); |
102 | - if(isset($elem)){ |
|
103 | - $this->_buttonAsSubmit($elem, $event,$url,$responseElement,$parameters); |
|
102 | + if (isset($elem)) { |
|
103 | + $this->_buttonAsSubmit($elem, $event, $url, $responseElement, $parameters); |
|
104 | 104 | } |
105 | 105 | return $form; |
106 | 106 | } |
107 | 107 | |
108 | - public function submitOnClick($identifier,$url,$responseElement,$parameters=NULL){ |
|
109 | - return $this->submitOn("click", $identifier, $url, $responseElement,$parameters); |
|
108 | + public function submitOnClick($identifier, $url, $responseElement, $parameters=NULL) { |
|
109 | + return $this->submitOn("click", $identifier, $url, $responseElement, $parameters); |
|
110 | 110 | } |
111 | 111 | |
112 | - public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
113 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
114 | - return $this->_buttonAsSubmit($bt, "click",$url,$responseElement,$parameters); |
|
112 | + public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
113 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
114 | + return $this->_buttonAsSubmit($bt, "click", $url, $responseElement, $parameters); |
|
115 | 115 | } |
116 | 116 | |
117 | - protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL){ |
|
117 | + protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement=NULL, $parameters=NULL) { |
|
118 | 118 | $form=$this->getForm(); |
119 | - if(isset($url) && isset($responseElement)){ |
|
120 | - $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true); |
|
121 | - $this->setSubmitParams($url,$responseElement,$parameters); |
|
119 | + if (isset($url) && isset($responseElement)) { |
|
120 | + $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');", true, true); |
|
121 | + $this->setSubmitParams($url, $responseElement, $parameters); |
|
122 | 122 | } |
123 | 123 | return $button; |
124 | 124 | } |
125 | 125 | |
126 | - public function setSubmitParams($url,$responseElement=NULL,$parameters=NULL){ |
|
126 | + public function setSubmitParams($url, $responseElement=NULL, $parameters=NULL) { |
|
127 | 127 | $form=$this->getForm(); |
128 | - $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true]; |
|
129 | - if(\is_array($parameters)){ |
|
130 | - $params=\array_merge($params,$parameters); |
|
128 | + $params=["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url, "stopPropagation"=>true]; |
|
129 | + if (\is_array($parameters)) { |
|
130 | + $params=\array_merge($params, $parameters); |
|
131 | 131 | } |
132 | 132 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
133 | 133 | return $this; |
134 | 134 | } |
135 | 135 | |
136 | - public function addReset($identifier,$value,$cssStyle=NULL){ |
|
137 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
136 | + public function addReset($identifier, $value, $cssStyle=NULL) { |
|
137 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
138 | 138 | $bt->setProperty("type", "reset"); |
139 | 139 | return $bt; |
140 | 140 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param string $jsCode |
145 | 145 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
146 | 146 | */ |
147 | - public function onValid($jsCode){ |
|
147 | + public function onValid($jsCode) { |
|
148 | 148 | $form=$this->getForm(); |
149 | 149 | $form->addValidationParam("onValid", "%function(){".$jsCode."}%"); |
150 | 150 | return $form; |
@@ -155,35 +155,35 @@ discard block |
||
155 | 155 | * @param string $jsCode can use event and fields parameters |
156 | 156 | * @return HtmlForm |
157 | 157 | */ |
158 | - public function onSuccess($jsCode){ |
|
158 | + public function onSuccess($jsCode) { |
|
159 | 159 | $form=$this->getForm(); |
160 | - $form->addValidationParam("onSuccess", $jsCode,"%function(event,fields){","}%"); |
|
160 | + $form->addValidationParam("onSuccess", $jsCode, "%function(event,fields){", "}%"); |
|
161 | 161 | return $form; |
162 | 162 | } |
163 | 163 | |
164 | - public function addExtraFieldRules($fieldname,$rules){ |
|
164 | + public function addExtraFieldRules($fieldname, $rules) { |
|
165 | 165 | $form=$this->getForm(); |
166 | 166 | $fv=$form->getExtraFieldValidation($fieldname); |
167 | - foreach ($rules as $rule){ |
|
167 | + foreach ($rules as $rule) { |
|
168 | 168 | $fv->addRule($rule); |
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | - public function addExtraFieldRule($fieldname,$type,$prompt=NULL,$value=NULL){ |
|
172 | + public function addExtraFieldRule($fieldname, $type, $prompt=NULL, $value=NULL) { |
|
173 | 173 | $form=$this->getForm(); |
174 | 174 | $fv=$form->getExtraFieldValidation($fieldname); |
175 | - $fv->addRule($type,$prompt,$value); |
|
175 | + $fv->addRule($type, $prompt, $value); |
|
176 | 176 | } |
177 | 177 | |
178 | - public function setOptional($fieldname,$optional=true){ |
|
178 | + public function setOptional($fieldname, $optional=true) { |
|
179 | 179 | $form=$this->getForm(); |
180 | 180 | $fv=$form->getExtraFieldValidation($fieldname); |
181 | 181 | $fv->setOptional($optional); |
182 | 182 | } |
183 | 183 | |
184 | - public function setActionTarget(string $action, string $target){ |
|
184 | + public function setActionTarget(string $action, string $target) { |
|
185 | 185 | $form=$this->getForm(); |
186 | - $form->setProperty('data-target',$target); |
|
187 | - $form->setProperty('action',$action); |
|
186 | + $form->setProperty('data-target', $target); |
|
187 | + $form->setProperty('action', $action); |
|
188 | 188 | } |
189 | 189 | } |
@@ -24,39 +24,39 @@ discard block |
||
24 | 24 | private $_inverted; |
25 | 25 | |
26 | 26 | public function __construct($identifier, $modelInstance=NULL) { |
27 | - parent::__construct($identifier, null,$modelInstance); |
|
27 | + parent::__construct($identifier, null, $modelInstance); |
|
28 | 28 | $this->_form=new HtmlForm($identifier); |
29 | 29 | $this->_init(new FormInstanceViewer($identifier), 'form', $this->_form, true); |
30 | 30 | } |
31 | 31 | |
32 | - protected function _getFieldIdentifier($prefix,$name=''){ |
|
32 | + protected function _getFieldIdentifier($prefix, $name='') { |
|
33 | 33 | return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier(); |
34 | 34 | } |
35 | 35 | |
36 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
37 | - if(!$this->_generated){ |
|
36 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
37 | + if (!$this->_generated) { |
|
38 | 38 | $this->_instanceViewer->setInstance($this->_modelInstance); |
39 | 39 | |
40 | 40 | $form=$this->content['form']; |
41 | 41 | $this->_generateContent($form); |
42 | 42 | |
43 | - if(isset($this->_toolbar)){ |
|
43 | + if (isset($this->_toolbar)) { |
|
44 | 44 | $this->_setToolbarPosition($form); |
45 | 45 | } |
46 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,'form',PositionInTable::AFTERTABLE]); |
|
47 | - if($this->_inverted){ |
|
46 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, 'form', PositionInTable::AFTERTABLE]); |
|
47 | + if ($this->_inverted) { |
|
48 | 48 | $this->content['form']->setInverted(true); |
49 | 49 | } |
50 | 50 | $this->_generated=true; |
51 | 51 | } |
52 | - return parent::compile($js,$view); |
|
52 | + return parent::compile($js, $view); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @param HtmlForm $form |
57 | 57 | */ |
58 | - protected function _generateContent($form){ |
|
59 | - $values= $this->_instanceViewer->getValues(); |
|
58 | + protected function _generateContent($form) { |
|
59 | + $values=$this->_instanceViewer->getValues(); |
|
60 | 60 | $count=$this->_instanceViewer->count(); |
61 | 61 | $separators=$this->_instanceViewer->getSeparators(); |
62 | 62 | $headers=$this->_instanceViewer->getHeaders(); |
@@ -65,42 +65,42 @@ discard block |
||
65 | 65 | \sort($separators); |
66 | 66 | $size=\count($separators); |
67 | 67 | $nb=0; |
68 | - if($size===1){ |
|
68 | + if ($size===1) { |
|
69 | 69 | $i=-1; |
70 | - foreach ($values as $k=>$v){ |
|
71 | - $this->_generateFields($form, [$v], $headers, $i, $wrappers,$nb++,$names[$k]??''); |
|
70 | + foreach ($values as $k=>$v) { |
|
71 | + $this->_generateFields($form, [$v], $headers, $i, $wrappers, $nb++, $names[$k] ?? ''); |
|
72 | 72 | $i++; |
73 | 73 | } |
74 | - }else{ |
|
74 | + } else { |
|
75 | 75 | $separators[]=$count; |
76 | - for($i=0;$i<$size;$i++){ |
|
77 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
78 | - $this->_generateFields($form, $fields, $headers, $separators[$i], $wrappers,$nb++,$names[$i]??''); |
|
76 | + for ($i=0; $i<$size; $i++) { |
|
77 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
78 | + $this->_generateFields($form, $fields, $headers, $separators[$i], $wrappers, $nb++, $names[$i] ?? ''); |
|
79 | 79 | } |
80 | 80 | } |
81 | - if($this->_hasRules && !$this->getForm()->hasValidationParams()){ |
|
81 | + if ($this->_hasRules && !$this->getForm()->hasValidationParams()) { |
|
82 | 82 | $this->setValidationParams(['inline'=>true]); |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | - protected function _generateFields($form, $values, $headers, $sepFirst, $wrappers, $nb, $name){ |
|
86 | + protected function _generateFields($form, $values, $headers, $sepFirst, $wrappers, $nb, $name) { |
|
87 | 87 | $wrapper=null; |
88 | - if(isset($headers[$sepFirst+1])) |
|
89 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
90 | - if(isset($wrappers[$sepFirst+1])){ |
|
88 | + if (isset($headers[$sepFirst+1])) |
|
89 | + $form->addHeader($headers[$sepFirst+1], 4, true); |
|
90 | + if (isset($wrappers[$sepFirst+1])) { |
|
91 | 91 | $wrapper=$wrappers[$sepFirst+1]; |
92 | 92 | } |
93 | 93 | $count=\count($values); |
94 | - if($count===1){ |
|
94 | + if ($count===1) { |
|
95 | 95 | $added=$form->addField($values[0]); |
96 | - }elseif($count>1){ |
|
96 | + }elseif ($count>1) { |
|
97 | 97 | $added=$form->addFields($values); |
98 | - }else |
|
98 | + } else |
|
99 | 99 | return; |
100 | - if(isset($wrapper)){ |
|
101 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
100 | + if (isset($wrapper)) { |
|
101 | + $added->wrap($wrapper[0], $wrapper[1]); |
|
102 | 102 | } |
103 | - $this->execHook('onGenerateFields',$added,$nb,$name); |
|
103 | + $this->execHook('onGenerateFields', $added, $nb, $name); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -108,18 +108,18 @@ discard block |
||
108 | 108 | * the generated field is the first parameter |
109 | 109 | * @param callable $callback the fonction to call when a field is generated |
110 | 110 | */ |
111 | - public function onGenerateField($callback){ |
|
112 | - $this->addHook('onGenerateFields',$callback); |
|
111 | + public function onGenerateField($callback) { |
|
112 | + $this->addHook('onGenerateFields', $callback); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
116 | 116 | * @return HtmlForm |
117 | 117 | */ |
118 | - public function getForm(){ |
|
118 | + public function getForm() { |
|
119 | 119 | return $this->content['form']; |
120 | 120 | } |
121 | 121 | |
122 | - public function addSeparatorAfter($fieldNum){ |
|
122 | + public function addSeparatorAfter($fieldNum) { |
|
123 | 123 | $fieldNum=$this->_getIndex($fieldNum); |
124 | 124 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
125 | 125 | return $this; |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | return $this; |
135 | 135 | } |
136 | 136 | |
137 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
138 | - return $this->_fieldAs(function($id,$name,$value) use ($cssStyle){ |
|
139 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
137 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
138 | + return $this->_fieldAs(function($id, $name, $value) use ($cssStyle){ |
|
139 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
140 | 140 | $button->setProperty('type', 'reset'); |
141 | 141 | return $button; |
142 | - }, $index,$attributes); |
|
142 | + }, $index, $attributes); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -158,19 +158,19 @@ discard block |
||
158 | 158 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
159 | 159 | } |
160 | 160 | |
161 | - public function addDividerBefore($index,$title){ |
|
161 | + public function addDividerBefore($index, $title) { |
|
162 | 162 | $index=$this->_getIndex($index); |
163 | 163 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
164 | 164 | return $this; |
165 | 165 | } |
166 | 166 | |
167 | - public function addWrapper($index,$contentBefore,$contentAfter=null){ |
|
167 | + public function addWrapper($index, $contentBefore, $contentAfter=null) { |
|
168 | 168 | $index=$this->_getIndex($index); |
169 | - $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
|
169 | + $this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter); |
|
170 | 170 | return $this; |
171 | 171 | } |
172 | 172 | |
173 | - public function run(JsUtils $js){ |
|
173 | + public function run(JsUtils $js) { |
|
174 | 174 | parent::run($js); |
175 | 175 | } |
176 | 176 |
@@ -7,20 +7,20 @@ discard block |
||
7 | 7 | |
8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
9 | 9 | |
10 | - public function __construct($identifier, $items = array(), $label = NULL, $value = "", $multiple = false, $associative = true) { |
|
11 | - parent::__construct("field-" . $identifier, (new HtmlDropdown("dropdown-" . $identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label); |
|
12 | - $this->_identifier = $identifier; |
|
10 | + public function __construct($identifier, $items=array(), $label=NULL, $value="", $multiple=false, $associative=true) { |
|
11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label); |
|
12 | + $this->_identifier=$identifier; |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | public function setItems($items) { |
16 | 16 | return $this->getField()->setItems($items); |
17 | 17 | } |
18 | 18 | |
19 | - public function addItem($item, $value = NULL, $image = NULL) { |
|
19 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
20 | 20 | return $this->getField()->addItem($item, $value, $image); |
21 | 21 | } |
22 | 22 | |
23 | - public static function multipleDropdown($identifier, $items = array(), $label = NULL, $value = "", $associative = true) { |
|
23 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value="", $associative=true) { |
|
24 | 24 | return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative); |
25 | 25 | } |
26 | 26 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | return $this->getField()->getInput(); |
33 | 33 | } |
34 | 34 | |
35 | - public function asSelect($name = NULL, $multiple = false, $selection = true) { |
|
35 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
36 | 36 | $this->getField()->asSelect($name, $multiple, $selection); |
37 | 37 | return $this; |
38 | 38 | } |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | * @param boolean $floating |
43 | 43 | * @return HtmlDropdown |
44 | 44 | */ |
45 | - public function asButton($floating = false) { |
|
46 | - $field = $this->content["field"]; |
|
47 | - $label = $this->content["label"]; |
|
45 | + public function asButton($floating=false) { |
|
46 | + $field=$this->content["field"]; |
|
47 | + $label=$this->content["label"]; |
|
48 | 48 | $field->addContent($label); |
49 | - $this->content = [ |
|
49 | + $this->content=[ |
|
50 | 50 | "field" => $field |
51 | 51 | ]; |
52 | 52 | $this->content["field"]->asButton($floating); |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | * @param boolean $labeled |
62 | 62 | * @return mixed|HtmlButton |
63 | 63 | */ |
64 | - public function addAction($action, $direction = Direction::RIGHT, $icon = NULL, $labeled = false) { |
|
64 | + public function addAction($action, $direction=Direction::RIGHT, $icon=NULL, $labeled=false) { |
|
65 | 65 | $this->getField()->setStyle('display:inline-block; width: auto'); |
66 | - $actionO = $action; |
|
67 | - if (\is_object($action) === false) { |
|
68 | - $actionO = new HtmlButton("action-" . $this->identifier, $action); |
|
66 | + $actionO=$action; |
|
67 | + if (\is_object($action)===false) { |
|
68 | + $actionO=new HtmlButton("action-".$this->identifier, $action); |
|
69 | 69 | if (isset($icon)) |
70 | 70 | $actionO->addIcon($icon, true, $labeled); |
71 | 71 | } |
72 | - $this->addContent($actionO, \strstr($direction, Direction::LEFT) !== false); |
|
72 | + $this->addContent($actionO, \strstr($direction, Direction::LEFT)!==false); |
|
73 | 73 | return $actionO; |
74 | 74 | } |
75 | 75 | } |
@@ -29,12 +29,12 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @var string|array |
31 | 31 | */ |
32 | - protected $_contentSeparator = ""; |
|
32 | + protected $_contentSeparator=""; |
|
33 | 33 | |
34 | 34 | public function __construct($identifier, $tagName, $baseClass) { |
35 | 35 | parent::__construct($identifier, $tagName, $baseClass); |
36 | - $this->root = ""; |
|
37 | - $this->attr = "data-ajax"; |
|
36 | + $this->root=""; |
|
37 | + $this->attr="data-ajax"; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -54,23 +54,23 @@ discard block |
||
54 | 54 | return JArray::implode($this->_contentSeparator, $this->content); |
55 | 55 | } |
56 | 56 | |
57 | - public function setContentDivider($divider, $index = NULL) { |
|
58 | - $divider = "<div class='divider'> {$divider} </div>"; |
|
57 | + public function setContentDivider($divider, $index=NULL) { |
|
58 | + $divider="<div class='divider'> {$divider} </div>"; |
|
59 | 59 | return $this->setDivider($divider, $index); |
60 | 60 | } |
61 | 61 | |
62 | - public function setIconContentDivider($iconContentDivider, $index = NULL) { |
|
63 | - $contentDivider = "<i class='" . $iconContentDivider . " icon divider'></i>"; |
|
62 | + public function setIconContentDivider($iconContentDivider, $index=NULL) { |
|
63 | + $contentDivider="<i class='".$iconContentDivider." icon divider'></i>"; |
|
64 | 64 | return $this->setDivider($contentDivider, $index); |
65 | 65 | } |
66 | 66 | |
67 | 67 | protected function setDivider($divider, $index) { |
68 | 68 | if (isset($index)) { |
69 | - if (! \is_array($this->_contentSeparator)) |
|
70 | - $this->_contentSeparator = array_fill(0, $this->count() - 1, $this->_contentSeparator); |
|
71 | - $this->_contentSeparator[$index] = $divider; |
|
69 | + if (!\is_array($this->_contentSeparator)) |
|
70 | + $this->_contentSeparator=array_fill(0, $this->count()-1, $this->_contentSeparator); |
|
71 | + $this->_contentSeparator[$index]=$divider; |
|
72 | 72 | } else { |
73 | - $this->_contentSeparator = $divider; |
|
73 | + $this->_contentSeparator=$divider; |
|
74 | 74 | } |
75 | 75 | return $this; |
76 | 76 | } |