Ejemplo n.º 1
0
 public function __invoke(Paginator\Paginator $paginator = null, $scrollingStyle = null, $partial = null, $params = null)
 {
     if (is_string($params)) {
         $params = (array) $params;
     }
     if (isset($params['size'])) {
         if ($params['size'] != 'sm' && $params['size'] != 'lg') {
             throw new \RuntimeException('Size parameter must be either "sm" or "lg"');
         }
     }
     if ($partial === null && isset($params['type'])) {
         if ($params['type'] == 'pager') {
             $partial = 'paginator/pager.phtml';
         }
     }
     if (!isset($params['aligned']) || !is_bool($params['aligned'])) {
         $params['aligned'] = true;
     }
     if (!isset($params['nextLabel'])) {
         $params['nextLabel'] = self::$nextLabel;
     }
     if (!isset($params['previousLabel'])) {
         $params['previousLabel'] = self::$previousLabel;
     }
     return parent::__invoke($paginator, $scrollingStyle, $partial, $params);
 }
    /**
     * @group ZF-4878
     */
    public function testCanUseObjectForScrollingStyle()
    {
        $all = new Paginator\ScrollingStyle\All();

        $output = $this->_viewHelper->__invoke($this->_paginator, $all, 'testPagination.phtml');

        $this->assertContains('page count (11) equals pages in range (11)', $output, $output);
    }
Ejemplo n.º 3
0
    /**
     * @group ZF-4878
     */
    public function testCanUseObjectForScrollingStyle()
    {
        $all = new Paginator\ScrollingStyle\All();

        try {
            $output = $this->_viewHelper->__invoke($this->_paginator, $all, 'testPagination.phtml');
        } catch (\Exception $e) {
            $this->fail('Could not use object for sliding style');
        }

        $this->assertContains('page count (11) equals pages in range (11)', $output, $output);
    }
Ejemplo n.º 4
0
 /**
  * @group ZF-4328
  */
 public function testUsesPaginatorFromViewOnlyIfNoneSupplied()
 {
     $this->_viewHelper->getView()->vars()->paginator = $this->_paginator;
     $paginator = Paginator\Paginator::factory(range(1, 30));
     Helper\PaginationControl::setDefaultViewPartial('testPagination.phtml');
     $output = $this->_viewHelper->__invoke($paginator);
     $this->assertContains('page count (3)', $output, $output);
 }
Ejemplo n.º 5
0
 public function testRendersWithPartial()
 {
     $view = new View\Renderer\PhpRenderer();
     $view->resolver()->addPath(__DIR__ . '/_files/scripts');
     Helper\PaginationControl::setDefaultViewPartial('partial.phtml');
     $this->paginator->setView($view);
     $string = $this->paginator->__toString();
     $this->assertEquals('partial rendered successfully', $string);
 }
Ejemplo n.º 6
0
 public function testRendersWithPartial()
 {
     $view = new View\View();
     $view->addBasePath(__DIR__ . '/_files');
     $view->addHelperPath(__DIR__ . '/../../../trunk/library/Zend/View/Helper', 'Zend\\View\\Helper');
     Helper\PaginationControl::setDefaultViewPartial('partial.phtml');
     $this->_paginator->setView($view);
     $string = $this->_paginator->__toString();
     $this->assertEquals('partial rendered successfully', $string);
 }
 public function setPaginator(EventInterface $event)
 {
     ZendPaginator::setDefaultItemCountPerPage(1);
     PaginationControl::setDefaultScrollingStyle('all');
     PaginationControl::setDefaultViewPartial('kp-user-pagination');
 }
Ejemplo n.º 8
0
 /**
  * (non-PHPdoc)
  * 
  * @see \Zend\ModuleManager\Feature\BootstrapListenerInterface::onBootstrap()
  */
 public function onBootstrap(EventInterface $e)
 {
     PaginationControl::setDefaultViewPartial('mwadmin/pagination');
 }
Ejemplo n.º 9
0
 /**
  *
  * @param array|object $offers
  * @return \Zend\Paginator\Paginator
  */
 private function _initPaginator($offers)
 {
     \Zend\Paginator\Paginator::setDefaultScrollingStyle('Sliding');
     \Zend\View\Helper\PaginationControl::setDefaultViewPartial('layout/pagination_control.phtml');
     $page = $this->params()->fromRoute('page');
     $page = $page ? $page : 1;
     if (is_object($offers)) {
         $offers = $offers->getArrayCopy();
     }
     $paginator = new \Zend\Paginator\Paginator(new \Zend\Paginator\Adapter\ArrayAdapter($offers));
     $paginator->setCurrentPageNumber($page);
     return $paginator;
 }
Ejemplo n.º 10
0
 public function getViewHelperConfig()
 {
     \Zend\Paginator\Paginator::setDefaultScrollingStyle('Sliding');
     \Zend\View\Helper\PaginationControl::setDefaultViewPartial("layout/paginatorItem");
     return array('invokables' => array(), 'factories' => array('App' => 'Home\\View\\Helper\\AppFactory'));
 }