本文整理汇总了PHP中Zend_Paginator::setItemCountPerPage方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Paginator::setItemCountPerPage方法的具体用法?PHP Zend_Paginator::setItemCountPerPage怎么用?PHP Zend_Paginator::setItemCountPerPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Paginator
的用法示例。
在下文中一共展示了Zend_Paginator::setItemCountPerPage方法的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\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_Sliding();
$this->_paginator = Zend_Paginator::factory(range(1, 101));
$this->_paginator->setItemCountPerPage(10);
$this->_paginator->setPageRange(5);
}
示例3: 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));
}
示例4: getCurrentItems
/**
* Get current items to display on current page
* @access public
* @return object ArrayIterator
*/
public function getCurrentItems()
{
$this->_paginator->setItemCountPerPage($this->_itemCountPerPage);
$this->_paginator->setCurrentPageNumber($this->_currentPage);
if ($this->_currentItems === null) {
$this->_currentItems = $this->_paginator->getCurrentItems();
}
return $this->_currentItems;
}
示例5: indexAction
/**
* Lists all servicePacks matching a criteria
*/
public function indexAction()
{
// Check permissions
$sp = new ServicePackModel();
$this->_helper->allowed('list', $sp);
// Pagination
$params = $this->_getPaginatorParams();
// Filters
$filters = $this->_mapToFilter($this->_getFilterParams());
$this->_checkFilterParams($filters, ServicePackFilterFields::getWhiteList());
$filterList = $this->_spSrv->buildFilterList($filters);
$this->_helper->filterNotAllowedFilters('filter_by', $filterList);
// Search
$spList = $this->_spSrv->listAll($filterList, $params);
if ($spList) {
$list = array();
foreach ($spList->getItems() as $item) {
try {
$this->_helper->allowed('read', $item);
$this->_helper->filterNotAllowedFields('read_field', $item);
$list[] = $item;
} catch (Exception $e) {
// Do nothing
}
}
// Simulate pagination
$it = new ArrayIterator($list);
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Iterator($it));
$paginator->setItemCountPerPage($params['count']);
// Result
$iterator = $paginator->getItemsByPage($params['page']);
$this->view->servicePacks = iterator_to_array($iterator, false);
}
}
示例6: indexAction
public function indexAction()
{
/**
* Form cadastro
*/
$formPropostaCadastro = new Form_Site_PropostaCadastro();
$formPropostaCadastro->submit->setLabel("CADASTRAR");
//$formPropostaCadastro->proposta_numero->setValue($this->getNumeroProposta());
$this->view->formPropostaCadastro = $formPropostaCadastro;
/**
* Busca as propostas
*/
$page = $this->getRequest()->getParam('page', 1);
//get curent page param, default 1 if param not available.
$modelProposta = new Model_DbTable_Proposta();
$data = $modelProposta->getQuery();
$adapter = new Zend_Paginator_Adapter_DbSelect($data);
//adapter
$paginator = new Zend_Paginator($adapter);
// setup Pagination
$paginator->setItemCountPerPage(Zend_Registry::get("config")->resource->rowspage);
// Items perpage, in this example is 10
$paginator->setCurrentPageNumber($page);
// current page
//Zend_Paginator::setDefaultScrollingStyle('Sliding');
//Zend_View_Helper_PaginationControl::setDefaultViewPartial('partials/pagination.phtml');
$this->view->propostas = $paginator;
}
示例7: fetchAllPage
public static function fetchAllPage($role, $page = 1, $perpage = 30)
{
if ($role != 0 && $role != 1 && $role != 2 && $role != 3) {
return array();
}
$select = self::select();
if ($role != 0) {
$select->where('urole = ?', $role)->order('ctime desc');
}
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage($perpage)->setCurrentPageNumber($page);
$data = $paginator->getCurrentItems();
$pages = $paginator->count();
$orders = array();
if (count($data) > 0) {
foreach ($data as $da) {
$orderModel = new Application_Model_O_MemberCardOrder();
$orderModel->setId($da->id)->setOrder_id($da->order_id)->setUid($da->uid)->setUrole($da->urole)->setMember_card_id($da->member_card_id)->setTotal_price($da->total_price)->setPayment_status($da->payment_status)->setRemark($da->remark)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status);
array_push($orders, $orderModel);
}
}
$res = array('orders' => $orders, 'pages' => $pages);
return $res;
}
示例8: getAll
public function getAll($active = false, $lng = 'nl', $paginator = true, $pindex = 1, $perpage = 25, $cache = true)
{
if ($cache == true) {
$cacheId = $this->generateCacheId(get_class($this) . '_' . __FUNCTION__, func_get_args());
$cache = Zend_Registry::get('cache');
if (true == ($result = $cache->load($cacheId))) {
return $result;
}
}
$db = Zend_Registry::get('db');
$select = $db->select()->from(array('n' => 'News'), array('*'))->joinLeft(array('t' => 'NewsTsl', array('lng', 'title', 'summary', 'content', 'url', 'seo_keywords', 'seo_title', 'seo_description', 'active')), 'n.nid = t.nid')->where('t.lng = ?', $lng);
if ($active) {
$select->where('t.active = 1')->where('n.date_published <= NOW()')->where('n.date_expired > NOW() OR n.date_expired is NULL')->order('n.date_message DESC')->order('n.date_published DESC');
} else {
$select->order('n.date_published DESC')->order('n.date_created DESC');
}
if ($paginator === true) {
$adapter = new Base_PaginatorAdapter($select);
$adapter->setMapper($this->_mapper);
$data = new Zend_Paginator($adapter);
$data->setCurrentPageNumber((int) $pindex);
$data->setItemCountPerPage((int) $perpage);
} else {
$results = $db->fetchAll($select);
$data = $this->_mapper->mapAll($results);
}
if ($cache == true) {
$cacheTags = $this->generateCacheTags(get_class($this) . '_' . __FUNCTION__);
$cache->save($data, $cacheId, $cacheTags);
}
return $data;
}
示例9: fetchByType
public static function fetchByType($type = 1, $page = 1, $perpage = 30)
{
if ($type != 0 && $type != 1 && $type != 2) {
return array();
}
$select = self::select();
if ($type != 0) {
$select->where('type = ?', $type);
}
$select->order('sort asc');
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage($perpage)->setCurrentPageNumber($page);
$data = $paginator->getCurrentItems();
$pages = $paginator->count();
$destinations = array();
if (count($data) > 0) {
foreach ($data as $da) {
$destinationModel = new Application_Model_O_Destination();
$destinationModel->setId($da->id)->setCity($da->city)->setType($da->type)->setLongitude($da->longitude)->setLatitude($da->latitude)->setImg($da->img)->setSort($da->sort)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status);
array_push($destinations, $destinationModel);
}
}
$res = array('destinations' => $destinations, 'pages' => $pages);
return $res;
}
示例10: 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;
}
}
示例11: getProductByCategory
/**
* gets a listing of products based on category
*
* (main method used in product listings)
*
* @param $categoryId category ID (can be more than one)
* @param null $paged current page (null, no pagination; not null contains the current page)
* @param null $order order clause
* @return Zend_Db_Table_Rowset_Abstract|Zend_Paginator
*/
public function getProductByCategory($categoryId, $paged = null, $order = null)
{
// creating the select statement
// using the IN clause is suitable as $categoryId is an array of categories
$select = $this->select()->from('product')->where('categoryId IN (?)', $categoryId);
// ordering according to order clause
// (e.g., array('name ASC', 'price DESC')
if (is_array($order) === true) {
$select->order($order);
}
// paginating the result
if ($paged !== null) {
// adapter to configure the paginator instance
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
// select statement that calculates the total amount of rows returned by the main statement
$count = clone $select;
// reseting the cloned statement
$count->reset(Zend_Db_Select::COLUMNS);
$count->reset(Zend_Db_Select::FROM);
// creating the count expression with Zend_Db_Expr
$count->from('product', new Zend_Db_Expr('COUNT(*) as `zend_paginator_row_count`'));
// setting the count statement in the adapter
$adapter->setRowCount($count);
// creating the zend paginator instance using the adapter
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage(5)->setCurrentPageNumber((int) $paged);
return $paginator;
}
return $this->fetchAll($select);
}
示例12: indexAction
public function indexAction()
{
$this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Pickup Groups")));
$db = Zend_Registry::get('db');
$select = $db->select()->from("pickup_group");
if ($this->_request->getPost('filtro')) {
$field = mysql_escape_string($this->_request->getPost('campo'));
$query = mysql_escape_string($this->_request->getPost('filtro'));
$select->where("`{$field}` like '%{$query}%'");
}
$page = $this->_request->getParam('page');
$this->view->page = isset($page) && is_numeric($page) ? $page : 1;
$this->view->filtro = $this->_request->getParam('filtro');
$paginatorAdapter = new Zend_Paginator_Adapter_DbSelect($select);
$paginator = new Zend_Paginator($paginatorAdapter);
$paginator->setCurrentPageNumber($this->view->page);
$paginator->setItemCountPerPage(Zend_Registry::get('config')->ambiente->linelimit);
$this->view->pickupgroups = $paginator;
$this->view->pages = $paginator->getPages();
$this->view->URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/";
$this->view->PAGE_URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/";
$opcoes = array("ds_name" => $this->view->translate("Name"));
// Formulário de filtro.
$filter = new Snep_Form_Filter();
$filter->setAction($this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index');
$filter->setValue($this->_request->getPost('campo'));
$filter->setFieldOptions($opcoes);
$filter->setFieldValue($this->_request->getPost('filtro'));
$filter->setResetUrl("{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/page/{$page}");
$this->view->form_filter = $filter;
$this->view->filter = array(array("url" => "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/add", "display" => $this->view->translate("Add Pickup Group"), "css" => "include"));
}
示例13: indexAction
/**
* List all Contacts
*/
public function indexAction()
{
$this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Contacts")));
$this->view->url = $this->getFrontController()->getBaseUrl() . "/" . $this->getRequest()->getControllerName();
$db = Zend_Registry::get('db');
$select = $db->select()->from(array("n" => "contact"), array("n.id_contact as id", "n.ds_name as name", "n.ds_city as city", "n.ds_state as state", "n.ds_cep as cep", "n.ds_phone as phone", "n.ds_cell_phone as cellphone", "g.ds_name as group"))->join(array("g" => "contact_group"), 'n.id_contact_group = g.id_contact_group', array())->order('n.id_contact');
if ($this->_request->getPost('filtro')) {
$field = pg_escape_string($this->_request->getPost('campo'));
$query = pg_escape_string($this->_request->getPost('filtro'));
$select->where("{$field} like '%{$query}%'");
}
$page = $this->_request->getParam('page');
$this->view->page = isset($page) && is_numeric($page) ? $page : 1;
$this->view->filtro = $this->_request->getParam('filtro');
$paginatorAdapter = new Zend_Paginator_Adapter_DbSelect($select);
$paginator = new Zend_Paginator($paginatorAdapter);
$paginator->setCurrentPageNumber($this->view->page);
$paginator->setItemCountPerPage(Zend_Registry::get('config')->ambiente->linelimit);
$this->view->contacts = $paginator;
$this->view->pages = $paginator->getPages();
$this->view->PAGE_URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/";
/*Opcoes do Filtro*/
$opcoes = array("n.ds_name" => $this->view->translate("Name"), "n.ds_city" => $this->view->translate("City"), "n.ds_state" => $this->view->translate("State"), "n.ds_cep" => $this->view->translate("ZIP Code"), "n.ds_phone" => $this->view->translate("Phone"), "n.ds_cell_phone" => $this->view->translate("Cellphone"));
$filter = new Snep_Form_Filter();
$filter->setAction($this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName() . '/index');
$filter->setValue($this->_request->getPost('campo'));
$filter->setFieldOptions($opcoes);
$filter->setFieldValue($this->_request->getPost('filtro'));
$filter->setResetUrl("{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/page/{$page}");
$this->view->form_filter = $filter;
$this->view->filter = array(array("url" => "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/add/", "display" => $this->view->translate("Add Contact"), "css" => "include"), array("url" => "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/multi-remove/", "display" => $this->view->translate("Remove Multiple"), "css" => "exclude"), array("url" => "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/import/", "display" => $this->view->translate("Import CSV"), "css" => "import"), array("url" => "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/export/", "display" => $this->view->translate("Export CSV"), "css" => "export"));
}
示例14: fetchByType
public static function fetchByType($type = 1, $filter, $order, $page = 1)
{
if ($type != 1 && $type != 2 && $type != 3) {
return array();
}
$select = self::select();
$select->where('type = ?', $type)->where('status =1');
if ($filter == 1 || $filter == 2) {
$select->where('location_type = ?', $filter);
}
if ($order == 1) {
$select->order('adult_dprice desc');
} elseif ($order == 2) {
$select->order('adult_dprice asc');
} elseif ($order == 3) {
$select->order('sales desc');
} elseif ($order == 4) {
$select->order('sales asc');
}
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
$paginator = new Zend_Paginator($adapter);
$paginator->setItemCountPerPage(10)->setCurrentPageNumber($page);
$data = $paginator->getCurrentItems();
$pages = $paginator->count();
$travels = array();
if (count($data) > 0) {
foreach ($data as $da) {
$travelModel = new Application_Model_O_Travel();
$travelModel->setId($da->id)->setType($da->type)->setLocation_type($da->location_type)->setAdult_oprice($da->adult_oprice)->setAdult_dprice($da->adult_dprice)->setChild_oprice($da->child_oprice)->setChild_dprice($da->child_dprice)->setArea($da->area)->setSales($da->sales)->setTitle($da->title)->setSubtitle($da->subtitle)->setImg($da->img)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status);
array_push($travels, $travelModel);
}
}
$res = array('travels' => $travels, 'pages' => $pages);
return $res;
}
示例15: rpsConsultarAction
/**
* Consulta notas para exportar RPS
*/
public function rpsConsultarAction()
{
parent::noTemplate();
$aParametros = $this->getRequest()->getParams();
/**
* Verifica se foi informado mês e ano da competência
*/
if (!empty($aParametros['mes_competencia']) && !empty($aParametros['ano_competencia'])) {
$oContribuinte = $this->_session->contribuinte;
$sCodigosContribuintes = implode(',', $oContribuinte->getContribuintes());
$oPaginatorAdapter = new DBSeller_Controller_Paginator(Contribuinte_Model_Nota::getQuery(), 'Contribuinte_Model_Nota', 'Contribuinte\\Nota');
/**
* Monta a query de consulta
*/
$oPaginatorAdapter->where("e.id_contribuinte in ({$sCodigosContribuintes})");
$oPaginatorAdapter->andWhere("e.mes_comp = {$aParametros['mes_competencia']}");
$oPaginatorAdapter->andWhere("e.ano_comp = {$aParametros['ano_competencia']}");
if (!empty($aParametros['numero_rps'])) {
$oPaginatorAdapter->andWhere("e.nota = {$aParametros['numero_rps']}");
}
$oPaginatorAdapter->orderBy('e.nota', 'DESC');
/**
* Monta a paginação do GridPanel
*/
$oResultado = new Zend_Paginator($oPaginatorAdapter);
$oResultado->setItemCountPerPage(10);
$oResultado->setCurrentPageNumber($this->_request->getParam('page'));
foreach ($oResultado as $oNota) {
$oNota->oContribuinte = $oContribuinte;
$oNota->lNaoGeraGuia = !$oNota->getEmite_guia();
$oNota->lGuiaEmitida = Contribuinte_Model_Guia::existeGuia($oContribuinte, $oNota->getMes_comp(), $oNota->getAno_comp(), Contribuinte_Model_Guia::$DOCUMENTO_ORIGEM_NFSE);
/**
* Informações da nota substituta
*/
$oNota->oNotaSubstituida = NULL;
if ($oNota->getIdNotaSubstituida()) {
$oNota->oNotaSubstituida = Contribuinte_Model_Nota::getById($oNota->getIdNotaSubstituida());
}
/**
* Informações da nota substituta
*/
$oNota->oNotaSubstituta = NULL;
if ($oNota->getIdNotaSubstituta()) {
$oNota->oNotaSubstituta = Contribuinte_Model_Nota::getById($oNota->getIdNotaSubstituta());
}
}
/**
* Valores da pesquisa para montar a paginação
*/
if (is_array($aParametros)) {
foreach ($aParametros as $sParametro => $sParametroValor) {
if ($sParametroValor) {
$sParametroValor = str_replace('/', '-', $sParametroValor);
$this->view->sBusca .= "{$sParametro}/{$sParametroValor}/";
}
}
}
$this->view->oDadosNota = $oResultado;
}
}