Example #1
0
 public function testPaginationPagesWithoutPermissions()
 {
     $pagination = $this->list->getPagination();
     $pagination->setMaxPerPage(2)->setCurrentPage(1);
     $this->assertEquals(6, $pagination->getTotalPages());
     $this->list->filterByType(\Concrete\Core\File\Type\Type::T_IMAGE);
     $pagination = $this->list->getPagination();
     $this->assertEquals(5, $pagination->getTotalResults());
     $pagination->setMaxPerPage(2)->setCurrentPage(2);
     $this->assertEquals(3, $pagination->getTotalPages());
     $this->assertTrue($pagination->hasNextPage());
     $this->assertTrue($pagination->hasPreviousPage());
     $pagination->setCurrentPage(1);
     $this->assertTrue($pagination->hasNextPage());
     $this->assertFalse($pagination->hasPreviousPage());
     $pagination->setCurrentPage(3);
     $this->assertFalse($pagination->hasNextPage());
     $this->assertTrue($pagination->hasPreviousPage());
     $results = $pagination->getCurrentPageResults();
     $this->assertInstanceOf('\\Concrete\\Core\\File\\File', $results[0]);
     $this->assertEquals(1, count($results[0]));
 }
 public function getFileSet()
 {
     $fs = FileSet::getById($this->fsID);
     $files = array();
     // if the file set exists (may have been deleted)
     if ($fs->fsID) {
         $this->fileSetName = $fs->getFileSetName();
         $fl = new FileList();
         $fl->filterBySet($fs);
         if ($this->fileOrder == 'date_asc') {
             $fl->sortBy('fDateAdded', 'asc');
         } elseif ($this->fileOrder == 'date_desc') {
             $fl->sortBy('fDateAdded', 'desc');
         } elseif ($this->fileOrder == 'alpha_asc') {
             $fl->sortBy('fvTitle', 'asc');
         } elseif ($this->fileOrder == 'alpha_desc') {
             $fl->sortBy('fvTitle', 'desc');
         } elseif ($this->fileOrder == 'set_order') {
             $fl->sortBy('fsDisplayOrder', 'asc');
         } elseif ($this->fileOrder == 'set_order_rev') {
             $fl->sortBy('fsDisplayOrder', 'desc');
         }
         if ($this->numberFiles > 0) {
             $fl->setItemsPerPage($this->numberFiles);
         } else {
             $fl->setItemsPerPage(10000);
         }
         $pagination = $fl->getPagination();
         $files = $pagination->getCurrentPageResults();
         if ($pagination->getTotalPages() > 1) {
             if ($this->paginate) {
                 $pagination = $pagination->renderDefaultView();
                 $this->set('pagination', $pagination);
             }
         }
     }
     return $files;
 }
Example #3
0
 /**
  * @return \Concrete\Core\Search\Pagination\Pagination|\Concrete\Core\Search\Pagination\PermissionablePagination
  */
 public function getPagination()
 {
     return parent::getPagination();
 }