@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @version 1.001 |
9 | 9 | * Generates a JSON field validator |
10 | 10 | */ |
11 | -class FieldValidation implements \JsonSerializable{ |
|
11 | +class FieldValidation implements \JsonSerializable { |
|
12 | 12 | /** |
13 | 13 | * @var string |
14 | 14 | */ |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | protected $optional; |
33 | 33 | |
34 | - public function __construct($identifier){ |
|
34 | + public function __construct($identifier) { |
|
35 | 35 | $this->identifier=$identifier; |
36 | 36 | $this->rules=[]; |
37 | 37 | } |
@@ -55,31 +55,31 @@ discard block |
||
55 | 55 | * @param string $value |
56 | 56 | * @return Rule |
57 | 57 | */ |
58 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
59 | - if($type instanceof Rule) { |
|
60 | - $rule = $type; |
|
61 | - if($type instanceof CustomRule){ |
|
58 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
59 | + if ($type instanceof Rule) { |
|
60 | + $rule=$type; |
|
61 | + if ($type instanceof CustomRule) { |
|
62 | 62 | $this->customRules[]=$type; |
63 | 63 | $this->hasCustomRules=true; |
64 | 64 | } |
65 | - }elseif(\is_array($type)){ |
|
65 | + }elseif (\is_array($type)) { |
|
66 | 66 | $value=JArray::getValue($type, "value", 2); |
67 | 67 | $prompt=JArray::getValue($type, "prompt", 1); |
68 | 68 | $type=JArray::getValue($type, "type", 0); |
69 | - $rule=new Rule($type,$prompt,$value); |
|
70 | - }else { |
|
71 | - $rule = new Rule($type, $prompt, $value); |
|
69 | + $rule=new Rule($type, $prompt, $value); |
|
70 | + } else { |
|
71 | + $rule=new Rule($type, $prompt, $value); |
|
72 | 72 | } |
73 | 73 | $this->rules[]=$rule; |
74 | 74 | return $rule; |
75 | 75 | } |
76 | 76 | |
77 | - public function jsonSerialize(){ |
|
78 | - $result=["identifier"=>$this->identifier,"rules"=>$this->rules]; |
|
79 | - if($this->optional){ |
|
77 | + public function jsonSerialize() { |
|
78 | + $result=["identifier"=>$this->identifier, "rules"=>$this->rules]; |
|
79 | + if ($this->optional) { |
|
80 | 80 | $result["optional"]=true; |
81 | 81 | } |
82 | - if(isset($this->depends)){ |
|
82 | + if (isset($this->depends)) { |
|
83 | 83 | $result["depends"]=$this->depends; |
84 | 84 | } |
85 | 85 | return $result; |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | return $this; |
96 | 96 | } |
97 | 97 | |
98 | - public function compile(JsUtils $js){ |
|
99 | - if($this->hasCustomRules) { |
|
98 | + public function compile(JsUtils $js) { |
|
99 | + if ($this->hasCustomRules) { |
|
100 | 100 | foreach ($this->customRules as $rule) { |
101 | 101 | $rule->compile($js); |
102 | 102 | } |
@@ -62,12 +62,12 @@ |
||
62 | 62 | $this->customRules[]=$type; |
63 | 63 | $this->hasCustomRules=true; |
64 | 64 | } |
65 | - }elseif(\is_array($type)){ |
|
65 | + } elseif(\is_array($type)){ |
|
66 | 66 | $value=JArray::getValue($type, "value", 2); |
67 | 67 | $prompt=JArray::getValue($type, "prompt", 1); |
68 | 68 | $type=JArray::getValue($type, "type", 0); |
69 | 69 | $rule=new Rule($type,$prompt,$value); |
70 | - }else { |
|
70 | + } else { |
|
71 | 71 | $rule = new Rule($type, $prompt, $value); |
72 | 72 | } |
73 | 73 | $this->rules[]=$rule; |
@@ -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); |
@@ -35,17 +35,19 @@ discard block |
||
35 | 35 | |
36 | 36 | public function addContent($content, $before = false) { |
37 | 37 | if (! \is_array($this->content)) { |
38 | - if (isset($this->content)) |
|
39 | - $this->content = array( |
|
38 | + if (isset($this->content)) { |
|
39 | + $this->content = array( |
|
40 | 40 | $this->content |
41 | 41 | ); |
42 | - else |
|
43 | - $this->content = array(); |
|
42 | + } else { |
|
43 | + $this->content = array(); |
|
44 | + } |
|
45 | + } |
|
46 | + if ($before) { |
|
47 | + array_unshift($this->content, $content); |
|
48 | + } else { |
|
49 | + $this->content[] = $content; |
|
44 | 50 | } |
45 | - if ($before) |
|
46 | - array_unshift($this->content, $content); |
|
47 | - else |
|
48 | - $this->content[] = $content; |
|
49 | 51 | return $this; |
50 | 52 | } |
51 | 53 | |
@@ -108,10 +110,12 @@ discard block |
||
108 | 110 | * @return HtmlDoubleElement |
109 | 111 | */ |
110 | 112 | public function asLink($href = NULL, $target = NULL) { |
111 | - if (isset($href)) |
|
112 | - $this->setProperty("href", $href); |
|
113 | - if (isset($target)) |
|
114 | - $this->setProperty("target", $target); |
|
113 | + if (isset($href)) { |
|
114 | + $this->setProperty("href", $href); |
|
115 | + } |
|
116 | + if (isset($target)) { |
|
117 | + $this->setProperty("target", $target); |
|
118 | + } |
|
115 | 119 | return $this->setTagName("a"); |
116 | 120 | } |
117 | 121 |