@param $width
@param $currentPageNumber
@param $lastPageNumber
@param $actionFirstPage
@param $actionPreviousPage
@param $actionNextPage
@param $actionLastPage

@return Frame
498879
public function create(
        $width,
        $currentPageNumber,
        $lastPageNumber,
        $actionFirstPage,
        $actionPreviousPage,
        $actionNextPage,
        $actionLastPage,
        $actionGotoPage
    ) {

        $frame = Frame::Create();
        $frame->setSize($width, 16);

        $pagerLine = $this->uiFactory->createLayoutLine(0, -1);
        $buttonSize = 6;

        $empty = Quad::create();
        $empty->setOpacity(0)->setSize($buttonSize, $buttonSize);

        // Show previous buttons
        if ($currentPageNumber > 2) {
            $button = $this->uiFactory->createButton("", Button::TYPE_DECORATED);
            $button
                ->setSize($buttonSize, $buttonSize)
                ->setAction($actionFirstPage);
        } else {
            $button = clone $empty;
        }


        $pagerLine->addChild($button);

        if ($currentPageNumber > 1) {
            $button = $this->uiFactory->createButton("", Button::TYPE_DECORATED);
            $button
                ->setSize($buttonSize, $buttonSize)
                ->setAction($actionPreviousPage);

        } else {
            $button = clone $empty;
        }
        $pagerLine->addChild($button);


        // Show current page.

        $input = $this->uiFactory->createInput('pager_gotopage', $currentPageNumber, 7);
        $input->setAction($actionGotoPage)->setPosition(0, 1)->setHorizontalAlign("center");


        $label = $this->uiFactory->createLabel(" / $lastPageNumber");
        $label->setSize(10, 7)->setHorizontalAlign("left");

        $line = $this->uiFactory->createLayoutLine(0, -2);
        $line->setHorizontalAlign("left");
        $line->addChildren([$input, $label]);

        if ($lastPageNumber > 1) {
            $pagerLine->addChild($line);
        } else {
            $label->setText("1 / 1");
            $pagerLine->addChild($label);
        }

        if ($currentPageNumber < $lastPageNumber) {
            $button = $this->uiFactory->createButton("", Button::TYPE_DECORATED);
            $button
                ->setSize($buttonSize, $buttonSize)
                ->setZ(3)
                ->setAction($actionNextPage);

        } else {
            $button = clone $empty;
        }
        $pagerLine->addChild($button);

        if ($currentPageNumber < $lastPageNumber - 1) {
            $button = $this->uiFactory->createButton("", Button::TYPE_DECORATED);
            $button
                ->setSize($buttonSize, $buttonSize)
                ->setAction($actionLastPage);

        } else {
            $button = clone $empty;
        }
        $pagerLine->addChild($button);

        $pagerLine->setAlign("center", "top");
        $pagerLine->setX(($width - $pagerLine->getWidth()) / 2);


        $borderTop = $this->uiFactory->createLine(0, 0);
        $borderTop->setLength($width)->setColor("fff");

        $frame->addChild($borderTop);
        $frame->addChild($pagerLine);

        return $frame;
    }
497854
@Override
    public Page<Entity> previousPage(final Page<Entity> page, 
                                     final TwilioRestClient client) {
        Request request = new Request(
            HttpMethod.GET,
            page.getPreviousPageUrl(
                Domains.AUTHY.toString(),
                client.getRegion()
            )
        );
        return pageForRequest(client, request);
    }
608637
public function getActPage()
    {
        $lastPage = $this->getPagesCount();
        $currentPage = parent::getActPage();

        if ($currentPage >= $lastPage) {
            $currentPage = $lastPage - 1;
        }

        return $currentPage;
    }
1351260
protected function setCurrentPage($currentPage, $pageName)
    {
        $currentPage = $currentPage ?: static::resolveCurrentPage($pageName);

        return $this->isValidPageNumber($currentPage) ? (int) $currentPage : 1;
    }
472506
@Override
    public Page<Variable> previousPage(final Page<Variable> page, 
                                       final TwilioRestClient client) {
        Request request = new Request(
            HttpMethod.GET,
            page.getPreviousPageUrl(
                Domains.SERVERLESS.toString(),
                client.getRegion()
            )
        );
        return pageForRequest(client, request);
    }
1187150
public function findAllWorkspaces($page, $max = 20, $orderedBy = 'id', $order = null)
    {
        $result = $this->workspaceRepo->findBy(array(), array($orderedBy => $order));

        return $this->pagerFactory->createPagerFromArray($result, $page, $max);
    }
565695
public static function navbarSearchForm($action, $method = 'post', $htmlOptions = array())
    {
        self::addCssClass('navbar-search', $htmlOptions);
        return self::searchForm($action, $method, $htmlOptions);
    }
