-
Notifications
You must be signed in to change notification settings - Fork 4
/
GridView.php
58 lines (52 loc) · 1.88 KB
/
GridView.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace nkovacs\pagesizer;
use yii\helpers\ArrayHelper;
class GridView extends \yii\grid\GridView
{
/**
* @var array the configuration for the page sizer widget. By default, [[LinkPageSizer]] will be
* used to render the page sizer. You can use a different widget class by configuring the "class" element.
*/
public $pageSizer = [];
/**
* @var string the layout that determines how different sections of the list view should be organized.
* The following tokens will be replaced with the corresponding section contents:
*
* - `{summary}`: the summary section. See [[renderSummary()]].
* - `{errors}`: the filter model error summary. See [[renderErrors()]].
* - `{items}`: the list items. See [[renderItems()]].
* - `{sorter}`: the sorter. See [[renderSorter()]].
* - `{pager}`: the pager. See [[renderPager()]].
* - `{pagesizer}`: the page sizer. See [[renderPagesizer()]].
*/
public $layout = "{summary}\n{items}\n{pager}\n{pagesizer}";
/**
* @inheritdoc
*/
public function renderSection($name)
{
switch ($name) {
case "{pagesizer}":
return $this->renderPagesizer();
default:
return parent::renderSection($name);
}
}
/**
* Renders the page sizer.
* @return string the rendering result
*/
public function renderPagesizer()
{
$pagination = $this->dataProvider->getPagination();
if ($pagination === false || $this->dataProvider->getCount() <= 0) {
return '';
}
/* @var $class LinkPageSizer */
$pageSizer = $this->pageSizer;
$class = ArrayHelper::remove($pageSizer, 'class', LinkPageSizer::className());
$pageSizer['pagination'] = $pagination;
$pageSizer['view'] = $this->getView();
return $class::widget($pageSizer);
}
}