@@ -57,6 +57,11 @@ discard block |
||
57 | 57 | $this->show($modelInstance); |
58 | 58 | } |
59 | 59 | |
60 | + /** |
|
61 | + * @param InstanceViewer $instanceViewer |
|
62 | + * @param string $contentKey |
|
63 | + * @param boolean $edition |
|
64 | + */ |
|
60 | 65 | protected function _init($instanceViewer,$contentKey,$content,$edition){ |
61 | 66 | $this->_instanceViewer=$instanceViewer; |
62 | 67 | $this->content=[$contentKey=>$content]; |
@@ -117,6 +122,9 @@ discard block |
||
117 | 122 | return $this; |
118 | 123 | } |
119 | 124 | |
125 | + /** |
|
126 | + * @param \Closure $field |
|
127 | + */ |
|
120 | 128 | public function addField($field){ |
121 | 129 | $this->_instanceViewer->addField($field); |
122 | 130 | return $this; |
@@ -132,11 +140,18 @@ discard block |
||
132 | 140 | return $this->addMessage(["error"=>true],"message"); |
133 | 141 | } |
134 | 142 | |
143 | + /** |
|
144 | + * @param integer $index |
|
145 | + * @param \Closure $field |
|
146 | + */ |
|
135 | 147 | public function insertField($index,$field){ |
136 | 148 | $this->_instanceViewer->insertField($index, $field); |
137 | 149 | return $this; |
138 | 150 | } |
139 | 151 | |
152 | + /** |
|
153 | + * @param \Closure $field |
|
154 | + */ |
|
140 | 155 | public function insertInField($index,$field){ |
141 | 156 | $this->_instanceViewer->insertInField($index, $field); |
142 | 157 | return $this; |
@@ -186,8 +186,9 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
188 | 188 | $result=$this->addInToolbar($caption,$callback); |
189 | - if(isset($icon)) |
|
190 | - $result->addIcon($icon); |
|
189 | + if(isset($icon)) { |
|
190 | + $result->addIcon($icon); |
|
191 | + } |
|
191 | 192 | return $result; |
192 | 193 | } |
193 | 194 | |
@@ -201,7 +202,7 @@ discard block |
||
201 | 202 | foreach ($items as $icon=>$item){ |
202 | 203 | $this->addItemInToolbar($item,$icon,$callback); |
203 | 204 | } |
204 | - }else{ |
|
205 | + } else{ |
|
205 | 206 | foreach ($items as $item){ |
206 | 207 | $this->addItemInToolbar($item,null,$callback); |
207 | 208 | } |
@@ -352,8 +353,9 @@ discard block |
||
352 | 353 | protected function _compileForm(){ |
353 | 354 | if(isset($this->_form)){ |
354 | 355 | $noValidate=""; |
355 | - if(\sizeof($this->_form->getValidationParams())>0) |
|
356 | - $noValidate="novalidate"; |
|
356 | + if(\sizeof($this->_form->getValidationParams())>0) { |
|
357 | + $noValidate="novalidate"; |
|
358 | + } |
|
357 | 359 | $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>"); |
358 | 360 | } |
359 | 361 | } |
@@ -26,9 +26,18 @@ discard block |
||
26 | 26 | trait FieldAsTrait{ |
27 | 27 | |
28 | 28 | abstract protected function _getFieldIdentifier($prefix,$name=""); |
29 | + |
|
30 | + /** |
|
31 | + * @param \Closure $callback |
|
32 | + */ |
|
29 | 33 | abstract public function setValueFunction($index,$callback); |
30 | 34 | abstract protected function _getFieldName($index); |
31 | 35 | abstract protected function _getFieldCaption($index); |
36 | + |
|
37 | + /** |
|
38 | + * @param HtmlButton $button |
|
39 | + * @param string $event |
|
40 | + */ |
|
32 | 41 | abstract protected function _buttonAsSubmit(&$button,$event,$url,$responseElement=NULL); |
33 | 42 | |
34 | 43 | /** |
@@ -65,12 +74,19 @@ discard block |
||
65 | 74 | } |
66 | 75 | } |
67 | 76 | |
77 | + /** |
|
78 | + * @param HtmlFormInput $field |
|
79 | + */ |
|
68 | 80 | protected function _prepareFormFields(&$field,$name,&$attributes){ |
69 | 81 | $field->setName($name); |
70 | 82 | $this->_addRules($field, $attributes); |
71 | 83 | return $field; |
72 | 84 | } |
73 | 85 | |
86 | + /** |
|
87 | + * @param \Closure $elementCallback |
|
88 | + * @param string $prefix |
|
89 | + */ |
|
74 | 90 | protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
75 | 91 | $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){ |
76 | 92 | $caption=$this->_getFieldCaption($index); |
@@ -221,6 +237,9 @@ discard block |
||
221 | 237 | } |
222 | 238 | } |
223 | 239 | |
240 | + /** |
|
241 | + * @param integer $index |
|
242 | + */ |
|
224 | 243 | public function fieldAs($index,$type,$attributes=NULL){ |
225 | 244 | $method="fieldAs".\ucfirst($type); |
226 | 245 | if(\method_exists($this, $method)){ |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | $rules=$attributes["rules"]; |
58 | 58 | if(\is_array($rules)){ |
59 | 59 | $element->addRules($rules); |
60 | - } |
|
61 | - else{ |
|
60 | + } else{ |
|
62 | 61 | $element->addRule($rules); |
63 | 62 | } |
64 | 63 | unset($attributes["rules"]); |
@@ -118,8 +117,9 @@ discard block |
||
118 | 117 | public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
119 | 118 | return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
120 | 119 | $header=new HtmlHeader($id,$niveau,$value); |
121 | - if(isset($icon)) |
|
122 | - $header->asIcon($icon, $value); |
|
120 | + if(isset($icon)) { |
|
121 | + $header->asIcon($icon, $value); |
|
122 | + } |
|
123 | 123 | return $header; |
124 | 124 | }, $index,$attributes,"header"); |
125 | 125 | } |
@@ -127,7 +127,9 @@ discard block |
||
127 | 127 | |
128 | 128 | public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
129 | 129 | $this->setValueFunction($index,function($img) use($size,$circular){ |
130 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
130 | + $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) { |
|
131 | + $image->setCircular(); |
|
132 | + } |
|
131 | 133 | return $image; |
132 | 134 | }); |
133 | 135 | return $this; |
@@ -209,12 +211,13 @@ discard block |
||
209 | 211 | $i=0; |
210 | 212 | if(JArray::isAssociative($types)){ |
211 | 213 | foreach ($types as $type=>$attributes){ |
212 | - if(\is_int($type)) |
|
213 | - $this->fieldAs($i++,$attributes,[]); |
|
214 | - else |
|
215 | - $this->fieldAs($i++,$type,$attributes); |
|
214 | + if(\is_int($type)) { |
|
215 | + $this->fieldAs($i++,$attributes,[]); |
|
216 | + } else { |
|
217 | + $this->fieldAs($i++,$type,$attributes); |
|
218 | + } |
|
216 | 219 | } |
217 | - }else{ |
|
220 | + } else{ |
|
218 | 221 | foreach ($types as $type){ |
219 | 222 | $this->fieldAs($i++,$type); |
220 | 223 | } |
@@ -226,7 +229,7 @@ discard block |
||
226 | 229 | if(\method_exists($this, $method)){ |
227 | 230 | if(!\is_array($attributes)){ |
228 | 231 | $attributes=[$index]; |
229 | - }else{ |
|
232 | + } else{ |
|
230 | 233 | \array_unshift($attributes, $index); |
231 | 234 | } |
232 | 235 | \call_user_func_array([$this,$method], $attributes); |
@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | } |
18 | 18 | |
19 | 19 | public function setValue($value) { |
20 | - if(isset($value)) |
|
21 | - $this->setProperty("value", $value); |
|
20 | + if(isset($value)) { |
|
21 | + $this->setProperty("value", $value); |
|
22 | + } |
|
22 | 23 | return $this; |
23 | 24 | } |
24 | 25 | |
@@ -27,16 +28,18 @@ discard block |
||
27 | 28 | } |
28 | 29 | |
29 | 30 | public function setPlaceholder($value){ |
30 | - if(JString::isNotNull($value)) |
|
31 | - $this->_placeholder=$value; |
|
31 | + if(JString::isNotNull($value)) { |
|
32 | + $this->_placeholder=$value; |
|
33 | + } |
|
32 | 34 | return $this; |
33 | 35 | } |
34 | 36 | |
35 | 37 | public function compile(JsUtils $js=NULL,&$view=NULL){ |
36 | 38 | $value=$this->_placeholder; |
37 | 39 | if(JString::isNull($value)){ |
38 | - if(JString::isNotNull($this->getProperty("name"))) |
|
39 | - $value=\ucfirst($this->getProperty("name")); |
|
40 | + if(JString::isNotNull($this->getProperty("name"))) { |
|
41 | + $value=\ucfirst($this->getProperty("name")); |
|
42 | + } |
|
40 | 43 | } |
41 | 44 | $this->setProperty("placeholder", $value); |
42 | 45 | return parent::compile($js,$view); |
@@ -52,8 +52,9 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function addHeader($title, $niveau=1, $dividing=true) { |
54 | 54 | $header=new HtmlHeader("", $niveau, $title); |
55 | - if ($dividing) |
|
56 | - $header->setDividing(); |
|
55 | + if ($dividing) { |
|
56 | + $header->setDividing(); |
|
57 | + } |
|
57 | 58 | return $this->addItem($header); |
58 | 59 | } |
59 | 60 | |
@@ -74,14 +75,16 @@ discard block |
||
74 | 75 | if (\is_string($end)) { |
75 | 76 | $label=$end; |
76 | 77 | \array_pop($fields); |
77 | - } else |
|
78 | - $label=NULL; |
|
78 | + } else { |
|
79 | + $label=NULL; |
|
80 | + } |
|
79 | 81 | } |
80 | 82 | $this->_fields=\array_merge($this->_fields, $fields); |
81 | 83 | $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
82 | 84 | } |
83 | - if (isset($label)) |
|
84 | - $fields=new HtmlFormField("", $fields, $label); |
|
85 | + if (isset($label)) { |
|
86 | + $fields=new HtmlFormField("", $fields, $label); |
|
87 | + } |
|
85 | 88 | } else { |
86 | 89 | $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
87 | 90 | } |
@@ -134,27 +137,31 @@ discard block |
||
134 | 137 | */ |
135 | 138 | public function addMessage($identifier, $content, $header=NULL, $icon=NULL, $type=NULL) { |
136 | 139 | $message=new HtmlMessage($identifier, $content); |
137 | - if (isset($header)) |
|
138 | - $message->addHeader($header); |
|
139 | - if (isset($icon)) |
|
140 | - $message->setIcon($icon); |
|
141 | - if (isset($type)) |
|
142 | - $message->setStyle($type); |
|
140 | + if (isset($header)) { |
|
141 | + $message->addHeader($header); |
|
142 | + } |
|
143 | + if (isset($icon)) { |
|
144 | + $message->setIcon($icon); |
|
145 | + } |
|
146 | + if (isset($type)) { |
|
147 | + $message->setStyle($type); |
|
148 | + } |
|
143 | 149 | return $this->addItem($message); |
144 | 150 | } |
145 | 151 | |
146 | 152 | |
147 | 153 | |
148 | 154 | public function compile(JsUtils $js=NULL,&$view=NULL){ |
149 | - if(\sizeof($this->_validationParams)>0) |
|
150 | - $this->setProperty("novalidate", ""); |
|
155 | + if(\sizeof($this->_validationParams)>0) { |
|
156 | + $this->setProperty("novalidate", ""); |
|
157 | + } |
|
151 | 158 | return parent::compile($js,$view); |
152 | 159 | } |
153 | 160 | |
154 | 161 | public function run(JsUtils $js) { |
155 | 162 | if(isset($js)){ |
156 | 163 | $compo=$js->semantic()->form("#".$this->identifier); |
157 | - }else{ |
|
164 | + } else{ |
|
158 | 165 | $compo=new Form(); |
159 | 166 | $compo->attach("#".$this->identifier); |
160 | 167 | } |
@@ -167,8 +174,9 @@ discard block |
||
167 | 174 | if($field instanceof HtmlFormFields){ |
168 | 175 | $items=$field->getItems(); |
169 | 176 | foreach ($items as $_field){ |
170 | - if($_field instanceof HtmlFormField) |
|
171 | - $compo=$this->addCompoValidation($compo, $_field); |
|
177 | + if($_field instanceof HtmlFormField) { |
|
178 | + $compo=$this->addCompoValidation($compo, $_field); |
|
179 | + } |
|
172 | 180 | } |
173 | 181 | } |
174 | 182 | } |