702576
public function previousPage(HTML_QuickForm2_Controller_Page $reference)
    {
        $previous = null;
        foreach ($this->pages as $page) {
            if ($page === $reference) {
                return $previous;
            }
            $previous = $page;
        }
        return null;
    }
667233
public function paginate($n, $current = 0, $chunk = null)
    {
        // We go a page back
        --$current;

        // Variable containing the number of jump. $jump;

        if ($current <= 0) {
            $jump = 0;

            $current = 1;
        } else {
            $jump = $n * $current;
            
            $current++;
        }

        // Saving information about where
        $where = $this->where;

        $dataBind = $this->where_data_binding;

        $data = $this->jump($jump)
            ->take($n)->get();

        // Reinitialization of where
        $this->where = $where;

        $this->where_data_binding = $dataBind;

        // We count the number of pages that remain
        $restOfPage = ceil($this->count() / $n) - $current;

        // Grouped data
        if (is_int($chunk)) {
            $data = array_chunk($data, $chunk);
        }

        // Enables automatic paging.
        $data = [
            'next' => $current >= 1 && $restOfPage > 0 ? $current + 1 : false,
            'previous' => ($current - 1) <= 0 ? 1 : ($current - 1),
            'total' => (int) ($restOfPage + $current),
            'current' => $current,
            'data' => $data
        ];

        return new Collection($data);
    }
1276718
public static function beginFormTb(
        $layout = self::FORM_LAYOUT_VERTICAL,
        $action = '',
        $method = 'post',
        $htmlOptions = array()
    ) {
        if (!empty($layout)) {
            self::addCssClass('form-' . $layout, $htmlOptions);
        }
        return parent::beginForm($action, $method, $htmlOptions);
    }
1023214
public function setPagination($currentPage, $perPage = null)
    {

        $this->currentPageNumber = $this->isValidPageNumber($currentPage) ? $currentPage : 1;
        $defaultPerPage = $this->perPage ? $this->perPage : static::$perPageDefault;
        $this->perPage = $perPage ?: $defaultPerPage;
        $this->pages = null;
        return $this;
    }
981017
protected function calculateLinks($currentPage, $numberOfPages)
    {
        $baseUrl = $this->getBaseUrl();
        $prev = ($currentPage > 1) ? $currentPage - 1 : null;
        $next = ($currentPage < $numberOfPages) ? $currentPage + 1 : null;

        $separator = ($this->paginationLink) ? '/' : '?page=';

        return [
            'current' => $baseUrl.$separator.$currentPage,
            'prev' => ($prev) ? $baseUrl.$separator.$prev : null,
            'next' => ($next) ? $baseUrl.$separator.$next : null,
            'last' => ($numberOfPages > 0) ? $baseUrl.$separator.$numberOfPages : null,
        ];
    }
354241
public static function calculateCurrentPage(int $first, int $after, int $defaultPage = 1): int
    {
        return $first && $after
            ? (int) floor(($first + $after) / $first)
            : $defaultPage;
    }
1228951
protected function getNextLinkUri(&$lastObject)
    {
        $currentExpandedProjectionNode = $this->getCurrentExpandedProjectionNode();
        $internalOrderByInfo = $currentExpandedProjectionNode->getInternalOrderByInfo();
        if (!$internalOrderByInfo instanceof InternalOrderByInfo) {
            throw new InvalidOperationException(get_class($internalOrderByInfo));
        }
        $numSegments = count($internalOrderByInfo->getOrderByPathSegments());
        $queryParameterString = $this->getNextPageLinkQueryParametersForRootResourceSet();

        $skipToken = $internalOrderByInfo->buildSkipTokenValue($lastObject);
        if (empty($skipToken)) {
            throw new InvalidOperationException('!is_null($skipToken)');
        }
        $token = (1 < $numSegments) ? '$skiptoken=' : '$skip=';
        $skipToken = (1 < $numSegments) ? $skipToken : intval(trim($skipToken, '\''));
        $skipToken = '?' . $queryParameterString . $token . $skipToken;

        return $skipToken;
    }
303903
protected function getPageFromInput($currentPage = null, array $options = [])
    {
        if (is_numeric($currentPage)) {
            return intval($currentPage);
        }

        $pageName = (array_key_exists('pageName', $options)) ? $options['pageName'] : 'page';

        $page = $this->request->input($pageName);

        if (is_numeric($page)) {
            return intval($page);
        }

        return 1;
    }
1264090
public function paginate($limit = null, $columns = ['*'], $pageName = 'page', $page = null)
    {
        return $this->simpleWrap(Action::READ, [$this, '_paginate']);
    }
1112171
private function createAfterButton($current, $limit, $url, $class, $fragments)
    {
        if ($this->isAvaibleCurrentPage($current) && $current < $limit) {

            $page = $current - 1;

            return $this->buildChieldString("&laquo;", $url, $class, $fragments, $page);
        } else {
            return false;
        }
    }