59 lines
1.8 KiB
PHP
Executable File
59 lines
1.8 KiB
PHP
Executable File
<?php
|
|
|
|
namespace backend\widgets\common;
|
|
|
|
use yii\helpers\Html;
|
|
use yii\widgets\LinkPager;
|
|
|
|
class LinkPages extends LinkPager
|
|
{
|
|
/**
|
|
* Renders the page buttons.
|
|
* @return string the rendering result
|
|
*/
|
|
protected function renderPageButtons()
|
|
{
|
|
$pageCount = $this->pagination->getPageCount();
|
|
if ($pageCount < 2 && $this->hideOnSinglePage) {
|
|
return '';
|
|
}
|
|
|
|
$buttons = [];
|
|
$currentPage = $this->pagination->getPage();
|
|
|
|
// first page
|
|
if ($this->firstPageLabel !== FALSE) {
|
|
$buttons[] = $this->renderPageButton($this->firstPageLabel, 0, $this->firstPageCssClass, $currentPage <= 0, FALSE);
|
|
}
|
|
|
|
// prev page
|
|
if ($this->prevPageLabel !== FALSE) {
|
|
if (($page = $currentPage - 1) < 0) {
|
|
$page = 0;
|
|
}
|
|
$buttons[] = $this->renderPageButton($this->prevPageLabel, $page, $this->prevPageCssClass, $currentPage <= 0, FALSE);
|
|
}
|
|
|
|
// internal pages
|
|
list($beginPage, $endPage) = $this->getPageRange();
|
|
for ($i = $beginPage; $i <= $endPage; ++$i) {
|
|
$buttons[] = $this->renderPageButton($i + 1, $i, NULL, FALSE, $i == $currentPage);
|
|
}
|
|
|
|
// next page
|
|
if ($this->nextPageLabel !== FALSE) {
|
|
if (($page = $currentPage + 1) >= $pageCount - 1) {
|
|
$page = $pageCount - 1;
|
|
}
|
|
$buttons[] = $this->renderPageButton($this->nextPageLabel, $page, $this->nextPageCssClass, $currentPage >= $pageCount - 1, FALSE);
|
|
}
|
|
|
|
// last page
|
|
if ($this->lastPageLabel !== FALSE) {
|
|
$buttons[] = $this->renderPageButton($this->lastPageLabel, $pageCount - 1, $this->lastPageCssClass, $currentPage >= $pageCount - 1, FALSE);
|
|
}
|
|
|
|
return html::tag('div', Html::tag('ul', implode("\n", $buttons), $this->options), ['class' => 'dataTables_paginate paging_bootstrap pagination']);
|
|
//return Html::tag('ul', implode("\n", $buttons), $this->options);
|
|
}
|
|
} |