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


PHP Zend_Paginator::getCurrentItemCount方法代码示例

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


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

示例1: testGetsCurrentItemCount

 public function testGetsCurrentItemCount()
 {
     $this->_paginator->setItemCountPerPage(10);
     $this->_paginator->setPageRange(10);
     $this->assertEquals(10, $this->_paginator->getCurrentItemCount());
     $this->_paginator->setCurrentPageNumber(11);
     $this->assertEquals(1, $this->_paginator->getCurrentItemCount());
     $this->_paginator->setCurrentPageNumber(1);
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:9,代码来源:PaginatorTest.php

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

示例3: testPaginator

 public function testPaginator()
 {
     $countries = My_ShantyMongo_Country::all();
     $this->assertEquals(239, $countries->count());
     $paginator = new Zend_Paginator(new Shanty_Paginator_Adapter_Mongo($countries));
     $paginator->setItemCountPerPage(10);
     $paginator->setCurrentPageNumber(3);
     $this->assertEquals(24, $paginator->count());
     // Count pages
     $this->assertEquals(239, $paginator->getTotalItemCount());
     // count total items
     $this->assertEquals(10, $paginator->getCurrentItemCount());
     // count items on this page
     $paginator->getCurrentItems()->rewind();
     $firstItem = $paginator->getCurrentItems()->current();
     $this->assertEquals($firstItem->code, 'BB');
     $this->assertEquals($firstItem->name, 'Barbados');
 }
开发者ID:hongliang,项目名称:Shanty-Mongo,代码行数:18,代码来源:MongoTest.php

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

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

示例6: businessAction

 /**
  * Job basic for seo.
  * show all the jobs in the city.
  * @return unknown_type
  */
 function businessAction()
 {
     //echo   "jobs";
     $this->view = $this->_setRequiredParamsToView($this->view);
     $this->view->category = $this->_busType;
     try {
         $this->view->business = $this->getBusiness();
         $this->view->form = $this->getForm($this->view->business, $this->view->location);
         //$values['cat4'] = Location::getStateIdByName($this->view->location->getState());
         //	$values['cat5'] = Location::getCityIdByName($this->view->location->getCity());
         $cat1 = $this->view->paramsHolder->cat1;
         $additonalData = $this->_getAdditionalData($this->view);
         $select = $this->view->business->search($this->view->location, $this->view->limit, $this->view->offset, $this->view->paramsHolder->query, $cat1, $this->view->paramsHolder->cat2, $this->view->paramsHolder->cat3, $this->view->paramsHolder->cat4, $this->view->paramsHolder->cat5, $additonalData);
         if (!empty($select)) {
             logfire('------select: ', $select->__toString());
             $adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
             $paginator = new Zend_Paginator($adapter);
             $paginator->setItemCountPerPage($this->view->limit);
             $paginator->setCurrentPageNumber($this->view->offset);
             Zend_Paginator::setDefaultScrollingStyle('Sliding');
             Zend_View_Helper_PaginationControl::setDefaultViewPartial('sitetemplate/_pagination.phtml');
             $this->view->currentItemCount = $paginator->getCurrentItemCount();
             $this->view->itemCount = $paginator->getTotalItemCount();
             //echo '------currentItemCoutn: ' .  $this->view->currentItemCount;
             $paginator->setView($this->view);
             $this->view->postings = $paginator;
             /*
             foreach($this->view->postings as $key=>$value)
             {
             print_r($value);break;
             }
             */
         }
     } catch (Exception $e) {
         echo $e;
     }
     //$this->renderScript('jobs/index.phtml');
     //  	echo Tag::link('jobsbasic',$this->view->location->toStdClass(),'test');
 }
开发者ID:xinghao,项目名称:shs,代码行数:44,代码来源:BusinessController.php


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