本文整理汇总了PHP中Zend\Paginator\Paginator::getTotalItemCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::getTotalItemCount方法的具体用法?PHP Paginator::getTotalItemCount怎么用?PHP Paginator::getTotalItemCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Paginator\Paginator
的用法示例。
在下文中一共展示了Paginator::getTotalItemCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dataAction
public function dataAction()
{
$response = $this->getResponse();
$grid = $this->grid('Application\\Index\\Index', array('-', 'id', 'title', 'category', 'username', 'created_at', '-'));
if (isset($this->getSessionContainer()->parent_id)) {
$grid['parent_id'] = $this->getSessionContainer()->parent_id;
}
$result = $this->getResourceTable()->fetchDataGrid($grid);
$adapter = new ArrayAdapter($result);
$paginator = new Paginator($adapter);
$page = ceil(intval($grid['start']) / intval($grid['length'])) + 1;
$paginator->setCurrentPageNumber($page);
$paginator->setItemCountPerPage(intval($grid['length']));
$data = array();
$data['data'] = array();
foreach ($paginator as $row) {
$category = array_key_exists('category', $row) ? $row['category'] : '-';
$title = $row['node_type'] == \Application\Model\Resource::NODE_TYPE_CATEGORY ? '<a href="/admin/resource/parent_id/' . $row['id'] . '" title="' . strip_tags($row['description']) . '">' . strip_tags($row['title']) . '</a>' : '<i>' . strip_tags($row['title']) . '</i>';
$actions = '';
if ($row['url']) {
$actions .= '<a class="btn btn-xs btn-outline blue-steel btn-view" href="' . $row['url'] . '" data-id="' . $row['id'] . '" target="_blank">View</a> ';
}
$actions .= '<a class="btn btn-xs btn-outline red" href="/admin/resource/delete/id/' . $row['id'] . '" onclick="return confirm("Are you sure you wish to delete selected resources?");">Delete</a>';
$data['data'][] = array('<input type="checkbox" name="id[' . $row['id'] . ']" value="' . $row['id'] . '" />', '<a class="btn btn-xs btn-outline blue-steel btn-view" href="/admin/resource/edit/id/' . $row['id'] . '/parent_id/' . $row['parent_id'] . '" title="' . $row['id'] . '">Edit: ' . $row['id'] . '</a>', $title, $category, $row['username'], date('F jS Y', strtotime($row['created_at'])), $actions);
}
$data['page'] = $page;
$data['grid'] = $grid;
$data['draw'] = intval($grid['draw']);
$data['recordsTotal'] = $paginator->getTotalItemCount();
$data['recordsFiltered'] = $paginator->getTotalItemCount();
$response->setStatusCode(200);
$response->setContent(Json::encode($data));
return $response;
}
示例2: paginatorToArray
/**
* Convert a paginator to array
*
* @param Paginator $paginator
* @param string $key root key for items, leave null to return items in root
* @return array
*/
protected function paginatorToArray(Paginator $paginator, $key = null)
{
$items = iterator_to_array($paginator->getCurrentItems());
if (null === $key) {
return $items;
}
return array('pages' => $paginator->count(), 'current' => $paginator->getCurrentPageNumber(), 'count' => $paginator->getTotalItemCount(), $key => $items);
}
示例3: getPagination
public function getPagination($iPageNumber = 0, $iCountPerPage = 0)
{
$paginatorAdapter = new DbSelect($this->mAdministratorTb->getSql()->select()->columns(array('id', 'role_id', 'username', 'realname', 'raw_add_time')), $this->mAdministratorTb->getAdapter(), $this->mAdministratorTb->getResultSetPrototype());
$paginator = new Paginator($paginatorAdapter);
$paginator->setCurrentPageNumber($iPageNumber)->setItemCountPerPage($iCountPerPage);
$aRows = $this->mCore->IteratorToArray($paginator->getCurrentItems());
$iTotal = $paginator->getTotalItemCount();
return json_encode(array('rows' => $aRows, 'total' => $iTotal));
}
示例4: getPagination
public function getPagination($iPageNumber = 0, $iCountPerPage = 0, $aOptions = array())
{
$paginatorAdapter = new DbSelect($this->mAuthorityTb->getSql()->select()->where($aOptions), $this->mAuthorityTb->getAdapter(), $this->mAuthorityTb->getResultSetPrototype());
$paginator = new Paginator($paginatorAdapter);
$paginator->setCurrentPageNumber($iPageNumber)->setItemCountPerPage($iCountPerPage);
$iTotal = $paginator->getTotalItemCount();
$aRows = $this->mCore->IteratorToArray($paginator->getCurrentItems());
return json_encode(array('rows' => $aRows, 'total' => $iTotal));
}
示例5: listAction
/**
* @return \Zend\View\Model\ViewModel
*/
public function listAction()
{
$page = $this->params('page');
$templateQuery = $this->getGeneralService()->findFiltered(WebInfo::class, []);
$paginator = new Paginator(new PaginatorAdapter(new ORMPaginator($templateQuery, false)));
$paginator->setDefaultItemCountPerPage($page === 'all' ? PHP_INT_MAX : 15);
$paginator->setCurrentPageNumber($page);
$paginator->setPageRange(ceil($paginator->getTotalItemCount() / $paginator->getDefaultItemCountPerPage()));
return new ViewModel(['paginator' => $paginator]);
}
示例6: missingAction
/**
* @return ViewModel
*/
public function missingAction()
{
$affiliation = $this->getAffiliationService()->findAffiliationWithMissingLoi();
$page = $this->params('page');
$paginator = new Paginator(new PaginatorAdapter(new ORMPaginator($affiliation, false)));
$paginator->setDefaultItemCountPerPage($page === 'all' ? PHP_INT_MAX : 15);
$paginator->setCurrentPageNumber($page);
$paginator->setPageRange(ceil($paginator->getTotalItemCount() / $paginator->getDefaultItemCountPerPage()));
return new ViewModel(['paginator' => $paginator]);
}
示例7: overviewAction
/**
* @return ViewModel
*/
public function overviewAction()
{
$which = $this->params('which', CalendarService::WHICH_UPCOMING);
$page = $this->params('page', 1);
$calendarItems = $this->getCalendarService()->findCalendarItems($which, $this->zfcUserAuthentication()->getIdentity());
$paginator = new Paginator(new PaginatorAdapter(new ORMPaginator($calendarItems)));
$paginator->setDefaultItemCountPerPage($page === 'all' ? PHP_INT_MAX : 15);
$paginator->setCurrentPageNumber($page);
$paginator->setPageRange(ceil($paginator->getTotalItemCount() / $paginator->getDefaultItemCountPerPage()));
$whichValues = $this->getCalendarService()->getWhichValues();
return new ViewModel(['enableCalendarContact' => $this->getModuleOptions()->getCommunityCalendarContactEnabled(), 'which' => $which, 'paginator' => $paginator, 'whichValues' => $whichValues]);
}
示例8: fetch
public function fetch($meta = null)
{
$this->select->from($this->name);
$dbSelect = new DbSelect($this->select, $this->tableGateway->getAdapter(), $this->getResultSet());
$paginator = new Paginator($dbSelect);
if ($meta) {
if (isset($meta['loadAllToFirstPage'])) {
$paginator->setItemCountPerPage($paginator->getTotalItemCount());
}
}
return $this->constructForeignKeys($paginator);
}
示例9: dataAction
public function dataAction()
{
$request = $this->getRequest();
$response = $this->getResponse();
$post = $this->purify($request->getPost());
$actionMessage = array();
if (isset($post->action)) {
if (sizeof($post->id)) {
if ($post->action == 'mark-delete') {
foreach ($post->id as $id) {
$this->getActivityTable()->delete(array('id' => $id));
}
$actionMessage = array('message' => 'A total of ' . count($post->id) . ' records have been deleted successfully.', 'status' => 'OK');
}
}
}
$grid = $this->grid('Admin\\Activity\\Index', array('-', 'id', 'text', 'username', 'created_at', '-'));
$result = $this->getActivityTable()->fetchDataGrid($grid);
$adapter = new ArrayAdapter($result);
$paginator = new Paginator($adapter);
$page = ceil(intval($grid['start']) / intval($grid['length'])) + 1;
$paginator->setCurrentPageNumber($page);
$paginator->setItemCountPerPage(intval($grid['length']));
$data = array();
$data['data'] = array();
foreach ($paginator as $row) {
$data['data'][] = array('<input type="checkbox" name="id[' . $row['id'] . ']" value="' . $row['id'] . '" />', $row['id'], $row['text'], $row['username'], $row['created_at'], '<a href="/admin/activity/view/id/' . $row['id'] . '" class="btn btn-xs btn-outline blue-steel" data-id="' . $row['id'] . '" title="View Activity"><i class="fa fa-search"></i> View</a>');
}
$data['page'] = $page;
$data['grid'] = $grid;
$data['draw'] = intval($grid['draw']);
$data['recordsTotal'] = $paginator->getTotalItemCount();
$data['recordsFiltered'] = $paginator->getTotalItemCount();
if (sizeof($actionMessage)) {
$data['actionMessage'] = $actionMessage;
}
$response->setStatusCode(200);
$response->setContent(Json::encode($data));
return $response;
}
示例10: listAction
/**
* @return \Zend\View\Model\ViewModel
*/
public function listAction()
{
$page = $this->params()->fromRoute('page', 1);
$filterPlugin = $this->getGeneralFilter();
$contactQuery = $this->getGeneralService()->findEntitiesFiltered('gender', $filterPlugin->getFilter());
$paginator = new Paginator(new PaginatorAdapter(new ORMPaginator($contactQuery, false)));
$paginator->setDefaultItemCountPerPage($page === 'all' ? PHP_INT_MAX : 20);
$paginator->setCurrentPageNumber($page);
$paginator->setPageRange(ceil($paginator->getTotalItemCount() / $paginator->getDefaultItemCountPerPage()));
$form = new GenderFilter($this->getGeneralService());
$form->setData(['filter' => $filterPlugin->getFilter()]);
return new ViewModel(['paginator' => $paginator, 'form' => $form, 'encodedFilter' => urlencode($filterPlugin->getHash()), 'order' => $filterPlugin->getOrder(), 'direction' => $filterPlugin->getDirection()]);
}
示例11: testNewInstance
/**
* @depends testApiAccess
*/
public function testNewInstance(SearchForm $form)
{
$adapter = new SearchFormAdapter($form);
$this->assertSame(6, $adapter->count());
$pager = new Paginator($adapter);
$pager->setCurrentPageNumber(1);
$pager->setItemCountPerPage(2);
$this->assertSame(6, $pager->getTotalItemCount());
foreach ($pager as $item) {
$this->assertInstanceOf('Prismic\\Document', $item);
$this->assertSame('pager-test-doc', $item->getType());
}
return $pager;
}
示例12: getList
/**
* Return list of resources
*
* @param callable $queryBuilderCallback
* @param callable $queryCallback
* @throws \Application\Library\Exception\ValidationException
* @return mixed
*/
public function getList(\Closure $queryBuilderCallback = null, \Closure $queryCallback = null)
{
$form = new ModelFilterForm();
$form->setData($this->params()->fromQuery());
if (!$form->isValid()) {
throw new ValidationException($form->getMessages(), 400);
}
$limit = $form->getData()['rows'];
$page = $form->getData()['page'];
$queryBuilder = $this->getEntityManager()->createQueryBuilder();
$queryBuilder->select('c')->from($this->entityClass, 'c');
if (!is_null($queryBuilderCallback)) {
$queryBuilderCallback($queryBuilder);
}
$query = $queryBuilder->getQuery()->setHydrationMode(Query::HYDRATE_ARRAY);
if (!is_null($queryCallback)) {
$queryCallback($query);
}
$paginator = new Paginator(new DoctrinePaginator(new ORMPaginator($query)));
$paginator->setCurrentPageNumber($page)->setItemCountPerPage($limit);
$return = array('page' => $paginator->getCurrentPageNumber(), 'total' => ceil($paginator->getTotalItemCount() / $limit), 'records' => $paginator->getTotalItemCount(), 'rows' => $paginator->getCurrentItems()->getArrayCopy());
return new JsonModel($return);
}
示例13: viewAction
/**
* @return ViewModel
*/
public function viewAction()
{
$organisationService = $this->getOrganisationService()->setOrganisationId($this->params('id'));
$page = $this->params()->fromRoute('page', 1);
$filterPlugin = $this->getInvoiceFilter();
$invoiceQuery = $this->getInvoiceService()->findEntitiesFiltered('invoice', array_merge($filterPlugin->getFilter(), ['organisation' => [$organisationService->getOrganisation()->getId()]]));
$paginator = new Paginator(new PaginatorAdapter(new ORMPaginator($invoiceQuery, false)));
$paginator->setDefaultItemCountPerPage($page === 'all' ? PHP_INT_MAX : 15);
$paginator->setCurrentPageNumber($page);
$paginator->setPageRange(ceil($paginator->getTotalItemCount() / $paginator->getDefaultItemCountPerPage()));
$form = new InvoiceFilter($this->getInvoiceService());
$form->setData(['filter' => $filterPlugin->getFilter()]);
$projects = $this->getProjectService()->findProjectByOrganisation($organisationService->getOrganisation(), ProjectService::WHICH_ALL);
return new ViewModel(['paginator' => $paginator, 'form' => $form, 'encodedFilter' => urlencode($filterPlugin->getHash()), 'order' => $filterPlugin->getOrder(), 'direction' => $filterPlugin->getDirection(), 'organisationService' => $organisationService, 'organisationDoa' => $this->getDoaService()->findDoaByOrganisation($organisationService->getOrganisation()), 'organisationLoi' => $this->getLoiService()->findLoiByOrganisation($organisationService->getOrganisation()), 'projects' => $projects, 'projectService' => $this->getProjectService()]);
}
示例14: dataAction
public function dataAction()
{
$response = $this->getResponse();
$grid = $this->grid('Application\\Index\\Index', array('id', 'title', 'category', 'created_at', '-'));
$result = $this->getResourceTable()->fetchResources($grid);
$adapter = new ArrayAdapter($result);
$paginator = new Paginator($adapter);
$page = ceil(intval($grid['start']) / intval($grid['length'])) + 1;
$paginator->setCurrentPageNumber($page);
$paginator->setItemCountPerPage(intval($grid['length']));
$data = array();
$data['data'] = array();
foreach ($paginator as $row) {
$data['data'][] = array($row['id'], '<strong>' . $row['title'] . '</strong><br/>' . $row['description'], $row['category'], $row['created_at'], '<a href="' . $row['url'] . '" class="btn btn-xs default btn-editable btn-view" data-id="' . $row['id'] . '" title="View Resource" target="_blank"><i class="fa fa-search"></i> View</a>');
}
$data['page'] = $page;
$data['grid'] = $grid;
$data['draw'] = intval($grid['draw']);
$data['recordsTotal'] = $paginator->getTotalItemCount();
$data['recordsFiltered'] = $paginator->getTotalItemCount();
$response->setStatusCode(200);
$response->setContent(Json::encode($data));
return $response;
}
示例15: __invoke
/**
*
* @return string
*/
public function __invoke(Paginator $paginator)
{
$content = <<<HTML
\t\t<label class="inline control-label">Displaying: </label>
\t\t<span>
\t\t\t%1\$s - %2\$s of %3\$s
\t\t</span>
HTML;
$limit = $paginator->getItemCountPerPage();
$page = $paginator->getCurrentPageNumber();
$current = $paginator->getCurrentItemCount();
$total = $paginator->getTotalItemCount();
$offset = $limit * $page - $limit;
return sprintf($content, intval($offset) + 1, intval($offset) + intval($current), $total);
}