当前位置: 首页>>代码示例>>PHP>>正文


PHP Paginator::getCurrentPageNumber方法代码示例

本文整理汇总了PHP中Zend\Paginator\Paginator::getCurrentPageNumber方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::getCurrentPageNumber方法的具体用法?PHP Paginator::getCurrentPageNumber怎么用?PHP Paginator::getCurrentPageNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Paginator\Paginator的用法示例。


在下文中一共展示了Paginator::getCurrentPageNumber方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: key

 /**
  * Return the key of the current element
  * @link http://php.net/manual/en/iterator.key.php
  * @return mixed scalar on success, or null on failure.
  */
 public function key()
 {
     $innerKey = $this->getInnerIterator()->key();
     $innerKey += 1;
     //Zend\Paginator\Paginator normalizes 0 to 1
     $page = $this->paginator->getCurrentPageNumber();
     return $this->paginator->getAbsoluteItemNumber($innerKey, $this->paginator->getCurrentPageNumber()) - 1;
 }
开发者ID:KBO-Techo-Dev,项目名称:MagazinePro-zf25,代码行数:13,代码来源:PaginatorIterator.php

示例2: getPages

    /**
     * Returns an array of "local" pages given a page number and range.
     *
     * @param  \Zend\Paginator\Paginator $paginator
     * @param  integer $pageRange (Optional) Page range
     * @return array
     */
    public function getPages(\Zend\Paginator\Paginator $paginator, $pageRange = null)
    {
        if ($pageRange === null) {
            $pageRange = $paginator->getPageRange();
        }

        $pageNumber = $paginator->getCurrentPageNumber();
        $pageCount  = count($paginator);

        if ($pageRange > $pageCount) {
            $pageRange = $pageCount;
        }

        $delta = ceil($pageRange / 2);

        if ($pageNumber - $delta > $pageCount - $pageRange) {
            $lowerBound = $pageCount - $pageRange + 1;
            $upperBound = $pageCount;
        } else {
            if ($pageNumber - $delta < 0) {
                $delta = $pageNumber;
            }

            $offset     = $pageNumber - $delta;
            $lowerBound = $offset + 1;
            $upperBound = $offset + $pageRange;
        }

        return $paginator->getPagesInRange($lowerBound, $upperBound);
    }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:37,代码来源:Sliding.php

示例3: 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);
 }
开发者ID:outeredge,项目名称:edge-zf2,代码行数:15,代码来源:Serializer.php

示例4: testCastsIntegerValuesToInteger

 /**
  * @group ZF-4193
  */
 public function testCastsIntegerValuesToInteger()
 {
     // Current page number
     $this->paginator->setCurrentPageNumber(3.3);
     $this->assertTrue($this->paginator->getCurrentPageNumber() == 3);
     // Item count per page
     $this->paginator->setItemCountPerPage(3.3);
     $this->assertTrue($this->paginator->getItemCountPerPage() == 3);
     // Page range
     $this->paginator->setPageRange(3.3);
     $this->assertTrue($this->paginator->getPageRange() == 3);
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:15,代码来源:PaginatorTest.php

示例5: getPages

 /**
  * Returns an array of "local" pages given a page number and range.
  *
  * @param  Paginator $paginator
  * @param  int $pageRange Unused
  * @return array
  */
 public function getPages(Paginator $paginator, $pageRange = null)
 {
     $pageRange = $paginator->getPageRange();
     $pageNumber = $paginator->getCurrentPageNumber();
     $delta = $pageNumber % $pageRange;
     if ($delta == 0) {
         $delta = $pageRange;
     }
     $offset = $pageNumber - $delta;
     $lowerBound = $offset + 1;
     $upperBound = $offset + $pageRange;
     return $paginator->getPagesInRange($lowerBound, $upperBound);
 }
开发者ID:KBO-Techo-Dev,项目名称:MagazinePro-zf25,代码行数:20,代码来源:Jumping.php

示例6: getPages

 /**
  * Returns an array of "local" pages given a page number and range.
  *
  * @param  Paginator $paginator
  * @param  int $pageRange Unused
  * @return array
  */
 public function getPages(Paginator $paginator, $pageRange = null)
 {
     $pageRange = $paginator->getPageRange();
     $pageNumber = $paginator->getCurrentPageNumber();
     $originalPageRange = $pageRange;
     $pageRange = $pageRange * 2 - 1;
     if ($originalPageRange + $pageNumber - 1 < $pageRange) {
         $pageRange = $originalPageRange + $pageNumber - 1;
     } elseif ($originalPageRange + $pageNumber - 1 > count($paginator)) {
         $pageRange = $originalPageRange + count($paginator) - $pageNumber;
     }
     return parent::getPages($paginator, $pageRange);
 }
开发者ID:leonardovn86,项目名称:zf2_basic2013,代码行数:20,代码来源:Elastic.php

示例7: __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);
    }
开发者ID:arstropica,项目名称:zf2-dashboard,代码行数:19,代码来源:PaginatorPosition.php

