/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/widgets/GridPageSize.php
73 строки
2 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\widgets; use yii\bootstrap\Html; /** * Выбор размера таблицы для отображения * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2020 */ class GridPageSize extends \yii\base\Widget { /** * @var integer */ public $defaultPageSize = 20; /** * @var string - GET param - size of the page */ public $pageSizeParam = 'per-page'; /** * @var array the list of page sizes */ public $sizes = [5, 10, 20, 50]; /** * @var array - options for the dropdown list */ public $options = ['class' => 'select2lite', 'id' => 'per_page']; /** * Callback function on get new page size */ public $callback; /** * Runs the widget and render the output */ public function run() { if (empty($this->options['id'])) { $this->options['id'] = $this->id; } $perPage = filter_input(INPUT_GET, $this->pageSizeParam, FILTER_VALIDATE_INT); if ($perPage) { $this->doStuff()->__invoke($perPage); } else { $perPage = $this->defaultPageSize; } return Html::dropDownList( $this->pageSizeParam, $perPage, array_combine($this->sizes, $this->sizes), $this->options); } public function doStuff() { if (is_callable($this->callback)) { return $this->callback; } return function () { }; } }