@@ -44,6 +44,11 @@ discard block |
||
44 | 44 | $this->show($modelInstance); |
45 | 45 | } |
46 | 46 | |
47 | + /** |
|
48 | + * @param InstanceViewer $instanceViewer |
|
49 | + * @param string $contentKey |
|
50 | + * @param boolean $edition |
|
51 | + */ |
|
47 | 52 | protected function _init($instanceViewer,$contentKey,$content,$edition){ |
48 | 53 | $this->_instanceViewer=$instanceViewer; |
49 | 54 | $this->content=[$contentKey=>$content]; |
@@ -96,16 +101,26 @@ discard block |
||
96 | 101 | return $this; |
97 | 102 | } |
98 | 103 | |
104 | + /** |
|
105 | + * @param \Closure $field |
|
106 | + */ |
|
99 | 107 | public function addField($field){ |
100 | 108 | $this->_instanceViewer->addField($field); |
101 | 109 | return $this; |
102 | 110 | } |
103 | 111 | |
112 | + /** |
|
113 | + * @param integer $index |
|
114 | + * @param \Closure $field |
|
115 | + */ |
|
104 | 116 | public function insertField($index,$field){ |
105 | 117 | $this->_instanceViewer->insertField($index, $field); |
106 | 118 | return $this; |
107 | 119 | } |
108 | 120 | |
121 | + /** |
|
122 | + * @param \Closure $field |
|
123 | + */ |
|
109 | 124 | public function insertInField($index,$field){ |
110 | 125 | $this->_instanceViewer->insertInField($index, $field); |
111 | 126 | return $this; |
@@ -25,9 +25,18 @@ discard block |
||
25 | 25 | trait FieldAsTrait{ |
26 | 26 | |
27 | 27 | abstract protected function _getFieldIdentifier($prefix,$name=""); |
28 | + |
|
29 | + /** |
|
30 | + * @param \Closure $callback |
|
31 | + */ |
|
28 | 32 | abstract public function setValueFunction($index,$callback); |
29 | 33 | abstract protected function _getFieldName($index); |
30 | 34 | abstract protected function _getFieldCaption($index); |
35 | + |
|
36 | + /** |
|
37 | + * @param HtmlButton $button |
|
38 | + * @param string $event |
|
39 | + */ |
|
31 | 40 | abstract protected function _buttonAsSubmit(&$button,$event,$url,$responseElement=NULL); |
32 | 41 | |
33 | 42 | /** |
@@ -64,12 +73,19 @@ discard block |
||
64 | 73 | } |
65 | 74 | } |
66 | 75 | |
76 | + /** |
|
77 | + * @param HtmlFormInput $field |
|
78 | + */ |
|
67 | 79 | protected function _prepareFormFields(&$field,$name,&$attributes){ |
68 | 80 | $field->setName($name); |
69 | 81 | $this->_addRules($field, $attributes); |
70 | 82 | return $field; |
71 | 83 | } |
72 | 84 | |
85 | + /** |
|
86 | + * @param \Closure $elementCallback |
|
87 | + * @param string $prefix |
|
88 | + */ |
|
73 | 89 | protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
74 | 90 | $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){ |
75 | 91 | $caption=$this->_getFieldCaption($index); |
@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | $rules=$attributes["rules"]; |
57 | 57 | if(\is_array($rules)){ |
58 | 58 | $element->addRules($rules); |
59 | - } |
|
60 | - else{ |
|
59 | + } else{ |
|
61 | 60 | $element->addRule($rules); |
62 | 61 | } |
63 | 62 | unset($attributes["rules"]); |
@@ -117,8 +116,9 @@ discard block |
||
117 | 116 | public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
118 | 117 | return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
119 | 118 | $header=new HtmlHeader($id,$niveau,$value); |
120 | - if(isset($icon)) |
|
121 | - $header->asIcon($icon, $value); |
|
119 | + if(isset($icon)) { |
|
120 | + $header->asIcon($icon, $value); |
|
121 | + } |
|
122 | 122 | return $header; |
123 | 123 | }, $index,$attributes,"header"); |
124 | 124 | } |
@@ -126,7 +126,9 @@ discard block |
||
126 | 126 | |
127 | 127 | public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
128 | 128 | $this->setValueFunction($index,function($img) use($size,$circular){ |
129 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
129 | + $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) { |
|
130 | + $image->setCircular(); |
|
131 | + } |
|
130 | 132 | return $image; |
131 | 133 | }); |
132 | 134 | return $this; |
@@ -18,6 +18,9 @@ |
||
18 | 18 | */ |
19 | 19 | class DataForm extends Widget { |
20 | 20 | |
21 | + /** |
|
22 | + * @param string $identifier |
|
23 | + */ |
|
21 | 24 | public function __construct($identifier, $modelInstance=NULL) { |
22 | 25 | parent::__construct($identifier, null,$modelInstance); |
23 | 26 | $this->_form=new HtmlForm($identifier); |
@@ -40,6 +40,10 @@ discard block |
||
40 | 40 | return parent::run($js); |
41 | 41 | } |
42 | 42 | |
43 | + /** |
|
44 | + * @param string $identifier |
|
45 | + * @param string $model |
|
46 | + */ |
|
43 | 47 | public function __construct($identifier,$model,$modelInstance=NULL) { |
44 | 48 | parent::__construct($identifier, $model,$modelInstance); |
45 | 49 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
@@ -163,6 +167,9 @@ discard block |
||
163 | 167 | return $this; |
164 | 168 | } |
165 | 169 | |
170 | + /** |
|
171 | + * @param PositionInTable $part |
|
172 | + */ |
|
166 | 173 | private function addToolbarRow($part,$table,$captions){ |
167 | 174 | $hasPart=$table->hasPart($part); |
168 | 175 | if($hasPart){ |
@@ -207,7 +214,7 @@ discard block |
||
207 | 214 | /** |
208 | 215 | * @param string $caption |
209 | 216 | * @param callable $callback |
210 | - * @return callable |
|
217 | + * @return \Closure |
|
211 | 218 | */ |
212 | 219 | private function getFieldButtonCallable($caption,$callback=null){ |
213 | 220 | return $this->getCallable("getFieldButton",[$caption],$callback); |
@@ -215,9 +222,9 @@ discard block |
||
215 | 222 | |
216 | 223 | /** |
217 | 224 | * @param callable $thisCallback |
218 | - * @param array $parameters |
|
225 | + * @param string[] $parameters |
|
219 | 226 | * @param callable $callback |
220 | - * @return callable |
|
227 | + * @return \Closure |
|
221 | 228 | */ |
222 | 229 | private function getCallable($thisCallback,$parameters,$callback=null){ |
223 | 230 | $result=function($instance) use($thisCallback,$parameters,$callback){ |
@@ -278,11 +285,19 @@ discard block |
||
278 | 285 | return $this; |
279 | 286 | } |
280 | 287 | |
288 | + /** |
|
289 | + * @param string $icon |
|
290 | + * @param string $class |
|
291 | + */ |
|
281 | 292 | private function addDefaultButton($icon,$class=null,$callback=null){ |
282 | 293 | $this->addField($this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
283 | 294 | return $this; |
284 | 295 | } |
285 | 296 | |
297 | + /** |
|
298 | + * @param string $icon |
|
299 | + * @param string $class |
|
300 | + */ |
|
286 | 301 | private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){ |
287 | 302 | $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
288 | 303 | return $this; |
@@ -51,8 +51,9 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function addHeader($title, $niveau=1, $dividing=true) { |
53 | 53 | $header=new HtmlHeader("", $niveau, $title); |
54 | - if ($dividing) |
|
55 | - $header->setDividing(); |
|
54 | + if ($dividing) { |
|
55 | + $header->setDividing(); |
|
56 | + } |
|
56 | 57 | return $this->addItem($header); |
57 | 58 | } |
58 | 59 | |
@@ -73,14 +74,16 @@ discard block |
||
73 | 74 | if (\is_string($end)) { |
74 | 75 | $label=$end; |
75 | 76 | \array_pop($fields); |
76 | - } else |
|
77 | - $label=NULL; |
|
77 | + } else { |
|
78 | + $label=NULL; |
|
79 | + } |
|
78 | 80 | } |
79 | 81 | $this->_fields=\array_merge($this->_fields, $fields); |
80 | 82 | $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
81 | 83 | } |
82 | - if (isset($label)) |
|
83 | - $fields=new HtmlFormField("", $fields, $label); |
|
84 | + if (isset($label)) { |
|
85 | + $fields=new HtmlFormField("", $fields, $label); |
|
86 | + } |
|
84 | 87 | } else { |
85 | 88 | $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
86 | 89 | } |
@@ -133,20 +136,24 @@ discard block |
||
133 | 136 | */ |
134 | 137 | public function addMessage($identifier, $content, $header=NULL, $icon=NULL, $type=NULL) { |
135 | 138 | $message=new HtmlMessage($identifier, $content); |
136 | - if (isset($header)) |
|
137 | - $message->addHeader($header); |
|
138 | - if (isset($icon)) |
|
139 | - $message->setIcon($icon); |
|
140 | - if (isset($type)) |
|
141 | - $message->setStyle($type); |
|
139 | + if (isset($header)) { |
|
140 | + $message->addHeader($header); |
|
141 | + } |
|
142 | + if (isset($icon)) { |
|
143 | + $message->setIcon($icon); |
|
144 | + } |
|
145 | + if (isset($type)) { |
|
146 | + $message->setStyle($type); |
|
147 | + } |
|
142 | 148 | return $this->addItem($message); |
143 | 149 | } |
144 | 150 | |
145 | 151 | |
146 | 152 | |
147 | 153 | public function compile(JsUtils $js=NULL,&$view=NULL){ |
148 | - if(\sizeof($this->_validationParams)>0) |
|
149 | - $this->setProperty("novalidate", ""); |
|
154 | + if(\sizeof($this->_validationParams)>0) { |
|
155 | + $this->setProperty("novalidate", ""); |
|
156 | + } |
|
150 | 157 | return parent::compile($js,$view); |
151 | 158 | } |
152 | 159 | |
@@ -161,8 +168,9 @@ discard block |
||
161 | 168 | if($field instanceof HtmlFormFields){ |
162 | 169 | $items=$field->getItems(); |
163 | 170 | foreach ($items as $_field){ |
164 | - if($_field instanceof HtmlFormField) |
|
165 | - $compo=$this->addCompoValidation($js, $compo, $_field); |
|
171 | + if($_field instanceof HtmlFormField) { |
|
172 | + $compo=$this->addCompoValidation($js, $compo, $_field); |
|
173 | + } |
|
166 | 174 | } |
167 | 175 | } |
168 | 176 | } |
@@ -29,15 +29,17 @@ discard block |
||
29 | 29 | |
30 | 30 | public function addContent($content,$before=false) { |
31 | 31 | if (!\is_array($this->content)) { |
32 | - if(isset($this->content)) |
|
33 | - $this->content=array ($this->content); |
|
34 | - else |
|
35 | - $this->content=array(); |
|
32 | + if(isset($this->content)) { |
|
33 | + $this->content=array ($this->content); |
|
34 | + } else { |
|
35 | + $this->content=array(); |
|
36 | + } |
|
37 | + } |
|
38 | + if($before) { |
|
39 | + array_unshift($this->content,$content); |
|
40 | + } else { |
|
41 | + $this->content []=$content; |
|
36 | 42 | } |
37 | - if($before) |
|
38 | - array_unshift($this->content,$content); |
|
39 | - else |
|
40 | - $this->content []=$content; |
|
41 | 43 | return $this; |
42 | 44 | } |
43 | 45 | |
@@ -75,9 +77,9 @@ discard block |
||
75 | 77 | $instances=[]; |
76 | 78 | if($content instanceof $class){ |
77 | 79 | $instances[]=$content; |
78 | - }elseif($content instanceof HtmlDoubleElement){ |
|
80 | + } elseif($content instanceof HtmlDoubleElement){ |
|
79 | 81 | $instances=\array_merge($instances,$content->getContentInstances($class)); |
80 | - }elseif (\is_array($content)){ |
|
82 | + } elseif (\is_array($content)){ |
|
81 | 83 | foreach ($content as $element){ |
82 | 84 | $instances=\array_merge($instances,$this->_getContentInstances($class, $element)); |
83 | 85 | } |