示例8: indexAction

 public function indexAction()
 {
     /** @var QueryBuilder $qb */
     $qb = $this->getObjectManager()->createQueryBuilder();
     $qb->select('w')->from(Word::class, 'w');
     $form = new WordSearchForm();
     $form->setData($this->params()->fromQuery());
     $form->setInputFilter(new WordSearchInputFilter());
     // it doesn't matter if the form is not valid, as we would fill in default values anyway. This is just to avoid the default error messages
     $form->isValid();
     // set query, direction and order for the querybuilder
     $direction = strtolower($form->getData()['d']);
     $direction = $direction == 'desc' ? 'desc' : 'asc';
     $orderBy = strtolower($form->getData()['o']);
     switch ($orderBy) {
         case 'created':
             $order = 'createdAt';
             break;
         case 'updated':
             $order = 'updatedAt';
             break;
         default:
             $orderBy = $order = 'word';
             break;
     }
     $qb->orderBy('w.' . $order, $direction);
     // no need to avoid SQL injection, as doctrine does this for us
     $query = $form->getData()['q'];
     $qb->where('w.word LIKE :query')->setParameter('query', '%' . $query . '%');
     $itemsPerPage = 50;
     // set up the paginator
     $adapter = new DoctrineAdapter(new ORMPaginator($qb->getQuery()));
     $paginator = new Paginator($adapter);
     $paginator->setDefaultItemCountPerPage(50);
     $page = (int) $this->params()->fromQuery('p');
     if ($page != null) {
         $paginator->setCurrentPageNumber($page);
     } else {
         $paginator->setCurrentPageNumber(1);
     }
     $pages = $paginator->getTotalItemCount() / $itemsPerPage;
     $paginator->setPageRange($pages);
     $viewModel = new ViewModel();
     $viewModel->setVariables(['words' => $paginator->getCurrentItems(), 'pageCount' => $paginator->getPageRange() + 1, 'currentPage' => $paginator->getCurrentPageNumber(), 'orderBy' => $orderBy, 'direction' => $direction, 'query' => $query, 'form' => $form]);
     return $viewModel;
 }
开发者ID:spoorey,项目名称:hangman,代码行数:46,代码来源:WordController.php

示例9: getList

 /**
  * getList
  *
  * @return mixed|JsonModel
  */
 public function getList()
 {
     //ACCESS CHECK
     if (!$this->rcmIsAllowed('sites', 'admin')) {
         $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);
         return $this->getResponse();
     }
     /** @var \Doctrine\ORM\EntityManagerInterface $entityManager */
     $entityManager = $this->getEntityManager();
     /** @var \Rcm\Repository\Site $siteRepo */
     $siteRepo = $entityManager->getRepository('\\Rcm\\Entity\\Site');
     $createQueryBuilder = $siteRepo->createQueryBuilder('site')->select('site')->leftJoin('site.domain', 'domain')->leftJoin('site.country', 'country')->leftJoin('site.language', 'language')->orderBy('domain.domain', 'ASC');
     $query = $createQueryBuilder->getQuery();
     $searchQuery = $this->params()->fromQuery('q');
     if ($searchQuery) {
         $createQueryBuilder->where($createQueryBuilder->expr()->like('domain.domain', ':searchQuery'));
         $query = $createQueryBuilder->getQuery();
         $query->setParameter('searchQuery', $searchQuery . '%');
     }
     $adaptor = new DoctrinePaginator(new ORMPaginator($query));
     $paginator = new Paginator($adaptor);
     $paginator->setDefaultItemCountPerPage(10);
     $page = (int) $this->params()->fromQuery('page');
     if ($page) {
         $paginator->setCurrentPageNumber($page);
     }
     $pageSize = (int) $this->params()->fromQuery('page_size');
     if ($pageSize) {
         $paginator->setItemCountPerPage($pageSize);
     }
     $sitesObjects = $paginator->getCurrentItems();
     $sites = [];
     /** @var \Rcm\Entity\Site $site */
     foreach ($sitesObjects as $site) {
         $sites[] = $site->toArray();
     }
     $list['items'] = $sites;
     $list['itemCount'] = $paginator->getTotalItemCount();
     $list['pageCount'] = $paginator->count();
     $list['currentPage'] = $paginator->getCurrentPageNumber();
     return new ApiJsonModel($list, 0, 'Success');
 }
开发者ID:reliv,项目名称:rcm-admin,代码行数:47,代码来源:ApiAdminManageSitesController.php

示例10: 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);
 }
开发者ID:sarancea,项目名称:ciklum,代码行数:31,代码来源:ApiAbstract.php

示例11: __invoke

 /**
  * @param  Paginator $paginator
  * @return array
  */
 public function __invoke(Paginator $paginator)
 {
     return ['limit' => $paginator->getItemCountPerPage(), 'offset' => ($paginator->getCurrentPageNumber() - 1) * $paginator->getItemCountPerPage(), 'total' => $paginator->getTotalItemCount()];
 }
开发者ID:omusico,项目名称:zfr-rest,代码行数:8,代码来源:RenderPaginator.php

示例12: getCurrentPage

 /**
  * Get the current page.
  *
  * @return int
  */
 public function getCurrentPage()
 {
     return $this->paginator->getCurrentPageNumber();
 }
开发者ID:JesseObrien,项目名称:fractal,代码行数:9,代码来源:ZendFrameworkPaginatorAdapter.php

示例13: isLastPage

 /**
  * Checks if provided paginator is in last page
  *
  * @param Paginator $paginator
  * @return bool
  */
 protected function isLastPage(Paginator $paginator)
 {
     return $paginator->getCurrentPageNumber() >= $paginator->count();
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:10,代码来源:PaginatorUtilsTrait.php


注:本文中的Zend\Paginator\Paginator::getCurrentPageNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。