@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | /** |
| 233 | 233 | * Add the edit and delete DDS object buttons to the grid |
| 234 | 234 | */ |
| 235 | - public function addActionButtonColumn($title=false) |
|
| 235 | + public function addActionButtonColumn($title = false) |
|
| 236 | 236 | { |
| 237 | 237 | $buttonCol = $this->addButtonColumn('edit')->setTitle($title); |
| 238 | 238 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | |
| 247 | 247 | if ($this->hasScope('deleted') && $this->isScopeActive('deleted')) { |
| 248 | 248 | if ($this->showGridUndeleteButton) { |
| 249 | - $buttonCol->addButton('undelete', '','', 'fa fa-undo', 'btn-default', [ |
|
| 249 | + $buttonCol->addButton('undelete', '', '', 'fa fa-undo', 'btn-default', [ |
|
| 250 | 250 | 'data-toggle' => 'tooltip', |
| 251 | 251 | 'title' => 'Restore', |
| 252 | 252 | 'data-action' => 'actionUndelete' |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | * Load appropriate columns based on DDS details |
| 378 | 378 | * @deprecated - just set the classType - either in the init or the config |
| 379 | 379 | */ |
| 380 | - public function ddsLoadGrid($classType, $includeDeleted=false, $pageSize=50) |
|
| 380 | + public function ddsLoadGrid($classType, $includeDeleted = false, $pageSize = 50) |
|
| 381 | 381 | { |
| 382 | 382 | if ($this->title == null) |
| 383 | 383 | $this->title = $classType; |
@@ -148,8 +148,9 @@ discard block |
||
| 148 | 148 | { |
| 149 | 149 | $this->_classType = $value; |
| 150 | 150 | // Set a default title |
| 151 | - if ($this->title === null) |
|
| 152 | - $this->title = $this->_classType; |
|
| 151 | + if ($this->title === null) { |
|
| 152 | + $this->title = $this->_classType; |
|
| 153 | + } |
|
| 153 | 154 | } |
| 154 | 155 | |
| 155 | 156 | /** |
@@ -191,18 +192,21 @@ discard block |
||
| 191 | 192 | parent::init(); |
| 192 | 193 | // don't configure the grid if the class type has not been set! |
| 193 | 194 | if ($this->_classType === null) { |
| 194 | - if (neon()->debug) |
|
| 195 | - throw new \RuntimeException('You need to configure the grid class type before calling init'); |
|
| 195 | + if (neon()->debug) { |
|
| 196 | + throw new \RuntimeException('You need to configure the grid class type before calling init'); |
|
| 197 | + } |
|
| 196 | 198 | return null; |
| 197 | 199 | } |
| 198 | 200 | |
| 199 | 201 | $this->addColumnsFromClassMembers(); |
| 200 | 202 | $this->addDdsObjectColumns(); |
| 201 | 203 | |
| 202 | - if ($this->useActiveScope) |
|
| 203 | - $this->addScope('active', 'Active'); |
|
| 204 | - if ($this->useDeletedScope) |
|
| 205 | - $this->addScope('deleted', 'Deleted'); |
|
| 204 | + if ($this->useActiveScope) { |
|
| 205 | + $this->addScope('active', 'Active'); |
|
| 206 | + } |
|
| 207 | + if ($this->useDeletedScope) { |
|
| 208 | + $this->addScope('deleted', 'Deleted'); |
|
| 209 | + } |
|
| 206 | 210 | |
| 207 | 211 | } |
| 208 | 212 | |
@@ -369,8 +373,9 @@ discard block |
||
| 369 | 373 | 'class' => 'neon\core\grid\column\DefinitionColumn', |
| 370 | 374 | 'member' => new $columnType($member), |
| 371 | 375 | ]; |
| 372 | - if (is_array($config)) |
|
| 373 | - $colConfig = array_merge($colConfig, $config); |
|
| 376 | + if (is_array($config)) { |
|
| 377 | + $colConfig = array_merge($colConfig, $config); |
|
| 378 | + } |
|
| 374 | 379 | return $this->addColumn($member, $colConfig); |
| 375 | 380 | } |
| 376 | 381 | |
@@ -380,8 +385,9 @@ discard block |
||
| 380 | 385 | */ |
| 381 | 386 | public function ddsLoadGrid($classType, $includeDeleted=false, $pageSize=50) |
| 382 | 387 | { |
| 383 | - if ($this->title == null) |
|
| 384 | - $this->title = $classType; |
|
| 388 | + if ($this->title == null) { |
|
| 389 | + $this->title = $classType; |
|
| 390 | + } |
|
| 385 | 391 | // TODO: should be in constructor can't create a DDS grid without the DDS class ref |
| 386 | 392 | $this->classType = $classType; |
| 387 | 393 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $paginator = [ |
|
| 64 | + $paginator = [ |
|
| 65 | 65 | 'start' => $pagination->getOffset(), |
| 66 | 66 | 'length' => $pagination->getLimit(), |
| 67 | 67 | 'total' => $pagination->totalCount |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $form = $this->getForm(); |
| 76 | 76 | |
| 77 | 77 | $data = []; |
| 78 | - foreach($results as $object) { |
|
| 78 | + foreach ($results as $object) { |
|
| 79 | 79 | $form->reset(); |
| 80 | 80 | $form->loadFromDb($object); |
| 81 | 81 | $data[] = array_merge($object, $form->getDataDisplay()); |
@@ -42,10 +42,12 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function init() |
| 44 | 44 | { |
| 45 | - if (empty($this->phoebeType)) |
|
| 46 | - throw new \RuntimeException('PhoebeDataProvider: the phoebe type has not been set. It needs to be set on construction'); |
|
| 47 | - if (empty($this->classType)) |
|
| 48 | - throw new \RuntimeException('PhoebeDataProvider: the phoebe class type has not been set. It needs to be set on construction'); |
|
| 45 | + if (empty($this->phoebeType)) { |
|
| 46 | + throw new \RuntimeException('PhoebeDataProvider: the phoebe type has not been set. It needs to be set on construction'); |
|
| 47 | + } |
|
| 48 | + if (empty($this->classType)) { |
|
| 49 | + throw new \RuntimeException('PhoebeDataProvider: the phoebe class type has not been set. It needs to be set on construction'); |
|
| 50 | + } |
|
| 49 | 51 | } |
| 50 | 52 | |
| 51 | 53 | /** |
@@ -142,8 +144,9 @@ discard block |
||
| 142 | 144 | */ |
| 143 | 145 | protected function getFormDefinition() |
| 144 | 146 | { |
| 145 | - if ($this->formDefinition == null) |
|
| 146 | - $this->formDefinition = neon('phoebe')->getFormDefinition($this->phoebeType, $this->classType); |
|
| 147 | + if ($this->formDefinition == null) { |
|
| 148 | + $this->formDefinition = neon('phoebe')->getFormDefinition($this->phoebeType, $this->classType); |
|
| 149 | + } |
|
| 147 | 150 | return $this->formDefinition; |
| 148 | 151 | } |
| 149 | 152 | |
@@ -40,7 +40,8 @@ |
||
| 40 | 40 | public function __clone() |
| 41 | 41 | { |
| 42 | 42 | parent::__clone(); |
| 43 | - if ($this->_queryBuilder) |
|
| 44 | - $this->_queryBuilder = clone $this->_queryBuilder; |
|
| 43 | + if ($this->_queryBuilder) { |
|
| 44 | + $this->_queryBuilder = clone $this->_queryBuilder; |
|
| 45 | + } |
|
| 45 | 46 | } |
| 46 | 47 | } |
| 47 | 48 | \ No newline at end of file |
@@ -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 | } |
@@ -935,8 +944,9 @@ discard block |
||
| 935 | 944 | { |
| 936 | 945 | foreach ($this->getScopes() as $key => $scope) { |
| 937 | 946 | // counts across whole tables are very very expensive. Don't count more than once |
| 938 | - if (isset($this->_scopeCounts[$key])) |
|
| 939 | - continue; |
|
| 947 | + if (isset($this->_scopeCounts[$key])) { |
|
| 948 | + continue; |
|
| 949 | + } |
|
| 940 | 950 | $dp = clone $this->getDataProvider(); |
| 941 | 951 | // call the scope function defined by `'scope'.$key` functions in child classes |
| 942 | 952 | $this->callScope($scope, $dp->getQueryBuilder()); |
@@ -964,8 +974,9 @@ discard block |
||
| 964 | 974 | public function processSearch() |
| 965 | 975 | { |
| 966 | 976 | $data = $this->getGridData(); |
| 967 | - if (!isset($data['filter'])) |
|
| 968 | - return; |
|
| 977 | + if (!isset($data['filter'])) { |
|
| 978 | + return; |
|
| 979 | + } |
|
| 969 | 980 | foreach ($this->getColumns() as $key => $column) { |
| 970 | 981 | // check there is a form filter field |
| 971 | 982 | // check that the filter field has request data |
@@ -1049,8 +1060,9 @@ discard block |
||
| 1049 | 1060 | */ |
| 1050 | 1061 | public function getColumn($columnKey) |
| 1051 | 1062 | { |
| 1052 | - if (!isset($this->_columns[$columnKey])) |
|
| 1053 | - throw new \Exception("No column with key '$columnKey' exists in the grid"); |
|
| 1063 | + if (!isset($this->_columns[$columnKey])) { |
|
| 1064 | + throw new \Exception("No column with key '$columnKey' exists in the grid"); |
|
| 1065 | + } |
|
| 1054 | 1066 | return $this->_columns[$columnKey]; |
| 1055 | 1067 | } |
| 1056 | 1068 | |
@@ -1141,8 +1153,9 @@ discard block |
||
| 1141 | 1153 | { |
| 1142 | 1154 | $columns = []; |
| 1143 | 1155 | foreach($this->getColumns() as $key => $column) { |
| 1144 | - if ($column->visible) |
|
| 1145 | - $columns[$key] = $column; |
|
| 1156 | + if ($column->visible) { |
|
| 1157 | + $columns[$key] = $column; |
|
| 1158 | + } |
|
| 1146 | 1159 | } |
| 1147 | 1160 | return $columns; |
| 1148 | 1161 | } |
@@ -1187,8 +1200,9 @@ discard block |
||
| 1187 | 1200 | */ |
| 1188 | 1201 | public function getIndexColumn() |
| 1189 | 1202 | { |
| 1190 | - if (!isset($this->_columns[$this->_indexedByColumn])) |
|
| 1191 | - throw new \Exception("No index column exists with key '$this->_indexedByColumn'."); |
|
| 1203 | + if (!isset($this->_columns[$this->_indexedByColumn])) { |
|
| 1204 | + throw new \Exception("No index column exists with key '$this->_indexedByColumn'."); |
|
| 1205 | + } |
|
| 1192 | 1206 | return $this->_columns[$this->_indexedByColumn]; |
| 1193 | 1207 | } |
| 1194 | 1208 | |
@@ -1250,8 +1264,9 @@ discard block |
||
| 1250 | 1264 | $plain = html_entity_decode( |
| 1251 | 1265 | str_replace(["\n", '"'], ['', '\''], strip_tags($content)), |
| 1252 | 1266 | ENT_HTML401 | ENT_QUOTES | ENT_HTML5); |
| 1253 | - if ($plain === $this->emptyCellDisplay) |
|
| 1254 | - $plain = ''; |
|
| 1267 | + if ($plain === $this->emptyCellDisplay) { |
|
| 1268 | + $plain = ''; |
|
| 1269 | + } |
|
| 1255 | 1270 | return '"'.$plain.'"'; |
| 1256 | 1271 | } |
| 1257 | 1272 | } |
@@ -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 | |
@@ -95,8 +95,8 @@ |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | - * @inheritDoc |
|
| 99 | - */ |
|
| 98 | + * @inheritDoc |
|
| 99 | + */ |
|
| 100 | 100 | public function having($column, $operator = null, $value = null) |
| 101 | 101 | { |
| 102 | 102 | throw new \Exception('Having clause is currently not supported by DDS - you need to be able to specify custom columns for a start'); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function addArrayOfWheres($columns) |
| 55 | 55 | { |
| 56 | - foreach($columns as $key => $value) { |
|
| 56 | + foreach ($columns as $key => $value) { |
|
| 57 | 57 | $this->_filters[] = [$key, '=', $value]; |
| 58 | 58 | } |
| 59 | 59 | return $this; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | /** |
| 63 | 63 | * @inheritDoc |
| 64 | 64 | */ |
| 65 | - public function addOrderBy($column, $order='DESC') |
|
| 65 | + public function addOrderBy($column, $order = 'DESC') |
|
| 66 | 66 | { |
| 67 | 67 | $this->_order[$column] = $order; |
| 68 | 68 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | /** |
| 71 | 71 | * @inheritDoc |
| 72 | 72 | */ |
| 73 | - public function orderBy($column, $order='DESC') |
|
| 73 | + public function orderBy($column, $order = 'DESC') |
|
| 74 | 74 | { |
| 75 | 75 | $this->_order[$column] = $order; |
| 76 | 76 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | /** |
| 106 | 106 | * @inheritDoc |
| 107 | 107 | */ |
| 108 | - public function orHaving($column, $operator=null, $value=null) |
|
| 108 | + public function orHaving($column, $operator = null, $value = null) |
|
| 109 | 109 | { |
| 110 | 110 | throw new \Exception('Having clause is currently not supported by DDS - you need to be able to specify custom columns for a start'); |
| 111 | 111 | } |