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


PHP Zend_Paginator::getPageRange方法代码示例

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


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

示例1: getPages

    /**
     * Returns an array of "local" pages given a page number and range.
     *
     * @param  Zend_Paginator $paginator
     * @param  integer $pageRange (Optional) Page range
     * @return array
     */
    public function getPages(Zend_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:padraic,项目名称:framework-benchs,代码行数:37,代码来源:Sliding.php

示例2: testGetSetPageRange

 public function testGetSetPageRange()
 {
     $this->_restorePaginatorDefaults();
     $this->assertEquals(10, $this->_paginator->getPageRange());
     $this->_paginator->setPageRange(15);
     $this->assertEquals(15, $this->_paginator->getPageRange());
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:7,代码来源:PaginatorTest.php

示例3: getPages

 /**
  * Returns an array of "local" pages given a page number and range.
  *
  * @param  Zend_Paginator $paginator
  * @param  integer $pageRange (Optional) Page range
  * @return array
  */
 public function getPages(Zend_Paginator $paginator, $pageRange = null)
 {
     // This is unused
     if ($pageRange === null) {
         $pageRange = $paginator->getPageRange();
     }
     $pageNumber = $paginator->getCurrentPageNumber();
     $pageCount = count($paginator);
     $range = array();
     if ($pageCount < 10) {
         // Show all pages if we have less than 10.
         for ($i = 1; $i < 10; $i++) {
             if ($i > $pageCount) {
                 break;
             }
             $range[$i] = $i;
         }
     } else {
         // More than 10 pages:
         foreach (array(1, 2) as $i) {
             $range[$i] = $i;
         }
         if ($pageNumber < 6) {
             // We are on page 1-5 from
             for ($i = 1; $i <= 7; $i++) {
                 $range[$i] = $i;
             }
         } else {
             // Current page > 5
             $range[] = '...';
             // Less than 5 pages left
             if ($pageCount - $pageNumber < 5) {
                 $start = 5 - ($pageCount - $pageNumber);
             } else {
                 $start = 1;
             }
             for ($i = $pageNumber - $start; $i < $pageNumber + (4 - $start); $i++) {
                 if ($i > $pageCount) {
                     break;
                 }
                 $range[$i] = $i;
             }
         }
         if ($pageNumber < $pageCount - 2) {
             $range[] = '...';
         }
         foreach (array($pageCount - 1, $pageCount) as $i) {
             $range[$i] = $i;
         }
     }
     if (empty($range)) {
         $range[] = 1;
     }
     return $range;
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:62,代码来源:SlidingWithBorder.php

示例4: getPages

 /**
  * Returns an array of "local" pages given a page number and range.
  * 
  * @param  Zend_Paginator $paginator
  * @param  integer $pageRange Unused
  * @return array
  */
 public function getPages(Zend_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;
     }
     return parent::getPages($paginator, $pageRange);
 }
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:18,代码来源:Elastic.php

示例5: 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:rafalwrzeszcz,项目名称:zf2,代码行数:15,代码来源:PaginatorTest.php

示例6: getPages

 /**
  * Returns an array of "local" pages given a page number and range.
  *
  * @param  Zend_Paginator $paginator
  * @param  integer $pageRange Unused
  * @return array
  */
 public function getPages(Zend_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:jkimdon,项目名称:cohomeals,代码行数:20,代码来源:Jumping.php

示例7: getPages

 /**
  * Create the page object used in View - paginator method
  * @access public
  * @return object
  */
 public function getPages()
 {
     $pages = new stdClass();
     $pageCount = $this->_paginator->count();
     $pages->pageCount = $pageCount;
     $pages->itemCountPerPage = $this->_itemCountPerPage;
     $pages->first = 1;
     $pages->current = (int) $this->_currentPage;
     $pages->last = $pageCount;
     // Previous and next
     if ($this->_currentPage - 1 > 0) {
         $pages->previous = $this->_currentPage - 1;
     }
     if ($this->_currentPage + 1 <= $pageCount) {
         $pages->next = $this->_currentPage + 1;
     }
     // Pages in range
     $pageRange = $this->_paginator->getPageRange();
     if ($pageRange > $pageCount) {
         $pageRange = $pageCount;
     }
     $delta = ceil($pageRange / 2);
     if ($this->_currentPage - $delta > $pageCount - $pageRange) {
         $lowerBound = $pageCount - $pageRange + 1;
         $upperBound = $pageCount;
     } else {
         if ($this->_currentPage - $delta < 0) {
             $delta = $this->_currentPage;
         }
         $offset = $this->_currentPage - $delta;
         $lowerBound = $offset + 1;
         $upperBound = $offset + $pageRange;
     }
     $pages->pagesInRange = $this->_paginator->getPagesInRange($lowerBound, $upperBound);
     $pages->firstPageInRange = min($pages->pagesInRange);
     $pages->lastPageInRange = max($pages->pagesInRange);
     // Item numbers
     if ($this->_currentItems == null) {
         $this->getCurrentItems();
     }
     if ($this->_currentItems !== null) {
         $pages->currentItemCount = $this->_paginator->getCurrentItemCount();
         $pages->itemCountPerPage = $this->_paginator->getItemCountPerPage();
         $pages->totalItemCount = $this->_paginator->getTotalItemCount();
         $pages->firstItemNumber = ($this->_currentPage - 1) * $this->_paginator->getItemCountPerPage() + 1;
         $pages->lastItemNumber = $pages->firstItemNumber + $pages->currentItemCount - 1;
     }
     return $pages;
 }
开发者ID:sandeepdwarkapuria,项目名称:dotkernel,代码行数:54,代码来源:Paginator.php

示例8: getPages

 /**
  * Returns an array of "local" pages given a page number and range.
  *
  * @param  Zend_Paginator $paginator
  * @param  integer $pageRange (Optional) Page range
  * @return array
  */
 public function getPages(Zend_Paginator $paginator, $pageRange = null)
 {
     if ($pageRange === null) {
         $pageRange = $paginator->getPageRange();
     }
     $pageNumber = $paginator->getCurrentPageNumber();
     $pageCount = count($paginator);
     $range = array();
     if ($pageCount < 15) {
         for ($i = 1; $i < 15; $i++) {
             if ($i > $pageCount) {
                 break;
             }
             $range[$i] = $i;
         }
     } else {
         foreach (array(1, 2) as $i) {
             $range[$i] = $i;
         }
         if ($pageNumber > 8) {
             $range[] = '...';
             $start = 5;
             if ($pageCount - $pageNumber < 8) {
                 $start = 9 - ($pageCount - $pageNumber);
             }
             for ($i = $pageNumber - $start; $i < $pageNumber + (10 - $start); $i++) {
                 if ($i > $pageCount) {
                     break;
                 }
                 $range[$i] = $i;
             }
         } else {
             for ($i = 3; $i <= 10; $i++) {
                 $range[$i] = $i;
             }
         }
         if ($pageNumber < $pageCount - 7) {
             $range[] = '...';
             foreach (array($pageCount - 1, $pageCount) as $i) {
                 $range[$i] = $i;
             }
         }
     }
     if (empty($range)) {
         $range[] = 1;
     }
     return $range;
 }
开发者ID:vbereza,项目名称:icinga2-migration,代码行数:55,代码来源:SlidingWithBorder.php


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