本文整理汇总了PHP中Zend_Paginator::setPageRange方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Paginator::setPageRange方法的具体用法?PHP Zend_Paginator::setPageRange怎么用?PHP Zend_Paginator::setPageRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Paginator
的用法示例。
在下文中一共展示了Zend_Paginator::setPageRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Prepares the environment before running a test.
*/
protected function setUp()
{
parent::setUp();
$this->_scrollingStyle = new Zend_Paginator_ScrollingStyle_Elastic();
$this->_paginator = Zend_Paginator::factory(range(1, 101));
$this->_paginator->setItemCountPerPage(5);
$this->_paginator->setPageRange(5);
}
示例2: setUp
/**
* Prepares the environment before running a test.
*/
protected function setUp()
{
parent::setUp();
$this->_scrollingStyle = new Zend_Paginator_ScrollingStyle_Jumping();
$this->_paginator = Zend_Paginator::factory(range(1, 101));
$this->_paginator->setItemCountPerPage(10);
$this->_paginator->setPageRange(10);
$this->_expectedRange = array_combine(range(1, 10), range(1, 10));
}
示例3: __construct
/**
* Dot_Paginator constructor that sets the main parameters
* If $page is 0 (zero), Zend_Paginator will not be called
* @access public
* @param Zend_Db_Select $select
* @param int $page [optional]
* @param int $resultsPerPage [optional]
* @return Dot_Paginator
*/
public function __construct($select, $page = 0, $resultsPerPage = 0)
{
$this->db = Zend_Registry::get('database');
$this->_select = $select;
$this->_currentPage = $page;
$this->_itemCountPerPage = $resultsPerPage;
$settings = Zend_Registry::get('settings');
if ($this->_currentPage > 0) {
$adapter = new Zend_Paginator_Adapter_DbSelect($select);
$this->_paginator = new Zend_Paginator($adapter);
$this->_paginator->totalItems = $adapter->count();
// page range = the pages on the left + the pages on the right + the current page
$this->_paginator->setPageRange($settings->paginationStep * 2 + 1);
}
}
示例4: testGetSetPageRange
public function testGetSetPageRange()
{
$this->_restorePaginatorDefaults();
$this->assertEquals(10, $this->_paginator->getPageRange());
$this->_paginator->setPageRange(15);
$this->assertEquals(15, $this->_paginator->getPageRange());
}
示例5: selectAll
public function selectAll($pageNumber = 1, $filter = array())
{
$db = $this->siteDbAdapter->select()->from($this->tablename);
foreach ($filter as $key => $val) {
if ($val) {
if (is_int($val)) {
$db->where($key . ' = ?', $val);
} else {
$db->where($key . ' LIKE ?', '%' . $val . '%');
}
}
}
$db->order('log_date DESC');
$adapter = new Zend_Paginator_Adapter_DbSelect($db);
$paginator = new Zend_Paginator($adapter);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage($this->countPerPage);
$paginator->setPageRange($this->pageRange);
return $paginator;
/*
$select = $this->siteDbAdapter->select();
$select->from($this->tablename);
$select->order(array('log_id'));
$log = $this->siteDbAdapter->fetchAll($select->__toString());
return $log;
*/
}
示例6: listAction
public function listAction()
{
// create search form
$searchForm = new Admin_Form_RouteSearch();
$searchForm->setAction('/admin/route/list')->setMethod('post');
$this->view->searchForm = $searchForm;
// get params from request
$sorter = $this->_request->getParam('sorter', null);
$filter = $this->_request->getParam('filter', null);
$filterText = $this->_request->getParam('filterText', null);
// populate them to form
$searchForm->getElement('sorter')->setValue($sorter);
$searchForm->getElement('filter')->setValue($filter);
$searchForm->getElement('filterText')->setValue($filterText);
// list route
$routeModel = new Admin_Model_Route();
$routeAdapter = $routeModel->getRoutePaginatorAdapter($filter, $filterText, $sorter);
if ($routeAdapter) {
$paginator = new Zend_Paginator($routeAdapter);
$page = $this->_request->getParam('page', 1);
$paginator->setItemCountPerPage(5);
$paginator->setCurrentPageNumber($page);
$paginator->setPageRange(8);
$this->view->paginator = $paginator;
}
}
示例7: testNoPagesBeforeSecondLastPageEqualsPageRangeMinTwo
public function testNoPagesBeforeSecondLastPageEqualsPageRangeMinTwo()
{
$this->_paginator->setPageRange(3);
$this->_paginator->setCurrentPageNumber(19);
$pages = $this->_paginator->getPages('Elastic');
$this->assertEquals(5, count($pages->pagesInRange));
}
示例8: createPaginator
public function createPaginator($totalItem, $arrPaginator, $options = null)
{
$adapter = new Zend_Paginator_Adapter_Null($totalItem);
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage($arrPaginator['itemCountPerPage']);
$paginator->setPageRange($arrPaginator['pageRange']);
$paginator->setCurrentPageNumber($arrPaginator['currentPage']);
return $paginator;
}
示例9: 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);
}
示例10: indexAction
public function indexAction()
{
// 博客列表
$modelBlog = new Page();
$where = array('type' => 'now');
$blogs = $modelBlog->getPages($where);
$paginator = new Zend_Paginator($blogs);
$paginator->setItemCountPerPage(5);
$paginator->setPageRange(5);
// 获得当前显示的页码
$page = $this->_request->getParam('page');
$paginator->setCurrentPageNumber($page);
// 渲染到视图
$this->view->blogs = $paginator;
$this->_helper->cache(array('index', 'view'), array('gook'));
}
示例11: __construct
/**
* Constructor
*
* Registers form view helper as decorator
*
* @param mixed $options
* @return void
*/
public function __construct($select, $numberOfColumns, $itemViewscript = null, $options = null)
{
$this->_db = Zend_registry::get('db');
$_frontController = Zend_Controller_Front::getInstance();
$this->_request = $_frontController->getRequest();
if (null === $this->_view) {
require_once 'Zend/Controller/Action/HelperBroker.php';
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$this->_view = $viewRenderer->view;
}
if (!empty($options['paginationViewScript'])) {
$this->_view->assign('paginationViewScript', $options['paginationViewScript']);
} else {
$this->_view->assign('paginationViewScript', null);
}
$this->_view->assign('numberOfColumns', $numberOfColumns);
$this->_view->assign('itemViewScript', $itemViewscript);
$adapter = new Zend_Paginator_Adapter_DbSelect($select);
$paginator = new Zend_Paginator($adapter);
$_config = Zend_Registry::get('config');
$itemPerPage = 12;
if (!empty($_config->products->itemPerPage)) {
$itemPerPage = $_config->products->itemPerPage;
}
if (!empty($options['list_options']['perPage'])) {
$itemPerPage = $options['list_options']['perPage'];
}
if ($this->_request->getParam('perPage')) {
$itemPerPage = $this->_request->getParam('perPage') == 'all' ? $paginator->getTotalItemCount() : $this->_request->getParam('perPage');
}
$pageRange = 5;
if (!empty($_config->products->pageRange)) {
$pageRange = $_config->products->pageRange;
}
$paginator->setItemCountPerPage($itemPerPage);
$paginator->setCurrentPageNumber($this->_request->getParam('page'));
$paginator->setPageRange($pageRange);
$this->_view->assign('paginator', $paginator);
}
示例12: getAll
/**
* Returns the result of a database query for all records
* of persons helped, associated with user name and id
*
* @return Persons_Model_Person
*/
public function getAll($params = array('from' => 'v_person_helped', 'appaccount_id' => 0, 'orderby' => 'name', 'paginator' => true))
{
$db = $this->getDefaultAdapter();
$sql = $db->select()->from($params['from'])->where('appaccount_id = ?', $params['appaccount_id'])->order($params['orderby']);
if (isset($params['filter-keyword'])) {
$normalize = new Agana_Filter_Normalize();
$sql->where('lower(unaccented(name)) LIKE ?', $normalize->filter($params['filter-keyword']));
}
$db->setFetchMode(Zend_DB::FETCH_ASSOC);
if ($params['paginator']) {
$adapter = new Zend_Paginator_Adapter_DbSelect($sql);
$paginator = new Zend_Paginator($adapter);
$page = isset($params['page']) ? $params['page'] : 1;
$paginator->setCurrentPageNumber($page);
$itemCountPerPage = isset($params['itemCountPerPage']) ? $params['itemCountPerPage'] : 20;
$paginator->setItemCountPerPage($itemCountPerPage);
$pageRange = isset($params['pageRange']) ? $params['pageRange'] : 7;
$paginator->setPageRange($pageRange);
return $paginator;
} else {
return $this->_prepareReturnData($db->fetchAll($sql));
}
}
示例13: selectAll
public function selectAll($pageNumber = 1, $filter = array())
{
$db = $this->allDbAdapter->select()->from(array('t' => $this->tablename), array('*', 'ip' => 'INET_NTOA(request_limits_user_ip)'));
foreach ($filter as $key => $val) {
if ($val) {
if ($key == 'request_limits_user_ip') {
$db->where('INET_NTOA(request_limits_user_ip) LIKE ?', '%' . $val . '%');
} else {
if ((int) $val == $val) {
$db->where($key . ' = ?', (int) $val);
} else {
$db->where($key . ' LIKE ?', '%' . $val . '%');
}
}
}
}
$db->order('request_limits_id ASC');
$adapter = new Zend_Paginator_Adapter_DbSelect($db);
$paginator = new Zend_Paginator($adapter);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage($this->countPerPage);
$paginator->setPageRange($this->pageRange);
return $paginator;
}
示例14: selectAll
public function selectAll($pageNumber = 1, $filter = array())
{
$db = $this->allDbAdapter->select()->from($this->tablename);
foreach ($filter as $key => $val) {
if ($val) {
if ($key == 'bl_site_id') {
$db->where($key . ' LIKE ?', '%"' . $val . '"%');
} else {
if (is_int($val)) {
$db->where($key . ' = ?', $val);
} else {
$db->where($key . ' LIKE ?', '%' . $val . '%');
}
}
}
}
$db->order('bl_id ASC');
$adapter = new Zend_Paginator_Adapter_DbSelect($db);
$paginator = new Zend_Paginator($adapter);
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage($this->countPerPage);
$paginator->setPageRange($this->pageRange);
return $paginator;
}
示例15: searchAction
/**
* 内容查询
*
*/
public function searchAction()
{
//获取页面提交参数
$keyWord = urldecode($this->_request->getParam('keyWord'));
$page = $this->_request->getParam('page');
$this->view->keyWord = urlencode($keyWord);
//关键字数组
$keywordsStrArray = explode(' ', $keyWord);
$this->view->keywordsStrArray = $keywordsStrArray;
//开始查询
$array = array();
//新闻
$model = new Model_DbTable_News();
$infos = $model->findByLike($keyWord);
$tmpArray = array();
foreach ($infos as $info) {
$tmpArray['flag'] = 0;
$tmpArray['id'] = $info['id'];
$tmpArray['title'] = $info['title'];
$tmpArray['uncontent'] = $info['uncontent'];
$tmpArray['addtime'] = $info['addtime'];
array_push($array, $tmpArray);
}
//分页参数
if ($page == null) {
$page = 1;
}
$pageRange = 10;
$itemCountPerPage = 10;
//实例并构建Zend_Paginator对象
$paginatorAdapter = new Zend_Paginator_Adapter_Array($array);
$paginator = new Zend_Paginator($paginatorAdapter);
$paginator->setPageRange($pageRange)->setItemCountPerPage($itemCountPerPage)->setCurrentPageNumber($page);
$this->view->paginator = $paginator;
//设置布局
$this->_helper->layout->disableLayout();
//页面信息
$this->view->title = '内容查询-' . $this->_config['pageInfo']['default']['title'];
}