@@ -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); |
@@ -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,$parameters=NULL); |
33 | 42 | |
34 | 43 | /** |
@@ -67,12 +76,19 @@ discard block |
||
67 | 76 | } |
68 | 77 | } |
69 | 78 | |
79 | + /** |
|
80 | + * @param HtmlFormInput $field |
|
81 | + */ |
|
70 | 82 | protected function _prepareFormFields(&$field,$name,&$attributes){ |
71 | 83 | $field->setName($name); |
72 | 84 | $this->_addRules($field, $attributes); |
73 | 85 | return $field; |
74 | 86 | } |
75 | 87 | |
88 | + /** |
|
89 | + * @param \Closure $elementCallback |
|
90 | + * @param string $prefix |
|
91 | + */ |
|
76 | 92 | protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
77 | 93 | $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){ |
78 | 94 | $caption=$this->_getFieldCaption($index); |
@@ -223,6 +239,9 @@ discard block |
||
223 | 239 | } |
224 | 240 | } |
225 | 241 | |
242 | + /** |
|
243 | + * @param integer $index |
|
244 | + */ |
|
226 | 245 | public function fieldAs($index,$type,$attributes=NULL){ |
227 | 246 | $method="fieldAs".\ucfirst($type); |
228 | 247 | if(\method_exists($this, $method)){ |
@@ -23,23 +23,23 @@ discard block |
||
23 | 23 | * @property boolean $_edition |
24 | 24 | * @property mixed _modelInstance |
25 | 25 | */ |
26 | -trait FieldAsTrait{ |
|
26 | +trait FieldAsTrait { |
|
27 | 27 | |
28 | - abstract protected function _getFieldIdentifier($prefix,$name=""); |
|
29 | - abstract public function setValueFunction($index,$callback); |
|
28 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
29 | + abstract public function setValueFunction($index, $callback); |
|
30 | 30 | abstract protected function _getFieldName($index); |
31 | 31 | abstract protected function _getFieldCaption($index); |
32 | - abstract protected function _buttonAsSubmit(&$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
|
32 | + abstract protected function _buttonAsSubmit(&$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @param HtmlFormField $element |
36 | 36 | * @param array $attributes |
37 | 37 | */ |
38 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
39 | - if(isset($attributes["callback"])){ |
|
38 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
39 | + if (isset($attributes["callback"])) { |
|
40 | 40 | $callback=$attributes["callback"]; |
41 | - if(\is_callable($callback)){ |
|
42 | - $callback($element,$this->_modelInstance,$index); |
|
41 | + if (\is_callable($callback)) { |
|
42 | + $callback($element, $this->_modelInstance, $index); |
|
43 | 43 | unset($attributes["callback"]); |
44 | 44 | } |
45 | 45 | } |
@@ -49,42 +49,42 @@ discard block |
||
49 | 49 | $element->fromArray($attributes); |
50 | 50 | } |
51 | 51 | |
52 | - private function _getLabelField($caption,$icon=NULL){ |
|
53 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
52 | + private function _getLabelField($caption, $icon=NULL) { |
|
53 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
54 | 54 | return $label; |
55 | 55 | } |
56 | 56 | |
57 | - protected function _addRules($element,&$attributes){ |
|
58 | - if(isset($attributes["rules"])){ |
|
57 | + protected function _addRules($element, &$attributes) { |
|
58 | + if (isset($attributes["rules"])) { |
|
59 | 59 | $rules=$attributes["rules"]; |
60 | - if(\is_array($rules)){ |
|
60 | + if (\is_array($rules)) { |
|
61 | 61 | $element->addRules($rules); |
62 | 62 | } |
63 | - else{ |
|
63 | + else { |
|
64 | 64 | $element->addRule($rules); |
65 | 65 | } |
66 | 66 | unset($attributes["rules"]); |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - protected function _prepareFormFields(&$field,$name,&$attributes){ |
|
70 | + protected function _prepareFormFields(&$field, $name, &$attributes) { |
|
71 | 71 | $field->setName($name); |
72 | 72 | $this->_addRules($field, $attributes); |
73 | 73 | return $field; |
74 | 74 | } |
75 | 75 | |
76 | - protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
|
77 | - $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){ |
|
76 | + protected function _fieldAs($elementCallback, $index, $attributes=NULL, $prefix=null) { |
|
77 | + $this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback, $prefix){ |
|
78 | 78 | $caption=$this->_getFieldCaption($index); |
79 | 79 | $name=$this->_getFieldName($index); |
80 | - $id=$this->_getFieldIdentifier($prefix,$name); |
|
81 | - if(isset($attributes["name"])){ |
|
80 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
81 | + if (isset($attributes["name"])) { |
|
82 | 82 | $name=$attributes["name"]; |
83 | 83 | unset($attributes["name"]); |
84 | 84 | } |
85 | - $element=$elementCallback($id,$name,$value,$caption); |
|
86 | - if(\is_array($attributes)){ |
|
87 | - $this->_applyAttributes($element, $attributes,$index); |
|
85 | + $element=$elementCallback($id, $name, $value, $caption); |
|
86 | + if (\is_array($attributes)) { |
|
87 | + $this->_applyAttributes($element, $attributes, $index); |
|
88 | 88 | } |
89 | 89 | $element->setDisabled(!$this->_edition); |
90 | 90 | return $element; |
@@ -93,153 +93,153 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | |
96 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
97 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
98 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
96 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
97 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
98 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
99 | 99 | return $pb; |
100 | 100 | }); |
101 | 101 | return $this; |
102 | 102 | } |
103 | 103 | |
104 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
105 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
106 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
104 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
105 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
106 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
107 | 107 | return $rating; |
108 | 108 | }); |
109 | 109 | return $this; |
110 | 110 | } |
111 | 111 | |
112 | - public function fieldAsLabel($index,$icon=NULL){ |
|
113 | - $this->setValueFunction($index,function($caption) use($icon){ |
|
114 | - $lbl=$this->_getLabelField($caption,$icon); |
|
112 | + public function fieldAsLabel($index, $icon=NULL) { |
|
113 | + $this->setValueFunction($index, function($caption) use($icon){ |
|
114 | + $lbl=$this->_getLabelField($caption, $icon); |
|
115 | 115 | return $lbl; |
116 | 116 | }); |
117 | 117 | return $this; |
118 | 118 | } |
119 | 119 | |
120 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
121 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
122 | - $header=new HtmlHeader($id,$niveau,$value); |
|
123 | - if(isset($icon)) |
|
120 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
121 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
122 | + $header=new HtmlHeader($id, $niveau, $value); |
|
123 | + if (isset($icon)) |
|
124 | 124 | $header->asIcon($icon, $value); |
125 | 125 | return $header; |
126 | - }, $index,$attributes,"header"); |
|
126 | + }, $index, $attributes, "header"); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
130 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
131 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
132 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
130 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
131 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
132 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
133 | 133 | return $image; |
134 | 134 | }); |
135 | 135 | return $this; |
136 | 136 | } |
137 | 137 | |
138 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
139 | - return $this->_fieldAs(function($id,$name,$value){ |
|
140 | - $img=new HtmlImage($id,$value); |
|
138 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
139 | + return $this->_fieldAs(function($id, $name, $value) { |
|
140 | + $img=new HtmlImage($id, $value); |
|
141 | 141 | $img->asAvatar(); |
142 | 142 | return $img; |
143 | - }, $index,$attributes,"avatar"); |
|
143 | + }, $index, $attributes, "avatar"); |
|
144 | 144 | } |
145 | 145 | |
146 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
147 | - return $this->_fieldAs(function($id,$name,$value){ |
|
148 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
146 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
147 | + return $this->_fieldAs(function($id, $name, $value) { |
|
148 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
149 | 149 | return $input; |
150 | - }, $index,$attributes,"radio"); |
|
150 | + }, $index, $attributes, "radio"); |
|
151 | 151 | } |
152 | 152 | |
153 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
154 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
155 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
156 | - }, $index,$attributes,"radios"); |
|
153 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
154 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
155 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
156 | + }, $index, $attributes, "radios"); |
|
157 | 157 | } |
158 | 158 | |
159 | - public function fieldAsInput($index,$attributes=NULL){ |
|
160 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
161 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
159 | + public function fieldAsInput($index, $attributes=NULL) { |
|
160 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
161 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
162 | 162 | return $this->_prepareFormFields($input, $name, $attributes); |
163 | - }, $index,$attributes,"input"); |
|
163 | + }, $index, $attributes, "input"); |
|
164 | 164 | } |
165 | 165 | |
166 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
167 | - return $this->_fieldAs(function($id,$name,$value){ |
|
168 | - $textarea=new HtmlFormTextarea($id,null,$value); |
|
166 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
167 | + return $this->_fieldAs(function($id, $name, $value) { |
|
168 | + $textarea=new HtmlFormTextarea($id, null, $value); |
|
169 | 169 | $textarea->setName($name); |
170 | 170 | return $textarea; |
171 | - }, $index,$attributes,"textarea"); |
|
171 | + }, $index, $attributes, "textarea"); |
|
172 | 172 | } |
173 | 173 | |
174 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
175 | - if(!\is_array($attributes)){ |
|
174 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
175 | + if (!\is_array($attributes)) { |
|
176 | 176 | $attributes=[]; |
177 | 177 | } |
178 | 178 | $attributes["imputType"]="hidden"; |
179 | - return $this->fieldAsInput($index,$attributes); |
|
179 | + return $this->fieldAsInput($index, $attributes); |
|
180 | 180 | } |
181 | 181 | |
182 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
183 | - return $this->_fieldAs(function($id,$name,$value){ |
|
184 | - $input=new HtmlFormCheckbox($id,NULL,$this->_instanceViewer->getIdentifier()); |
|
182 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
183 | + return $this->_fieldAs(function($id, $name, $value) { |
|
184 | + $input=new HtmlFormCheckbox($id, NULL, $this->_instanceViewer->getIdentifier()); |
|
185 | 185 | $input->setChecked(JString::isBooleanTrue($value)); |
186 | 186 | $input->setName($name); |
187 | 187 | return $input; |
188 | - }, $index,$attributes,"ck"); |
|
188 | + }, $index, $attributes, "ck"); |
|
189 | 189 | } |
190 | 190 | |
191 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
192 | - return $this->_fieldAs(function($id,$name,$value) use($elements,$multiple){ |
|
193 | - $dd=new HtmlFormDropdown($id,$elements,NULL,$value); |
|
194 | - $dd->asSelect($name,$multiple); |
|
191 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
192 | + return $this->_fieldAs(function($id, $name, $value) use($elements, $multiple){ |
|
193 | + $dd=new HtmlFormDropdown($id, $elements, NULL, $value); |
|
194 | + $dd->asSelect($name, $multiple); |
|
195 | 195 | return $dd; |
196 | - }, $index,$attributes,"dd"); |
|
196 | + }, $index, $attributes, "dd"); |
|
197 | 197 | } |
198 | 198 | |
199 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
200 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
201 | - $mess= new HtmlMessage("message-".$id,$value); |
|
199 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
200 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
201 | + $mess=new HtmlMessage("message-".$id, $value); |
|
202 | 202 | $mess->addHeader($caption); |
203 | 203 | return $mess; |
204 | - }, $index,$attributes,"message"); |
|
204 | + }, $index, $attributes, "message"); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /**Change fields type |
208 | 208 | * @param array $types an array or associative array $type=>$attribute |
209 | 209 | */ |
210 | - public function fieldsAs(array $types){ |
|
210 | + public function fieldsAs(array $types) { |
|
211 | 211 | $i=0; |
212 | - if(JArray::isAssociative($types)){ |
|
213 | - foreach ($types as $type=>$attributes){ |
|
214 | - if(\is_int($type)) |
|
215 | - $this->fieldAs($i++,$attributes,[]); |
|
212 | + if (JArray::isAssociative($types)) { |
|
213 | + foreach ($types as $type=>$attributes) { |
|
214 | + if (\is_int($type)) |
|
215 | + $this->fieldAs($i++, $attributes, []); |
|
216 | 216 | else |
217 | - $this->fieldAs($i++,$type,$attributes); |
|
217 | + $this->fieldAs($i++, $type, $attributes); |
|
218 | 218 | } |
219 | - }else{ |
|
220 | - foreach ($types as $type){ |
|
221 | - $this->fieldAs($i++,$type); |
|
219 | + } else { |
|
220 | + foreach ($types as $type) { |
|
221 | + $this->fieldAs($i++, $type); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
226 | - public function fieldAs($index,$type,$attributes=NULL){ |
|
226 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
227 | 227 | $method="fieldAs".\ucfirst($type); |
228 | - if(\method_exists($this, $method)){ |
|
229 | - if(!\is_array($attributes)){ |
|
228 | + if (\method_exists($this, $method)) { |
|
229 | + if (!\is_array($attributes)) { |
|
230 | 230 | $attributes=[$index]; |
231 | - }else{ |
|
231 | + } else { |
|
232 | 232 | \array_unshift($attributes, $index); |
233 | 233 | } |
234 | - \call_user_func_array([$this,$method], $attributes); |
|
234 | + \call_user_func_array([$this, $method], $attributes); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | |
238 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
239 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
240 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
241 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,$attributes["ajax"]); |
|
238 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
239 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
240 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
241 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, $attributes["ajax"]); |
|
242 | 242 | return $button; |
243 | - }, $index,$attributes,"submit"); |
|
243 | + }, $index, $attributes, "submit"); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | \ No newline at end of file |
@@ -19,45 +19,45 @@ discard block |
||
19 | 19 | class DataElement extends Widget { |
20 | 20 | |
21 | 21 | public function __construct($identifier, $modelInstance=NULL) { |
22 | - parent::__construct($identifier, null,$modelInstance); |
|
23 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,2), false); |
|
22 | + parent::__construct($identifier, null, $modelInstance); |
|
23 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 2), false); |
|
24 | 24 | $this->content["table"]->setDefinition(); |
25 | 25 | } |
26 | 26 | |
27 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
28 | - if(!$this->_generated){ |
|
27 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
28 | + if (!$this->_generated) { |
|
29 | 29 | $this->_instanceViewer->setInstance($this->_modelInstance); |
30 | 30 | |
31 | 31 | $table=$this->content["table"]; |
32 | 32 | $this->_generateContent($table); |
33 | 33 | |
34 | - if(isset($this->_toolbar)){ |
|
34 | + if (isset($this->_toolbar)) { |
|
35 | 35 | $this->_setToolbarPosition($table); |
36 | 36 | } |
37 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
37 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
38 | 38 | $this->_compileForm(); |
39 | 39 | $this->_generated=true; |
40 | 40 | } |
41 | - return parent::compile($js,$view); |
|
41 | + return parent::compile($js, $view); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @param HtmlTable $table |
46 | 46 | */ |
47 | - protected function _generateContent($table){ |
|
47 | + protected function _generateContent($table) { |
|
48 | 48 | $captions=$this->_instanceViewer->getCaptions(); |
49 | - $values= $this->_instanceViewer->getValues(); |
|
49 | + $values=$this->_instanceViewer->getValues(); |
|
50 | 50 | $count=$this->_instanceViewer->count(); |
51 | - for($i=0;$i<$count;$i++){ |
|
52 | - $table->addRow([$captions[$i],$values[$i]]); |
|
51 | + for ($i=0; $i<$count; $i++) { |
|
52 | + $table->addRow([$captions[$i], $values[$i]]); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | - protected function _getFieldName($index){ |
|
56 | + protected function _getFieldName($index) { |
|
57 | 57 | return $this->_instanceViewer->getFieldName($index); |
58 | 58 | } |
59 | 59 | |
60 | - protected function _getFieldCaption($index){ |
|
60 | + protected function _getFieldCaption($index) { |
|
61 | 61 | return null; |
62 | 62 | } |
63 | 63 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | return $this; |
90 | 90 | } |
91 | 91 | |
92 | - public function asForm(){ |
|
92 | + public function asForm() { |
|
93 | 93 | return $this->getForm(); |
94 | 94 | } |
95 | 95 | } |
96 | 96 | \ No newline at end of file |
@@ -16,6 +16,6 @@ |
||
16 | 16 | if (isset($toElement)) { |
17 | 17 | $toElement->setAttached(true); |
18 | 18 | } |
19 | - return $this->addToPropertyCtrl("class", $side . " attached", Side::getConstantValues("attached")); |
|
19 | + return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached")); |
|
20 | 20 | } |
21 | 21 | } |
22 | 22 | \ No newline at end of file |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | * @property string $identifier |
13 | 13 | */ |
14 | 14 | trait BaseTrait { |
15 | - protected $_variations=[ ]; |
|
16 | - protected $_states=[ ]; |
|
15 | + protected $_variations=[]; |
|
16 | + protected $_states=[]; |
|
17 | 17 | protected $_baseClass; |
18 | 18 | |
19 | 19 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | abstract public function setProperty($name, $value); |
28 | 28 | |
29 | - abstract public function addContent($content,$before=false); |
|
29 | + abstract public function addContent($content, $before=false); |
|
30 | 30 | |
31 | 31 | abstract public function onCreate($jsCode); |
32 | 32 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $this->setProperty("class", $this->_baseClass); |
48 | 48 | if (\is_string($variations)) |
49 | 49 | $variations=\explode(" ", $variations); |
50 | - foreach ( $variations as $variation ) { |
|
50 | + foreach ($variations as $variation) { |
|
51 | 51 | $this->addVariation($variation); |
52 | 52 | } |
53 | 53 | return $this; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public function addVariations($variations=array()) { |
62 | 62 | if (\is_string($variations)) |
63 | 63 | $variations=\explode(" ", $variations); |
64 | - foreach ( $variations as $variation ) { |
|
64 | + foreach ($variations as $variation) { |
|
65 | 65 | $this->addVariation($variation); |
66 | 66 | } |
67 | 67 | return $this; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | public function addStates($states=array()) { |
71 | 71 | if (\is_string($states)) |
72 | 72 | $states=\explode(" ", $states); |
73 | - foreach ( $states as $state ) { |
|
73 | + foreach ($states as $state) { |
|
74 | 74 | $this->addState($state); |
75 | 75 | } |
76 | 76 | return $this; |
@@ -80,17 +80,17 @@ discard block |
||
80 | 80 | $this->setProperty("class", $this->_baseClass); |
81 | 81 | if (\is_string($states)) |
82 | 82 | $states=\explode(" ", $states); |
83 | - foreach ( $states as $state ) { |
|
83 | + foreach ($states as $state) { |
|
84 | 84 | $this->addState($state); |
85 | 85 | } |
86 | 86 | return $this; |
87 | 87 | } |
88 | 88 | |
89 | 89 | public function addIcon($icon, $before=true) { |
90 | - return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
90 | + return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before); |
|
91 | 91 | } |
92 | 92 | |
93 | - public function addSticky($context="body"){ |
|
93 | + public function addSticky($context="body") { |
|
94 | 94 | $this->onCreate("$('#".$this->identifier."').sticky({ context: '".$context."'});"); |
95 | 95 | return $this; |
96 | 96 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
112 | 112 | */ |
113 | 113 | public function setDisabled($disable=true) { |
114 | - if($disable) |
|
114 | + if ($disable) |
|
115 | 115 | $this->addToProperty("class", "disabled"); |
116 | 116 | return $this; |
117 | 117 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
139 | 139 | */ |
140 | - public function asHeader(){ |
|
140 | + public function asHeader() { |
|
141 | 141 | return $this->addToProperty("class", "header"); |
142 | 142 | } |
143 | 143 | |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | * show it is currently the active user selection |
146 | 146 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
147 | 147 | */ |
148 | - public function setActive($value=true){ |
|
149 | - if($value) |
|
148 | + public function setActive($value=true) { |
|
149 | + if ($value) |
|
150 | 150 | $this->addToProperty("class", "active"); |
151 | 151 | return $this; |
152 | 152 | } |
153 | 153 | |
154 | - public function setAttached($value=true){ |
|
155 | - if($value) |
|
156 | - $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
154 | + public function setAttached($value=true) { |
|
155 | + if ($value) |
|
156 | + $this->addToPropertyCtrl("class", "attached", array("attached")); |
|
157 | 157 | return $this; |
158 | 158 | } |
159 | 159 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | } |
170 | 170 | |
171 | 171 | public function setFloated($direction="right") { |
172 | - return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
172 | + return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | public function floatRight() { |
@@ -45,8 +45,9 @@ discard block |
||
45 | 45 | |
46 | 46 | public function setVariations($variations) { |
47 | 47 | $this->setProperty("class", $this->_baseClass); |
48 | - if (\is_string($variations)) |
|
49 | - $variations=\explode(" ", $variations); |
|
48 | + if (\is_string($variations)) { |
|
49 | + $variations=\explode(" ", $variations); |
|
50 | + } |
|
50 | 51 | foreach ( $variations as $variation ) { |
51 | 52 | $this->addVariation($variation); |
52 | 53 | } |
@@ -59,8 +60,9 @@ discard block |
||
59 | 60 | } |
60 | 61 | |
61 | 62 | public function addVariations($variations=array()) { |
62 | - if (\is_string($variations)) |
|
63 | - $variations=\explode(" ", $variations); |
|
63 | + if (\is_string($variations)) { |
|
64 | + $variations=\explode(" ", $variations); |
|
65 | + } |
|
64 | 66 | foreach ( $variations as $variation ) { |
65 | 67 | $this->addVariation($variation); |
66 | 68 | } |
@@ -68,8 +70,9 @@ discard block |
||
68 | 70 | } |
69 | 71 | |
70 | 72 | public function addStates($states=array()) { |
71 | - if (\is_string($states)) |
|
72 | - $states=\explode(" ", $states); |
|
73 | + if (\is_string($states)) { |
|
74 | + $states=\explode(" ", $states); |
|
75 | + } |
|
73 | 76 | foreach ( $states as $state ) { |
74 | 77 | $this->addState($state); |
75 | 78 | } |
@@ -78,8 +81,9 @@ discard block |
||
78 | 81 | |
79 | 82 | public function setStates($states) { |
80 | 83 | $this->setProperty("class", $this->_baseClass); |
81 | - if (\is_string($states)) |
|
82 | - $states=\explode(" ", $states); |
|
84 | + if (\is_string($states)) { |
|
85 | + $states=\explode(" ", $states); |
|
86 | + } |
|
83 | 87 | foreach ( $states as $state ) { |
84 | 88 | $this->addState($state); |
85 | 89 | } |
@@ -111,8 +115,9 @@ discard block |
||
111 | 115 | * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
112 | 116 | */ |
113 | 117 | public function setDisabled($disable=true) { |
114 | - if($disable) |
|
115 | - $this->addToProperty("class", "disabled"); |
|
118 | + if($disable) { |
|
119 | + $this->addToProperty("class", "disabled"); |
|
120 | + } |
|
116 | 121 | return $this; |
117 | 122 | } |
118 | 123 | |
@@ -146,14 +151,16 @@ discard block |
||
146 | 151 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
147 | 152 | */ |
148 | 153 | public function setActive($value=true){ |
149 | - if($value) |
|
150 | - $this->addToProperty("class", "active"); |
|
154 | + if($value) { |
|
155 | + $this->addToProperty("class", "active"); |
|
156 | + } |
|
151 | 157 | return $this; |
152 | 158 | } |
153 | 159 | |
154 | 160 | public function setAttached($value=true){ |
155 | - if($value) |
|
156 | - $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
161 | + if($value) { |
|
162 | + $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
163 | + } |
|
157 | 164 | return $this; |
158 | 165 | } |
159 | 166 |
@@ -42,8 +42,9 @@ discard block |
||
42 | 42 | |
43 | 43 | public function setAttached($value=true){ |
44 | 44 | $form=$this->getForm(); |
45 | - if($value) |
|
46 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
45 | + if($value) { |
|
46 | + $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
47 | + } |
|
47 | 48 | return $form; |
48 | 49 | } |
49 | 50 | |
@@ -85,8 +86,9 @@ discard block |
||
85 | 86 | if(isset($url) && isset($responseElement)){ |
86 | 87 | $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');"); |
87 | 88 | $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url]; |
88 | - if(\is_array($parameters)) |
|
89 | - $params=\array_merge($params,$parameters); |
|
89 | + if(\is_array($parameters)) { |
|
90 | + $params=\array_merge($params,$parameters); |
|
91 | + } |
|
90 | 92 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
91 | 93 | } |
92 | 94 | return $button; |
@@ -6,28 +6,28 @@ discard block |
||
6 | 6 | use Ajax\service\AjaxCall; |
7 | 7 | use Ajax\JsUtils; |
8 | 8 | |
9 | -trait FormTrait{ |
|
9 | +trait FormTrait { |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @return HtmlForm |
13 | 13 | */ |
14 | 14 | abstract protected function getForm(); |
15 | 15 | |
16 | - protected function addCompoValidation($compo,$field){ |
|
16 | + protected function addCompoValidation($compo, $field) { |
|
17 | 17 | $validation=$field->getValidation(); |
18 | - if(isset($validation)){ |
|
18 | + if (isset($validation)) { |
|
19 | 19 | $validation->setIdentifier($field->getDataField()->getIdentifier()); |
20 | 20 | $compo->addFieldValidation($validation); |
21 | 21 | } |
22 | 22 | return $compo; |
23 | 23 | } |
24 | 24 | |
25 | - protected function _runValidationParams(&$compo,JsUtils $js=NULL){ |
|
25 | + protected function _runValidationParams(&$compo, JsUtils $js=NULL) { |
|
26 | 26 | $form=$this->getForm(); |
27 | 27 | $params=$form->getValidationParams(); |
28 | - if(isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall){ |
|
28 | + if (isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall) { |
|
29 | 29 | $compilation=$params["_ajaxSubmit"]->compile($js); |
30 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
30 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
31 | 31 | $this->onSuccess($compilation); |
32 | 32 | $form->removeValidationParam("_ajaxSubmit"); |
33 | 33 | } |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | return $this->getForm()->addToProperty("class", "loading"); |
41 | 41 | } |
42 | 42 | |
43 | - public function setAttached($value=true){ |
|
43 | + public function setAttached($value=true) { |
|
44 | 44 | $form=$this->getForm(); |
45 | - if($value) |
|
46 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
45 | + if ($value) |
|
46 | + $form->addToPropertyCtrl("class", "attached", array("attached")); |
|
47 | 47 | return $form; |
48 | 48 | } |
49 | 49 | |
50 | - public function addErrorMessage(){ |
|
50 | + public function addErrorMessage() { |
|
51 | 51 | return $this->getForm()->addContent((new HtmlMessage(""))->setError()); |
52 | 52 | } |
53 | 53 | |
@@ -62,38 +62,38 @@ discard block |
||
62 | 62 | * @param string $responseElement |
63 | 63 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
64 | 64 | */ |
65 | - public function submitOn($event,$identifier,$url,$responseElement){ |
|
65 | + public function submitOn($event, $identifier, $url, $responseElement) { |
|
66 | 66 | $form=$this->getForm(); |
67 | 67 | $elem=$form->getElementById($identifier, $form->getContent()); |
68 | - if(isset($elem)){ |
|
69 | - $this->_buttonAsSubmit($elem, $event,$url,$responseElement); |
|
68 | + if (isset($elem)) { |
|
69 | + $this->_buttonAsSubmit($elem, $event, $url, $responseElement); |
|
70 | 70 | } |
71 | 71 | return $form; |
72 | 72 | } |
73 | 73 | |
74 | - public function submitOnClick($identifier,$url,$responseElement){ |
|
74 | + public function submitOnClick($identifier, $url, $responseElement) { |
|
75 | 75 | return $this->submitOn("click", $identifier, $url, $responseElement); |
76 | 76 | } |
77 | 77 | |
78 | - public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){ |
|
79 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
80 | - return $this->_buttonAsSubmit($bt, "click",$url,$responseElement); |
|
78 | + public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) { |
|
79 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
80 | + return $this->_buttonAsSubmit($bt, "click", $url, $responseElement); |
|
81 | 81 | } |
82 | 82 | |
83 | - protected function _buttonAsSubmit(&$button,$event,$url,$responseElement=NULL,$parameters=NULL){ |
|
83 | + protected function _buttonAsSubmit(&$button, $event, $url, $responseElement=NULL, $parameters=NULL) { |
|
84 | 84 | $form=$this->getForm(); |
85 | - if(isset($url) && isset($responseElement)){ |
|
85 | + if (isset($url) && isset($responseElement)) { |
|
86 | 86 | $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');"); |
87 | - $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url]; |
|
88 | - if(\is_array($parameters)) |
|
89 | - $params=\array_merge($params,$parameters); |
|
87 | + $params=["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url]; |
|
88 | + if (\is_array($parameters)) |
|
89 | + $params=\array_merge($params, $parameters); |
|
90 | 90 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
91 | 91 | } |
92 | 92 | return $button; |
93 | 93 | } |
94 | 94 | |
95 | - public function addReset($identifier,$value,$cssStyle=NULL){ |
|
96 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
95 | + public function addReset($identifier, $value, $cssStyle=NULL) { |
|
96 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
97 | 97 | $bt->setProperty("type", "reset"); |
98 | 98 | return $bt; |
99 | 99 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param string $jsCode |
104 | 104 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
105 | 105 | */ |
106 | - public function onValid($jsCode){ |
|
106 | + public function onValid($jsCode) { |
|
107 | 107 | $form=$this->getForm(); |
108 | 108 | $form->addValidationParam("onValid", "%function(){".$jsCode."}%"); |
109 | 109 | return $form; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param string $jsCode can use event and fields parameters |
115 | 115 | * @return HtmlForm |
116 | 116 | */ |
117 | - public function onSuccess($jsCode){ |
|
117 | + public function onSuccess($jsCode) { |
|
118 | 118 | $form=$this->getForm(); |
119 | 119 | $form->addValidationParam("onSuccess", "%function(event,fields){console.log(fields);".$jsCode."}%"); |
120 | 120 | return $form; |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Ajax\semantic\html\collections\table\traits; |
3 | 3 | |
4 | -trait TableTrait{ |
|
4 | +trait TableTrait { |
|
5 | 5 | /** |
6 | 6 | * @return HtmlTable |
7 | 7 | */ |
8 | 8 | abstract protected function getTable(); |
9 | 9 | |
10 | - protected function addToPropertyTable($property,$value){ |
|
10 | + protected function addToPropertyTable($property, $value) { |
|
11 | 11 | return $this->getTable()->addToProperty($property, $value); |
12 | 12 | } |
13 | 13 | |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | public function setBasic($very=false) { |
19 | 19 | $table=$this->getTable(); |
20 | 20 | if ($very) |
21 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
22 | - return $table->addToPropertyCtrl("class", "basic", array ("basic" )); |
|
21 | + $table->addToPropertyCtrl("class", "very", array("very")); |
|
22 | + return $table->addToPropertyCtrl("class", "basic", array("basic")); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function setCompact($very=false) { |
26 | 26 | $table=$this->getTable(); |
27 | 27 | if ($very) |
28 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
29 | - return $table->addToPropertyCtrl("class", "compact", array ("compact" )); |
|
28 | + $table->addToPropertyCtrl("class", "very", array("very")); |
|
29 | + return $table->addToPropertyCtrl("class", "compact", array("compact")); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function setCollapsing() { |
@@ -17,15 +17,17 @@ |
||
17 | 17 | |
18 | 18 | public function setBasic($very=false) { |
19 | 19 | $table=$this->getTable(); |
20 | - if ($very) |
|
21 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
20 | + if ($very) { |
|
21 | + $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
22 | + } |
|
22 | 23 | return $table->addToPropertyCtrl("class", "basic", array ("basic" )); |
23 | 24 | } |
24 | 25 | |
25 | 26 | public function setCompact($very=false) { |
26 | 27 | $table=$this->getTable(); |
27 | - if ($very) |
|
28 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
28 | + if ($very) { |
|
29 | + $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
30 | + } |
|
29 | 31 | return $table->addToPropertyCtrl("class", "compact", array ("compact" )); |
30 | 32 | } |
31 | 33 |
@@ -17,183 +17,183 @@ discard block |
||
17 | 17 | |
18 | 18 | public static $index=0; |
19 | 19 | |
20 | - public function __construct($identifier,$instance=NULL,$captions=NULL){ |
|
20 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
21 | 21 | $this->widgetIdentifier=$identifier; |
22 | 22 | $this->values=[]; |
23 | 23 | $this->afterCompile=[]; |
24 | - if(isset($instance)) |
|
24 | + if (isset($instance)) |
|
25 | 25 | $this->setInstance($instance); |
26 | 26 | $this->setCaptions($captions); |
27 | 27 | $this->captionCallback=NULL; |
28 | - $this->defaultValueFunction=function($name,$value){return $value;}; |
|
28 | + $this->defaultValueFunction=function($name, $value) {return $value; }; |
|
29 | 29 | } |
30 | 30 | |
31 | - public function getValues(){ |
|
31 | + public function getValues() { |
|
32 | 32 | $values=[]; |
33 | 33 | $index=0; |
34 | 34 | $count=$this->count(); |
35 | - while($index<$count){ |
|
35 | + while ($index<$count) { |
|
36 | 36 | $values[]=$this->getValue($index++); |
37 | 37 | } |
38 | 38 | return $values; |
39 | 39 | } |
40 | 40 | |
41 | - public function getIdentifier($index=NULL){ |
|
42 | - if(!isset($index)) |
|
41 | + public function getIdentifier($index=NULL) { |
|
42 | + if (!isset($index)) |
|
43 | 43 | $index=self::$index; |
44 | 44 | $value=$index; |
45 | - if(isset($this->values["identifier"])) |
|
46 | - $value=$this->values["identifier"]($index,$this->instance); |
|
45 | + if (isset($this->values["identifier"])) |
|
46 | + $value=$this->values["identifier"]($index, $this->instance); |
|
47 | 47 | return $value; |
48 | 48 | } |
49 | 49 | |
50 | - public function getValue($index){ |
|
50 | + public function getValue($index) { |
|
51 | 51 | $property=$this->properties[$index]; |
52 | 52 | return $this->_getValue($property, $index); |
53 | 53 | } |
54 | 54 | |
55 | - protected function _beforeAddProperty($index,&$field){ |
|
55 | + protected function _beforeAddProperty($index, &$field) { |
|
56 | 56 | |
57 | 57 | } |
58 | 58 | |
59 | - protected function _getDefaultValue($name,$value,$index){ |
|
59 | + protected function _getDefaultValue($name, $value, $index) { |
|
60 | 60 | $func=$this->defaultValueFunction; |
61 | - return $func($name,$value,$index,$this->instance); |
|
61 | + return $func($name, $value, $index, $this->instance); |
|
62 | 62 | } |
63 | 63 | |
64 | - protected function _getValue($property,$index){ |
|
65 | - if($property instanceof \ReflectionProperty){ |
|
64 | + protected function _getValue($property, $index) { |
|
65 | + if ($property instanceof \ReflectionProperty) { |
|
66 | 66 | $property->setAccessible(true); |
67 | 67 | $value=$property->getValue($this->instance); |
68 | - if(isset($this->values[$index])){ |
|
69 | - $value= $this->values[$index]($value,$this->instance,$index); |
|
70 | - }else{ |
|
71 | - $value=$this->_getDefaultValue($property->getName(),$value, $index); |
|
68 | + if (isset($this->values[$index])) { |
|
69 | + $value=$this->values[$index]($value, $this->instance, $index); |
|
70 | + } else { |
|
71 | + $value=$this->_getDefaultValue($property->getName(), $value, $index); |
|
72 | 72 | } |
73 | - }else{ |
|
74 | - if(\is_callable($property)) |
|
73 | + } else { |
|
74 | + if (\is_callable($property)) |
|
75 | 75 | $value=$property($this->instance); |
76 | - elseif(\is_array($property)){ |
|
77 | - $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
|
76 | + elseif (\is_array($property)) { |
|
77 | + $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property); |
|
78 | 78 | $value=\implode("", $values); |
79 | - }else{ |
|
80 | - if(isset($this->values[$index])){ |
|
81 | - $value= $this->values[$index]($property,$this->instance,$index); |
|
82 | - }elseif(isset($this->instance->{$property})){ |
|
79 | + } else { |
|
80 | + if (isset($this->values[$index])) { |
|
81 | + $value=$this->values[$index]($property, $this->instance, $index); |
|
82 | + }elseif (isset($this->instance->{$property})) { |
|
83 | 83 | $value=$this->instance->{$property}; |
84 | 84 | } |
85 | - else{ |
|
85 | + else { |
|
86 | 86 | $value=null; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | } |
90 | - if(isset($this->afterCompile[$index])){ |
|
91 | - if(\is_callable($this->afterCompile[$index])){ |
|
92 | - $this->afterCompile[$index]($value,$this->instance,$index); |
|
90 | + if (isset($this->afterCompile[$index])) { |
|
91 | + if (\is_callable($this->afterCompile[$index])) { |
|
92 | + $this->afterCompile[$index]($value, $this->instance, $index); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | return $value; |
96 | 96 | } |
97 | 97 | |
98 | - public function insertField($index,$field){ |
|
99 | - array_splice( $this->visibleProperties, $index, 0, $field ); |
|
98 | + public function insertField($index, $field) { |
|
99 | + array_splice($this->visibleProperties, $index, 0, $field); |
|
100 | 100 | return $this; |
101 | 101 | } |
102 | 102 | |
103 | - public function insertInField($index,$field){ |
|
103 | + public function insertInField($index, $field) { |
|
104 | 104 | $vb=$this->visibleProperties; |
105 | - if(isset($vb[$index])){ |
|
106 | - if(\is_array($vb[$index])){ |
|
105 | + if (isset($vb[$index])) { |
|
106 | + if (\is_array($vb[$index])) { |
|
107 | 107 | $this->visibleProperties[$index][]=$field; |
108 | - }else{ |
|
109 | - $this->visibleProperties[$index]=[$vb[$index],$field]; |
|
108 | + } else { |
|
109 | + $this->visibleProperties[$index]=[$vb[$index], $field]; |
|
110 | 110 | } |
111 | - }else{ |
|
111 | + } else { |
|
112 | 112 | return $this->insertField($index, $field); |
113 | 113 | } |
114 | 114 | return $this; |
115 | 115 | } |
116 | 116 | |
117 | - public function addField($field){ |
|
117 | + public function addField($field) { |
|
118 | 118 | $this->visibleProperties[]=$field; |
119 | 119 | return $this; |
120 | 120 | } |
121 | 121 | |
122 | - public function count(){ |
|
122 | + public function count() { |
|
123 | 123 | return \sizeof($this->properties); |
124 | 124 | } |
125 | 125 | |
126 | - public function visiblePropertiesCount(){ |
|
126 | + public function visiblePropertiesCount() { |
|
127 | 127 | return \sizeof($this->visibleProperties); |
128 | 128 | } |
129 | 129 | |
130 | - public function getProperty($index){ |
|
130 | + public function getProperty($index) { |
|
131 | 131 | return $this->properties[$index]; |
132 | 132 | } |
133 | 133 | |
134 | - public function getFieldName($index){ |
|
134 | + public function getFieldName($index) { |
|
135 | 135 | $property=$this->getProperty($index); |
136 | - if($property instanceof \ReflectionProperty){ |
|
136 | + if ($property instanceof \ReflectionProperty) { |
|
137 | 137 | $result=$property->getName(); |
138 | - }elseif(\is_callable($property)){ |
|
138 | + }elseif (\is_callable($property)) { |
|
139 | 139 | $result=$this->visibleProperties[$index]; |
140 | - }else{ |
|
140 | + } else { |
|
141 | 141 | $result=$property; |
142 | 142 | } |
143 | 143 | return $result; |
144 | 144 | } |
145 | 145 | |
146 | 146 | |
147 | - protected function showableProperty(\ReflectionProperty $rProperty){ |
|
148 | - return JString::startswith($rProperty->getName(),"_")===false; |
|
147 | + protected function showableProperty(\ReflectionProperty $rProperty) { |
|
148 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | public function setInstance($instance) { |
152 | - if(\is_string($instance)){ |
|
152 | + if (\is_string($instance)) { |
|
153 | 153 | $instance=new $instance(); |
154 | 154 | } |
155 | 155 | $this->instance=$instance; |
156 | 156 | $this->properties=[]; |
157 | 157 | $this->reflect=new \ReflectionClass($instance); |
158 | - if(\sizeof($this->visibleProperties)===0){ |
|
158 | + if (\sizeof($this->visibleProperties)===0) { |
|
159 | 159 | $this->properties=$this->getDefaultProperties(); |
160 | - }else{ |
|
161 | - foreach ($this->visibleProperties as $property){ |
|
160 | + } else { |
|
161 | + foreach ($this->visibleProperties as $property) { |
|
162 | 162 | $this->setInstanceProperty($property); |
163 | 163 | } |
164 | 164 | } |
165 | 165 | return $this; |
166 | 166 | } |
167 | 167 | |
168 | - private function setInstanceProperty($property){ |
|
169 | - if(\is_callable($property)){ |
|
168 | + private function setInstanceProperty($property) { |
|
169 | + if (\is_callable($property)) { |
|
170 | 170 | $this->properties[]=$property; |
171 | - }elseif(\is_string($property)){ |
|
172 | - try{ |
|
171 | + }elseif (\is_string($property)) { |
|
172 | + try { |
|
173 | 173 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
174 | 174 | $rProperty=$this->reflect->getProperty($property); |
175 | 175 | $this->properties[]=$rProperty; |
176 | - }catch(\Exception $e){ |
|
176 | + }catch (\Exception $e) { |
|
177 | 177 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
178 | 178 | $this->properties[]=$property; |
179 | 179 | } |
180 | - }elseif(\is_int($property)){ |
|
180 | + }elseif (\is_int($property)) { |
|
181 | 181 | $props=$this->getDefaultProperties(); |
182 | - if(isset($props[$property])) |
|
182 | + if (isset($props[$property])) |
|
183 | 183 | $this->properties[]=$props[$property]; |
184 | 184 | else |
185 | 185 | $this->properties[]=$property; |
186 | - }else{ |
|
186 | + } else { |
|
187 | 187 | $this->properties[]=$property; |
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - protected function getDefaultProperties(){ |
|
191 | + protected function getDefaultProperties() { |
|
192 | 192 | $result=[]; |
193 | 193 | $properties=$this->reflect->getProperties(); |
194 | - foreach ($properties as $property){ |
|
194 | + foreach ($properties as $property) { |
|
195 | 195 | $showable=$this->showableProperty($property); |
196 | - if($showable!==false){ |
|
196 | + if ($showable!==false) { |
|
197 | 197 | $result[]=$property; |
198 | 198 | } |
199 | 199 | } |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | return $this; |
206 | 206 | } |
207 | 207 | |
208 | - public function setValueFunction($index,$callback){ |
|
208 | + public function setValueFunction($index, $callback) { |
|
209 | 209 | $this->values[$index]=$callback; |
210 | 210 | return $this; |
211 | 211 | } |
212 | 212 | |
213 | - public function setIdentifierFunction($callback){ |
|
213 | + public function setIdentifierFunction($callback) { |
|
214 | 214 | $this->values["identifier"]=$callback; |
215 | 215 | return $this; |
216 | 216 | } |
@@ -223,41 +223,41 @@ discard block |
||
223 | 223 | return $this->properties; |
224 | 224 | } |
225 | 225 | |
226 | - public function getCaption($index){ |
|
227 | - if(isset($this->captions[$index])){ |
|
226 | + public function getCaption($index) { |
|
227 | + if (isset($this->captions[$index])) { |
|
228 | 228 | return $this->captions[$index]; |
229 | 229 | } |
230 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
230 | + if ($this->properties[$index] instanceof \ReflectionProperty) |
|
231 | 231 | return $this->properties[$index]->getName(); |
232 | - elseif(\is_callable($this->properties[$index])) |
|
232 | + elseif (\is_callable($this->properties[$index])) |
|
233 | 233 | return ""; |
234 | 234 | else |
235 | 235 | return $this->properties[$index]; |
236 | 236 | } |
237 | 237 | |
238 | - public function getCaptions(){ |
|
239 | - if(isset($this->captions)){ |
|
240 | - $captions= $this->captions; |
|
241 | - for($i=\sizeof($captions);$i<$this->count();$i++){ |
|
238 | + public function getCaptions() { |
|
239 | + if (isset($this->captions)) { |
|
240 | + $captions=$this->captions; |
|
241 | + for ($i=\sizeof($captions); $i<$this->count(); $i++) { |
|
242 | 242 | $captions[]=""; |
243 | 243 | } |
244 | - }else{ |
|
244 | + } else { |
|
245 | 245 | $captions=[]; |
246 | 246 | $index=0; |
247 | 247 | $count=$this->count(); |
248 | - while($index<$count){ |
|
248 | + while ($index<$count) { |
|
249 | 249 | $captions[]=$this->getCaption($index++); |
250 | 250 | } |
251 | 251 | } |
252 | - if(isset($this->captionCallback) && \is_callable($this->captionCallback)){ |
|
252 | + if (isset($this->captionCallback) && \is_callable($this->captionCallback)) { |
|
253 | 253 | $callback=$this->captionCallback; |
254 | - $callback($captions,$this->instance); |
|
254 | + $callback($captions, $this->instance); |
|
255 | 255 | } |
256 | 256 | return $captions; |
257 | 257 | } |
258 | 258 | |
259 | - public function setCaption($index,$caption){ |
|
260 | - if(isset($this->captions)===false) |
|
259 | + public function setCaption($index, $caption) { |
|
260 | + if (isset($this->captions)===false) |
|
261 | 261 | $this->captions=[]; |
262 | 262 | $this->captions[$index]=$caption; |
263 | 263 | return $this; |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * @param callable $callback function called after the field compilation |
276 | 276 | * @return \Ajax\semantic\widgets\datatable\InstanceViewer |
277 | 277 | */ |
278 | - public function afterCompile($index,$callback){ |
|
278 | + public function afterCompile($index, $callback) { |
|
279 | 279 | $this->afterCompile[$index]=$callback; |
280 | 280 | return $this; |
281 | 281 | } |
@@ -21,8 +21,9 @@ discard block |
||
21 | 21 | $this->widgetIdentifier=$identifier; |
22 | 22 | $this->values=[]; |
23 | 23 | $this->afterCompile=[]; |
24 | - if(isset($instance)) |
|
25 | - $this->setInstance($instance); |
|
24 | + if(isset($instance)) { |
|
25 | + $this->setInstance($instance); |
|
26 | + } |
|
26 | 27 | $this->setCaptions($captions); |
27 | 28 | $this->captionCallback=NULL; |
28 | 29 | $this->defaultValueFunction=function($name,$value){return $value;}; |
@@ -39,11 +40,13 @@ discard block |
||
39 | 40 | } |
40 | 41 | |
41 | 42 | public function getIdentifier($index=NULL){ |
42 | - if(!isset($index)) |
|
43 | - $index=self::$index; |
|
43 | + if(!isset($index)) { |
|
44 | + $index=self::$index; |
|
45 | + } |
|
44 | 46 | $value=$index; |
45 | - if(isset($this->values["identifier"])) |
|
46 | - $value=$this->values["identifier"]($index,$this->instance); |
|
47 | + if(isset($this->values["identifier"])) { |
|
48 | + $value=$this->values["identifier"]($index,$this->instance); |
|
49 | + } |
|
47 | 50 | return $value; |
48 | 51 | } |
49 | 52 | |
@@ -67,22 +70,21 @@ discard block |
||
67 | 70 | $value=$property->getValue($this->instance); |
68 | 71 | if(isset($this->values[$index])){ |
69 | 72 | $value= $this->values[$index]($value,$this->instance,$index); |
70 | - }else{ |
|
73 | + } else{ |
|
71 | 74 | $value=$this->_getDefaultValue($property->getName(),$value, $index); |
72 | 75 | } |
73 | - }else{ |
|
74 | - if(\is_callable($property)) |
|
75 | - $value=$property($this->instance); |
|
76 | - elseif(\is_array($property)){ |
|
76 | + } else{ |
|
77 | + if(\is_callable($property)) { |
|
78 | + $value=$property($this->instance); |
|
79 | + } elseif(\is_array($property)){ |
|
77 | 80 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
78 | 81 | $value=\implode("", $values); |
79 | - }else{ |
|
82 | + } else{ |
|
80 | 83 | if(isset($this->values[$index])){ |
81 | 84 | $value= $this->values[$index]($property,$this->instance,$index); |
82 | - }elseif(isset($this->instance->{$property})){ |
|
85 | + } elseif(isset($this->instance->{$property})){ |
|
83 | 86 | $value=$this->instance->{$property}; |
84 | - } |
|
85 | - else{ |
|
87 | + } else{ |
|
86 | 88 | $value=null; |
87 | 89 | } |
88 | 90 | } |
@@ -105,10 +107,10 @@ discard block |
||
105 | 107 | if(isset($vb[$index])){ |
106 | 108 | if(\is_array($vb[$index])){ |
107 | 109 | $this->visibleProperties[$index][]=$field; |
108 | - }else{ |
|
110 | + } else{ |
|
109 | 111 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
110 | 112 | } |
111 | - }else{ |
|
113 | + } else{ |
|
112 | 114 | return $this->insertField($index, $field); |
113 | 115 | } |
114 | 116 | return $this; |
@@ -135,9 +137,9 @@ discard block |
||
135 | 137 | $property=$this->getProperty($index); |
136 | 138 | if($property instanceof \ReflectionProperty){ |
137 | 139 | $result=$property->getName(); |
138 | - }elseif(\is_callable($property)){ |
|
140 | + } elseif(\is_callable($property)){ |
|
139 | 141 | $result=$this->visibleProperties[$index]; |
140 | - }else{ |
|
142 | + } else{ |
|
141 | 143 | $result=$property; |
142 | 144 | } |
143 | 145 | return $result; |
@@ -157,7 +159,7 @@ discard block |
||
157 | 159 | $this->reflect=new \ReflectionClass($instance); |
158 | 160 | if(\sizeof($this->visibleProperties)===0){ |
159 | 161 | $this->properties=$this->getDefaultProperties(); |
160 | - }else{ |
|
162 | + } else{ |
|
161 | 163 | foreach ($this->visibleProperties as $property){ |
162 | 164 | $this->setInstanceProperty($property); |
163 | 165 | } |
@@ -168,22 +170,23 @@ discard block |
||
168 | 170 | private function setInstanceProperty($property){ |
169 | 171 | if(\is_callable($property)){ |
170 | 172 | $this->properties[]=$property; |
171 | - }elseif(\is_string($property)){ |
|
173 | + } elseif(\is_string($property)){ |
|
172 | 174 | try{ |
173 | 175 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
174 | 176 | $rProperty=$this->reflect->getProperty($property); |
175 | 177 | $this->properties[]=$rProperty; |
176 | - }catch(\Exception $e){ |
|
178 | + } catch(\Exception $e){ |
|
177 | 179 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
178 | 180 | $this->properties[]=$property; |
179 | 181 | } |
180 | - }elseif(\is_int($property)){ |
|
182 | + } elseif(\is_int($property)){ |
|
181 | 183 | $props=$this->getDefaultProperties(); |
182 | - if(isset($props[$property])) |
|
183 | - $this->properties[]=$props[$property]; |
|
184 | - else |
|
185 | - $this->properties[]=$property; |
|
186 | - }else{ |
|
184 | + if(isset($props[$property])) { |
|
185 | + $this->properties[]=$props[$property]; |
|
186 | + } else { |
|
187 | + $this->properties[]=$property; |
|
188 | + } |
|
189 | + } else{ |
|
187 | 190 | $this->properties[]=$property; |
188 | 191 | } |
189 | 192 | } |
@@ -227,12 +230,13 @@ discard block |
||
227 | 230 | if(isset($this->captions[$index])){ |
228 | 231 | return $this->captions[$index]; |
229 | 232 | } |
230 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
231 | - return $this->properties[$index]->getName(); |
|
232 | - elseif(\is_callable($this->properties[$index])) |
|
233 | - return ""; |
|
234 | - else |
|
235 | - return $this->properties[$index]; |
|
233 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
234 | + return $this->properties[$index]->getName(); |
|
235 | + } elseif(\is_callable($this->properties[$index])) { |
|
236 | + return ""; |
|
237 | + } else { |
|
238 | + return $this->properties[$index]; |
|
239 | + } |
|
236 | 240 | } |
237 | 241 | |
238 | 242 | public function getCaptions(){ |
@@ -241,7 +245,7 @@ discard block |
||
241 | 245 | for($i=\sizeof($captions);$i<$this->count();$i++){ |
242 | 246 | $captions[]=""; |
243 | 247 | } |
244 | - }else{ |
|
248 | + } else{ |
|
245 | 249 | $captions=[]; |
246 | 250 | $index=0; |
247 | 251 | $count=$this->count(); |
@@ -257,8 +261,9 @@ discard block |
||
257 | 261 | } |
258 | 262 | |
259 | 263 | public function setCaption($index,$caption){ |
260 | - if(isset($this->captions)===false) |
|
261 | - $this->captions=[]; |
|
264 | + if(isset($this->captions)===false) { |
|
265 | + $this->captions=[]; |
|
266 | + } |
|
262 | 267 | $this->captions[$index]=$caption; |
263 | 268 | return $this; |
264 | 269 | } |
@@ -6,8 +6,8 @@ |
||
6 | 6 | public static $preventDefault="\nif(event && event.preventDefault) event.preventDefault();\n"; |
7 | 7 | public static $stopPropagation="\nif(event && event.stopPropagation) event.stopPropagation();\n"; |
8 | 8 | |
9 | - public static function containsCode($expression){ |
|
10 | - return strrpos($expression, 'this')!==false||strrpos($expression, 'event')!==false||strrpos($expression, 'self')!==false; |
|
9 | + public static function containsCode($expression) { |
|
10 | + return strrpos($expression, 'this')!==false || strrpos($expression, 'event')!==false || strrpos($expression, 'self')!==false; |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -37,6 +37,10 @@ discard block |
||
37 | 37 | protected $_targetSelector; |
38 | 38 | protected $_checkedMessage; |
39 | 39 | |
40 | + /** |
|
41 | + * @param string $identifier |
|
42 | + * @param string $model |
|
43 | + */ |
|
40 | 44 | public function __construct($identifier,$model,$modelInstance=NULL) { |
41 | 45 | parent::__construct($identifier, $model,$modelInstance); |
42 | 46 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
@@ -76,6 +80,9 @@ discard block |
||
76 | 80 | if(allChecked) {\$parentCheckbox.checkbox('set checked');}else if(allUnchecked){\$parentCheckbox.checkbox('set unchecked');}else{\$parentCheckbox.checkbox('set indeterminate');};".$checkedMessageCall); |
77 | 81 | } |
78 | 82 | |
83 | + /** |
|
84 | + * @param string $op |
|
85 | + */ |
|
79 | 86 | protected function _generateBehavior($op,JsUtils $js){ |
80 | 87 | if(isset($this->_urls[$op])) |
81 | 88 | $js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]); |
@@ -211,6 +218,9 @@ discard block |
||
211 | 218 | return $this; |
212 | 219 | } |
213 | 220 | |
221 | + /** |
|
222 | + * @param PositionInTable $part |
|
223 | + */ |
|
214 | 224 | private function addToolbarRow($part,$table,$captions){ |
215 | 225 | $hasPart=$table->hasPart($part); |
216 | 226 | if($hasPart){ |
@@ -267,7 +277,7 @@ discard block |
||
267 | 277 | * @param string $caption |
268 | 278 | * @param callable $callback |
269 | 279 | * @param boolean $visibleHover |
270 | - * @return callable |
|
280 | + * @return \Closure |
|
271 | 281 | */ |
272 | 282 | private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
273 | 283 | return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
@@ -277,7 +287,7 @@ discard block |
||
277 | 287 | * @param callable $thisCallback |
278 | 288 | * @param array $parameters |
279 | 289 | * @param callable $callback |
280 | - * @return callable |
|
290 | + * @return \Closure |
|
281 | 291 | */ |
282 | 292 | private function getCallable($thisCallback,$parameters,$callback=null){ |
283 | 293 | $result=function($instance) use($thisCallback,$parameters,$callback){ |
@@ -346,11 +356,19 @@ discard block |
||
346 | 356 | return $this; |
347 | 357 | } |
348 | 358 | |
359 | + /** |
|
360 | + * @param string $icon |
|
361 | + * @param string $class |
|
362 | + */ |
|
349 | 363 | private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
350 | 364 | $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
351 | 365 | return $this; |
352 | 366 | } |
353 | 367 | |
368 | + /** |
|
369 | + * @param string $icon |
|
370 | + * @param string $class |
|
371 | + */ |
|
354 | 372 | private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
355 | 373 | $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
356 | 374 | return $this; |
@@ -437,6 +455,9 @@ discard block |
||
437 | 455 | }, $index,$attributes); |
438 | 456 | } |
439 | 457 | |
458 | + /** |
|
459 | + * @param HtmlButton $element |
|
460 | + */ |
|
440 | 461 | protected function _visibleOver($element){ |
441 | 462 | $this->_visibleHover=true; |
442 | 463 | return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
@@ -37,30 +37,30 @@ discard block |
||
37 | 37 | protected $_targetSelector; |
38 | 38 | protected $_checkedMessage; |
39 | 39 | |
40 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
41 | - parent::__construct($identifier, $model,$modelInstance); |
|
42 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
|
40 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
41 | + parent::__construct($identifier, $model, $modelInstance); |
|
42 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
|
43 | 43 | $this->_urls=[]; |
44 | 44 | } |
45 | 45 | |
46 | - public function run(JsUtils $js){ |
|
47 | - if($this->_hasCheckboxes && isset($js)){ |
|
46 | + public function run(JsUtils $js) { |
|
47 | + if ($this->_hasCheckboxes && isset($js)) { |
|
48 | 48 | $this->_runCheckboxes($js); |
49 | 49 | } |
50 | - if($this->_visibleHover){ |
|
51 | - $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
52 | - $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
50 | + if ($this->_visibleHover) { |
|
51 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
52 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
53 | 53 | } |
54 | - if($this->_hasDelete) |
|
54 | + if ($this->_hasDelete) |
|
55 | 55 | $this->_generateBehavior("delete", $js); |
56 | - if($this->_hasEdit) |
|
56 | + if ($this->_hasEdit) |
|
57 | 57 | $this->_generateBehavior("edit", $js); |
58 | 58 | return parent::run($js); |
59 | 59 | } |
60 | 60 | |
61 | - protected function _runCheckboxes(JsUtils $js){ |
|
61 | + protected function _runCheckboxes(JsUtils $js) { |
|
62 | 62 | $checkedMessageCall=""; |
63 | - if($this->_hasCheckedMessage){ |
|
63 | + if ($this->_hasCheckedMessage) { |
|
64 | 64 | $msg=$this->getCheckedMessage(); |
65 | 65 | $checkedMessageFunction="function updateChecked(){var msg='".$msg[0]."',count=\$('#{$this->identifier} [name=\"selection[]\"]:checked').length,all=\$('#{$this->identifier} [name=\"selection[]\"]').length; |
66 | 66 | if(count==1) msg='".$msg[1]."'; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | \$('#checked-count-".$this->identifier."').contents().filter(function() {return this.nodeType == 3;}).each(function(){this.textContent = msg.replace('{count}',count);}); |
69 | 69 | \$('#toolbar-{$this->identifier} .visibleOnChecked').toggle(count>0);}\$('#toolbar-".$this->identifier." .visibleOnChecked').hide();"; |
70 | 70 | $checkedMessageCall="updateChecked();"; |
71 | - $js->exec($checkedMessageFunction,true); |
|
71 | + $js->exec($checkedMessageFunction, true); |
|
72 | 72 | } |
73 | 73 | $js->execOn("change", "#".$this->identifier." [name='selection[]']", " |
74 | 74 | var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true; |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | if(allChecked) {\$parentCheckbox.checkbox('set checked');}else if(allUnchecked){\$parentCheckbox.checkbox('set unchecked');}else{\$parentCheckbox.checkbox('set indeterminate');};".$checkedMessageCall); |
77 | 77 | } |
78 | 78 | |
79 | - protected function _generateBehavior($op,JsUtils $js){ |
|
80 | - if(isset($this->_urls[$op])) |
|
81 | - $js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]); |
|
79 | + protected function _generateBehavior($op, JsUtils $js) { |
|
80 | + if (isset($this->_urls[$op])) |
|
81 | + $js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op], $this->getTargetSelector(), ["preventDefault"=>false, "attr"=>"data-ajax"]); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -90,70 +90,70 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
94 | - if(!$this->_generated){ |
|
93 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
94 | + if (!$this->_generated) { |
|
95 | 95 | $this->_instanceViewer->setInstance($this->_model); |
96 | 96 | $captions=$this->_instanceViewer->getCaptions(); |
97 | 97 | |
98 | 98 | $table=$this->content["table"]; |
99 | 99 | |
100 | - if($this->_hasCheckboxes){ |
|
100 | + if ($this->_hasCheckboxes) { |
|
101 | 101 | $this->_generateMainCheckbox($captions); |
102 | 102 | } |
103 | 103 | |
104 | 104 | $table->setRowCount(0, \sizeof($captions)); |
105 | 105 | $table->setHeaderValues($captions); |
106 | - if(isset($this->_compileParts)) |
|
106 | + if (isset($this->_compileParts)) |
|
107 | 107 | $table->setCompileParts($this->_compileParts); |
108 | 108 | |
109 | - if(isset($this->_searchField) && isset($js)){ |
|
110 | - if(isset($this->_urls["refresh"])) |
|
111 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
109 | + if (isset($this->_searchField) && isset($js)) { |
|
110 | + if (isset($this->_urls["refresh"])) |
|
111 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | $this->_generateContent($table); |
115 | 115 | |
116 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
117 | - $table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort"); |
|
116 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
117 | + $table->getHeader()->getCell(0, 0)->addToProperty("class", "no-sort"); |
|
118 | 118 | } |
119 | 119 | |
120 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
120 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
121 | 121 | $this->_generatePagination($table); |
122 | 122 | } |
123 | - if(isset($this->_toolbar)){ |
|
123 | + if (isset($this->_toolbar)) { |
|
124 | 124 | $this->_setToolbarPosition($table, $captions); |
125 | 125 | } |
126 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
126 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
127 | 127 | $this->_compileForm(); |
128 | 128 | $this->_generated=true; |
129 | 129 | } |
130 | - return parent::compile($js,$view); |
|
130 | + return parent::compile($js, $view); |
|
131 | 131 | } |
132 | 132 | |
133 | - private function _generateMainCheckbox(&$captions){ |
|
134 | - $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
|
133 | + private function _generateMainCheckbox(&$captions) { |
|
134 | + $ck=new HtmlCheckbox("main-ck-".$this->identifier, ""); |
|
135 | 135 | $checkedMessageCall=""; |
136 | - if($this->_hasCheckedMessage) |
|
136 | + if ($this->_hasCheckedMessage) |
|
137 | 137 | $checkedMessageCall="updateChecked();"; |
138 | 138 | $ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);".$checkedMessageCall); |
139 | 139 | $ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);".$checkedMessageCall); |
140 | 140 | \array_unshift($captions, $ck); |
141 | 141 | } |
142 | 142 | |
143 | - protected function _generateContent($table){ |
|
143 | + protected function _generateContent($table) { |
|
144 | 144 | $objects=$this->_modelInstance; |
145 | - if(isset($this->_pagination)){ |
|
145 | + if (isset($this->_pagination)) { |
|
146 | 146 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
147 | 147 | } |
148 | 148 | InstanceViewer::setIndex(0); |
149 | 149 | $table->fromDatabaseObjects($objects, function($instance) use($table){ |
150 | 150 | $this->_instanceViewer->setInstance($instance); |
151 | 151 | InstanceViewer::$index++; |
152 | - $values= $this->_instanceViewer->getValues(); |
|
153 | - if($this->_hasCheckboxes){ |
|
154 | - $ck=new HtmlCheckbox("ck-".$this->identifier,""); |
|
152 | + $values=$this->_instanceViewer->getValues(); |
|
153 | + if ($this->_hasCheckboxes) { |
|
154 | + $ck=new HtmlCheckbox("ck-".$this->identifier, ""); |
|
155 | 155 | $field=$ck->getField(); |
156 | - $field->setProperty("value",$this->_instanceViewer->getIdentifier()); |
|
156 | + $field->setProperty("value", $this->_instanceViewer->getIdentifier()); |
|
157 | 157 | $field->setProperty("name", "selection[]"); |
158 | 158 | \array_unshift($values, $ck); |
159 | 159 | } |
@@ -164,37 +164,37 @@ discard block |
||
164 | 164 | }); |
165 | 165 | } |
166 | 166 | |
167 | - private function _generatePagination($table){ |
|
167 | + private function _generatePagination($table) { |
|
168 | 168 | $footer=$table->getFooter(); |
169 | 169 | $footer->mergeCol(); |
170 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
170 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
171 | 171 | $menu->floatRight(); |
172 | 172 | $menu->setActiveItem($this->_pagination->getPage()-1); |
173 | 173 | $footer->setValues($menu); |
174 | - if(isset($this->_urls["refresh"])) |
|
175 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
174 | + if (isset($this->_urls["refresh"])) |
|
175 | + $menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
176 | 176 | } |
177 | 177 | |
178 | - protected function _getFieldName($index){ |
|
178 | + protected function _getFieldName($index) { |
|
179 | 179 | return parent::_getFieldName($index)."[]"; |
180 | 180 | } |
181 | 181 | |
182 | - protected function _getFieldCaption($index){ |
|
182 | + protected function _getFieldCaption($index) { |
|
183 | 183 | return null; |
184 | 184 | } |
185 | 185 | |
186 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
187 | - switch ($this->_toolbarPosition){ |
|
186 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
187 | + switch ($this->_toolbarPosition) { |
|
188 | 188 | case PositionInTable::BEFORETABLE: |
189 | 189 | case PositionInTable::AFTERTABLE: |
190 | - if(isset($this->_compileParts)===false){ |
|
190 | + if (isset($this->_compileParts)===false) { |
|
191 | 191 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
192 | 192 | } |
193 | 193 | break; |
194 | 194 | case PositionInTable::HEADER: |
195 | 195 | case PositionInTable::FOOTER: |
196 | 196 | case PositionInTable::BODY: |
197 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
197 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
198 | 198 | break; |
199 | 199 | } |
200 | 200 | } |
@@ -206,23 +206,23 @@ discard block |
||
206 | 206 | * @param callable $callback function called after the field compilation |
207 | 207 | * @return \Ajax\semantic\widgets\datatable\DataTable |
208 | 208 | */ |
209 | - public function afterCompile($index,$callback){ |
|
210 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
209 | + public function afterCompile($index, $callback) { |
|
210 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
211 | 211 | return $this; |
212 | 212 | } |
213 | 213 | |
214 | - private function addToolbarRow($part,$table,$captions){ |
|
214 | + private function addToolbarRow($part, $table, $captions) { |
|
215 | 215 | $hasPart=$table->hasPart($part); |
216 | - if($hasPart){ |
|
216 | + if ($hasPart) { |
|
217 | 217 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
218 | - }else{ |
|
218 | + } else { |
|
219 | 219 | $row=$table->getPart($part)->getRow(0); |
220 | 220 | } |
221 | 221 | $row->mergeCol(); |
222 | 222 | $row->setValues([$this->_toolbar]); |
223 | 223 | } |
224 | 224 | |
225 | - public function getHtmlComponent(){ |
|
225 | + public function getHtmlComponent() { |
|
226 | 226 | return $this->content["table"]; |
227 | 227 | } |
228 | 228 | |
@@ -236,18 +236,18 @@ discard block |
||
236 | 236 | * @return \Ajax\semantic\widgets\datatable\DataTable |
237 | 237 | */ |
238 | 238 | public function setUrls($urls) { |
239 | - if(\is_array($urls)){ |
|
240 | - $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
|
241 | - $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
|
242 | - $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
|
243 | - }else{ |
|
244 | - $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
|
239 | + if (\is_array($urls)) { |
|
240 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
241 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
242 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
243 | + } else { |
|
244 | + $this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls]; |
|
245 | 245 | } |
246 | 246 | return $this; |
247 | 247 | } |
248 | 248 | |
249 | - public function paginate($items_per_page=10,$page=1){ |
|
250 | - $this->_pagination=new Pagination($items_per_page,4,$page); |
|
249 | + public function paginate($items_per_page=10, $page=1) { |
|
250 | + $this->_pagination=new Pagination($items_per_page, 4, $page); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | public function getHasCheckboxes() { |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | return $this; |
260 | 260 | } |
261 | 261 | |
262 | - public function refresh($compileParts=["tbody"]){ |
|
262 | + public function refresh($compileParts=["tbody"]) { |
|
263 | 263 | $this->_compileParts=$compileParts; |
264 | 264 | return $this; |
265 | 265 | } |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @param boolean $visibleHover |
270 | 270 | * @return callable |
271 | 271 | */ |
272 | - private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
|
273 | - return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
|
272 | + private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) { |
|
273 | + return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -279,19 +279,19 @@ discard block |
||
279 | 279 | * @param callable $callback |
280 | 280 | * @return callable |
281 | 281 | */ |
282 | - private function getCallable($thisCallback,$parameters,$callback=null){ |
|
283 | - $result=function($instance) use($thisCallback,$parameters,$callback){ |
|
284 | - $object=call_user_func_array(array($this,$thisCallback), $parameters); |
|
285 | - if(isset($callback)){ |
|
286 | - if(\is_callable($callback)){ |
|
287 | - $callback($object,$instance); |
|
282 | + private function getCallable($thisCallback, $parameters, $callback=null) { |
|
283 | + $result=function($instance) use($thisCallback, $parameters, $callback){ |
|
284 | + $object=call_user_func_array(array($this, $thisCallback), $parameters); |
|
285 | + if (isset($callback)) { |
|
286 | + if (\is_callable($callback)) { |
|
287 | + $callback($object, $instance); |
|
288 | 288 | } |
289 | 289 | } |
290 | - if($object instanceof HtmlSemDoubleElement){ |
|
291 | - $object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier()); |
|
292 | - if($object->propertyContains("class","visibleover")){ |
|
290 | + if ($object instanceof HtmlSemDoubleElement) { |
|
291 | + $object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier()); |
|
292 | + if ($object->propertyContains("class", "visibleover")) { |
|
293 | 293 | $this->_visibleHover=true; |
294 | - $object->setProperty("style","visibility:hidden;"); |
|
294 | + $object->setProperty("style", "visibility:hidden;"); |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | return $object; |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | * @param string $caption |
304 | 304 | * @return HtmlButton |
305 | 305 | */ |
306 | - private function getFieldButton($caption,$visibleHover=true){ |
|
307 | - $bt= new HtmlButton("",$caption); |
|
308 | - if($visibleHover) |
|
306 | + private function getFieldButton($caption, $visibleHover=true) { |
|
307 | + $bt=new HtmlButton("", $caption); |
|
308 | + if ($visibleHover) |
|
309 | 309 | $this->_visibleOver($bt); |
310 | 310 | return $bt; |
311 | 311 | } |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | * @param boolean $visibleHover |
318 | 318 | * @return \Ajax\semantic\widgets\datatable\DataTable |
319 | 319 | */ |
320 | - public function addFieldButton($caption,$visibleHover=true,$callback=null){ |
|
321 | - $this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback)); |
|
320 | + public function addFieldButton($caption, $visibleHover=true, $callback=null) { |
|
321 | + $this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback)); |
|
322 | 322 | return $this; |
323 | 323 | } |
324 | 324 | |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | * @param callable $callback |
330 | 330 | * @return \Ajax\semantic\widgets\datatable\DataTable |
331 | 331 | */ |
332 | - public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
333 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
332 | + public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
333 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
334 | 334 | return $this; |
335 | 335 | } |
336 | 336 | |
@@ -341,64 +341,64 @@ discard block |
||
341 | 341 | * @param callable $callback |
342 | 342 | * @return \Ajax\semantic\widgets\datatable\DataTable |
343 | 343 | */ |
344 | - public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
345 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
344 | + public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
345 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
346 | 346 | return $this; |
347 | 347 | } |
348 | 348 | |
349 | - private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
|
350 | - $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
|
349 | + private function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null) { |
|
350 | + $this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback)); |
|
351 | 351 | return $this; |
352 | 352 | } |
353 | 353 | |
354 | - private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
|
355 | - $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
|
354 | + private function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null) { |
|
355 | + $this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback)); |
|
356 | 356 | return $this; |
357 | 357 | } |
358 | 358 | |
359 | - private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
|
360 | - $bt=$this->getFieldButton("",$visibleHover); |
|
359 | + private function getDefaultButton($icon, $class=null, $visibleHover=true) { |
|
360 | + $bt=$this->getFieldButton("", $visibleHover); |
|
361 | 361 | $bt->asIcon($icon); |
362 | - if(isset($class)) |
|
362 | + if (isset($class)) |
|
363 | 363 | $bt->addToProperty("class", $class); |
364 | 364 | return $bt; |
365 | 365 | } |
366 | 366 | |
367 | - public function addDeleteButton($visibleHover=true,$generateBehavior=true,$callback=null){ |
|
367 | + public function addDeleteButton($visibleHover=true, $generateBehavior=true, $callback=null) { |
|
368 | 368 | $this->_hasDelete=$generateBehavior; |
369 | - return $this->addDefaultButton("remove","delete red basic",$visibleHover,$callback); |
|
369 | + return $this->addDefaultButton("remove", "delete red basic", $visibleHover, $callback); |
|
370 | 370 | } |
371 | 371 | |
372 | - public function addEditButton($visibleHover=true,$generateBehavior=true,$callback=null){ |
|
372 | + public function addEditButton($visibleHover=true, $generateBehavior=true, $callback=null) { |
|
373 | 373 | $this->_hasEdit=$generateBehavior; |
374 | - return $this->addDefaultButton("edit","edit basic",$visibleHover,$callback); |
|
374 | + return $this->addDefaultButton("edit", "edit basic", $visibleHover, $callback); |
|
375 | 375 | } |
376 | 376 | |
377 | - public function addEditDeleteButtons($visibleHover=true,$generateBehavior=true,$callbackEdit=null,$callbackDelete=null){ |
|
378 | - $this->addEditButton($visibleHover,$generateBehavior,$callbackEdit); |
|
377 | + public function addEditDeleteButtons($visibleHover=true, $generateBehavior=true, $callbackEdit=null, $callbackDelete=null) { |
|
378 | + $this->addEditButton($visibleHover, $generateBehavior, $callbackEdit); |
|
379 | 379 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
380 | - $this->insertDeleteButtonIn($index,$visibleHover,$generateBehavior,$callbackDelete); |
|
380 | + $this->insertDeleteButtonIn($index, $visibleHover, $generateBehavior, $callbackDelete); |
|
381 | 381 | return $this; |
382 | 382 | } |
383 | 383 | |
384 | - public function insertDeleteButtonIn($index,$visibleHover=true,$generateBehavior=true,$callback=null){ |
|
384 | + public function insertDeleteButtonIn($index, $visibleHover=true, $generateBehavior=true, $callback=null) { |
|
385 | 385 | $this->_hasDelete=$generateBehavior; |
386 | - return $this->insertDefaultButtonIn($index,"remove","delete red basic",$visibleHover,$callback); |
|
386 | + return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $visibleHover, $callback); |
|
387 | 387 | } |
388 | 388 | |
389 | - public function insertEditButtonIn($index,$visibleHover=true,$generateBehavior=true,$callback=null){ |
|
389 | + public function insertEditButtonIn($index, $visibleHover=true, $generateBehavior=true, $callback=null) { |
|
390 | 390 | $this->_hasEdit=$generateBehavior; |
391 | - return $this->insertDefaultButtonIn($index,"edit","edit basic",$visibleHover,$callback); |
|
391 | + return $this->insertDefaultButtonIn($index, "edit", "edit basic", $visibleHover, $callback); |
|
392 | 392 | } |
393 | 393 | |
394 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
394 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
395 | 395 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
396 | 396 | } |
397 | 397 | |
398 | - public function getSearchField(){ |
|
399 | - if(isset($this->_searchField)===false){ |
|
400 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
401 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
398 | + public function getSearchField() { |
|
399 | + if (isset($this->_searchField)===false) { |
|
400 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
401 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
402 | 402 | } |
403 | 403 | return $this->_searchField; |
404 | 404 | } |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | return $this; |
415 | 415 | } |
416 | 416 | |
417 | - public function asForm(){ |
|
417 | + public function asForm() { |
|
418 | 418 | return $this->getForm(); |
419 | 419 | } |
420 | 420 | |
@@ -427,24 +427,24 @@ discard block |
||
427 | 427 | * @param array $attributes |
428 | 428 | * @return \Ajax\semantic\widgets\datatable\DataTable |
429 | 429 | */ |
430 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
431 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
|
432 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
433 | - $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
|
434 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
430 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
431 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $index, $attributes){ |
|
432 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
433 | + $button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]); |
|
434 | + if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
435 | 435 | $this->_visibleOver($button); |
436 | 436 | return $button; |
437 | - }, $index,$attributes); |
|
437 | + }, $index, $attributes); |
|
438 | 438 | } |
439 | 439 | |
440 | - protected function _visibleOver($element){ |
|
440 | + protected function _visibleOver($element) { |
|
441 | 441 | $this->_visibleHover=true; |
442 | - return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
|
442 | + return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;"); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | protected function getTargetSelector() { |
446 | 446 | $result=$this->_targetSelector; |
447 | - if(!isset($result)) |
|
447 | + if (!isset($result)) |
|
448 | 448 | $result="#".$this->identifier; |
449 | 449 | return $result; |
450 | 450 | } |
@@ -460,9 +460,9 @@ discard block |
||
460 | 460 | } |
461 | 461 | |
462 | 462 | protected function getCheckedMessage() { |
463 | - $result= $this->_checkedMessage; |
|
464 | - if(!isset($result)){ |
|
465 | - $result=[0=>"none selected",1=>"one item selected","other"=>"{count} items selected"]; |
|
463 | + $result=$this->_checkedMessage; |
|
464 | + if (!isset($result)) { |
|
465 | + $result=[0=>"none selected", 1=>"one item selected", "other"=>"{count} items selected"]; |
|
466 | 466 | } |
467 | 467 | return $result; |
468 | 468 | } |
@@ -482,14 +482,14 @@ discard block |
||
482 | 482 | * @param array $checkedMessage |
483 | 483 | * @param callable $callback |
484 | 484 | */ |
485 | - public function addCountCheckedInToolbar(array $checkedMessage=null,$callback=null){ |
|
486 | - if(isset($checkedMessage)) |
|
485 | + public function addCountCheckedInToolbar(array $checkedMessage=null, $callback=null) { |
|
486 | + if (isset($checkedMessage)) |
|
487 | 487 | $this->_checkedMessage=$checkedMessage; |
488 | 488 | $checkedMessage=$this->getCheckedMessage(); |
489 | 489 | $this->_hasCheckboxes=true; |
490 | 490 | $this->_hasCheckedMessage=true; |
491 | - $element=new HtmlLabel("checked-count-".$this->identifier,$checkedMessage[0]); |
|
492 | - $this->addInToolbar($element,$callback); |
|
491 | + $element=new HtmlLabel("checked-count-".$this->identifier, $checkedMessage[0]); |
|
492 | + $this->addInToolbar($element, $callback); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 |
@@ -51,10 +51,12 @@ discard block |
||
51 | 51 | $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
52 | 52 | $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
53 | 53 | } |
54 | - if($this->_hasDelete) |
|
55 | - $this->_generateBehavior("delete", $js); |
|
56 | - if($this->_hasEdit) |
|
57 | - $this->_generateBehavior("edit", $js); |
|
54 | + if($this->_hasDelete) { |
|
55 | + $this->_generateBehavior("delete", $js); |
|
56 | + } |
|
57 | + if($this->_hasEdit) { |
|
58 | + $this->_generateBehavior("edit", $js); |
|
59 | + } |
|
58 | 60 | return parent::run($js); |
59 | 61 | } |
60 | 62 | |
@@ -77,8 +79,9 @@ discard block |
||
77 | 79 | } |
78 | 80 | |
79 | 81 | protected function _generateBehavior($op,JsUtils $js){ |
80 | - if(isset($this->_urls[$op])) |
|
81 | - $js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]); |
|
82 | + if(isset($this->_urls[$op])) { |
|
83 | + $js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]); |
|
84 | + } |
|
82 | 85 | } |
83 | 86 | |
84 | 87 | /** |
@@ -103,12 +106,14 @@ discard block |
||
103 | 106 | |
104 | 107 | $table->setRowCount(0, \sizeof($captions)); |
105 | 108 | $table->setHeaderValues($captions); |
106 | - if(isset($this->_compileParts)) |
|
107 | - $table->setCompileParts($this->_compileParts); |
|
109 | + if(isset($this->_compileParts)) { |
|
110 | + $table->setCompileParts($this->_compileParts); |
|
111 | + } |
|
108 | 112 | |
109 | 113 | if(isset($this->_searchField) && isset($js)){ |
110 | - if(isset($this->_urls["refresh"])) |
|
111 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
114 | + if(isset($this->_urls["refresh"])) { |
|
115 | + $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
116 | + } |
|
112 | 117 | } |
113 | 118 | |
114 | 119 | $this->_generateContent($table); |
@@ -133,8 +138,9 @@ discard block |
||
133 | 138 | private function _generateMainCheckbox(&$captions){ |
134 | 139 | $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
135 | 140 | $checkedMessageCall=""; |
136 | - if($this->_hasCheckedMessage) |
|
137 | - $checkedMessageCall="updateChecked();"; |
|
141 | + if($this->_hasCheckedMessage) { |
|
142 | + $checkedMessageCall="updateChecked();"; |
|
143 | + } |
|
138 | 144 | $ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);".$checkedMessageCall); |
139 | 145 | $ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);".$checkedMessageCall); |
140 | 146 | \array_unshift($captions, $ck); |
@@ -171,8 +177,9 @@ discard block |
||
171 | 177 | $menu->floatRight(); |
172 | 178 | $menu->setActiveItem($this->_pagination->getPage()-1); |
173 | 179 | $footer->setValues($menu); |
174 | - if(isset($this->_urls["refresh"])) |
|
175 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
180 | + if(isset($this->_urls["refresh"])) { |
|
181 | + $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
182 | + } |
|
176 | 183 | } |
177 | 184 | |
178 | 185 | protected function _getFieldName($index){ |
@@ -215,7 +222,7 @@ discard block |
||
215 | 222 | $hasPart=$table->hasPart($part); |
216 | 223 | if($hasPart){ |
217 | 224 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
218 | - }else{ |
|
225 | + } else{ |
|
219 | 226 | $row=$table->getPart($part)->getRow(0); |
220 | 227 | } |
221 | 228 | $row->mergeCol(); |
@@ -240,7 +247,7 @@ discard block |
||
240 | 247 | $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
241 | 248 | $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
242 | 249 | $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
243 | - }else{ |
|
250 | + } else{ |
|
244 | 251 | $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
245 | 252 | } |
246 | 253 | return $this; |
@@ -305,8 +312,9 @@ discard block |
||
305 | 312 | */ |
306 | 313 | private function getFieldButton($caption,$visibleHover=true){ |
307 | 314 | $bt= new HtmlButton("",$caption); |
308 | - if($visibleHover) |
|
309 | - $this->_visibleOver($bt); |
|
315 | + if($visibleHover) { |
|
316 | + $this->_visibleOver($bt); |
|
317 | + } |
|
310 | 318 | return $bt; |
311 | 319 | } |
312 | 320 | |
@@ -359,8 +367,9 @@ discard block |
||
359 | 367 | private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
360 | 368 | $bt=$this->getFieldButton("",$visibleHover); |
361 | 369 | $bt->asIcon($icon); |
362 | - if(isset($class)) |
|
363 | - $bt->addToProperty("class", $class); |
|
370 | + if(isset($class)) { |
|
371 | + $bt->addToProperty("class", $class); |
|
372 | + } |
|
364 | 373 | return $bt; |
365 | 374 | } |
366 | 375 | |
@@ -431,8 +440,9 @@ discard block |
||
431 | 440 | return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
432 | 441 | $button=new HtmlButton($id,$value,$cssStyle); |
433 | 442 | $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
434 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
435 | - $this->_visibleOver($button); |
|
443 | + if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) { |
|
444 | + $this->_visibleOver($button); |
|
445 | + } |
|
436 | 446 | return $button; |
437 | 447 | }, $index,$attributes); |
438 | 448 | } |
@@ -444,8 +454,9 @@ discard block |
||
444 | 454 | |
445 | 455 | protected function getTargetSelector() { |
446 | 456 | $result=$this->_targetSelector; |
447 | - if(!isset($result)) |
|
448 | - $result="#".$this->identifier; |
|
457 | + if(!isset($result)) { |
|
458 | + $result="#".$this->identifier; |
|
459 | + } |
|
449 | 460 | return $result; |
450 | 461 | } |
451 | 462 | |
@@ -483,8 +494,9 @@ discard block |
||
483 | 494 | * @param callable $callback |
484 | 495 | */ |
485 | 496 | public function addCountCheckedInToolbar(array $checkedMessage=null,$callback=null){ |
486 | - if(isset($checkedMessage)) |
|
487 | - $this->_checkedMessage=$checkedMessage; |
|
497 | + if(isset($checkedMessage)) { |
|
498 | + $this->_checkedMessage=$checkedMessage; |
|
499 | + } |
|
488 | 500 | $checkedMessage=$this->getCheckedMessage(); |
489 | 501 | $this->_hasCheckboxes=true; |
490 | 502 | $this->_hasCheckedMessage=true; |