Prado\Web\UI\WebControls\TDataGrid::buildNumericPager PHP 메소드

buildNumericPager() 보호된 메소드

Builds a numeric pager
protected buildNumericPager ( $pager )
    protected function buildNumericPager($pager)
    {
        $style = $this->getPagerStyle();
        $buttonType = $style->getButtonType();
        $controls = $pager->getControls();
        $pageCount = $this->getPageCount();
        $pageIndex = $this->getCurrentPageIndex() + 1;
        $maxButtonCount = $style->getPageButtonCount();
        $buttonCount = $maxButtonCount > $pageCount ? $pageCount : $maxButtonCount;
        $startPageIndex = 1;
        $endPageIndex = $buttonCount;
        if ($pageIndex > $endPageIndex) {
            $startPageIndex = (int) (($pageIndex - 1) / $maxButtonCount) * $maxButtonCount + 1;
            if (($endPageIndex = $startPageIndex + $maxButtonCount - 1) > $pageCount) {
                $endPageIndex = $pageCount;
            }
            if ($endPageIndex - $startPageIndex + 1 < $maxButtonCount) {
                if (($startPageIndex = $endPageIndex - $maxButtonCount + 1) < 1) {
                    $startPageIndex = 1;
                }
            }
        }
        if ($startPageIndex > 1) {
            if (($text = $style->getFirstPageText()) !== '') {
                $button = $this->createPagerButton($pager, $buttonType, true, $text, self::CMD_PAGE, self::CMD_PAGE_FIRST);
                $controls->add($button);
                $controls->add("\n");
            }
            $prevPageIndex = $startPageIndex - 1;
            $button = $this->createPagerButton($pager, $buttonType, true, $style->getPrevPageText(), self::CMD_PAGE, "{$prevPageIndex}");
            $controls->add($button);
            $controls->add("\n");
        }
        for ($i = $startPageIndex; $i <= $endPageIndex; ++$i) {
            if ($i === $pageIndex) {
                $label = $this->createPagerButton($pager, $buttonType, false, "{$i}", '', '');
                $controls->add($label);
            } else {
                $button = $this->createPagerButton($pager, $buttonType, true, "{$i}", self::CMD_PAGE, "{$i}");
                $controls->add($button);
            }
            if ($i < $endPageIndex) {
                $controls->add("\n");
            }
        }
        if ($pageCount > $endPageIndex) {
            $controls->add("\n");
            $nextPageIndex = $endPageIndex + 1;
            $button = $this->createPagerButton($pager, $buttonType, true, $style->getNextPageText(), self::CMD_PAGE, "{$nextPageIndex}");
            $controls->add($button);
            if (($text = $style->getLastPageText()) !== '') {
                $controls->add("\n");
                $button = $this->createPagerButton($pager, $buttonType, true, $text, self::CMD_PAGE, self::CMD_PAGE_LAST);
                $controls->add($button);
            }
        }
    }