/**
  * Displays a list of all members on the site that belong to the selected
  * groups.
  *
  * @return string
  */
 public function handleList($request)
 {
     $fields = $this->parent->Fields()->filter('MemberListVisible', true);
     $members = $this->parent->Groups()->relation('Members');
     $members = new PaginatedList($members, $request);
     $list = new PaginatedList(new ArrayList(), $request);
     $list->setLimitItems(false);
     $list->setTotalItems($members->getTotalItems());
     foreach ($members as $member) {
         $cols = new ArrayList();
         $public = $member->getPublicFields();
         $link = $this->Link($member->ID);
         foreach ($fields as $field) {
             if ($field->PublicVisibility == 'MemberChoice' && !in_array($field->MemberField, $public)) {
                 $value = null;
             } else {
                 $value = $member->{$field->MemberField};
             }
             $cols->push(new ArrayData(array('Name' => $field->MemberField, 'Title' => $field->Title, 'Value' => $value, 'Sortable' => $member->hasDatabaseField($field->MemberField), 'Link' => $link)));
         }
         $list->push($member->customise(array('Fields' => $cols)));
     }
     $this->data()->Title = _t('MemberProfiles.MEMBERLIST', 'Member List');
     $this->data()->Parent = $this->parent;
     $controller = $this->customise(array('Members' => $list));
     return $controller->renderWith(array('MemberProfileViewer_list', 'MemberProfileViewer', 'Page'));
 }
 /**
  * Show the "login" page
  *
  * @return string Returns the "login" page as HTML code.
  */
 public function requests()
 {
     // Vorerst keine Seite erstellt
     $Contacts = new PaginatedList(Member::currentUser()->OpenConfirmations(), $this->request);
     $Contacts->setPageLength(10);
     if ($Contacts->getTotalItems() == 0) {
         return $this->redirect('contacts/index');
     }
     return $this->customise(new ArrayData(array("Title" => _t('Contacts.REQUESTSTITLE', 'Contacts.REQUESTSTITLE'), "Contacts" => $Contacts)))->renderWith(array('Contacts_requests', 'Contacts', $this->stat('template_main'), $this->stat('template')));
 }
Beispiel #3
0
 public function testSetPaginationFromQuery()
 {
     $query = $this->getMock('SQLQuery');
     $query->expects($this->once())->method('getLimit')->will($this->returnValue(array('limit' => 15, 'start' => 30)));
     $query->expects($this->once())->method('unlimitedRowCount')->will($this->returnValue(100));
     $list = new PaginatedList(new ArrayList());
     $list->setPaginationFromQuery($query);
     $this->assertEquals(15, $list->getPageLength());
     $this->assertEquals(30, $list->getPageStart());
     $this->assertEquals(100, $list->getTotalItems());
 }
 public function testGetIterator()
 {
     $list = new PaginatedList(new ArrayList(array(new DataObject(array('Num' => 1)), new DataObject(array('Num' => 2)), new DataObject(array('Num' => 3)), new DataObject(array('Num' => 4)), new DataObject(array('Num' => 5)))));
     $list->setPageLength(2);
     $this->assertDOSEquals(array(array('Num' => 1), array('Num' => 2)), $list->getIterator());
     $list->setCurrentPage(2);
     $this->assertDOSEquals(array(array('Num' => 3), array('Num' => 4)), $list->getIterator());
     $list->setCurrentPage(3);
     $this->assertDOSEquals(array(array('Num' => 5)), $list->getIterator());
     $list->setCurrentPage(999);
     $this->assertDOSEquals(array(), $list->getIterator());
     $players = DataObjectTest_Player::get();
     $list = new PaginatedList($players);
     $list->setPageLength(1);
     $list->getIterator();
     $this->assertEquals(4, $list->getTotalItems(), 'Getting an iterator should not trim the list to the page length.');
 }
 /**
  * @param $sort
  * @param $sortAscending
  * @param $start
  * @param $length
  * @return array
  */
 public function serialize($sort, $sortAscending, $start, $length)
 {
     $list = $this->list;
     $start = intval($start);
     $length = intval($length);
     $sortAscending = $sortAscending == 'true';
     $direction = $sortAscending ? 'ASC' : 'DESC';
     $results = array('data' => array(), 'start' => $start, 'length' => $length);
     if (in_array($sort, $this->columns)) {
         if ($this->list->canSortBy($sort)) {
             $list = $list->sort($sort, $direction);
             $results['sort'] = $sort;
             $results['ascending'] = $sortAscending;
         }
     }
     $paginatedList = new PaginatedList($list, array('start' => $start));
     $paginatedList->setPageLength($length);
     $results['total'] = $paginatedList->getTotalItems();
     foreach ($paginatedList as $key => $record) {
         foreach ($this->getColumnMappings() as $name => $map) {
             $results['data'][$key][$name] = $this->getValue($record, $map);
         }
     }
     return $results;
 }
Beispiel #6
0
 /**
  * Return the products for this group.
  */
 public function Products($recursive = true)
 {
     $products = $this->ProductsShowable($recursive);
     //sort the products
     $products = $this->getSorter()->sortList($products);
     //paginate the products, if necessary
     $pagelength = ProductCategory::config()->page_length;
     if ($pagelength > 0) {
         $products = new PaginatedList($products, $this->request);
         $products->setPageLength($pagelength);
         $products->TotalCount = $products->getTotalItems();
     }
     return $products;
 }