/**
  * Shows a pager as a frontend plugin
  *
  * @return string Rendered pager action HTML source
  */
 public function showAction()
 {
     // Do not show pager when nothing to page.
     if ($this->pagerCollection->getItemCount() <= 0) {
         return '';
     }
     $pager = $this->pagerCollection->getPagerByIdentifier($this->pagerIdentifier);
     $this->view->assign('pagerCollection', $this->pagerCollection);
     $this->view->assign('pager', $pager);
 }
 /**
  * Returns pager collection fo databacken for this list context
  *
  * @return Tx_PtExtlist_Domain_Model_Pager_PagerCollection
  */
 public function getPagerCollection()
 {
     if ($this->pagerCollection === null) {
         $this->pagerCollection = $this->dataBackend->getPagerCollection();
         $this->pagerCollection->setItemCount($this->dataBackend->getTotalItemsCount());
     }
     return $this->pagerCollection;
 }
 /**
  * Reset all pagers for this list.
  *
  */
 protected function resetPagers()
 {
     // Reset pagers
     if ($this->pagerCollection === null) {
         // Only get pagerCollection if it's not set already. Important for testing.
         $this->pagerCollection = $this->dataBackend->getPagerCollection();
     }
     $this->pagerCollection->reset();
 }
 /**
  * Reset all pagers for this list.
  *
  */
 protected function resetPagers()
 {
     // TODO put this into abstract controller
     // Reset pagers
     if ($this->pagerCollection === NULL) {
         // Only get pagerCollection if it's not set already. Important for testing.
         $this->pagerCollection = $this->dataBackend->getPagerCollection();
     }
     $this->pagerCollection->reset();
     $this->dataBackend->resetListDataCache();
 }
 /** @test */
 public function pagerCollectionReturnsFirstPageIfCurrentPageIsOutOfItemCount()
 {
     $collection = new Tx_PtExtlist_Domain_Model_Pager_PagerCollection($this->configurationBuilderMock);
     $pager = $this->getMock('Tx_PtExtlist_Domain_Model_Pager_DefaultPager', array('setCurrentPage', 'getItemCount', 'getLastPage'), array(), '', false, false);
     $pager->expects($this->any())->method('getItemCount')->will($this->returnValue(10));
     $pager->expects($this->any())->method('getLastPage')->will($this->returnValue(2));
     $collection->addPager($pager);
     $collection->_injectSessionData(array('page' => 2));
     $collection->setItemsPerPage(5);
     // We check whether we still get correct page, if we are "in bound"
     $this->assertEquals($collection->getCurrentPage(), 2);
     // We check whether pager is reset if we run "out of bound"3
     $collection->setCurrentPage(3);
     $this->assertEquals($collection->getCurrentPage(), 1);
 }