@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param array $options - additional html attribute options |
32 | 32 | * @return $this |
33 | 33 | */ |
34 | - public function setEdit($url, array $options=[]) |
|
34 | + public function setEdit($url, array $options = []) |
|
35 | 35 | { |
36 | 36 | $this->_buttons['edit'] = $options; |
37 | 37 | $this->_buttons['edit']['url'] = $url; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param array|string $url |
44 | 44 | * @param array $options - additional html attribute options |
45 | 45 | */ |
46 | - public function setDelete($url, array $options=[]) |
|
46 | + public function setDelete($url, array $options = []) |
|
47 | 47 | { |
48 | 48 | $this->_buttons['delete'] = $options; |
49 | 49 | $this->_buttons['delete']['url'] = $url; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * will append text to the CSS class e.g. btn-$type |
60 | 60 | * @param array $options - passed to Html::buttonCustom |
61 | 61 | */ |
62 | - public function addButton($key, $url, $text, $icon='', $class='', $options=[]) |
|
62 | + public function addButton($key, $url, $text, $icon = '', $class = '', $options = []) |
|
63 | 63 | { |
64 | 64 | $this->_buttons[$key] = array_merge(compact('url', 'text', 'icon', 'class'), $options); |
65 | 65 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function getWidth() |
85 | 85 | { |
86 | - return 'calc(' . (count($this->_buttons)+count($this->_actions)) . ' * ' .$this->buttonWidth . ')'; |
|
86 | + return 'calc('.(count($this->_buttons) + count($this->_actions)).' * '.$this->buttonWidth.')'; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | if (!isset($btnOps['data'])) |
98 | 98 | $btnOps['data'] = []; |
99 | 99 | if ($this->getGrid()->hasIndexColumn()) |
100 | - $btnOps['data'] = ['index' => $model[$this->getGrid()->getIndexColumn()->getKey()] ]; |
|
100 | + $btnOps['data'] = ['index' => $model[$this->getGrid()->getIndexColumn()->getKey()]]; |
|
101 | 101 | $func = 'buttonCustom'; |
102 | 102 | if ($buttonKey === 'delete') { |
103 | 103 | $func = 'buttonDelete'; |
104 | - $btnOps['data'] = Arr::merge($btnOps['data'], ['data'=> ['delete-ajax' => true ]]); |
|
104 | + $btnOps['data'] = Arr::merge($btnOps['data'], ['data'=> ['delete-ajax' => true]]); |
|
105 | 105 | } |
106 | 106 | if ($buttonKey === 'edit') { |
107 | 107 | $func = 'buttonEdit'; |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | $text = Arr::remove($btnOps, 'text', ''); |
110 | 110 | $url = Arr::remove($btnOps, 'url', ''); |
111 | 111 | $url = $this->grid->replaceRowTagsWithValues($url, $model); |
112 | - $btnOps['class'] = Arr::get($btnOps, 'class', '') . ' btn-grid'; |
|
112 | + $btnOps['class'] = Arr::get($btnOps, 'class', '').' btn-grid'; |
|
113 | 113 | $buttons[] = Html::$func($url, $text, $btnOps); |
114 | 114 | } |
115 | - return '<div class="btn-group btn-column">' . implode('', $buttons) . '</div>'; |
|
115 | + return '<div class="btn-group btn-column">'.implode('', $buttons).'</div>'; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -94,10 +94,12 @@ |
||
94 | 94 | $buttons = []; |
95 | 95 | $options = $this->_buttons; |
96 | 96 | foreach ($options as $buttonKey => $btnOps) { |
97 | - if (!isset($btnOps['data'])) |
|
98 | - $btnOps['data'] = []; |
|
99 | - if ($this->getGrid()->hasIndexColumn()) |
|
100 | - $btnOps['data'] = ['index' => $model[$this->getGrid()->getIndexColumn()->getKey()] ]; |
|
97 | + if (!isset($btnOps['data'])) { |
|
98 | + $btnOps['data'] = []; |
|
99 | + } |
|
100 | + if ($this->getGrid()->hasIndexColumn()) { |
|
101 | + $btnOps['data'] = ['index' => $model[$this->getGrid()->getIndexColumn()->getKey()] ]; |
|
102 | + } |
|
101 | 103 | $func = 'buttonCustom'; |
102 | 104 | if ($buttonKey === 'delete') { |
103 | 105 | $func = 'buttonDelete'; |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | |
15 | 15 | interface IColumn |
16 | 16 | { |
17 | - public function __construct($config=[]); |
|
17 | + public function __construct($config = []); |
|
18 | 18 | |
19 | - public function renderDataCell($model, $key, $index); // GRID: called by grid |
|
19 | + public function renderDataCell($model, $key, $index); // GRID: called by grid |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Renders the contents of the cell (can be overriden by setting self::setDataCellContentFunction) |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * Set whether this column is sortable or not |
150 | 150 | * @param bool $bool |
151 | 151 | */ |
152 | - public function setIsSortable($bool=true); |
|
152 | + public function setIsSortable($bool = true); |
|
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Is the column sortable |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @param boolean $bool |
224 | 224 | */ |
225 | - public function setAsIndex($bool=true); |
|
225 | + public function setAsIndex($bool = true); |
|
226 | 226 | |
227 | 227 | /** |
228 | 228 | * Set the title of the column |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @return null|callable |
272 | 272 | */ |
273 | - public function getSearchFunction(); // GRID: called by grid |
|
273 | + public function getSearchFunction(); // GRID: called by grid |
|
274 | 274 | |
275 | 275 | /** |
276 | 276 | * Set the database field name, this is used to lookup the row data |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * @param array $linkOptions |
315 | 315 | * @return mixed |
316 | 316 | */ |
317 | - public function addRowAction($key, $text, $linkOptions=[]); |
|
317 | + public function addRowAction($key, $text, $linkOptions = []); |
|
318 | 318 | |
319 | 319 | public function renderRowActions($model, $key, $index); |
320 | 320 |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | return $this->_width; |
165 | 165 | } |
166 | 166 | |
167 | - public function __construct($config=[]) |
|
167 | + public function __construct($config = []) |
|
168 | 168 | { |
169 | 169 | parent::__construct($config); |
170 | 170 | if (!isset($config['key'])) { |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | /** |
253 | 253 | * @inheritDoc |
254 | 254 | */ |
255 | - public function setIsSortable($bool=true) |
|
255 | + public function setIsSortable($bool = true) |
|
256 | 256 | { |
257 | 257 | $this->_sortable = $bool; |
258 | 258 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | return $this->_sortable; |
266 | 266 | } |
267 | 267 | |
268 | - public function setAsIndex($bool=true) |
|
268 | + public function setAsIndex($bool = true) |
|
269 | 269 | { |
270 | 270 | $this->grid->setIndexedByColumn($this->key); |
271 | 271 | // thi is a bit gnarly but tests for yii Active record data providers specifically |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | return $this->_dataCellContentFunction; |
334 | 334 | } |
335 | 335 | // check for convention |
336 | - $functionName = 'render' . $this->key; |
|
336 | + $functionName = 'render'.$this->key; |
|
337 | 337 | if (method_exists($this->grid, $functionName) && $functionName !== 'renderfile') { |
338 | 338 | return $functionName; |
339 | 339 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | /** |
400 | 400 | * @inheritDoc |
401 | 401 | */ |
402 | - public function setDbField($field){ |
|
402 | + public function setDbField($field) { |
|
403 | 403 | $this->_dbKey = $field; |
404 | 404 | return $this; |
405 | 405 | } |
@@ -407,8 +407,8 @@ discard block |
||
407 | 407 | /** |
408 | 408 | * @inheritDoc |
409 | 409 | */ |
410 | - public function getDbField(){ |
|
411 | - if ($this->_dbKey === null){ |
|
410 | + public function getDbField() { |
|
411 | + if ($this->_dbKey === null) { |
|
412 | 412 | // set to be the key |
413 | 413 | $this->_dbKey = $this->key; |
414 | 414 | } |
@@ -457,9 +457,9 @@ discard block |
||
457 | 457 | if ($this->grid->hasSort($this->key)) { |
458 | 458 | $sort = $this->grid->hasSortDescending() ? ' - ' : ' + '; |
459 | 459 | } |
460 | - $sortParam = $this->grid->hasSortDescending() ? $this->key : '-' . $this->key; |
|
460 | + $sortParam = $this->grid->hasSortDescending() ? $this->key : '-'.$this->key; |
|
461 | 461 | $url = neon()->getUrlManager()->createUrl([\Yii::$app->controller->getRoute(), $this->grid->id => ['sort' => $sortParam]]); |
462 | - return Html::a($this->getTitle() . $sort, $url, ['data-sort'=>$sortParam]); |
|
462 | + return Html::a($this->getTitle().$sort, $url, ['data-sort'=>$sortParam]); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | /** |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | public function getFilterField() |
514 | 514 | { |
515 | 515 | $field = $this->getBaseFilterField(); |
516 | - foreach($this->filterFieldConfig as $key => $value) |
|
516 | + foreach ($this->filterFieldConfig as $key => $value) |
|
517 | 517 | $field[$key] = $value; |
518 | 518 | return $field; |
519 | 519 | } |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | |
530 | 530 | public function setMemberConfig($config) |
531 | 531 | { |
532 | - foreach($config as $key => $value) { |
|
532 | + foreach ($config as $key => $value) { |
|
533 | 533 | if (isset($this->member->$key)) |
534 | 534 | $this->member->$key = $value; |
535 | 535 | } |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | /** |
540 | 540 | * @inheritDoc |
541 | 541 | */ |
542 | - public function getCellData($row, $noValue='-') |
|
542 | + public function getCellData($row, $noValue = '-') |
|
543 | 543 | { |
544 | 544 | $data = null; |
545 | 545 | $key = $this->getKey(); |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | */ |
604 | 604 | public function getFieldName() |
605 | 605 | { |
606 | - return $this->getGrid()->getId() . '[' . $this->key . '][search]'; |
|
606 | + return $this->getGrid()->getId().'['.$this->key.'][search]'; |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | /** |
@@ -677,12 +677,12 @@ discard block |
||
677 | 677 | throw new \Exception('Unable to call a valid search function'); |
678 | 678 | } |
679 | 679 | |
680 | - protected $_actions =[]; |
|
680 | + protected $_actions = []; |
|
681 | 681 | |
682 | 682 | /** |
683 | 683 | * @inheritDoc |
684 | 684 | */ |
685 | - public function addRowAction($key, $text, $linkOptions=[]) |
|
685 | + public function addRowAction($key, $text, $linkOptions = []) |
|
686 | 686 | { |
687 | 687 | $linkOptions['text'] = $text; |
688 | 688 | $linkOptions['data-action'] = $key; |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | } |
709 | 709 | $out = '<div class="neonGrid_rowActions">'; |
710 | 710 | $i = 0; |
711 | - foreach($this->_actions as $actionKey => $linkOptions) { |
|
711 | + foreach ($this->_actions as $actionKey => $linkOptions) { |
|
712 | 712 | if ($i > 0) $out .= ' | '; |
713 | 713 | if (isset($linkOptions['function'])) { |
714 | 714 | $func = $linkOptions['function']; |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | * @param array $arguments of arguments |
736 | 736 | * @return mixed |
737 | 737 | */ |
738 | - public function callFunction($function, $arguments=[]) |
|
738 | + public function callFunction($function, $arguments = []) |
|
739 | 739 | { |
740 | 740 | if (is_string($function)) { |
741 | 741 | return call_user_func_array([$this->grid, $function], $arguments); |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | if (count($columnData)) { |
761 | 761 | $this->member->dataMapFilters = ['uuid' => $columnData]; |
762 | 762 | } |
763 | - foreach($models as $model) { |
|
763 | + foreach ($models as $model) { |
|
764 | 764 | $this->member->makeMapRequest($this->getCellData($model, null)); |
765 | 765 | } |
766 | 766 | } |
@@ -105,8 +105,9 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function getEmptyCellDisplay() |
107 | 107 | { |
108 | - if ($this->_emptyCellDisplay !== null) |
|
109 | - return $this->_emptyCellDisplay; |
|
108 | + if ($this->_emptyCellDisplay !== null) { |
|
109 | + return $this->_emptyCellDisplay; |
|
110 | + } |
|
110 | 111 | return $this->getGrid()->emptyCellDisplay; |
111 | 112 | } |
112 | 113 | |
@@ -437,10 +438,12 @@ discard block |
||
437 | 438 | public function renderHeaderCell() |
438 | 439 | { |
439 | 440 | $options = $this->getHeaderCellAttributes(); |
440 | - if ($this->grid->hasSort($this->key)) |
|
441 | - Html::addCssClass($options, ($this->grid->hasSortDescending() ? 'desc' : 'asc')); |
|
442 | - if (trim($this->width) != '') |
|
443 | - Html::addCssStyle($options, ["width" => $this->width]); |
|
441 | + if ($this->grid->hasSort($this->key)) { |
|
442 | + Html::addCssClass($options, ($this->grid->hasSortDescending() ? 'desc' : 'asc')); |
|
443 | + } |
|
444 | + if (trim($this->width) != '') { |
|
445 | + Html::addCssStyle($options, ["width" => $this->width]); |
|
446 | + } |
|
444 | 447 | Html::addCssStyle($options, $this->_style); |
445 | 448 | |
446 | 449 | return Html::tag('th', $this->renderHeaderCellContent(), $options); |
@@ -451,8 +454,9 @@ discard block |
||
451 | 454 | */ |
452 | 455 | public function renderHeaderCellContent() |
453 | 456 | { |
454 | - if (!$this->isSortable()) |
|
455 | - return $this->getTitle(); |
|
457 | + if (!$this->isSortable()) { |
|
458 | + return $this->getTitle(); |
|
459 | + } |
|
456 | 460 | $sort = ''; |
457 | 461 | if ($this->grid->hasSort($this->key)) { |
458 | 462 | $sort = $this->grid->hasSortDescending() ? ' - ' : ' + '; |
@@ -482,10 +486,12 @@ discard block |
||
482 | 486 | */ |
483 | 487 | public function renderFilterCellContent() |
484 | 488 | { |
485 | - if ($this->filter === false) |
|
486 | - return ''; |
|
487 | - if (!$this->getGrid()->getFilterForm()->hasField($this->getKey())) |
|
488 | - return ''; |
|
489 | + if ($this->filter === false) { |
|
490 | + return ''; |
|
491 | + } |
|
492 | + if (!$this->getGrid()->getFilterForm()->hasField($this->getKey())) { |
|
493 | + return ''; |
|
494 | + } |
|
489 | 495 | $field = $this->getGrid()->getFilterForm()->getField($this->getKey()); |
490 | 496 | // remove any automatic validators |
491 | 497 | $field->setValidators([], true); |
@@ -513,8 +519,9 @@ discard block |
||
513 | 519 | public function getFilterField() |
514 | 520 | { |
515 | 521 | $field = $this->getBaseFilterField(); |
516 | - foreach($this->filterFieldConfig as $key => $value) |
|
517 | - $field[$key] = $value; |
|
522 | + foreach($this->filterFieldConfig as $key => $value) { |
|
523 | + $field[$key] = $value; |
|
524 | + } |
|
518 | 525 | return $field; |
519 | 526 | } |
520 | 527 | |
@@ -530,8 +537,9 @@ discard block |
||
530 | 537 | public function setMemberConfig($config) |
531 | 538 | { |
532 | 539 | foreach($config as $key => $value) { |
533 | - if (isset($this->member->$key)) |
|
534 | - $this->member->$key = $value; |
|
540 | + if (isset($this->member->$key)) { |
|
541 | + $this->member->$key = $value; |
|
542 | + } |
|
535 | 543 | } |
536 | 544 | return $this; |
537 | 545 | } |
@@ -709,7 +717,9 @@ discard block |
||
709 | 717 | $out = '<div class="neonGrid_rowActions">'; |
710 | 718 | $i = 0; |
711 | 719 | foreach($this->_actions as $actionKey => $linkOptions) { |
712 | - if ($i > 0) $out .= ' | '; |
|
720 | + if ($i > 0) { |
|
721 | + $out .= ' | '; |
|
722 | + } |
|
713 | 723 | if (isset($linkOptions['function'])) { |
714 | 724 | $func = $linkOptions['function']; |
715 | 725 | $out .= $this->callFunction($func, [$model, $key, $index]); |
@@ -17,7 +17,7 @@ |
||
17 | 17 | */ |
18 | 18 | class GridAssets extends AssetBundle |
19 | 19 | { |
20 | - public $sourcePath = __DIR__ . '/assets'; |
|
20 | + public $sourcePath = __DIR__.'/assets'; |
|
21 | 21 | |
22 | 22 | public $js = [ |
23 | 23 | (YII_DEBUG ? 'neon-grid.js' : 'neon-grid.build.js'), |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @param string $name |
376 | 376 | * @param callable $function |
377 | 377 | */ |
378 | - public function addScope($key, $name, $function=null) |
|
378 | + public function addScope($key, $name, $function = null) |
|
379 | 379 | { |
380 | 380 | $this->_scopes[$key] = compact('key', 'name', 'function'); |
381 | 381 | } |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | $this->_filterForm = (new Form($this->getId())) |
439 | 439 | ->setId($this->getId().'Filter') |
440 | 440 | ->addSubForm('filter'); |
441 | - foreach($this->getColumns() as $key => $column) { |
|
441 | + foreach ($this->getColumns() as $key => $column) { |
|
442 | 442 | if ($column->getFilter() && $column->getFilterField() !== false) { |
443 | 443 | $field = $column->getFilterField(); |
444 | 444 | if (is_object($field)) |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | */ |
549 | 549 | public function setColumns($columns) |
550 | 550 | { |
551 | - foreach($columns as $key => $config) { |
|
551 | + foreach ($columns as $key => $config) { |
|
552 | 552 | $this->addColumn($key, $config); |
553 | 553 | } |
554 | 554 | } |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | * @throws \Exception on incorrect column config |
562 | 562 | * @return \neon\core\grid\column\Text |
563 | 563 | */ |
564 | - public function addTextColumn($key, $config=[]) |
|
564 | + public function addTextColumn($key, $config = []) |
|
565 | 565 | { |
566 | 566 | $config['class'] = isset($config['class']) ? $config['class'] : 'neon\core\grid\column\Text'; |
567 | 567 | return $this->addColumn($key, $config); |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * @throws \Exception on incorrect column config |
576 | 576 | * @return \neon\core\grid\column\Date |
577 | 577 | */ |
578 | - public function addDateColumn($key, $config=[]) |
|
578 | + public function addDateColumn($key, $config = []) |
|
579 | 579 | { |
580 | 580 | $config['class'] = isset($config['class']) ? $config['class'] : 'neon\core\grid\column\Date'; |
581 | 581 | return $this->addColumn($key, $config); |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | * @throws \Exception on incorrect column config |
590 | 590 | * @return \neon\core\grid\column\IntColumn |
591 | 591 | */ |
592 | - public function addIntColumn($key, $config=[]) |
|
592 | + public function addIntColumn($key, $config = []) |
|
593 | 593 | { |
594 | 594 | $config['class'] = isset($config['class']) ? $config['class'] : 'neon\core\grid\column\IntColumn'; |
595 | 595 | return $this->addColumn($key, $config); |
@@ -603,9 +603,9 @@ discard block |
||
603 | 603 | * @return \neon\core\grid\column\Check |
604 | 604 | * @throws \Exception |
605 | 605 | */ |
606 | - public function addCheckColumn($key, $config=[]) |
|
606 | + public function addCheckColumn($key, $config = []) |
|
607 | 607 | { |
608 | - $config['class'] = isset($config['class']) ? $config['class'] : 'neon\core\grid\column\Check'; |
|
608 | + $config['class'] = isset($config['class']) ? $config['class'] : 'neon\core\grid\column\Check'; |
|
609 | 609 | return $this->addColumn($key, $config); |
610 | 610 | } |
611 | 611 | |
@@ -617,9 +617,9 @@ discard block |
||
617 | 617 | * @throws \Exception on incorrect column config |
618 | 618 | * @return \neon\core\grid\column\Button |
619 | 619 | */ |
620 | - public function addButtonColumn($key, $config=[]) |
|
620 | + public function addButtonColumn($key, $config = []) |
|
621 | 621 | { |
622 | - $config['class'] = isset($config['class']) ? $config['class'] : 'neon\core\grid\column\Button'; |
|
622 | + $config['class'] = isset($config['class']) ? $config['class'] : 'neon\core\grid\column\Button'; |
|
623 | 623 | return $this->addColumn($key, $config); |
624 | 624 | } |
625 | 625 | |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * @throws \Exception |
635 | 635 | * @return Column |
636 | 636 | */ |
637 | - public function addColumnFromDefinition($key, $class, $member=null, $phoebeType='daedalus') |
|
637 | + public function addColumnFromDefinition($key, $class, $member = null, $phoebeType = 'daedalus') |
|
638 | 638 | { |
639 | - static $formsDefinitionCache=[]; |
|
639 | + static $formsDefinitionCache = []; |
|
640 | 640 | $cacheKey = $class.$phoebeType; |
641 | 641 | if (!array_key_exists($cacheKey, $formsDefinitionCache)) { |
642 | 642 | $formDefinition = neon('phoebe')->getFormDefinition($phoebeType, $class); |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | * @return \neon\core\grid\column\Column |
684 | 684 | * @throws \Exception if no `$config['class']` is set |
685 | 685 | */ |
686 | - public function addColumn($key, $config=[]) |
|
686 | + public function addColumn($key, $config = []) |
|
687 | 687 | { |
688 | 688 | if (!isset($config['class'])) { |
689 | 689 | // 99% of the time you just want the standard Column class |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | */ |
746 | 746 | public function hasData() |
747 | 747 | { |
748 | - return ! empty($this->_gridData); |
|
748 | + return !empty($this->_gridData); |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | /** |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | */ |
781 | 781 | public function gridBoot() |
782 | 782 | { |
783 | - if (! $this->hasData()) |
|
783 | + if (!$this->hasData()) |
|
784 | 784 | $this->_gridData = Arr::get($_REQUEST, $this->id, null); |
785 | 785 | // load the active scope |
786 | 786 | $this->_scope = Arr::get($this->_gridData, "scope", []); |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | * and true if you want the data returned as an array |
816 | 816 | * @return string | array depending on value of $asRows |
817 | 817 | */ |
818 | - public function exportCsv($page=0, $pageSize=1000, $asRows=false) |
|
818 | + public function exportCsv($page = 0, $pageSize = 1000, $asRows = false) |
|
819 | 819 | { |
820 | 820 | // check we're allowed to do this |
821 | 821 | if (!$this->canExportCsv) |
@@ -838,14 +838,14 @@ discard block |
||
838 | 838 | // Render the rows |
839 | 839 | $dataProvider = $this->getDataProvider(); |
840 | 840 | $pagination = $dataProvider->pagination; |
841 | - $pagination->page=$page; |
|
842 | - $pagination->pageSize = min(1000,$pageSize); |
|
841 | + $pagination->page = $page; |
|
842 | + $pagination->pageSize = min(1000, $pageSize); |
|
843 | 843 | $models = $dataProvider->getModels(); |
844 | 844 | if (empty($models)) |
845 | 845 | return null; |
846 | 846 | |
847 | 847 | $rows = []; |
848 | - foreach($models as $index => $row) { |
|
848 | + foreach ($models as $index => $row) { |
|
849 | 849 | $singleRow = []; |
850 | 850 | // use the columns set as not all columns exists in row data e.g. derived ones |
851 | 851 | foreach ($columns as $colKey => $column) { |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | $dataProvider->models = null; |
859 | 859 | |
860 | 860 | // Add headers columns as the first row if we are on the first page |
861 | - if ($page==0) |
|
861 | + if ($page == 0) |
|
862 | 862 | array_unshift($rows, implode(',', $headerCols)); |
863 | 863 | |
864 | 864 | return $asRows ? $rows : implode("\n", $rows); |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | public function callScope($scope, IQuery $query) |
1067 | 1067 | { |
1068 | 1068 | if ($scope['function'] == null) { |
1069 | - $func = 'scope' . ucfirst($scope['key']); |
|
1069 | + $func = 'scope'.ucfirst($scope['key']); |
|
1070 | 1070 | if ($this->hasMethod($func, false)) { |
1071 | 1071 | call_user_func(array($this, $func), $query); |
1072 | 1072 | } else { |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | public function getColumnsVisible() |
1133 | 1133 | { |
1134 | 1134 | $columns = []; |
1135 | - foreach($this->getColumns() as $key => $column) { |
|
1135 | + foreach ($this->getColumns() as $key => $column) { |
|
1136 | 1136 | if ($column->visible) |
1137 | 1137 | $columns[$key] = $column; |
1138 | 1138 | } |
@@ -1219,8 +1219,8 @@ discard block |
||
1219 | 1219 | { |
1220 | 1220 | $tags = []; |
1221 | 1221 | foreach ($row as $key => $val) { |
1222 | - if (!is_array($val)){ |
|
1223 | - $tags['{{' . $key . '}}'] = $val; |
|
1222 | + if (!is_array($val)) { |
|
1223 | + $tags['{{'.$key.'}}'] = $val; |
|
1224 | 1224 | } |
1225 | 1225 | } |
1226 | 1226 | return $tags; |
@@ -311,8 +311,9 @@ discard block |
||
311 | 311 | return $scope['key']; |
312 | 312 | } |
313 | 313 | // No url request scope defined check if a default is set |
314 | - if ($this->defaultScope !== null) |
|
315 | - return $this->defaultScope; |
|
314 | + if ($this->defaultScope !== null) { |
|
315 | + return $this->defaultScope; |
|
316 | + } |
|
316 | 317 | |
317 | 318 | // No default scope so return the first in the list as the default |
318 | 319 | $defaultScope = reset($this->_scopes); |
@@ -441,8 +442,9 @@ discard block |
||
441 | 442 | foreach($this->getColumns() as $key => $column) { |
442 | 443 | if ($column->getFilter() && $column->getFilterField() !== false) { |
443 | 444 | $field = $column->getFilterField(); |
444 | - if (is_object($field)) |
|
445 | - $field = $field->toArray(); |
|
445 | + if (is_object($field)) { |
|
446 | + $field = $field->toArray(); |
|
447 | + } |
|
446 | 448 | $field['name'] = $key; |
447 | 449 | $field['dataKey'] = $column->getDbField(); |
448 | 450 | $this->_filterForm->add($field); |
@@ -643,8 +645,9 @@ discard block |
||
643 | 645 | $formsDefinitionCache[$cacheKey] = $formDefinition; |
644 | 646 | } |
645 | 647 | $form = new \neon\core\form\Form($formsDefinitionCache[$cacheKey]); |
646 | - if ($member === null) |
|
647 | - $member = $key; |
|
648 | + if ($member === null) { |
|
649 | + $member = $key; |
|
650 | + } |
|
648 | 651 | return $this->addColumn($key, [ |
649 | 652 | 'title' => $form->getField($member)->getLabel(), |
650 | 653 | 'class' => 'neon\core\grid\column\Column', |
@@ -706,8 +709,9 @@ discard block |
||
706 | 709 | */ |
707 | 710 | public function removeColumn($key) |
708 | 711 | { |
709 | - if ($this->columnExists($key)) |
|
710 | - unset($this->_columns[$key]); |
|
712 | + if ($this->columnExists($key)) { |
|
713 | + unset($this->_columns[$key]); |
|
714 | + } |
|
711 | 715 | } |
712 | 716 | |
713 | 717 | /** |
@@ -754,8 +758,9 @@ discard block |
||
754 | 758 | */ |
755 | 759 | public function refreshDataProvider() |
756 | 760 | { |
757 | - if ($this->_dataProvider) |
|
758 | - $this->_dataProvider = clone $this->getDataProvider(); |
|
761 | + if ($this->_dataProvider) { |
|
762 | + $this->_dataProvider = clone $this->getDataProvider(); |
|
763 | + } |
|
759 | 764 | } |
760 | 765 | |
761 | 766 | /** |
@@ -780,8 +785,9 @@ discard block |
||
780 | 785 | */ |
781 | 786 | public function gridBoot() |
782 | 787 | { |
783 | - if (! $this->hasData()) |
|
784 | - $this->_gridData = Arr::get($_REQUEST, $this->id, null); |
|
788 | + if (! $this->hasData()) { |
|
789 | + $this->_gridData = Arr::get($_REQUEST, $this->id, null); |
|
790 | + } |
|
785 | 791 | // load the active scope |
786 | 792 | $this->_scope = Arr::get($this->_gridData, "scope", []); |
787 | 793 | // load request data into the form |
@@ -818,8 +824,9 @@ discard block |
||
818 | 824 | public function exportCsv($page=0, $pageSize=1000, $asRows=false) |
819 | 825 | { |
820 | 826 | // check we're allowed to do this |
821 | - if (!$this->canExportCsv) |
|
822 | - return null; |
|
827 | + if (!$this->canExportCsv) { |
|
828 | + return null; |
|
829 | + } |
|
823 | 830 | |
824 | 831 | $this->gridBoot(); |
825 | 832 | // Get header column names |
@@ -841,8 +848,9 @@ discard block |
||
841 | 848 | $pagination->page=$page; |
842 | 849 | $pagination->pageSize = min(1000,$pageSize); |
843 | 850 | $models = $dataProvider->getModels(); |
844 | - if (empty($models)) |
|
845 | - return null; |
|
851 | + if (empty($models)) { |
|
852 | + return null; |
|
853 | + } |
|
846 | 854 | |
847 | 855 | $rows = []; |
848 | 856 | foreach($models as $index => $row) { |
@@ -858,8 +866,9 @@ discard block |
||
858 | 866 | $dataProvider->models = null; |
859 | 867 | |
860 | 868 | // Add headers columns as the first row if we are on the first page |
861 | - if ($page==0) |
|
862 | - array_unshift($rows, implode(',', $headerCols)); |
|
869 | + if ($page==0) { |
|
870 | + array_unshift($rows, implode(',', $headerCols)); |
|
871 | + } |
|
863 | 872 | |
864 | 873 | return $asRows ? $rows : implode("\n", $rows); |
865 | 874 | } |
@@ -956,8 +965,9 @@ discard block |
||
956 | 965 | public function processSearch() |
957 | 966 | { |
958 | 967 | $data = $this->getGridData(); |
959 | - if (!isset($data['filter'])) |
|
960 | - return; |
|
968 | + if (!isset($data['filter'])) { |
|
969 | + return; |
|
970 | + } |
|
961 | 971 | foreach ($this->getColumns() as $key => $column) { |
962 | 972 | // check there is a form filter field |
963 | 973 | // check that the filter field has request data |
@@ -1041,8 +1051,9 @@ discard block |
||
1041 | 1051 | */ |
1042 | 1052 | public function getColumn($columnKey) |
1043 | 1053 | { |
1044 | - if (!isset($this->_columns[$columnKey])) |
|
1045 | - throw new \Exception("No column with key '$columnKey' exists in the grid"); |
|
1054 | + if (!isset($this->_columns[$columnKey])) { |
|
1055 | + throw new \Exception("No column with key '$columnKey' exists in the grid"); |
|
1056 | + } |
|
1046 | 1057 | return $this->_columns[$columnKey]; |
1047 | 1058 | } |
1048 | 1059 | |
@@ -1133,8 +1144,9 @@ discard block |
||
1133 | 1144 | { |
1134 | 1145 | $columns = []; |
1135 | 1146 | foreach($this->getColumns() as $key => $column) { |
1136 | - if ($column->visible) |
|
1137 | - $columns[$key] = $column; |
|
1147 | + if ($column->visible) { |
|
1148 | + $columns[$key] = $column; |
|
1149 | + } |
|
1138 | 1150 | } |
1139 | 1151 | return $columns; |
1140 | 1152 | } |
@@ -1179,8 +1191,9 @@ discard block |
||
1179 | 1191 | */ |
1180 | 1192 | public function getIndexColumn() |
1181 | 1193 | { |
1182 | - if (!isset($this->_columns[$this->_indexedByColumn])) |
|
1183 | - throw new \Exception("No index column exists with key '$this->_indexedByColumn'."); |
|
1194 | + if (!isset($this->_columns[$this->_indexedByColumn])) { |
|
1195 | + throw new \Exception("No index column exists with key '$this->_indexedByColumn'."); |
|
1196 | + } |
|
1184 | 1197 | return $this->_columns[$this->_indexedByColumn]; |
1185 | 1198 | } |
1186 | 1199 | |
@@ -1242,8 +1255,9 @@ discard block |
||
1242 | 1255 | $plain = html_entity_decode( |
1243 | 1256 | str_replace(["\n", '"'], ['', '\''], strip_tags($content)), |
1244 | 1257 | ENT_HTML401 | ENT_QUOTES | ENT_HTML5); |
1245 | - if ($plain === $this->emptyCellDisplay) |
|
1246 | - $plain = ''; |
|
1258 | + if ($plain === $this->emptyCellDisplay) { |
|
1259 | + $plain = ''; |
|
1260 | + } |
|
1247 | 1261 | return '"'.$plain.'"'; |
1248 | 1262 | } |
1249 | 1263 | } |
1250 | 1264 | \ No newline at end of file |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - $limit = [ |
|
76 | + $limit = [ |
|
77 | 77 | 'start' => $pagination->getOffset(), |
78 | 78 | 'length' => $pagination->getLimit(), |
79 | 79 | 'total' => $pagination->totalCount |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * Store a total count to save multiple recalculations |
124 | 124 | * @var type |
125 | 125 | */ |
126 | - private $_totalCountCache=[]; |
|
126 | + private $_totalCountCache = []; |
|
127 | 127 | |
128 | 128 | /** |
129 | 129 | * @inheritDoc |
@@ -45,8 +45,9 @@ |
||
45 | 45 | public function __clone() |
46 | 46 | { |
47 | 47 | parent::__clone(); |
48 | - if ($this->_queryBuilder) |
|
49 | - $this->_queryBuilder = clone $this->_queryBuilder; |
|
48 | + if ($this->_queryBuilder) { |
|
49 | + $this->_queryBuilder = clone $this->_queryBuilder; |
|
50 | + } |
|
50 | 51 | } |
51 | 52 | |
52 | 53 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function getViewPath() |
88 | 88 | { |
89 | - return __DIR__ . DIRECTORY_SEPARATOR . 'views'; |
|
89 | + return __DIR__.DIRECTORY_SEPARATOR.'views'; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | $out = '<tr>'; |
115 | - foreach($this->_grid->getColumnGroups() as $groupLabel => $details) { |
|
115 | + foreach ($this->_grid->getColumnGroups() as $groupLabel => $details) { |
|
116 | 116 | $colspan = count($details['columns']); |
117 | 117 | $out .= "<td colspan='$colspan'>$groupLabel</td>"; |
118 | 118 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | $pagination = $this->_grid->getDataProvider()->getPagination(); |
134 | 134 | $filters = []; |
135 | - foreach($this->_grid->getFilterForm()->getFields() as $field) { |
|
135 | + foreach ($this->_grid->getFilterForm()->getFields() as $field) { |
|
136 | 136 | if (!empty($field->getValue())) |
137 | 137 | $filters[$field->getInputName()] = $field->getValue(); |
138 | 138 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | { |
161 | 161 | $models = array_values($this->_grid->getDataProvider()->getModels()); |
162 | 162 | $out = ''; |
163 | - foreach($models as $index => $row) { |
|
163 | + foreach ($models as $index => $row) { |
|
164 | 164 | $out .= $this->renderRow($row); |
165 | 165 | } |
166 | 166 | return $out; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | $first = true; |
202 | 202 | $filtersHTML = ''; |
203 | - foreach($this->_grid->getScopes() as $link => $scope) { |
|
203 | + foreach ($this->_grid->getScopes() as $link => $scope) { |
|
204 | 204 | |
205 | 205 | $count = $this->_grid->getScopeTotalCount($link); |
206 | 206 | $current = ''; |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $page = $pagination->getPage() + 1; |
250 | 250 | $pageCount = $pagination->pageCount; |
251 | 251 | $tagMessage = ' <b>{begin, number}-{end, number}</b> of <b>{totalCount, number}</b> {totalCount, plural, one{item} other{items}}.'; |
252 | - return Html::tag($tag, \Yii::t('yii', $tagMessage, [ |
|
252 | + return Html::tag($tag, \Yii::t('yii', $tagMessage, [ |
|
253 | 253 | 'begin' => $begin, |
254 | 254 | 'end' => $end, |
255 | 255 | 'count' => $count, |
@@ -133,13 +133,15 @@ |
||
133 | 133 | $pagination = $this->_grid->getDataProvider()->getPagination(); |
134 | 134 | $filters = []; |
135 | 135 | foreach($this->_grid->getFilterForm()->getFields() as $field) { |
136 | - if (!empty($field->getValue())) |
|
137 | - $filters[$field->getInputName()] = $field->getValue(); |
|
136 | + if (!empty($field->getValue())) { |
|
137 | + $filters[$field->getInputName()] = $field->getValue(); |
|
138 | + } |
|
138 | 139 | } |
139 | 140 | $queryParams = neon()->request->queryParams; |
140 | 141 | // remove any pre existing grid specific filters from the url - we don't want to add them twice |
141 | - if (isset($queryParams[$this->_grid->gridName()])) |
|
142 | - unset($queryParams[$this->_grid->gridName()]); |
|
142 | + if (isset($queryParams[$this->_grid->gridName()])) { |
|
143 | + unset($queryParams[$this->_grid->gridName()]); |
|
144 | + } |
|
143 | 145 | // gross - we need to remove any pre existing filters from the query params |
144 | 146 | $pagination->params = $queryParams + $filters; |
145 | 147 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * e.g. 'data' and 'deleted'. Set during construction via config. |
43 | 43 | * @var array |
44 | 44 | */ |
45 | - public $additionalColumns=[]; |
|
45 | + public $additionalColumns = []; |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Default page size |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | |
71 | - public function __construct($config=[]) |
|
71 | + public function __construct($config = []) |
|
72 | 72 | { |
73 | 73 | if (empty($config['phoebeType']) || empty($config['classType'])) { |
74 | 74 | throw new \RuntimeException('You need to provide at least the phoebeType and classType on construction'); |
@@ -124,8 +124,9 @@ |
||
124 | 124 | */ |
125 | 125 | public function getDataProvider() |
126 | 126 | { |
127 | - if (!$this->_dataProvider) |
|
128 | - throw new \RuntimeException('You need to call phoebeLoadGrid before the grid can be used'); |
|
127 | + if (!$this->_dataProvider) { |
|
128 | + throw new \RuntimeException('You need to call phoebeLoadGrid before the grid can be used'); |
|
129 | + } |
|
129 | 130 | return $this->_dataProvider; |
130 | 131 | } |
131 | 132 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @inheritDoc |
24 | 24 | */ |
25 | - public function where($column, $operator=null, $value=null) |
|
25 | + public function where($column, $operator = null, $value = null) |
|
26 | 26 | { |
27 | 27 | // If the column is an array, we will assume it is an array of key-value pairs |
28 | 28 | // and can add them each as a where clause. We will maintain the boolean we |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | if (is_array($column)) { |
31 | 31 | return $this->addArrayOfWheres($column); |
32 | 32 | } |
33 | - if ($operator==='=') |
|
33 | + if ($operator === '=') |
|
34 | 34 | $this->_activeQuery->andWhere([$column => $value]); |
35 | 35 | else |
36 | 36 | $this->_activeQuery->andWhere([$operator, $column, $value]); |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @inheritDoc |
42 | 42 | */ |
43 | - public function addOrderBy($column, $order='DESC') |
|
43 | + public function addOrderBy($column, $order = 'DESC') |
|
44 | 44 | { |
45 | - $this->_activeQuery->addOrderBy([$column => ($order=='DESC') ? SORT_DESC : SORT_ASC]); |
|
45 | + $this->_activeQuery->addOrderBy([$column => ($order == 'DESC') ? SORT_DESC : SORT_ASC]); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @inheritDoc |
50 | 50 | */ |
51 | - public function orderBy($column, $order='DESC') |
|
51 | + public function orderBy($column, $order = 'DESC') |
|
52 | 52 | { |
53 | - $this->_activeQuery->orderBy([$column => ($order=='DESC') ? SORT_DESC : SORT_ASC]); |
|
53 | + $this->_activeQuery->orderBy([$column => ($order == 'DESC') ? SORT_DESC : SORT_ASC]); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -30,10 +30,11 @@ |
||
30 | 30 | if (is_array($column)) { |
31 | 31 | return $this->addArrayOfWheres($column); |
32 | 32 | } |
33 | - if ($operator==='=') |
|
34 | - $this->_activeQuery->andWhere([$column => $value]); |
|
35 | - else |
|
36 | - $this->_activeQuery->andWhere([$operator, $column, $value]); |
|
33 | + if ($operator==='=') { |
|
34 | + $this->_activeQuery->andWhere([$column => $value]); |
|
35 | + } else { |
|
36 | + $this->_activeQuery->andWhere([$operator, $column, $value]); |
|
37 | + } |
|
37 | 38 | return $this; |
38 | 39 | } |
39 | 40 |