@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | private $pages_visibles; |
10 | 10 | private $row_count; |
11 | 11 | |
12 | - public function __construct($items_per_page=10,$pages_visibles=null,$page=1,$row_count=null){ |
|
12 | + public function __construct($items_per_page=10, $pages_visibles=null, $page=1, $row_count=null) { |
|
13 | 13 | $this->items_per_page=$items_per_page; |
14 | 14 | $this->row_count=$row_count; |
15 | 15 | $this->page=$page; |
@@ -17,30 +17,30 @@ discard block |
||
17 | 17 | $this->visible=true; |
18 | 18 | } |
19 | 19 | |
20 | - public function getObjects($objects){ |
|
20 | + public function getObjects($objects) { |
|
21 | 21 | $auto=(!isset($this->row_count)); |
22 | 22 | $os=$objects; |
23 | - if(!\is_array($os)){ |
|
23 | + if (!\is_array($os)) { |
|
24 | 24 | $os=[]; |
25 | - foreach ($objects as $o){ |
|
25 | + foreach ($objects as $o) { |
|
26 | 26 | $os[]=$o; |
27 | 27 | } |
28 | 28 | } |
29 | - $this->page_count = 0; |
|
30 | - $row_count=($auto)?\sizeof($os):$this->row_count; |
|
31 | - if (0 === $row_count) { |
|
29 | + $this->page_count=0; |
|
30 | + $row_count=($auto) ?\sizeof($os) : $this->row_count; |
|
31 | + if (0===$row_count) { |
|
32 | 32 | $this->visible=false; |
33 | 33 | } else { |
34 | 34 | |
35 | - $this->page_count = (int)ceil($row_count / $this->items_per_page); |
|
35 | + $this->page_count=(int)ceil($row_count/$this->items_per_page); |
|
36 | 36 | $this->visible=$this->page_count>1; |
37 | - if($this->page > $this->page_count+1) { |
|
38 | - $this->page = 1; |
|
37 | + if ($this->page>$this->page_count+1) { |
|
38 | + $this->page=1; |
|
39 | 39 | } |
40 | 40 | } |
41 | - if($auto){ |
|
42 | - $offset = ($this->page - 1) * $this->items_per_page; |
|
43 | - return array_slice($os, $offset,$this->items_per_page); |
|
41 | + if ($auto) { |
|
42 | + $offset=($this->page-1)*$this->items_per_page; |
|
43 | + return array_slice($os, $offset, $this->items_per_page); |
|
44 | 44 | } |
45 | 45 | return $os; |
46 | 46 | } |
@@ -76,22 +76,22 @@ discard block |
||
76 | 76 | return $this->page_count; |
77 | 77 | } |
78 | 78 | |
79 | - public function getPagesNumbers(){ |
|
80 | - $middle= (int)ceil(($this->pages_visibles-1)/ 2); |
|
79 | + public function getPagesNumbers() { |
|
80 | + $middle=(int)ceil(($this->pages_visibles-1)/2); |
|
81 | 81 | $first=$this->page-$middle; |
82 | - if($first<1){ |
|
82 | + if ($first<1) { |
|
83 | 83 | $first=1; |
84 | 84 | } |
85 | 85 | $last=$first+$this->pages_visibles-1; |
86 | - if($last>$this->page_count){ |
|
86 | + if ($last>$this->page_count) { |
|
87 | 87 | $last=$this->page_count; |
88 | 88 | } |
89 | 89 | return \range($first, $last); |
90 | 90 | } |
91 | 91 | |
92 | 92 | public function setPagesVisibles($pages_visibles) { |
93 | - if(!isset($pages_visibles)) |
|
94 | - $pages_visibles=(int)ceil($this->row_count / $this->items_per_page)+1; |
|
93 | + if (!isset($pages_visibles)) |
|
94 | + $pages_visibles=(int)ceil($this->row_count/$this->items_per_page)+1; |
|
95 | 95 | $this->pages_visibles=$pages_visibles; |
96 | 96 | return $this; |
97 | 97 | } |
@@ -16,16 +16,16 @@ |
||
16 | 16 | return $this; |
17 | 17 | } |
18 | 18 | |
19 | - public function showDimmer(){ |
|
19 | + public function showDimmer() { |
|
20 | 20 | return $this->setBehavior("hide dimmer"); |
21 | 21 | } |
22 | 22 | |
23 | - public function setInverted(){ |
|
23 | + public function setInverted() { |
|
24 | 24 | $this->params["inverted"]=true; |
25 | 25 | } |
26 | 26 | |
27 | 27 | public function setOnHidden($jsCode) { |
28 | - $jsCode=str_ireplace("\"","%quote%", $jsCode); |
|
28 | + $jsCode=str_ireplace("\"", "%quote%", $jsCode); |
|
29 | 29 | return $this->setParam("onHidden", "%function(){".$jsCode."}%"); |
30 | 30 | } |
31 | 31 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | use Ajax\semantic\html\modules\HtmlModal; |
21 | 21 | |
22 | 22 | abstract class Widget extends HtmlDoubleElement { |
23 | - use FieldAsTrait,FormTrait; |
|
23 | + use FieldAsTrait, FormTrait; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @var string classname |
@@ -53,17 +53,17 @@ discard block |
||
53 | 53 | protected $_generated; |
54 | 54 | |
55 | 55 | |
56 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
56 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
57 | 57 | parent::__construct($identifier); |
58 | 58 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
59 | 59 | $this->setModel($model); |
60 | - if(isset($modelInstance)){ |
|
60 | + if (isset($modelInstance)) { |
|
61 | 61 | $this->show($modelInstance); |
62 | 62 | } |
63 | 63 | $this->_generated=false; |
64 | 64 | } |
65 | 65 | |
66 | - protected function _init($instanceViewer,$contentKey,$content,$edition){ |
|
66 | + protected function _init($instanceViewer, $contentKey, $content, $edition) { |
|
67 | 67 | $this->_instanceViewer=$instanceViewer; |
68 | 68 | $this->content=[$contentKey=>$content]; |
69 | 69 | $this->_self=$content; |
@@ -75,31 +75,31 @@ discard block |
||
75 | 75 | * @param int|string $fieldName |
76 | 76 | * @return int|string |
77 | 77 | */ |
78 | - protected function _getIndex($fieldName){ |
|
78 | + protected function _getIndex($fieldName) { |
|
79 | 79 | $index=$fieldName; |
80 | - if(\is_string($fieldName)){ |
|
80 | + if (\is_string($fieldName)) { |
|
81 | 81 | $fields=$this->_instanceViewer->getVisibleProperties(); |
82 | 82 | $index=\array_search($fieldName, $fields); |
83 | 83 | } |
84 | 84 | return $index; |
85 | 85 | } |
86 | 86 | |
87 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
87 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
88 | 88 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
89 | 89 | } |
90 | 90 | |
91 | - protected function _getFieldName($index){ |
|
91 | + protected function _getFieldName($index) { |
|
92 | 92 | return $this->_instanceViewer->getFieldName($index); |
93 | 93 | } |
94 | 94 | |
95 | - protected function _getFieldCaption($index){ |
|
95 | + protected function _getFieldCaption($index) { |
|
96 | 96 | return $this->_instanceViewer->getCaption($index); |
97 | 97 | } |
98 | 98 | |
99 | - abstract protected function _setToolbarPosition($table,$captions=NULL); |
|
99 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
100 | 100 | |
101 | - public function show($modelInstance){ |
|
102 | - if(\is_array($modelInstance)){ |
|
101 | + public function show($modelInstance) { |
|
102 | + if (\is_array($modelInstance)) { |
|
103 | 103 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
104 | 104 | } |
105 | 105 | $this->_modelInstance=$modelInstance; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | abstract public function getHtmlComponent(); |
127 | 127 | |
128 | - public function setAttached($value=true){ |
|
128 | + public function setAttached($value=true) { |
|
129 | 129 | return $this->getHtmlComponent()->setAttached($value); |
130 | 130 | } |
131 | 131 | |
@@ -136,71 +136,71 @@ discard block |
||
136 | 136 | * @param callable $callback function called after the field compilation |
137 | 137 | * @return Widget |
138 | 138 | */ |
139 | - public function afterCompile($index,$callback){ |
|
139 | + public function afterCompile($index, $callback) { |
|
140 | 140 | $index=$this->_getIndex($index); |
141 | 141 | $this->_instanceViewer->afterCompile($index, $callback); |
142 | 142 | return $this; |
143 | 143 | } |
144 | 144 | |
145 | - public function setColor($color){ |
|
145 | + public function setColor($color) { |
|
146 | 146 | return $this->getHtmlComponent()->setColor($color); |
147 | 147 | } |
148 | 148 | |
149 | 149 | |
150 | - public function setCaptions($captions){ |
|
150 | + public function setCaptions($captions) { |
|
151 | 151 | $this->_instanceViewer->setCaptions($captions); |
152 | 152 | return $this; |
153 | 153 | } |
154 | 154 | |
155 | - public function setCaption($index,$caption){ |
|
155 | + public function setCaption($index, $caption) { |
|
156 | 156 | $this->_instanceViewer->setCaption($this->_getIndex($index), $caption); |
157 | 157 | return $this; |
158 | 158 | } |
159 | 159 | |
160 | - public function setFields($fields){ |
|
160 | + public function setFields($fields) { |
|
161 | 161 | $this->_instanceViewer->setVisibleProperties($fields); |
162 | 162 | return $this; |
163 | 163 | } |
164 | 164 | |
165 | - public function addField($field){ |
|
165 | + public function addField($field) { |
|
166 | 166 | $this->_instanceViewer->addField($field); |
167 | 167 | return $this; |
168 | 168 | } |
169 | 169 | |
170 | - public function addFields($fields){ |
|
170 | + public function addFields($fields) { |
|
171 | 171 | $this->_instanceViewer->addFields($fields); |
172 | 172 | return $this; |
173 | 173 | } |
174 | 174 | |
175 | - public function addMessage($attributes=NULL,$fieldName="message"){ |
|
175 | + public function addMessage($attributes=NULL, $fieldName="message") { |
|
176 | 176 | $this->_instanceViewer->addField($fieldName); |
177 | 177 | $count=$this->_instanceViewer->visiblePropertiesCount(); |
178 | - return $this->fieldAsMessage($count-1,$attributes); |
|
178 | + return $this->fieldAsMessage($count-1, $attributes); |
|
179 | 179 | } |
180 | 180 | |
181 | - public function addErrorMessage(){ |
|
182 | - return $this->addMessage(["error"=>true],"message"); |
|
181 | + public function addErrorMessage() { |
|
182 | + return $this->addMessage(["error"=>true], "message"); |
|
183 | 183 | } |
184 | 184 | |
185 | - public function insertField($index,$field){ |
|
185 | + public function insertField($index, $field) { |
|
186 | 186 | $index=$this->_getIndex($index); |
187 | 187 | $this->_instanceViewer->insertField($index, $field); |
188 | 188 | return $this; |
189 | 189 | } |
190 | 190 | |
191 | - public function insertInField($index,$field){ |
|
191 | + public function insertInField($index, $field) { |
|
192 | 192 | $index=$this->_getIndex($index); |
193 | 193 | $this->_instanceViewer->insertInField($index, $field); |
194 | 194 | return $this; |
195 | 195 | } |
196 | 196 | |
197 | - public function setValueFunction($index,$callback){ |
|
197 | + public function setValueFunction($index, $callback) { |
|
198 | 198 | $index=$this->_getIndex($index); |
199 | 199 | $this->_instanceViewer->setValueFunction($index, $callback); |
200 | 200 | return $this; |
201 | 201 | } |
202 | 202 | |
203 | - public function setIdentifierFunction($callback){ |
|
203 | + public function setIdentifierFunction($callback) { |
|
204 | 204 | $this->_instanceViewer->setIdentifierFunction($callback); |
205 | 205 | return $this; |
206 | 206 | } |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | /** |
209 | 209 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
210 | 210 | */ |
211 | - public function getToolbar(){ |
|
212 | - if(isset($this->_toolbar)===false){ |
|
211 | + public function getToolbar() { |
|
212 | + if (isset($this->_toolbar)===false) { |
|
213 | 213 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
214 | 214 | } |
215 | 215 | return $this->_toolbar; |
@@ -221,15 +221,15 @@ discard block |
||
221 | 221 | * @param callable $callback function to call on $element |
222 | 222 | * @return \Ajax\common\html\HtmlDoubleElement |
223 | 223 | */ |
224 | - public function addInToolbar($element,$callback=NULL){ |
|
224 | + public function addInToolbar($element, $callback=NULL) { |
|
225 | 225 | $tb=$this->getToolbar(); |
226 | - if($element instanceof BaseWidget){ |
|
227 | - if($element->getIdentifier()===""){ |
|
226 | + if ($element instanceof BaseWidget) { |
|
227 | + if ($element->getIdentifier()==="") { |
|
228 | 228 | $element->setIdentifier("tb-item-".$this->identifier."-".$tb->count()); |
229 | 229 | } |
230 | 230 | } |
231 | - if(isset($callback)){ |
|
232 | - if(\is_callable($callback)){ |
|
231 | + if (isset($callback)) { |
|
232 | + if (\is_callable($callback)) { |
|
233 | 233 | $callback($element); |
234 | 234 | } |
235 | 235 | } |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | * @param callable $callback function($element) |
243 | 243 | * @return \Ajax\common\html\HtmlDoubleElement |
244 | 244 | */ |
245 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
246 | - $result=$this->addInToolbar($caption,$callback); |
|
247 | - if(isset($icon)) |
|
245 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
246 | + $result=$this->addInToolbar($caption, $callback); |
|
247 | + if (isset($icon)) |
|
248 | 248 | $result->addIcon($icon); |
249 | 249 | return $result; |
250 | 250 | } |
@@ -254,14 +254,14 @@ discard block |
||
254 | 254 | * @param callable $callback function($element) |
255 | 255 | * @return \Ajax\common\Widget |
256 | 256 | */ |
257 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
258 | - if(JArray::isAssociative($items)){ |
|
259 | - foreach ($items as $icon=>$item){ |
|
260 | - $this->addItemInToolbar($item,$icon,$callback); |
|
257 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
258 | + if (JArray::isAssociative($items)) { |
|
259 | + foreach ($items as $icon=>$item) { |
|
260 | + $this->addItemInToolbar($item, $icon, $callback); |
|
261 | 261 | } |
262 | - }else{ |
|
263 | - foreach ($items as $item){ |
|
264 | - $this->addItemInToolbar($item,null,$callback); |
|
262 | + } else { |
|
263 | + foreach ($items as $item) { |
|
264 | + $this->addItemInToolbar($item, null, $callback); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | return $this; |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | * @param callable $callback function($element) |
274 | 274 | * @return \Ajax\common\html\HtmlDoubleElement |
275 | 275 | */ |
276 | - public function addDropdownInToolbar($value,$items,$callback=NULL){ |
|
276 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
277 | 277 | $dd=$value; |
278 | 278 | if (\is_string($value)) { |
279 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
279 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
280 | 280 | } |
281 | - return $this->addInToolbar($dd,$callback); |
|
281 | + return $this->addInToolbar($dd, $callback); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | * @param callable $callback function($element) |
288 | 288 | * @return \Ajax\common\html\HtmlDoubleElement |
289 | 289 | */ |
290 | - public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){ |
|
291 | - $bt=new HtmlButton("bt-".$caption,$caption,$cssStyle); |
|
292 | - return $this->addInToolbar($bt,$callback); |
|
290 | + public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) { |
|
291 | + $bt=new HtmlButton("bt-".$caption, $caption, $cssStyle); |
|
292 | + return $this->addInToolbar($bt, $callback); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -298,9 +298,9 @@ discard block |
||
298 | 298 | * @param callable $callback function($element) |
299 | 299 | * @return \Ajax\common\html\HtmlDoubleElement |
300 | 300 | */ |
301 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
302 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
303 | - return $this->addInToolbar($bts,$callback); |
|
301 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
302 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
303 | + return $this->addInToolbar($bts, $callback); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -310,15 +310,15 @@ discard block |
||
310 | 310 | * @param boolean $labeled |
311 | 311 | * @return \Ajax\common\html\HtmlDoubleElement |
312 | 312 | */ |
313 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
314 | - $bt=new HtmlButton("",$caption); |
|
315 | - $bt->addIcon($icon,$before,$labeled); |
|
313 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
314 | + $bt=new HtmlButton("", $caption); |
|
315 | + $bt->addIcon($icon, $before, $labeled); |
|
316 | 316 | return $this->addInToolbar($bt); |
317 | 317 | } |
318 | 318 | |
319 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
320 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
321 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters); |
|
319 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
320 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
321 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters); |
|
322 | 322 | return $this->addInToolbar($button); |
323 | 323 | } |
324 | 324 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model |
349 | 349 | * @return \Ajax\common\Widget |
350 | 350 | */ |
351 | - public function setDefaultValueFunction($defaultValueFunction){ |
|
351 | + public function setDefaultValueFunction($defaultValueFunction) { |
|
352 | 352 | $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction); |
353 | 353 | return $this; |
354 | 354 | } |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | * @param string|boolean $disable |
358 | 358 | * @return string |
359 | 359 | */ |
360 | - public function jsDisabled($disable=true){ |
|
360 | + public function jsDisabled($disable=true) { |
|
361 | 361 | return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
362 | 362 | } |
363 | 363 | |
@@ -366,12 +366,12 @@ discard block |
||
366 | 366 | * @param callable $callback function($element) |
367 | 367 | * @return \Ajax\common\html\HtmlDoubleElement |
368 | 368 | */ |
369 | - public function addEditButtonInToolbar($caption,$callback=NULL){ |
|
370 | - $bt=new HtmlButton($this->identifier."-editBtn",$caption); |
|
369 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
370 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
371 | 371 | $bt->setToggle(); |
372 | 372 | $bt->setActive($this->_edition); |
373 | 373 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
374 | - return $this->addInToolbar($bt,$callback); |
|
374 | + return $this->addInToolbar($bt, $callback); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | public function setToolbar(HtmlMenu $_toolbar) { |
@@ -385,35 +385,35 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | public function getForm() { |
388 | - if(!isset($this->_form)){ |
|
388 | + if (!isset($this->_form)) { |
|
389 | 389 | $this->_form=new HtmlForm("frm-".$this->identifier); |
390 | 390 | $this->setEdition(true); |
391 | 391 | } |
392 | 392 | return $this->_form; |
393 | 393 | } |
394 | 394 | |
395 | - public function run(JsUtils $js){ |
|
395 | + public function run(JsUtils $js) { |
|
396 | 396 | $result=parent::run($js); |
397 | - if(isset($this->_form)){ |
|
397 | + if (isset($this->_form)) { |
|
398 | 398 | $result=$this->runForm($js); |
399 | 399 | } |
400 | 400 | return $result; |
401 | 401 | } |
402 | 402 | |
403 | - protected function runForm(JsUtils $js){ |
|
403 | + protected function runForm(JsUtils $js) { |
|
404 | 404 | $fields=$this->getContentInstances(HtmlFormField::class); |
405 | - foreach ($fields as $field){ |
|
405 | + foreach ($fields as $field) { |
|
406 | 406 | $this->_form->addField($field); |
407 | 407 | } |
408 | 408 | return $this->_form->run($js); |
409 | 409 | } |
410 | 410 | |
411 | - protected function _compileForm(){ |
|
412 | - if(isset($this->_form)){ |
|
411 | + protected function _compileForm() { |
|
412 | + if (isset($this->_form)) { |
|
413 | 413 | $noValidate=""; |
414 | - if(\sizeof($this->_form->getValidationParams())>0) |
|
414 | + if (\sizeof($this->_form->getValidationParams())>0) |
|
415 | 415 | $noValidate="novalidate"; |
416 | - $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>"); |
|
416 | + $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>"); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
@@ -422,32 +422,32 @@ discard block |
||
422 | 422 | return $this; |
423 | 423 | } |
424 | 424 | |
425 | - public function moveFieldTo($from,$to){ |
|
425 | + public function moveFieldTo($from, $to) { |
|
426 | 426 | return $this->_instanceViewer->moveFieldTo($from, $to); |
427 | 427 | } |
428 | 428 | |
429 | - public function swapFields($index1,$index2){ |
|
429 | + public function swapFields($index1, $index2) { |
|
430 | 430 | $index1=$this->_getIndex($index1); |
431 | 431 | $index2=$this->_getIndex($index2); |
432 | 432 | return $this->_instanceViewer->swapFields($index1, $index2); |
433 | 433 | } |
434 | 434 | |
435 | - public function removeField($index){ |
|
435 | + public function removeField($index) { |
|
436 | 436 | $index=$this->_getIndex($index); |
437 | 437 | $this->_instanceViewer->removeField($index); |
438 | 438 | return $this; |
439 | 439 | } |
440 | 440 | |
441 | - public function asModal($header=null){ |
|
442 | - $modal=new HtmlModal("modal-".$this->identifier,$header); |
|
441 | + public function asModal($header=null) { |
|
442 | + $modal=new HtmlModal("modal-".$this->identifier, $header); |
|
443 | 443 | $modal->setContent($this); |
444 | - if(isset($this->_form)){ |
|
444 | + if (isset($this->_form)) { |
|
445 | 445 | $this->_form->onSuccess($modal->jsHide()); |
446 | 446 | } |
447 | 447 | return $modal; |
448 | 448 | } |
449 | 449 | |
450 | 450 | public function addToProperty($name, $value, $separator=" ") { |
451 | - return $this->getHtmlComponent()->addToProperty($name,$value,$separator); |
|
451 | + return $this->getHtmlComponent()->addToProperty($name, $value, $separator); |
|
452 | 452 | } |
453 | 453 | } |
@@ -19,220 +19,220 @@ discard block |
||
19 | 19 | |
20 | 20 | public static $index=0; |
21 | 21 | |
22 | - public function __construct($identifier,$instance=NULL,$captions=NULL){ |
|
22 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
23 | 23 | $this->widgetIdentifier=$identifier; |
24 | 24 | $this->values=[]; |
25 | 25 | $this->afterCompile=[]; |
26 | - if(isset($instance)) |
|
26 | + if (isset($instance)) |
|
27 | 27 | $this->setInstance($instance); |
28 | 28 | $this->setCaptions($captions); |
29 | 29 | $this->captionCallback=NULL; |
30 | - $this->defaultValueFunction=function($name,$value){return $value;}; |
|
30 | + $this->defaultValueFunction=function($name, $value) {return $value; }; |
|
31 | 31 | } |
32 | 32 | |
33 | - public function moveFieldTo($from,$to){ |
|
34 | - if(JArray::moveElementTo($this->visibleProperties, $from, $to)){ |
|
33 | + public function moveFieldTo($from, $to) { |
|
34 | + if (JArray::moveElementTo($this->visibleProperties, $from, $to)) { |
|
35 | 35 | return JArray::moveElementTo($this->values, $from, $to); |
36 | 36 | } |
37 | 37 | return false; |
38 | 38 | } |
39 | 39 | |
40 | - public function swapFields($index1,$index2){ |
|
41 | - if(JArray::swapElements($this->visibleProperties, $index1, $index2)){ |
|
40 | + public function swapFields($index1, $index2) { |
|
41 | + if (JArray::swapElements($this->visibleProperties, $index1, $index2)) { |
|
42 | 42 | return JArray::swapElements($this->values, $index1, $index2); |
43 | 43 | } |
44 | 44 | return false; |
45 | 45 | } |
46 | 46 | |
47 | - public function removeField($index){ |
|
48 | - \array_splice($this->visibleProperties,$index,1); |
|
49 | - \array_splice($this->values,$index,1); |
|
50 | - \array_splice($this->captions,$index,1); |
|
47 | + public function removeField($index) { |
|
48 | + \array_splice($this->visibleProperties, $index, 1); |
|
49 | + \array_splice($this->values, $index, 1); |
|
50 | + \array_splice($this->captions, $index, 1); |
|
51 | 51 | return $this; |
52 | 52 | } |
53 | 53 | |
54 | - public function getValues(){ |
|
54 | + public function getValues() { |
|
55 | 55 | $values=[]; |
56 | 56 | $index=0; |
57 | 57 | $count=$this->count(); |
58 | - while($index<$count){ |
|
58 | + while ($index<$count) { |
|
59 | 59 | $values[]=$this->getValue($index++); |
60 | 60 | } |
61 | 61 | return $values; |
62 | 62 | } |
63 | 63 | |
64 | - public function getIdentifier($index=NULL){ |
|
65 | - if(!isset($index)) |
|
64 | + public function getIdentifier($index=NULL) { |
|
65 | + if (!isset($index)) |
|
66 | 66 | $index=self::$index; |
67 | 67 | $value=$index; |
68 | - if(isset($this->values["identifier"])){ |
|
69 | - if(\is_string($this->values["identifier"])) |
|
68 | + if (isset($this->values["identifier"])) { |
|
69 | + if (\is_string($this->values["identifier"])) |
|
70 | 70 | $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
71 | 71 | else |
72 | - $value=$this->values["identifier"]($index,$this->instance); |
|
72 | + $value=$this->values["identifier"]($index, $this->instance); |
|
73 | 73 | } |
74 | 74 | return $value; |
75 | 75 | } |
76 | 76 | |
77 | - public function getValue($index){ |
|
77 | + public function getValue($index) { |
|
78 | 78 | $property=$this->properties[$index]; |
79 | 79 | return $this->_getValue($property, $index); |
80 | 80 | } |
81 | 81 | |
82 | - protected function _beforeAddProperty($index,&$field){ |
|
82 | + protected function _beforeAddProperty($index, &$field) { |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | |
86 | - protected function _getDefaultValue($name,$value,$index){ |
|
86 | + protected function _getDefaultValue($name, $value, $index) { |
|
87 | 87 | $func=$this->defaultValueFunction; |
88 | - return $func($name,$value,$index,$this->instance); |
|
88 | + return $func($name, $value, $index, $this->instance); |
|
89 | 89 | } |
90 | 90 | |
91 | - protected function _getPropertyValue(\ReflectionProperty $property,$index){ |
|
91 | + protected function _getPropertyValue(\ReflectionProperty $property, $index) { |
|
92 | 92 | $property->setAccessible(true); |
93 | 93 | return $property->getValue($this->instance); |
94 | 94 | } |
95 | 95 | |
96 | - protected function _getValue($property,$index){ |
|
96 | + protected function _getValue($property, $index) { |
|
97 | 97 | $value=null; |
98 | 98 | $propertyName=$property; |
99 | - if($property instanceof \ReflectionProperty){ |
|
99 | + if ($property instanceof \ReflectionProperty) { |
|
100 | 100 | $value=$this->_getPropertyValue($property, $index); |
101 | 101 | $propertyName=$property->getName(); |
102 | - }elseif(\is_array($property)){ |
|
103 | - $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
|
102 | + }elseif (\is_array($property)) { |
|
103 | + $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property); |
|
104 | 104 | $value=\implode("", $values); |
105 | - }elseif(\is_string($property)){ |
|
105 | + }elseif (\is_string($property)) { |
|
106 | 106 | $value=$property; |
107 | - if(isset($this->instance->{$property})){ |
|
107 | + if (isset($this->instance->{$property})) { |
|
108 | 108 | $value=$this->instance->{$property}; |
109 | - }elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){ |
|
109 | + }elseif (\method_exists($this->instance, $getter=JReflection::getterName($property))) { |
|
110 | 110 | $value=JReflection::callMethod($this->instance, $getter, []); |
111 | 111 | } |
112 | - }elseif(\is_callable($property)){ |
|
112 | + }elseif (\is_callable($property)) { |
|
113 | 113 | $value=$property($this->instance); |
114 | 114 | } |
115 | 115 | return $this->_postGetValue($index, $propertyName, $value); |
116 | 116 | } |
117 | 117 | |
118 | - protected function _postGetValue($index,$propertyName,$value){ |
|
119 | - if(isset($this->values[$index])){ |
|
120 | - $value= $this->values[$index]($value,$this->instance,$index); |
|
121 | - }else{ |
|
122 | - $value=$this->_getDefaultValue($propertyName,$value, $index); |
|
118 | + protected function _postGetValue($index, $propertyName, $value) { |
|
119 | + if (isset($this->values[$index])) { |
|
120 | + $value=$this->values[$index]($value, $this->instance, $index); |
|
121 | + } else { |
|
122 | + $value=$this->_getDefaultValue($propertyName, $value, $index); |
|
123 | 123 | } |
124 | - if(isset($this->afterCompile[$index])){ |
|
125 | - if(\is_callable($this->afterCompile[$index])){ |
|
126 | - $this->afterCompile[$index]($value,$this->instance,$index); |
|
124 | + if (isset($this->afterCompile[$index])) { |
|
125 | + if (\is_callable($this->afterCompile[$index])) { |
|
126 | + $this->afterCompile[$index]($value, $this->instance, $index); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | return $value; |
130 | 130 | } |
131 | 131 | |
132 | - public function insertField($index,$field){ |
|
133 | - array_splice( $this->visibleProperties, $index, 0, $field ); |
|
132 | + public function insertField($index, $field) { |
|
133 | + array_splice($this->visibleProperties, $index, 0, $field); |
|
134 | 134 | return $this; |
135 | 135 | } |
136 | 136 | |
137 | - public function insertInField($index,$field){ |
|
137 | + public function insertInField($index, $field) { |
|
138 | 138 | $vb=$this->visibleProperties; |
139 | - if(isset($vb[$index])){ |
|
140 | - if(\is_array($vb[$index])){ |
|
139 | + if (isset($vb[$index])) { |
|
140 | + if (\is_array($vb[$index])) { |
|
141 | 141 | $this->visibleProperties[$index][]=$field; |
142 | - }else{ |
|
143 | - $this->visibleProperties[$index]=[$vb[$index],$field]; |
|
142 | + } else { |
|
143 | + $this->visibleProperties[$index]=[$vb[$index], $field]; |
|
144 | 144 | } |
145 | - }else{ |
|
145 | + } else { |
|
146 | 146 | return $this->insertField($index, $field); |
147 | 147 | } |
148 | 148 | return $this; |
149 | 149 | } |
150 | 150 | |
151 | - public function addField($field){ |
|
151 | + public function addField($field) { |
|
152 | 152 | $this->visibleProperties[]=$field; |
153 | 153 | return $this; |
154 | 154 | } |
155 | 155 | |
156 | - public function addFields($fields){ |
|
157 | - $this->visibleProperties=\array_merge($this->visibleProperties,$fields); |
|
156 | + public function addFields($fields) { |
|
157 | + $this->visibleProperties=\array_merge($this->visibleProperties, $fields); |
|
158 | 158 | return $this; |
159 | 159 | } |
160 | 160 | |
161 | - public function count(){ |
|
161 | + public function count() { |
|
162 | 162 | return \sizeof($this->properties); |
163 | 163 | } |
164 | 164 | |
165 | - public function visiblePropertiesCount(){ |
|
165 | + public function visiblePropertiesCount() { |
|
166 | 166 | return \sizeof($this->visibleProperties); |
167 | 167 | } |
168 | 168 | |
169 | - public function getProperty($index){ |
|
169 | + public function getProperty($index) { |
|
170 | 170 | return $this->properties[$index]; |
171 | 171 | } |
172 | 172 | |
173 | - public function getFieldName($index){ |
|
173 | + public function getFieldName($index) { |
|
174 | 174 | $property=$this->getProperty($index); |
175 | - if($property instanceof \ReflectionProperty){ |
|
175 | + if ($property instanceof \ReflectionProperty) { |
|
176 | 176 | $result=$property->getName(); |
177 | - }elseif(\is_callable($property)){ |
|
177 | + }elseif (\is_callable($property)) { |
|
178 | 178 | $result=$this->visibleProperties[$index]; |
179 | - }else{ |
|
179 | + } else { |
|
180 | 180 | $result=$property; |
181 | 181 | } |
182 | 182 | return $result; |
183 | 183 | } |
184 | 184 | |
185 | 185 | |
186 | - protected function showableProperty(\ReflectionProperty $rProperty){ |
|
187 | - return JString::startswith($rProperty->getName(),"_")===false; |
|
186 | + protected function showableProperty(\ReflectionProperty $rProperty) { |
|
187 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | public function setInstance($instance) { |
191 | - if(\is_string($instance)){ |
|
191 | + if (\is_string($instance)) { |
|
192 | 192 | $instance=new $instance(); |
193 | 193 | } |
194 | 194 | $this->instance=$instance; |
195 | 195 | $this->properties=[]; |
196 | 196 | $this->reflect=new \ReflectionClass($instance); |
197 | - if(\sizeof($this->visibleProperties)===0){ |
|
197 | + if (\sizeof($this->visibleProperties)===0) { |
|
198 | 198 | $this->properties=$this->getDefaultProperties(); |
199 | - }else{ |
|
200 | - foreach ($this->visibleProperties as $property){ |
|
199 | + } else { |
|
200 | + foreach ($this->visibleProperties as $property) { |
|
201 | 201 | $this->setInstanceProperty($property); |
202 | 202 | } |
203 | 203 | } |
204 | 204 | return $this; |
205 | 205 | } |
206 | 206 | |
207 | - private function setInstanceProperty($property){ |
|
208 | - if(\is_callable($property)){ |
|
207 | + private function setInstanceProperty($property) { |
|
208 | + if (\is_callable($property)) { |
|
209 | 209 | $this->properties[]=$property; |
210 | - }elseif(\is_string($property)){ |
|
211 | - try{ |
|
210 | + }elseif (\is_string($property)) { |
|
211 | + try { |
|
212 | 212 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
213 | 213 | $rProperty=$this->reflect->getProperty($property); |
214 | 214 | $this->properties[]=$rProperty; |
215 | - }catch(\Exception $e){ |
|
215 | + }catch (\Exception $e) { |
|
216 | 216 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
217 | 217 | $this->properties[]=$property; |
218 | 218 | } |
219 | - }elseif(\is_int($property)){ |
|
219 | + }elseif (\is_int($property)) { |
|
220 | 220 | $props=$this->getDefaultProperties(); |
221 | - if(isset($props[$property])) |
|
221 | + if (isset($props[$property])) |
|
222 | 222 | $this->properties[]=$props[$property]; |
223 | 223 | else |
224 | 224 | $this->properties[]=$property; |
225 | - }else{ |
|
225 | + } else { |
|
226 | 226 | $this->properties[]=$property; |
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | - protected function getDefaultProperties(){ |
|
230 | + protected function getDefaultProperties() { |
|
231 | 231 | $result=[]; |
232 | 232 | $properties=$this->reflect->getProperties(); |
233 | - foreach ($properties as $property){ |
|
233 | + foreach ($properties as $property) { |
|
234 | 234 | $showable=$this->showableProperty($property); |
235 | - if($showable!==false){ |
|
235 | + if ($showable!==false) { |
|
236 | 236 | $result[]=$property; |
237 | 237 | } |
238 | 238 | } |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | return $this; |
245 | 245 | } |
246 | 246 | |
247 | - public function setValueFunction($index,$callback){ |
|
247 | + public function setValueFunction($index, $callback) { |
|
248 | 248 | $this->values[$index]=$callback; |
249 | 249 | return $this; |
250 | 250 | } |
251 | 251 | |
252 | - public function setIdentifierFunction($callback){ |
|
252 | + public function setIdentifierFunction($callback) { |
|
253 | 253 | $this->values["identifier"]=$callback; |
254 | 254 | return $this; |
255 | 255 | } |
@@ -262,42 +262,42 @@ discard block |
||
262 | 262 | return $this->properties; |
263 | 263 | } |
264 | 264 | |
265 | - public function getCaption($index){ |
|
266 | - if(isset($this->captions[$index])){ |
|
265 | + public function getCaption($index) { |
|
266 | + if (isset($this->captions[$index])) { |
|
267 | 267 | return $this->captions[$index]; |
268 | 268 | } |
269 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
269 | + if ($this->properties[$index] instanceof \ReflectionProperty) |
|
270 | 270 | return $this->properties[$index]->getName(); |
271 | - elseif(\is_callable($this->properties[$index])) |
|
271 | + elseif (\is_callable($this->properties[$index])) |
|
272 | 272 | return ""; |
273 | 273 | else |
274 | 274 | return $this->properties[$index]; |
275 | 275 | } |
276 | 276 | |
277 | - public function getCaptions(){ |
|
277 | + public function getCaptions() { |
|
278 | 278 | $count=$this->count(); |
279 | - if(isset($this->captions)){ |
|
280 | - $captions= \array_values($this->captions); |
|
279 | + if (isset($this->captions)) { |
|
280 | + $captions=\array_values($this->captions); |
|
281 | 281 | $captionsSize=\sizeof($captions); |
282 | - for($i=$captionsSize;$i<$count;$i++){ |
|
282 | + for ($i=$captionsSize; $i<$count; $i++) { |
|
283 | 283 | $captions[]=""; |
284 | 284 | } |
285 | - }else{ |
|
285 | + } else { |
|
286 | 286 | $captions=[]; |
287 | 287 | $index=0; |
288 | - while($index<$count){ |
|
288 | + while ($index<$count) { |
|
289 | 289 | $captions[]=$this->getCaption($index++); |
290 | 290 | } |
291 | 291 | } |
292 | - if(isset($this->captionCallback) && \is_callable($this->captionCallback)){ |
|
292 | + if (isset($this->captionCallback) && \is_callable($this->captionCallback)) { |
|
293 | 293 | $callback=$this->captionCallback; |
294 | - $callback($captions,$this->instance); |
|
294 | + $callback($captions, $this->instance); |
|
295 | 295 | } |
296 | 296 | return $captions; |
297 | 297 | } |
298 | 298 | |
299 | - public function setCaption($index,$caption){ |
|
300 | - if(isset($this->captions)===false) |
|
299 | + public function setCaption($index, $caption) { |
|
300 | + if (isset($this->captions)===false) |
|
301 | 301 | $this->captions=[]; |
302 | 302 | $this->captions[$index]=$caption; |
303 | 303 | return $this; |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @param callable $callback function called after the field compilation |
316 | 316 | * @return \Ajax\semantic\widgets\datatable\InstanceViewer |
317 | 317 | */ |
318 | - public function afterCompile($index,$callback){ |
|
318 | + public function afterCompile($index, $callback) { |
|
319 | 319 | $this->afterCompile[$index]=$callback; |
320 | 320 | return $this; |
321 | 321 | } |
@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | abstract class HtmlViewItem extends HtmlSemDoubleElement { |
18 | 18 | use ContentPartTrait; |
19 | 19 | |
20 | - public function __construct($identifier,$baseClass,$content=NULL) { |
|
20 | + public function __construct($identifier, $baseClass, $content=NULL) { |
|
21 | 21 | parent::__construct($identifier, "div", $baseClass); |
22 | 22 | $this->content=["content"=>new HtmlViewContent("content-".$this->identifier)]; |
23 | - if(isset($content)) |
|
23 | + if (isset($content)) |
|
24 | 24 | $this->setContent($content); |
25 | 25 | } |
26 | 26 | |
27 | - public function setContent($value){ |
|
27 | + public function setContent($value) { |
|
28 | 28 | if (\is_array($value)) { |
29 | 29 | $image=JArray::getValue($value, "image", 0); |
30 | 30 | $content=JArray::getValue($value, "content", 1); |
@@ -32,57 +32,57 @@ discard block |
||
32 | 32 | if (isset($image)) { |
33 | 33 | $this->addImage($image); |
34 | 34 | } |
35 | - if(isset($content)) |
|
35 | + if (isset($content)) |
|
36 | 36 | $this->content["content"]->setContent($content); |
37 | - if(isset($extra)) |
|
37 | + if (isset($extra)) |
|
38 | 38 | $this->addExtraContent($extra); |
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | 42 | private function createContent($content, $baseClass="content") { |
43 | 43 | $count=\sizeof($this->content); |
44 | - $result=new HtmlViewContent("content-" . $count . "-" . $this->identifier, $content); |
|
44 | + $result=new HtmlViewContent("content-".$count."-".$this->identifier, $content); |
|
45 | 45 | $result->setClass($baseClass); |
46 | 46 | return $result; |
47 | 47 | } |
48 | 48 | |
49 | 49 | private function addElementIn($key, $element) { |
50 | - if (\array_key_exists($key, $this->content) === false) { |
|
50 | + if (\array_key_exists($key, $this->content)===false) { |
|
51 | 51 | $this->content[$key]=[]; |
52 | 52 | } |
53 | - if($this->content[$key] instanceof HtmlViewContent) |
|
53 | + if ($this->content[$key] instanceof HtmlViewContent) |
|
54 | 54 | $this->content[$key]->addElement($element); |
55 | 55 | else |
56 | 56 | $this->content[$key][]=$element; |
57 | 57 | return $element; |
58 | 58 | } |
59 | 59 | |
60 | - public function addIcon($icon,$before=true){ |
|
61 | - return $this->addElementIn("icon",new HtmlIcon("icon-" . $this->identifier, $icon)); |
|
60 | + public function addIcon($icon, $before=true) { |
|
61 | + return $this->addElementIn("icon", new HtmlIcon("icon-".$this->identifier, $icon)); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | 65 | public function addHeader($header, $niveau=4, $type="page") { |
66 | 66 | if (!$header instanceof HtmlHeader) { |
67 | - $header=new HtmlHeader("header-" . $this->identifier, $niveau, $header, $type); |
|
67 | + $header=new HtmlHeader("header-".$this->identifier, $niveau, $header, $type); |
|
68 | 68 | } |
69 | - return $this->addElementIn("header",$this->createContent($header)); |
|
69 | + return $this->addElementIn("header", $this->createContent($header)); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | public function addImage($image, $title="") { |
73 | 73 | if (!$image instanceof HtmlImage) { |
74 | - $image=new HtmlImage("image-" . $this->identifier, $image, $title); |
|
74 | + $image=new HtmlImage("image-".$this->identifier, $image, $title); |
|
75 | 75 | } |
76 | 76 | $image->setClass("ui image"); |
77 | - return $this->content["image"]= $image; |
|
77 | + return $this->content["image"]=$image; |
|
78 | 78 | } |
79 | 79 | |
80 | - public function addReveal($visibleContent, $hiddenContent=NULL, $type=RevealType::FADE, $attributeType=NULL,$key="extra-content") { |
|
80 | + public function addReveal($visibleContent, $hiddenContent=NULL, $type=RevealType::FADE, $attributeType=NULL, $key="extra-content") { |
|
81 | 81 | $reveal=$visibleContent; |
82 | 82 | if (!$visibleContent instanceof HtmlReveal) { |
83 | - $reveal=new HtmlReveal("reveral-" . $this->identifier, $visibleContent, $hiddenContent, $type, $attributeType); |
|
83 | + $reveal=new HtmlReveal("reveral-".$this->identifier, $visibleContent, $hiddenContent, $type, $attributeType); |
|
84 | 84 | } |
85 | - return $this->content[$key]= $reveal; |
|
85 | + return $this->content[$key]=$reveal; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | public function addRevealImage($visibleContent, $hiddenContent=NULL, $type=RevealType::FADE, $attributeType=NULL) { |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | if (!$visibleContent instanceof HtmlReveal) { |
91 | 91 | return $this->addReveal(new HtmlImage("", $visibleContent), new HtmlImage("", $hiddenContent), $type, $attributeType); |
92 | 92 | } |
93 | - return $this->content["image"]= $reveal; |
|
93 | + return $this->content["image"]=$reveal; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | public function addExtraContent($content=array()) { |
97 | - return $this->content["extra-content"]= $this->createContent($content, "extra content"); |
|
97 | + return $this->content["extra-content"]=$this->createContent($content, "extra content"); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /*public function addContent($content=array(), $before=false) { |
@@ -112,23 +112,23 @@ discard block |
||
112 | 112 | * @param boolean $before |
113 | 113 | * @return HtmlButtonGroups |
114 | 114 | */ |
115 | - public function addContentButtons($elements=array(), $asIcons=false,$part="extra",$before=false){ |
|
116 | - return $this->content["content"]->addContentButtons($elements,$asIcons,$part, $before); |
|
115 | + public function addContentButtons($elements=array(), $asIcons=false, $part="extra", $before=false) { |
|
116 | + return $this->content["content"]->addContentButtons($elements, $asIcons, $part, $before); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | |
120 | 120 | |
121 | - public function addItemHeaderContent($header, $metas=array(), $description=NULL,$extra=NULL) { |
|
122 | - return $this->content["content"]->addHeaderContent($header, $metas, $description,$extra); |
|
121 | + public function addItemHeaderContent($header, $metas=array(), $description=NULL, $extra=NULL) { |
|
122 | + return $this->content["content"]->addHeaderContent($header, $metas, $description, $extra); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | public function addItemContent($content=array()) { |
126 | 126 | $count=\sizeof($this->content); |
127 | - return $this->addElementIn("content", new HtmlViewContent("content-" . $count . "-" . $this->identifier, $content)); |
|
127 | + return $this->addElementIn("content", new HtmlViewContent("content-".$count."-".$this->identifier, $content)); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | public function getItemContent() { |
131 | - return $this->getPart("content",null,true); |
|
131 | + return $this->getPart("content", null, true); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | public function getItemExtraContent() { |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | * @see HtmlSemDoubleElement::compile() |
151 | 151 | */ |
152 | 152 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
153 | - $this->content=JArray::sortAssociative($this->content, ["header","image","icon","content","extra-content"]); |
|
153 | + $this->content=JArray::sortAssociative($this->content, ["header", "image", "icon", "content", "extra-content"]); |
|
154 | 154 | return parent::compile($js, $view); |
155 | 155 | } |
156 | 156 | |
157 | - public function asLink($href="",$target=NULL) { |
|
157 | + public function asLink($href="", $target=NULL) { |
|
158 | 158 | $this->addToProperty("class", "link"); |
159 | - if ($href !== "") { |
|
159 | + if ($href!=="") { |
|
160 | 160 | $this->setProperty("href", $href); |
161 | 161 | if (isset($target)) |
162 | 162 | $this->setProperty("target", $target); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | abstract class HtmlViewGroups extends HtmlSemCollection { |
11 | 11 | |
12 | - public function __construct($identifier, $uiClass,$items=array()) { |
|
12 | + public function __construct($identifier, $uiClass, $items=array()) { |
|
13 | 13 | parent::__construct($identifier, "div", $uiClass); |
14 | 14 | $this->addItems($items); |
15 | 15 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param int $wide |
42 | 42 | */ |
43 | 43 | public function setWide($wide) { |
44 | - $wide=Wide::getConstants()["W" . $wide]; |
|
44 | + $wide=Wide::getConstants()["W".$wide]; |
|
45 | 45 | return $this->addToPropertyCtrl("class", $wide, Wide::getConstants()); |
46 | 46 | } |
47 | 47 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | return $this->addItem($function($object)); |
60 | 60 | } |
61 | 61 | |
62 | - public function run(JsUtils $js){ |
|
62 | + public function run(JsUtils $js) { |
|
63 | 63 | $result=parent::run($js); |
64 | 64 | return $result->setItemSelector(".item"); |
65 | 65 | } |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | * @version 1.3 |
16 | 16 | */ |
17 | 17 | abstract class BaseHtml extends BaseWidget { |
18 | - use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait; |
|
18 | + use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait; |
|
19 | 19 | protected $_template; |
20 | 20 | protected $tagName; |
21 | - protected $_wrapBefore=array (); |
|
22 | - protected $_wrapAfter=array (); |
|
21 | + protected $_wrapBefore=array(); |
|
22 | + protected $_wrapAfter=array(); |
|
23 | 23 | protected $_bsComponent; |
24 | 24 | protected $_compiled=false; |
25 | 25 | protected $_postCompile; |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | */ |
33 | 33 | abstract public function run(JsUtils $js); |
34 | 34 | |
35 | - private function _callSetter($setter,$key,$value,&$array){ |
|
35 | + private function _callSetter($setter, $key, $value, &$array) { |
|
36 | 36 | $result=false; |
37 | 37 | if (method_exists($this, $setter) && !JString::startswith($key, "_")) { |
38 | 38 | try { |
39 | 39 | $this->$setter($value); |
40 | 40 | unset($array[$key]); |
41 | 41 | $result=true; |
42 | - } catch ( \Exception $e ) { |
|
42 | + }catch (\Exception $e) { |
|
43 | 43 | $result=false; |
44 | 44 | } |
45 | 45 | } |
@@ -47,17 +47,17 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | protected function getTemplate(JsUtils $js=NULL) { |
50 | - return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
50 | + return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | protected function ctrl($name, $value, $typeCtrl) { |
54 | 54 | if (\is_array($typeCtrl)) { |
55 | - if (array_search($value, $typeCtrl) === false) { |
|
56 | - throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}"); |
|
55 | + if (array_search($value, $typeCtrl)===false) { |
|
56 | + throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
57 | 57 | } |
58 | 58 | } else { |
59 | 59 | if (!$typeCtrl($value)) { |
60 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name); |
|
60 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | return true; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | |
68 | 68 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
69 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
69 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
70 | 70 | return $name=$value; |
71 | 71 | } |
72 | 72 | return $this; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") { |
76 | 76 | if (\is_array($typeCtrl)) { |
77 | 77 | $this->removeOldValues($name, $typeCtrl); |
78 | - $name.=$separator . $value; |
|
78 | + $name.=$separator.$value; |
|
79 | 79 | } |
80 | 80 | return $this; |
81 | 81 | } |
@@ -83,17 +83,17 @@ discard block |
||
83 | 83 | |
84 | 84 | |
85 | 85 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
86 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
86 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
87 | 87 | if (\is_array($typeCtrl)) { |
88 | 88 | $this->removeOldValues($name, $typeCtrl); |
89 | 89 | } |
90 | - $name.=$separator . $value; |
|
90 | + $name.=$separator.$value; |
|
91 | 91 | } |
92 | 92 | return $this; |
93 | 93 | } |
94 | 94 | |
95 | 95 | protected function addToMember(&$name, $value, $separator=" ") { |
96 | - $name=str_ireplace($value, "", $name) . $separator . $value; |
|
96 | + $name=str_ireplace($value, "", $name).$separator.$value; |
|
97 | 97 | return $this; |
98 | 98 | } |
99 | 99 | |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | $oldValue=trim($oldValue); |
105 | 105 | } |
106 | 106 | |
107 | - protected function _getElementBy($callback,$elements){ |
|
107 | + protected function _getElementBy($callback, $elements) { |
|
108 | 108 | if (\is_array($elements)) { |
109 | 109 | $elements=\array_values($elements); |
110 | 110 | $flag=false; |
111 | 111 | $index=0; |
112 | - while ( !$flag && $index < sizeof($elements) ) { |
|
112 | + while (!$flag && $index<sizeof($elements)) { |
|
113 | 113 | if ($elements[$index] instanceof BaseHtml) |
114 | 114 | $flag=($callback($elements[$index])); |
115 | 115 | $index++; |
116 | 116 | } |
117 | - if ($flag === true) |
|
118 | - return $elements[$index - 1]; |
|
117 | + if ($flag===true) |
|
118 | + return $elements[$index-1]; |
|
119 | 119 | } elseif ($elements instanceof BaseHtml) { |
120 | 120 | if ($callback($elements)) |
121 | 121 | return $elements; |
@@ -143,13 +143,13 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | public function fromArray($array) { |
146 | - foreach ( $this as $key => $value ) { |
|
147 | - if(array_key_exists($key, $array)===true) |
|
148 | - $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
146 | + foreach ($this as $key => $value) { |
|
147 | + if (array_key_exists($key, $array)===true) |
|
148 | + $this->_callSetter("set".ucfirst($key), $key, $array[$key], $array); |
|
149 | 149 | } |
150 | - foreach ( $array as $key => $value ) { |
|
151 | - if($this->_callSetter($key, $key, $value, $array)===false){ |
|
152 | - $this->_callSetter("set" . ucfirst($key), $key, $value, $array); |
|
150 | + foreach ($array as $key => $value) { |
|
151 | + if ($this->_callSetter($key, $key, $value, $array)===false) { |
|
152 | + $this->_callSetter("set".ucfirst($key), $key, $value, $array); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | return $array; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | public function fromDatabaseObjects($objects, $function) { |
159 | 159 | if (isset($objects)) { |
160 | - foreach ( $objects as $object ) { |
|
160 | + foreach ($objects as $object) { |
|
161 | 161 | $this->fromDatabaseObject($object, $function); |
162 | 162 | } |
163 | 163 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | |
179 | 179 | |
180 | 180 | public function getElementById($identifier, $elements) { |
181 | - return $this->_getElementBy(function(BaseWidget $element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements); |
|
181 | + return $this->_getElementBy(function(BaseWidget $element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | public function getBsComponent() { |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | } |
192 | 192 | |
193 | 193 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
194 | - if(!$this->_compiled){ |
|
195 | - if(isset($js)){ |
|
194 | + if (!$this->_compiled) { |
|
195 | + if (isset($js)) { |
|
196 | 196 | $beforeCompile=$js->getParam("beforeCompileHtml"); |
197 | - if(\is_callable($beforeCompile)){ |
|
198 | - $beforeCompile($this,$js,$view); |
|
197 | + if (\is_callable($beforeCompile)) { |
|
198 | + $beforeCompile($this, $js, $view); |
|
199 | 199 | } |
200 | 200 | } |
201 | - if(\is_callable($this->_preCompile)){ |
|
201 | + if (\is_callable($this->_preCompile)) { |
|
202 | 202 | $pc=$this->_preCompile; |
203 | 203 | $pc($this); |
204 | 204 | } |
@@ -207,26 +207,26 @@ discard block |
||
207 | 207 | } |
208 | 208 | |
209 | 209 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
210 | - $this->compile_once($js,$view); |
|
210 | + $this->compile_once($js, $view); |
|
211 | 211 | $result=$this->getTemplate($js); |
212 | - foreach ( $this as $key => $value ) { |
|
213 | - if (JString::startswith($key, "_") === false && $key !== "events") { |
|
212 | + foreach ($this as $key => $value) { |
|
213 | + if (JString::startswith($key, "_")===false && $key!=="events") { |
|
214 | 214 | if (\is_array($value)) { |
215 | 215 | $v=PropertyWrapper::wrap($value, $js); |
216 | 216 | } else { |
217 | 217 | $v=$value; |
218 | 218 | } |
219 | - $result=str_ireplace("%" . $key . "%", $v, $result); |
|
219 | + $result=str_ireplace("%".$key."%", $v, $result); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | if (isset($js)===true) { |
223 | 223 | $this->run($js); |
224 | - if (isset($view) === true) { |
|
224 | + if (isset($view)===true) { |
|
225 | 225 | $js->addViewElement($this->_identifier, $result, $view); |
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | - if(\is_callable($this->_postCompile)){ |
|
229 | + if (\is_callable($this->_postCompile)) { |
|
230 | 230 | $pc=$this->_postCompile; |
231 | 231 | $pc($this); |
232 | 232 | } |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | return $this->compile(); |
238 | 238 | } |
239 | 239 | |
240 | - public function onPostCompile($callback){ |
|
240 | + public function onPostCompile($callback) { |
|
241 | 241 | $this->_postCompile=$callback; |
242 | 242 | } |
243 | 243 | |
244 | - public function onPreCompile($callback){ |
|
244 | + public function onPreCompile($callback) { |
|
245 | 245 | $this->_preCompile=$callback; |
246 | 246 | } |
247 | 247 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | */ |
26 | 26 | class DataTable extends Widget { |
27 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait; |
|
27 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait; |
|
28 | 28 | protected $_searchField; |
29 | 29 | protected $_urls; |
30 | 30 | protected $_pagination; |
@@ -42,35 +42,35 @@ discard block |
||
42 | 42 | protected $_colWidths; |
43 | 43 | |
44 | 44 | |
45 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
46 | - parent::__construct($identifier, $model,$modelInstance); |
|
47 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
|
45 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
46 | + parent::__construct($identifier, $model, $modelInstance); |
|
47 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
|
48 | 48 | $this->_urls=[]; |
49 | - $this->_emptyMessage=new HtmlMessage("","nothing to display"); |
|
49 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
50 | 50 | $this->_emptyMessage->setIcon("info circle"); |
51 | 51 | } |
52 | 52 | |
53 | - public function run(JsUtils $js){ |
|
54 | - if($this->_hasCheckboxes && isset($js)){ |
|
53 | + public function run(JsUtils $js) { |
|
54 | + if ($this->_hasCheckboxes && isset($js)) { |
|
55 | 55 | $this->_runCheckboxes($js); |
56 | 56 | } |
57 | - if($this->_visibleHover){ |
|
58 | - $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
59 | - $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
57 | + if ($this->_visibleHover) { |
|
58 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
59 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
60 | 60 | } |
61 | - if(\is_array($this->_deleteBehavior)) |
|
62 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
63 | - if(\is_array($this->_editBehavior)) |
|
64 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
61 | + if (\is_array($this->_deleteBehavior)) |
|
62 | + $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
63 | + if (\is_array($this->_editBehavior)) |
|
64 | + $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
65 | 65 | return parent::run($js); |
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | - protected function _generateBehavior($op,$params,JsUtils $js){ |
|
71 | - if(isset($this->_urls[$op])){ |
|
72 | - $params=\array_merge($params,["attr"=>"data-ajax"]); |
|
73 | - $js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector($op),$params); |
|
70 | + protected function _generateBehavior($op, $params, JsUtils $js) { |
|
71 | + if (isset($this->_urls[$op])) { |
|
72 | + $params=\array_merge($params, ["attr"=>"data-ajax"]); |
|
73 | + $js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -83,156 +83,156 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | |
86 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
87 | - if(!$this->_generated){ |
|
86 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
87 | + if (!$this->_generated) { |
|
88 | 88 | $this->_instanceViewer->setInstance($this->_model); |
89 | 89 | $captions=$this->_instanceViewer->getCaptions(); |
90 | 90 | $table=$this->content["table"]; |
91 | - if($this->_hasCheckboxes){ |
|
91 | + if ($this->_hasCheckboxes) { |
|
92 | 92 | $this->_generateMainCheckbox($captions); |
93 | 93 | } |
94 | 94 | $table->setRowCount(0, \sizeof($captions)); |
95 | - $this->_generateHeader($table,$captions); |
|
95 | + $this->_generateHeader($table, $captions); |
|
96 | 96 | |
97 | - if(isset($this->_compileParts)) |
|
97 | + if (isset($this->_compileParts)) |
|
98 | 98 | $table->setCompileParts($this->_compileParts); |
99 | 99 | |
100 | 100 | $this->_generateContent($table); |
101 | 101 | |
102 | - $this->compileExtraElements($table, $captions,$js); |
|
102 | + $this->compileExtraElements($table, $captions, $js); |
|
103 | 103 | |
104 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
104 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
105 | 105 | $this->_compileForm(); |
106 | 106 | $this->_applyStyleAttributes($table); |
107 | 107 | $this->_generated=true; |
108 | 108 | } |
109 | - return parent::compile($js,$view); |
|
109 | + return parent::compile($js, $view); |
|
110 | 110 | } |
111 | 111 | |
112 | - protected function compileExtraElements($table,$captions,JsUtils $js=NULL){ |
|
113 | - if(isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])){ |
|
114 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
112 | + protected function compileExtraElements($table, $captions, JsUtils $js=NULL) { |
|
113 | + if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) { |
|
114 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
115 | 115 | } |
116 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
116 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
117 | 117 | $table->getHeader()->getCell(0, 0)->addClass("no-sort"); |
118 | 118 | } |
119 | 119 | |
120 | - if(isset($this->_toolbar)){ |
|
120 | + if (isset($this->_toolbar)) { |
|
121 | 121 | $this->_setToolbarPosition($table, $captions); |
122 | 122 | } |
123 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
124 | - $this->_generatePagination($table,$js); |
|
123 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
124 | + $this->_generatePagination($table, $js); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | - protected function _applyStyleAttributes($table){ |
|
129 | - if(isset($this->_hiddenColumns)) |
|
128 | + protected function _applyStyleAttributes($table) { |
|
129 | + if (isset($this->_hiddenColumns)) |
|
130 | 130 | $this->_hideColumns(); |
131 | - if(isset($this->_colWidths)){ |
|
132 | - foreach ($this->_colWidths as $colIndex=>$width){ |
|
133 | - $table->setColWidth($colIndex,$width); |
|
131 | + if (isset($this->_colWidths)) { |
|
132 | + foreach ($this->_colWidths as $colIndex=>$width) { |
|
133 | + $table->setColWidth($colIndex, $width); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | - protected function _hideColumns(){ |
|
139 | - foreach ($this->_hiddenColumns as $colIndex){ |
|
138 | + protected function _hideColumns() { |
|
139 | + foreach ($this->_hiddenColumns as $colIndex) { |
|
140 | 140 | $this->_self->hideColumn($colIndex); |
141 | 141 | } |
142 | 142 | return $this; |
143 | 143 | } |
144 | 144 | |
145 | - protected function _generateHeader(HtmlTable $table,$captions){ |
|
145 | + protected function _generateHeader(HtmlTable $table, $captions) { |
|
146 | 146 | $table->setHeaderValues($captions); |
147 | - if(isset($this->_sortable)){ |
|
147 | + if (isset($this->_sortable)) { |
|
148 | 148 | $table->setSortable($this->_sortable); |
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | 152 | |
153 | 153 | |
154 | - protected function _generateContent($table){ |
|
154 | + protected function _generateContent($table) { |
|
155 | 155 | $objects=$this->_modelInstance; |
156 | - if(isset($this->_pagination)){ |
|
156 | + if (isset($this->_pagination)) { |
|
157 | 157 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
158 | 158 | } |
159 | 159 | InstanceViewer::setIndex(0); |
160 | 160 | $table->fromDatabaseObjects($objects, function($instance) use($table){ |
161 | 161 | return $this->_generateRow($instance, $table); |
162 | 162 | }); |
163 | - if($table->getRowCount()==0){ |
|
163 | + if ($table->getRowCount()==0) { |
|
164 | 164 | $result=$table->addRow(); |
165 | 165 | $result->mergeRow(); |
166 | 166 | $result->setValues([$this->_emptyMessage]); |
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - protected function _generateRow($instance,&$table,$checkedClass=null){ |
|
170 | + protected function _generateRow($instance, &$table, $checkedClass=null) { |
|
171 | 171 | $this->_instanceViewer->setInstance($instance); |
172 | 172 | InstanceViewer::$index++; |
173 | - $values= $this->_instanceViewer->getValues(); |
|
173 | + $values=$this->_instanceViewer->getValues(); |
|
174 | 174 | $id=$this->_instanceViewer->getIdentifier(); |
175 | - if($this->_hasCheckboxes){ |
|
176 | - $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,""); |
|
175 | + if ($this->_hasCheckboxes) { |
|
176 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
177 | 177 | $ck->setOnChange("event.stopPropagation();"); |
178 | 178 | $field=$ck->getField(); |
179 | - $field->setProperty("value",$id); |
|
179 | + $field->setProperty("value", $id); |
|
180 | 180 | $field->setProperty("name", "selection[]"); |
181 | - if(isset($checkedClass)) |
|
181 | + if (isset($checkedClass)) |
|
182 | 182 | $field->setClass($checkedClass); |
183 | 183 | \array_unshift($values, $ck); |
184 | 184 | } |
185 | 185 | $result=$table->newRow(); |
186 | 186 | $result->setIdentifier($this->identifier."-tr-".$id); |
187 | - $result->setProperty("data-ajax",$id); |
|
187 | + $result->setProperty("data-ajax", $id); |
|
188 | 188 | $result->setValues($values); |
189 | - $result->addToProperty("class",$this->_rowClass); |
|
189 | + $result->addToProperty("class", $this->_rowClass); |
|
190 | 190 | return $result; |
191 | 191 | } |
192 | 192 | |
193 | - protected function _generatePagination($table,$js=NULL){ |
|
194 | - if(isset($this->_toolbar)){ |
|
195 | - if($this->_toolbarPosition==PositionInTable::FOOTER) |
|
193 | + protected function _generatePagination($table, $js=NULL) { |
|
194 | + if (isset($this->_toolbar)) { |
|
195 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
196 | 196 | $this->_toolbar->setFloated("left"); |
197 | 197 | } |
198 | 198 | $footer=$table->getFooter(); |
199 | 199 | $footer->mergeCol(); |
200 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
200 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
201 | 201 | $menu->floatRight(); |
202 | 202 | $menu->setActiveItem($this->_pagination->getPage()-1); |
203 | 203 | $footer->addValues($menu); |
204 | - $this->_associatePaginationBehavior($menu,$js); |
|
204 | + $this->_associatePaginationBehavior($menu, $js); |
|
205 | 205 | } |
206 | 206 | |
207 | - protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){ |
|
208 | - if(isset($this->_urls["refresh"])){ |
|
209 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith","hasLoader"=>false]); |
|
207 | + protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) { |
|
208 | + if (isset($this->_urls["refresh"])) { |
|
209 | + $menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith", "hasLoader"=>false]); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
213 | - protected function _getFieldName($index){ |
|
213 | + protected function _getFieldName($index) { |
|
214 | 214 | $fieldName=parent::_getFieldName($index); |
215 | - if(\is_object($fieldName)) |
|
215 | + if (\is_object($fieldName)) |
|
216 | 216 | $fieldName="field-".$index; |
217 | 217 | return $fieldName."[]"; |
218 | 218 | } |
219 | 219 | |
220 | - protected function _getFieldCaption($index){ |
|
220 | + protected function _getFieldCaption($index) { |
|
221 | 221 | return null; |
222 | 222 | } |
223 | 223 | |
224 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
225 | - switch ($this->_toolbarPosition){ |
|
224 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
225 | + switch ($this->_toolbarPosition) { |
|
226 | 226 | case PositionInTable::BEFORETABLE: |
227 | 227 | case PositionInTable::AFTERTABLE: |
228 | - if(isset($this->_compileParts)===false){ |
|
228 | + if (isset($this->_compileParts)===false) { |
|
229 | 229 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
230 | 230 | } |
231 | 231 | break; |
232 | 232 | case PositionInTable::HEADER: |
233 | 233 | case PositionInTable::FOOTER: |
234 | 234 | case PositionInTable::BODY: |
235 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
235 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
236 | 236 | break; |
237 | 237 | } |
238 | 238 | } |
@@ -244,16 +244,16 @@ discard block |
||
244 | 244 | * @param callable $callback function called after the field compilation |
245 | 245 | * @return DataTable |
246 | 246 | */ |
247 | - public function afterCompile($index,$callback){ |
|
248 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
247 | + public function afterCompile($index, $callback) { |
|
248 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
249 | 249 | return $this; |
250 | 250 | } |
251 | 251 | |
252 | - private function addToolbarRow($part,$table,$captions){ |
|
252 | + private function addToolbarRow($part, $table, $captions) { |
|
253 | 253 | $hasPart=$table->hasPart($part); |
254 | - if($hasPart){ |
|
254 | + if ($hasPart) { |
|
255 | 255 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
256 | - }else{ |
|
256 | + } else { |
|
257 | 257 | $row=$table->getPart($part)->getRow(0); |
258 | 258 | } |
259 | 259 | $row->mergeCol(); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * @see Widget::getHtmlComponent() |
266 | 266 | * @return HtmlTable |
267 | 267 | */ |
268 | - public function getHtmlComponent(){ |
|
268 | + public function getHtmlComponent() { |
|
269 | 269 | return $this->content["table"]; |
270 | 270 | } |
271 | 271 | |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | * @return DataTable |
281 | 281 | */ |
282 | 282 | public function setUrls($urls) { |
283 | - if(\is_array($urls)){ |
|
284 | - $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
|
285 | - $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
|
286 | - $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
|
287 | - }else{ |
|
288 | - $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
|
283 | + if (\is_array($urls)) { |
|
284 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
285 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
286 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
287 | + } else { |
|
288 | + $this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls]; |
|
289 | 289 | } |
290 | 290 | return $this; |
291 | 291 | } |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | * @param number $pages_visibles The number of visible pages in the Pagination component |
299 | 299 | * @return DataTable |
300 | 300 | */ |
301 | - public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){ |
|
302 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount); |
|
301 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
302 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
303 | 303 | return $this; |
304 | 304 | } |
305 | 305 | |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | * @param number $pages_visibles The number of visible pages in the Pagination component |
311 | 311 | * @return DataTable |
312 | 312 | */ |
313 | - public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){ |
|
314 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page); |
|
313 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
314 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
315 | 315 | return $this; |
316 | 316 | } |
317 | 317 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @param array $compileParts |
322 | 322 | * @return DataTable |
323 | 323 | */ |
324 | - public function refresh($compileParts=["tbody"]){ |
|
324 | + public function refresh($compileParts=["tbody"]) { |
|
325 | 325 | $this->_compileParts=$compileParts; |
326 | 326 | return $this; |
327 | 327 | } |
@@ -332,14 +332,14 @@ discard block |
||
332 | 332 | * @param string $position |
333 | 333 | * @return \Ajax\common\html\HtmlDoubleElement |
334 | 334 | */ |
335 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
335 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
336 | 336 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
337 | 337 | } |
338 | 338 | |
339 | - public function getSearchField(){ |
|
340 | - if(isset($this->_searchField)===false){ |
|
341 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
342 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
339 | + public function getSearchField() { |
|
340 | + if (isset($this->_searchField)===false) { |
|
341 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
342 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
343 | 343 | } |
344 | 344 | return $this->_searchField; |
345 | 345 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * Returns a form corresponding to the Datatable |
360 | 360 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
361 | 361 | */ |
362 | - public function asForm(){ |
|
362 | + public function asForm() { |
|
363 | 363 | return $this->getForm(); |
364 | 364 | } |
365 | 365 | |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | |
368 | 368 | protected function getTargetSelector($op) { |
369 | 369 | $result=$this->_targetSelector; |
370 | - if(!isset($result[$op])) |
|
370 | + if (!isset($result[$op])) |
|
371 | 371 | $result="#".$this->identifier; |
372 | 372 | return $result[$op]; |
373 | 373 | } |
@@ -378,15 +378,15 @@ discard block |
||
378 | 378 | * @return DataTable |
379 | 379 | */ |
380 | 380 | public function setTargetSelector($_targetSelector) { |
381 | - if(!\is_array($_targetSelector)){ |
|
382 | - $_targetSelector=["edit"=>$_targetSelector,"delete"=>$_targetSelector]; |
|
381 | + if (!\is_array($_targetSelector)) { |
|
382 | + $_targetSelector=["edit"=>$_targetSelector, "delete"=>$_targetSelector]; |
|
383 | 383 | } |
384 | 384 | $this->_targetSelector=$_targetSelector; |
385 | 385 | return $this; |
386 | 386 | } |
387 | 387 | |
388 | 388 | public function getRefreshSelector() { |
389 | - if(isset($this->_refreshSelector)) |
|
389 | + if (isset($this->_refreshSelector)) |
|
390 | 390 | return $this->_refreshSelector; |
391 | 391 | return "#".$this->identifier." tbody"; |
392 | 392 | } |
@@ -404,9 +404,9 @@ discard block |
||
404 | 404 | * {@inheritDoc} |
405 | 405 | * @see \Ajax\common\Widget::show() |
406 | 406 | */ |
407 | - public function show($modelInstance){ |
|
408 | - if(\is_array($modelInstance)){ |
|
409 | - if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
|
407 | + public function show($modelInstance) { |
|
408 | + if (\is_array($modelInstance)) { |
|
409 | + if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
|
410 | 410 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
411 | 411 | } |
412 | 412 | $this->_modelInstance=$modelInstance; |
@@ -441,29 +441,29 @@ discard block |
||
441 | 441 | return $this; |
442 | 442 | } |
443 | 443 | |
444 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
445 | - $this->_self->setActiveRowSelector($class,$event,$multiple); |
|
444 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
445 | + $this->_self->setActiveRowSelector($class, $event, $multiple); |
|
446 | 446 | return $this; |
447 | 447 | } |
448 | 448 | |
449 | - public function hideColumn($colIndex){ |
|
450 | - if(!\is_array($this->_hiddenColumns)) |
|
449 | + public function hideColumn($colIndex) { |
|
450 | + if (!\is_array($this->_hiddenColumns)) |
|
451 | 451 | $this->_hiddenColumns=[]; |
452 | 452 | $this->_hiddenColumns[]=$colIndex; |
453 | 453 | return $this; |
454 | 454 | } |
455 | 455 | |
456 | - public function setColWidth($colIndex,$width){ |
|
456 | + public function setColWidth($colIndex, $width) { |
|
457 | 457 | $this->_colWidths[$colIndex]=$width; |
458 | 458 | return $this; |
459 | 459 | } |
460 | 460 | public function setColWidths($_colWidths) { |
461 | - $this->_colWidths = $_colWidths; |
|
461 | + $this->_colWidths=$_colWidths; |
|
462 | 462 | return $this; |
463 | 463 | } |
464 | 464 | |
465 | - public function setColAlignment($colIndex,$alignment){ |
|
466 | - $this->content["table"]->setColAlignment($colIndex,$alignment); |
|
465 | + public function setColAlignment($colIndex, $alignment) { |
|
466 | + $this->content["table"]->setColAlignment($colIndex, $alignment); |
|
467 | 467 | return $this; |
468 | 468 | } |
469 | 469 | } |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | * @author jc |
8 | 8 | * @property HtmlTable $_self |
9 | 9 | */ |
10 | -trait TableTrait{ |
|
10 | +trait TableTrait { |
|
11 | 11 | |
12 | 12 | abstract public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false); |
13 | 13 | abstract public function getOn($event, $url, $responseElement="", $parameters=array()); |
14 | 14 | |
15 | - protected function addToPropertyTable($property,$value){ |
|
15 | + protected function addToPropertyTable($property, $value) { |
|
16 | 16 | return $this->_self->addToProperty($property, $value); |
17 | 17 | } |
18 | 18 | |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | public function setBasic($very=false) { |
24 | 24 | $table=$this->_self; |
25 | 25 | if ($very) |
26 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
27 | - return $table->addToPropertyCtrl("class", "basic", array ("basic" )); |
|
26 | + $table->addToPropertyCtrl("class", "very", array("very")); |
|
27 | + return $table->addToPropertyCtrl("class", "basic", array("basic")); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function setCompact($very=false) { |
31 | 31 | $table=$this->_self; |
32 | 32 | if ($very) |
33 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
34 | - return $table->addToPropertyCtrl("class", "compact", array ("compact" )); |
|
33 | + $table->addToPropertyCtrl("class", "very", array("very")); |
|
34 | + return $table->addToPropertyCtrl("class", "compact", array("compact")); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function setCollapsing() { |
@@ -70,16 +70,16 @@ discard block |
||
70 | 70 | return $this->addToPropertyTable("class", "striped"); |
71 | 71 | } |
72 | 72 | |
73 | - public function onRowClick($jsCode, $stopPropagation=false, $preventDefault=false){ |
|
74 | - return $this->onRow("click", $jsCode,$stopPropagation,$preventDefault); |
|
73 | + public function onRowClick($jsCode, $stopPropagation=false, $preventDefault=false) { |
|
74 | + return $this->onRow("click", $jsCode, $stopPropagation, $preventDefault); |
|
75 | 75 | } |
76 | 76 | |
77 | - public function onRow($event,$jsCode, $stopPropagation=false, $preventDefault=false){ |
|
78 | - return $this->_self->addEvent($event."{{tr}}",$jsCode,$stopPropagation,$preventDefault); |
|
77 | + public function onRow($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
|
78 | + return $this->_self->addEvent($event."{{tr}}", $jsCode, $stopPropagation, $preventDefault); |
|
79 | 79 | } |
80 | 80 | |
81 | - public function getOnRow($event, $url, $responseElement="", $parameters=array()){ |
|
82 | - $parameters=\array_merge($parameters,["stopPropagation"=>false,"preventDefault"=>false]); |
|
83 | - return $this->_self->getOn($event."{{tbody tr}}", $url,$responseElement,$parameters); |
|
81 | + public function getOnRow($event, $url, $responseElement="", $parameters=array()) { |
|
82 | + $parameters=\array_merge($parameters, ["stopPropagation"=>false, "preventDefault"=>false]); |
|
83 | + return $this->_self->getOn($event."{{tbody tr}}", $url, $responseElement, $parameters); |
|
84 | 84 | } |
85 | 85 | } |