public function pagination($maxPageNumbers = 10, $itemType = 'Items', $class = '', $element = 'Filter/pagination', $passParams = [])
    {
        if (empty($this->paginationParams)) {
            return '';
        }

        $this->_passParams = array_merge($this->paginationParams['passParams'], $passParams);

        $page = (integer)$this->paginationParams['page'];
        $pages = (integer)$this->paginationParams['pages'];
        $pagesOnLeft = floor($maxPageNumbers / 2);
        $pagesOnRight = $maxPageNumbers - $pagesOnLeft - 1;
        $minPage = $page - $pagesOnLeft;
        $maxPage = $page + $pagesOnRight;
        $firstUrl = false;
        $prevUrl = false;
        $pageLinks = [];
        $nextUrl = false;
        $lastUrl = false;

        if ($page > 1) {
            $firstUrl = $this->_getPaginatedUrl(1);
            $prevUrl = $this->_getPaginatedUrl($page - 1);
        }
        if ($minPage < 1) {
            $minPage = 1;
            $maxPage = $maxPageNumbers;
        }
        if ($maxPage > $pages) {
            $maxPage = $pages;
            $minPage = $maxPage + 1 - $maxPageNumbers;
        }
        if ($minPage < 1) {
            $minPage = 1;
        }
        foreach (range($minPage, $maxPage) as $p) {
            $link = [
                'page' => (int)$p,
                'url' => $this->_getPaginatedUrl($p),
                'active' => ((int)$p === $page)
            ];
            $pageLinks[] = $link;
        }
        if ($page < $pages) {
            $nextUrl = $this->_getPaginatedUrl($page + 1);
            $lastUrl = $this->_getPaginatedUrl($pages);
        }
        return $this->_View->element($element, [
            'total' => $this->paginationParams['total'],
            'itemType' => $itemType,
            'first' => $firstUrl,
            'prev' => $prevUrl,
            'pages' => $pageLinks,
            'next' => $nextUrl,
            'last' => $lastUrl,
            'class' => $class,
            'currentPage' => $page,
            'baseUrl' => Router::url($this->_getFilterUrl(false)),
            'from' => $this->paginationParams['from'],
            'to' => $this->paginationParams['to'],
            'nrOfPages' => $pages
        ]);
    }
public function pagination($maxPageNumbers = 10, $itemType = 'Items', $class = '', $element = 'Filter/pagination', $passParams = [])
    {
        if (empty($this->paginationParams)) {
            return '';
        }

        $this->_passParams = array_merge($this->paginationParams['passParams'], $passParams);

        $page = (integer)$this->paginationParams['page'];
        $pages = (integer)$this->paginationParams['pages'];
        $pagesOnLeft = floor($maxPageNumbers / 2);
        $pagesOnRight = $maxPageNumbers - $pagesOnLeft - 1;
        $minPage = $page - $pagesOnLeft;
        $maxPage = $page + $pagesOnRight;
        $firstUrl = false;
        $prevUrl = false;
        $pageLinks = [];
        $nextUrl = false;
        $lastUrl = false;

        if ($page > 1) {
            $firstUrl = $this->_getPaginatedUrl(1);
            $prevUrl = $this->_getPaginatedUrl($page - 1);
        }
        if ($minPage < 1) {
            $minPage = 1;
            $maxPage = $maxPageNumbers;
        }
        if ($maxPage > $pages) {
            $maxPage = $pages;
            $minPage = $maxPage + 1 - $maxPageNumbers;
        }
        if ($minPage < 1) {
            $minPage = 1;
        }
        foreach (range($minPage, $maxPage) as $p) {
            $link = [
                'page' => (int)$p,
                'url' => $this->_getPaginatedUrl($p),
                'active' => ((int)$p === $page)
            ];
            $pageLinks[] = $link;
        }
        if ($page < $pages) {
            $nextUrl = $this->_getPaginatedUrl($page + 1);
            $lastUrl = $this->_getPaginatedUrl($pages);
        }
        return $this->_View->element($element, [
            'total' => $this->paginationParams['total'],
            'itemType' => $itemType,
            'first' => $firstUrl,
            'prev' => $prevUrl,
            'pages' => $pageLinks,
            'next' => $nextUrl,
            'last' => $lastUrl,
            'class' => $class,
            'currentPage' => $page,
            'baseUrl' => Router::url($this->_getFilterUrl(false)),
            'from' => $this->paginationParams['from'],
            'to' => $this->paginationParams['to'],
            'nrOfPages' => $pages
        ]);
    }
public function pagination ( $ maxPageNumbers = 10 , $ itemType = 'Items' , $ class = '' , $ element = 'Filter/pagination' , $ passParams = [ ] ) { if ( empty ( $ this -> paginationParams ) ) { return '' ; } $ this -> _passParams = array_merge ( $ this -> paginationParams [ 'passParams' ] , $ passParams ) ; $ page = ( integer ) $ this -> paginationParams [ 'page' ] ; $ pages = ( integer ) $ this -> paginationParams [ 'pages' ] ; $ pagesOnLeft = floor ( $ maxPageNumbers / 2 ) ; $ pagesOnRight = $ maxPageNumbers - $ pagesOnLeft - 1 ; $ minPage = $ page - $ pagesOnLeft ; $ maxPage = $ page + $ pagesOnRight ; $ firstUrl = false ; $ prevUrl = false ; $ pageLinks = [ ] ; $ nextUrl = false ; $ lastUrl = false ; if ( $ page > 1 ) { $ firstUrl = $ this -> _getPaginatedUrl ( 1 ) ; $ prevUrl = $ this -> _getPaginatedUrl ( $ page - 1 ) ; } if ( $ minPage < 1 ) { $ minPage = 1 ; $ maxPage = $ maxPageNumbers ; } if ( $ maxPage > $ pages ) { $ maxPage = $ pages ; $ minPage = $ maxPage + 1 - $ maxPageNumbers ; } if ( $ minPage < 1 ) { $ minPage = 1 ; } foreach ( range ( $ minPage , $ maxPage ) as $ p ) { $ link = [ 'page' => ( int ) $ p , 'url' => $ this -> _getPaginatedUrl ( $ p ) , 'active' => ( ( int ) $ p === $ page ) ] ; $ pageLinks [ ] = $ link ; } if ( $ page < $ pages ) { $ nextUrl = $ this -> _getPaginatedUrl ( $ page + 1 ) ; $ lastUrl = $ this -> _getPaginatedUrl ( $ pages ) ; } return $ this -> _View -> element ( $ element , [ 'total' => $ this -> paginationParams [ 'total' ] , 'itemType' => $ itemType , 'first' => $ firstUrl , 'prev' => $ prevUrl , 'pages' => $ pageLinks , 'next' => $ nextUrl , 'last' => $ lastUrl , 'class' => $ class , 'currentPage' => $ page , 'baseUrl' => Router :: url ( $ this -> _getFilterUrl ( false ) ) , 'from' => $ this -> paginationParams [ 'from' ] , 'to' => $ this -> paginationParams [ 'to' ] , 'nrOfPages' => $ pages ] ) ; }
Render the pagination.

@param int $maxPageNumbers The maximum number of pages to show in the link list.
@param string $itemType The item type that is paginated.
@param string $class An optional css class for the pagination.
@param string $element The pagination element to render.
@param array $passParams Optional params passed to the filter urls.
@return string
Render the pagination .