public function pagination($paginator, $config = array())
    {
        if (!$paginator) {
            return '';
        }

        $config = new AnConfig($config);

        $config->append(array(
            'url' => (string) $this->_template->getView()->getRoute(),
            'force' => false,
            'options' => array(
                'limit' => 20,
            ),
        ));

        if (is($paginator, 'AnDomainEntitysetDefault')) {
            $entityset = $paginator;
            $paginator = new AnConfigPaginator(array(
                'offset' => $entityset->getOffset(),
                'limit' => 20,
            ));

            $paginator->total = $entityset->getTotal();
        }

        if (!$paginator instanceof AnConfigPaginator) {
            $paginator = new AnConfigPaginator($paginator);
        }

        $paginator->display = 5;

        //if our total is less than the limit don't show paginator
        if ($paginator->total < $paginator->limit) {
            return;
        }

        $config->paginator = $paginator;

        //convert url to the httpurl object
        $config->url = $this->getService('anahita:http.url', array('url' => $config->url));

        $pages = array();

        foreach ($paginator->pages->offsets as $offset) {
            $page = array();
            $url = clone $config->url;
            $query = array_merge($url->getQuery(true), array('limit' => $offset->limit, 'start' => $offset->offset));

            $url->setQuery($query);

            $page['number'] = $offset->page;
            $page['current'] = $offset->current;
            $page['url'] = (string) $url;

            $pages[] = $page;
        }

        $config['pages'] = $pages;
        $config['total'] = $paginator->total;
        $pages = array('prev','next');

        foreach ($pages as $page) {
            if ($paginator->pages->$page) {
                $url = clone $config->url;
                $query = array_merge($url->getQuery(true), array('limit' => $paginator->pages->$page->limit, 'start' => $paginator->pages->$page->offset));

                $url->setQuery($query);
                $config->{$page.'_page'} = (string) $url;
            }
        }

        return $this->_render('pagination', $config);
    }
public function pagination($paginator, $config = array())
    {
        if (!$paginator) {
            return '';
        }

        $config = new AnConfig($config);

        $config->append(array(
            'url' => (string) $this->_template->getView()->getRoute(),
            'force' => false,
            'options' => array(
                'limit' => 20,
            ),
        ));

        if (is($paginator, 'AnDomainEntitysetDefault')) {
            $entityset = $paginator;
            $paginator = new AnConfigPaginator(array(
                'offset' => $entityset->getOffset(),
                'limit' => 20,
            ));

            $paginator->total = $entityset->getTotal();
        }

        if (!$paginator instanceof AnConfigPaginator) {
            $paginator = new AnConfigPaginator($paginator);
        }

        $paginator->display = 5;

        //if our total is less than the limit don't show paginator
        if ($paginator->total < $paginator->limit) {
            return;
        }

        $config->paginator = $paginator;

        //convert url to the httpurl object
        $config->url = $this->getService('anahita:http.url', array('url' => $config->url));

        $pages = array();

        foreach ($paginator->pages->offsets as $offset) {
            $page = array();
            $url = clone $config->url;
            $query = array_merge($url->getQuery(true), array('limit' => $offset->limit, 'start' => $offset->offset));

            $url->setQuery($query);

            $page['number'] = $offset->page;
            $page['current'] = $offset->current;
            $page['url'] = (string) $url;

            $pages[] = $page;
        }

        $config['pages'] = $pages;
        $config['total'] = $paginator->total;
        $pages = array('prev','next');

        foreach ($pages as $page) {
            if ($paginator->pages->$page) {
                $url = clone $config->url;
                $query = array_merge($url->getQuery(true), array('limit' => $paginator->pages->$page->limit, 'start' => $paginator->pages->$page->offset));

                $url->setQuery($query);
                $config->{$page.'_page'} = (string) $url;
            }
        }

        return $this->_render('pagination', $config);
    }
public function pagination ( $ paginator , $ config = array ( ) ) { if ( ! $ paginator ) { return '' ; } $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'url' => ( string ) $ this -> _template -> getView ( ) -> getRoute ( ) , 'force' => false , 'options' => array ( 'limit' => 20 , ) , ) ) ; if ( is ( $ paginator , 'AnDomainEntitysetDefault' ) ) { $ entityset = $ paginator ; $ paginator = new AnConfigPaginator ( array ( 'offset' => $ entityset -> getOffset ( ) , 'limit' => 20 , ) ) ; $ paginator -> total = $ entityset -> getTotal ( ) ; } if ( ! $ paginator instanceof AnConfigPaginator ) { $ paginator = new AnConfigPaginator ( $ paginator ) ; } $ paginator -> display = 5 ; //if our total is less than the limit don't show paginator if ( $ paginator -> total < $ paginator -> limit ) { return ; } $ config -> paginator = $ paginator ; //convert url to the httpurl object $ config -> url = $ this -> getService ( 'anahita:http.url' , array ( 'url' => $ config -> url ) ) ; $ pages = array ( ) ; foreach ( $ paginator -> pages -> offsets as $ offset ) { $ page = array ( ) ; $ url = clone $ config -> url ; $ query = array_merge ( $ url -> getQuery ( true ) , array ( 'limit' => $ offset -> limit , 'start' => $ offset -> offset ) ) ; $ url -> setQuery ( $ query ) ; $ page [ 'number' ] = $ offset -> page ; $ page [ 'current' ] = $ offset -> current ; $ page [ 'url' ] = ( string ) $ url ; $ pages [ ] = $ page ; } $ config [ 'pages' ] = $ pages ; $ config [ 'total' ] = $ paginator -> total ; $ pages = array ( 'prev' , 'next' ) ; foreach ( $ pages as $ page ) { if ( $ paginator -> pages -> $ page ) { $ url = clone $ config -> url ; $ query = array_merge ( $ url -> getQuery ( true ) , array ( 'limit' => $ paginator -> pages -> $ page -> limit , 'start' => $ paginator -> pages -> $ page -> offset ) ) ; $ url -> setQuery ( $ query ) ; $ config -> { $ page . '_page' } = ( string ) $ url ; } } return $ this -> _render ( 'pagination' , $ config ) ; }
Renders a pagination using the paginator object.

@param AnDomainEntitysetDefault|AnConfigPaginator $paginator Paginator object
@param array                                     $config    Configuration

@returns string
Renders a pagination using the paginator object .