src/ORM/PaginatedList.php
public function Pages($max = null)
    {
        $result = new ArrayList();

        if ($max) {
            $start = ($this->CurrentPage() - floor($max / 2)) - 1;
            $end = $this->CurrentPage() + floor($max / 2);

            if ($start < 0) {
                $start = 0;
                $end = $max;
            }

            if ($end > $this->TotalPages()) {
                $end = $this->TotalPages();
                $start = max(0, $end - $max);
            }
        } else {
            $start = 0;
            $end = $this->TotalPages();
        }

        for ($i = $start; $i < $end; $i++) {
            $result->push(new ArrayData(array(
                'PageNum' => $i + 1,
                'Link' => HTTP::setGetVar(
                    $this->getPaginationGetVar(),
                    $i * $this->getPageLength(),
                    ($this->request instanceof HTTPRequest) ? $this->request->getURL(true) : null
                ),
                'CurrentBool' => $this->CurrentPage() == ($i + 1)
            )));
        }

        return $result;
    }
public function Pages($max = null)
    {
        $result = new ArrayList();

        if ($max) {
            $start = ($this->CurrentPage() - floor($max / 2)) - 1;
            $end = $this->CurrentPage() + floor($max / 2);

            if ($start < 0) {
                $start = 0;
                $end = $max;
            }

            if ($end > $this->TotalPages()) {
                $end = $this->TotalPages();
                $start = max(0, $end - $max);
            }
        } else {
            $start = 0;
            $end = $this->TotalPages();
        }

        for ($i = $start; $i < $end; $i++) {
            $result->push(new ArrayData(array(
                'PageNum' => $i + 1,
                'Link' => HTTP::setGetVar(
                    $this->getPaginationGetVar(),
                    $i * $this->getPageLength(),
                    ($this->request instanceof HTTPRequest) ? $this->request->getURL(true) : null
                ),
                'CurrentBool' => $this->CurrentPage() == ($i + 1)
            )));
        }

        return $result;
    }
public function Pages ( $ max = null ) { $ result = new ArrayList ( ) ; if ( $ max ) { $ start = ( $ this -> CurrentPage ( ) - floor ( $ max / 2 ) ) - 1 ; $ end = $ this -> CurrentPage ( ) + floor ( $ max / 2 ) ; if ( $ start < 0 ) { $ start = 0 ; $ end = $ max ; } if ( $ end > $ this -> TotalPages ( ) ) { $ end = $ this -> TotalPages ( ) ; $ start = max ( 0 , $ end - $ max ) ; } } else { $ start = 0 ; $ end = $ this -> TotalPages ( ) ; } for ( $ i = $ start ; $ i < $ end ; $ i ++ ) { $ result -> push ( new ArrayData ( array ( 'PageNum' => $ i + 1 , 'Link' => HTTP :: setGetVar ( $ this -> getPaginationGetVar ( ) , $ i * $ this -> getPageLength ( ) , ( $ this -> request instanceof HTTPRequest ) ? $ this -> request -> getURL ( true ) : null ) , 'CurrentBool' => $ this -> CurrentPage ( ) == ( $ i + 1 ) ) ) ) ; } return $ result ; }
Returns a set of links to all the pages in the list. This is useful for
basic pagination.

By default it returns links to every page, but if you pass the $max
parameter the number of pages will be limited to that number, centered
around the current page.

@param  int $max
@return SS_List
Returns a set of links to all the pages in the list . This is useful for basic pagination .