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


PHP Zend_Paginator::getCurrentPageNumber方法代码示例

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


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

示例3: 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

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

示例5: 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

示例6: testGetSetCurrentPageNumber

 public function testGetSetCurrentPageNumber()
 {
     $this->_restorePaginatorDefaults();
     $this->assertEquals(1, $this->_paginator->getCurrentPageNumber());
     $this->_paginator->setCurrentPageNumber(-1);
     $this->assertEquals(1, $this->_paginator->getCurrentPageNumber());
     $this->_paginator->setCurrentPageNumber(11);
     $this->assertEquals(11, $this->_paginator->getCurrentPageNumber());
     $this->_paginator->setCurrentPageNumber(111);
     $this->assertEquals(11, $this->_paginator->getCurrentPageNumber());
     $this->_paginator->setCurrentPageNumber(1);
     $this->assertEquals(1, $this->_paginator->getCurrentPageNumber());
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:13,代码来源:PaginatorTest.php

示例7: search

 /**
  * Returns a paginated list of all sites matching the given parameters.
  * 
  * @param array $params
  * @return array
  */
 public static function search(array $params)
 {
     $siteDb = Yadda_Db_Table::getInstance('site');
     $select = $siteDb->select()->setIntegrityCheck(false)->from('site')->joinLeft('deal', 'site.id = deal.site_id', array('latest_deal' => 'MAX(deal.created)'))->where('site.status = ?', 'active')->group('site.id')->order('site.name');
     // fetch
     $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
     $paginator->setCurrentPageNumber(isset($params['page']) ? (int) $params['page'] : 1);
     $paginator->setItemCountPerPage(isset($params['count']) ? (int) $params['count'] : 10);
     $return = array('params' => $params, 'total' => $paginator->getTotalItemCount(), 'page' => $paginator->getCurrentPageNumber(), 'pages' => $paginator->count(), 'results' => array());
     $sites = new Zend_Db_Table_Rowset(array('table' => $siteDb, 'data' => (array) $paginator->getCurrentItems()));
     foreach ($sites as $site) {
         $return['results'][] = self::toArray($site);
     }
     return $return;
 }
开发者ID:neilgarb,项目名称:yadda,代码行数:21,代码来源:Site.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

示例9: search

 public static function search($params)
 {
     // build query
     $subscriptionDb = Yadda_Db_Table::getInstance('subscription');
     $select = $subscriptionDb->select()->setIntegrityCheck(false)->from('subscription')->joinLeft('user', 'subscription.user_id = user.id', array('user_email' => 'email'))->where('subscription.status = ?', 'active')->order('created DESC');
     // fetch
     $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
     $paginator->setCurrentPageNumber(isset($params['page']) ? (int) $params['page'] : 1);
     $paginator->setItemCountPerPage(isset($params['count']) ? (int) $params['count'] : 10);
     $return = array('params' => $params, 'total' => $paginator->getTotalItemCount(), 'page' => $paginator->getCurrentPageNumber(), 'pages' => $paginator->count(), 'results' => array());
     $subscriptions = new Zend_Db_Table_Rowset(array('table' => $subscriptionDb, 'data' => (array) $paginator->getCurrentItems()));
     foreach ($subscriptions as $subscription) {
         $return['results'][] = self::toArray($subscription);
     }
     return $return;
 }
开发者ID:neilgarb,项目名称:yadda,代码行数:16,代码来源:Subscription.php

示例10: search

 /**
  * Returns a paginated list of regions matching the given parameters.
  * 
  * @param array $params
  * @return array
  */
 public static function search(array $params)
 {
     // build query
     $regionDb = Yadda_Db_Table::getInstance('region');
     $select = $regionDb->select()->from('region')->where('status = ?', 'active')->order('name');
     // fetch
     $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
     $paginator->setCurrentPageNumber(isset($params['page']) ? (int) $params['page'] : 1);
     $paginator->setItemCountPerPage(isset($params['count']) ? (int) $params['count'] : 10);
     $return = array('params' => $params, 'total' => $paginator->getTotalItemCount(), 'page' => $paginator->getCurrentPageNumber(), 'pages' => $paginator->count(), 'results' => array());
     $regions = new Zend_Db_Table_Rowset(array('table' => $regionDb, 'data' => (array) $paginator->getCurrentItems()));
     foreach ($regions as $region) {
         $return['results'][] = self::toArray($region);
     }
     return $return;
 }
开发者ID:neilgarb,项目名称:yadda,代码行数:22,代码来源:Region.php

示例11: _createGridData

 /**
  * Create the grid data structure
  * 
  * @return object
  */
 protected function _createGridData(Zend_Controller_Request_Abstract $request)
 {
     // Instantiate Zend_Paginator with the required data source adaptor
     if (!$this->_paginator instanceof Zend_Paginator) {
         $this->_paginator = new Zend_Paginator($this->_adapter);
         $this->_paginator->setDefaultItemCountPerPage($request->getParam('rows', $this->_defaultItemCountPerPage));
     }
     // Filter items by supplied search criteria
     if ($request->getParam('_search') == 'true') {
         $filter = $this->_getFilterParams($request);
         $this->_paginator->getAdapter()->filter($filter['field'], $filter['value'], $filter['expression'], $filter['options']);
     }
     // Sort items by the supplied column field
     if ($request->getParam('sidx')) {
         $this->_paginator->getAdapter()->sort($request->getParam('sidx'), $request->getParam('sord', 'asc'));
     }
     // Pass the current page number to paginator
     $this->_paginator->setCurrentPageNumber($request->getParam('page', 1));
     // Fetch a row of items from the adapter
     $rows = $this->_paginator->getCurrentItems();
     $grid = new stdClass();
     $grid->page = $this->_paginator->getCurrentPageNumber();
     $grid->total = $this->_paginator->getItemCountPerPage();
     $grid->records = $this->_paginator->getTotalItemCount();
     $grid->rows = array();
     foreach ($rows as $k => $row) {
         if (isset($row['id'])) {
             $grid->rows[$k]['id'] = $row['id'];
         }
         $grid->rows[$k]['cell'] = array();
         foreach ($this->_columns as $column) {
             array_push($grid->rows[$k]['cell'], $column->cellValue($row));
         }
     }
     return $grid;
 }
开发者ID:josmel,项目名称:adminwap,代码行数:41,代码来源:JqGrid.php

示例12: listAction

 public function listAction()
 {
     if ($this->_request->isXmlHttpRequest()) {
         $pageId = $this->_getParam('page', 1);
         $limit = $this->_getParam('limit', 10);
         $sortCol = $this->_getParam('sortCol', 1);
         $sortOrder = $this->_getParam('sortOrder', 'asc');
         $whereParam = $this->_getParam('where', '');
         $modelTable = $this->_getModel();
         $modelTableName = $modelTable->info(Centurion_Db_Table_Abstract::NAME);
         $where = $this->_getSelect();
         if (get_magic_quotes_gpc()) {
             $whereParam = stripslashes($whereParam);
         }
         $whereParam = (array) json_decode($whereParam);
         foreach ($whereParam as $param => $values) {
             if (isset($this->_filters[$param]['type']) && $this->_filters[$param]['type'] === self::FILTER_EXPR) {
                 foreach ($values as $key => $value) {
                     $where->filter($this->_filters[$param]['data'][$value]['expr']);
                 }
                 unset($whereParam[$param]);
             }
             if (isset($this->_filters[$param]) && $this->_filters[$param]['type'] === self::FILTER_CUSTOM && is_callable($this->_filters[$param]['callback'])) {
                 $where = call_user_func($this->_filters[$param]['callback'], $where, $values, $param);
                 unset($whereParam[$param]);
             }
             if (isset($this->_filters[$param]['method']) && is_callable($this->_filters[$param]['method'])) {
                 call_user_func_array($this->_filters[$param]['method'], array($where, $values));
                 unset($whereParam[$param]);
             }
         }
         $where->filter($whereParam);
         $cols = array();
         $naturals = $modelTable->info(Centurion_Db_Table_Abstract::COLS);
         $queryCols = $where->getColumnsName();
         foreach ($this->_displays as $col => $value) {
             if (is_array($value)) {
                 if ($value['expr'] instanceof Zend_Db_Expr) {
                     $cols[] = $value['expr'];
                 }
             } else {
                 if (in_array($col, $naturals)) {
                     if (!$where->isInQuery($col, $modelTableName)) {
                         $cols[] = new Zend_Db_Expr(sprintf(sprintf('%s.%s', $modelTable->getAdapter()->quoteIdentifier($modelTableName), $modelTable->getAdapter()->quoteIdentifier($col))));
                     }
                 } else {
                     if (!in_array($col, $queryCols)) {
                         $cols[] = new Zend_Db_Expr(sprintf('%s AS %s', $where->addRelated($col), $modelTable->getAdapter()->quoteIdentifier($col)));
                     }
                 }
             }
         }
         $where->columns($cols);
         if (in_array($sortCol, array_keys($this->_extras)) && method_exists($this, 'resolveCol' . ucfirst($sortCol))) {
             $sortCol = $this->{'resolveCol' . ucfirst($sortCol)}($where);
             $where->order(sprintf('%s %s', $sortCol, $sortOrder));
         } else {
             if ($sortCol !== 1 && in_array($sortCol, array_keys($this->_displays))) {
                 $where->order(sprintf('%s %s', $sortCol, $sortOrder));
             }
         }
         $this->_preList();
         $adapter = new Zend_Paginator_Adapter_DbTableSelect($where);
         $paginator = new Zend_Paginator($adapter);
         $paginator->setCurrentPageNumber($pageId)->setItemCountPerPage($limit);
         $result = array('pageId' => $paginator->getCurrentPageNumber(), 'nbPages' => $paginator->count(), 'nbRows' => $paginator->getTotalItemCount(), 'rows' => array());
         foreach ($paginator->getCurrentItems() as $modelRow) {
             $tempArray = $modelRow->toArray();
             foreach ($this->_extras as $key => $extra) {
                 if (method_exists($this, $key)) {
                     $tempArray[$key] = $this->{$key}($modelRow);
                 } elseif (method_exists($modelRow, $key)) {
                     $tempArray[$key] = call_user_func(array($modelRow, $key));
                 } else {
                     $tempArray[$key] = $modelRow->{$key};
                 }
             }
             array_push($result['rows'], array('id' => $modelRow->pk, 'cell' => $tempArray));
         }
         $result = $this->_postList($result);
         $json = Zend_Json::encode($result);
         $this->getResponse()->appendBody($json);
     }
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:84,代码来源:CRUD.php

示例13: indexAction

 /** The lister function of all guardian articles
  * @access public
  */
 public function indexAction()
 {
     $page = $this->getParam('page');
     $key = md5('pas' . self::QUERY);
     if (!$this->getCache()->test($key)) {
         $guardian = self::GUARDIANAPI_URL . 'search?q=' . urlencode(self::QUERY) . '&page-size=50&order-by=newest&format=' . self::FORMAT . '&show-fields=all&show-tags=all&show-factboxes=all&show-references=all&api-key=' . $this->_apikey;
         $this->_curl->setUri($guardian);
         $this->_curl->getRequest();
         $articles = $this->_curl->getJson();
         $this->getCache()->save($articles);
     } else {
         $articles = $this->getCache()->load($key);
     }
     $results = array();
     foreach ($articles->response->results as $article) {
         if (isset($article->fields->thumbnail)) {
             $image = $article->fields->thumbnail;
         } else {
             $image = null;
         }
         if (isset($article->fields->standfirst)) {
             $stand = $article->fields->standfirst;
         } else {
             $stand = null;
         }
         $tags = array();
         foreach ($article->tags as $k => $v) {
             $tags[$k] = $v;
         }
         if (isset($article->fields->byline)) {
             $byline = $article->fields->byline;
         } else {
             $byline = null;
         }
         $results[] = array('id' => $article->id, 'headline' => $article->fields->headline, 'byline' => $byline, 'image' => $image, 'pubDate' => $article->webPublicationDate, 'content' => $article->fields->body, 'trailtext' => $article->fields->trailText, 'publication' => $article->fields->publication, 'sectionName' => $article->sectionName, 'linkText' => $article->webTitle, 'standfirst' => $stand, 'section' => $article->sectionName, 'url' => $article->webUrl, 'shortUrl' => $article->fields->shortUrl, 'publication' => $article->fields->publication, 'tags' => $tags);
     }
     $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($results));
     Zend_Paginator::setCache($this->getCache());
     if (isset($page) && $page != "") {
         $paginator->setCurrentPageNumber((int) $page);
     }
     $paginator->setItemCountPerPage(20)->setPageRange(10);
     if (in_array($this->_helper->contextSwitch()->getCurrentContext(), array('xml', 'json', 'rss', 'atom'))) {
         $paginated = array();
         foreach ($paginator as $k => $v) {
             $paginated[$k] = $v;
         }
         $data = array('pageNumber' => $paginator->getCurrentPageNumber(), 'total' => number_format($paginator->getTotalItemCount(), 0), 'itemsReturned' => $paginator->getCurrentItemCount(), 'totalPages' => number_format($paginator->getTotalItemCount() / $paginator->getItemCountPerPage(), 0));
         $this->view->data = $data;
         $this->view->guardianStories = array('guardianStory' => $paginated);
     } else {
         $this->view->data = $paginator;
     }
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:57,代码来源:GuardianController.php

示例14: membersAction

 public function membersAction()
 {
     $page = $this->_getParam('page');
     if (!$this->_cache->test('members')) {
         $query = 'getMps';
         $output = '&output=xml';
         $key = '&key=' . self::TWFYAPIKEY;
         $twfy = self::TWFYURL . $query . $output . $key;
         $data = Zend_Json::fromXml($this->get($twfy), true);
         $data = json_decode($data);
         $this->_cache->save($data);
     } else {
         $data = $this->_cache->load('members');
     }
     $data2 = array();
     foreach ($data->twfy->match as $a) {
         if (in_array($a->constituency, $this->_remove)) {
             unset($a->name);
             unset($a->person_id);
             unset($a->party);
             unset($a->constituency);
         }
         if (isset($a->name)) {
             $data2[] = array('name' => $a->name, 'person_id' => $a->person_id, 'constituency' => $a->constituency, 'party' => $a->party);
         }
     }
     $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($data2));
     if (isset($page) && $page != "") {
         $paginator->setCurrentPageNumber((int) $page);
     }
     $paginator->setItemCountPerPage(40)->setPageRange(10);
     if (in_array($this->_helper->contextSwitch()->getCurrentContext(), array('xml', 'json'))) {
         $data = array('pageNumber' => $paginator->getCurrentPageNumber(), 'total' => number_format($paginator->getTotalItemCount(), 0), 'itemsReturned' => $paginator->getCurrentItemCount(), 'totalPages' => number_format($paginator->getTotalItemCount() / $paginator->getItemCountPerPage(), 0));
         $this->view->data = $data;
         $members = array();
         foreach ($paginator as $k => $v) {
             $members[] = array();
             $members[$k] = $v;
         }
         $this->view->members = $members;
     } else {
         $this->view->data = $paginator;
     }
 }
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:44,代码来源:TheyworkforyouController.php


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