本文整理汇总了PHP中PaginatedList::getTotalItems方法的典型用法代码示例。如果您正苦于以下问题:PHP PaginatedList::getTotalItems方法的具体用法?PHP PaginatedList::getTotalItems怎么用?PHP PaginatedList::getTotalItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaginatedList
的用法示例。
在下文中一共展示了PaginatedList::getTotalItems方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleList
/**
* 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'));
}
示例2: requests
/**
* 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')));
}
示例3: testSetPaginationFromQuery
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());
}
示例4: testGetIterator
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.');
}
示例5: serialize
/**
* @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;
}
示例6: Products
/**
* 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;
}