本文整理汇总了PHP中Zend_Paginator::getPages方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Paginator::getPages方法的具体用法?PHP Zend_Paginator::getPages怎么用?PHP Zend_Paginator::getPages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Paginator
的用法示例。
在下文中一共展示了Zend_Paginator::getPages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testNoPagesBeforeSecondLastPageEqualsPageRangeMinTwo
public function testNoPagesBeforeSecondLastPageEqualsPageRangeMinTwo()
{
$this->_paginator->setPageRange(3);
$this->_paginator->setCurrentPageNumber(19);
$pages = $this->_paginator->getPages('Elastic');
$this->assertEquals(5, count($pages->pagesInRange));
}
示例2: 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"));
}
示例3: indexAction
public function indexAction()
{
// @todo localização das datas na listagem da view
$this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Users")));
$this->view->url = $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName();
$db = Zend_Registry::get('db');
$select = $db->select()->from("user");
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->users = $paginator;
$this->view->pages = $paginator->getPages();
$this->view->PAGE_URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/";
$opcoes = array('ds_login' => $this->view->translate('Name'), 'ds_mail' => $this->view->translate('E-mail'));
$this->view->active = array(1 => $this->view->translate('Yes'), 0 => $this->view->translate('No'));
$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 User"), "css" => "include"));
}
示例4: indexAction
/**
* List all Queues
*/
public function indexAction()
{
$this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Queues")));
$this->view->url = $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName();
$db = Zend_Registry::get('db');
$select = $db->select()->from("queue");
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->queues = $paginator;
$this->view->pages = $paginator->getPages();
$this->view->PAGE_URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/";
$opcoes = array("name" => $this->view->translate("Name"), "musiconhold" => $this->view->translate("Audio Class"), "strategy" => $this->view->translate("Strategy"), "servicelevel" => $this->view->translate("SLA"), "timeout" => $this->view->translate("Timeout"));
$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 Queue"), "css" => "include"));
}
示例5: 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"));
}
示例6: consultaEmissaoAction
/**
* Exibe a lista das guias geradas
*/
public function consultaEmissaoAction()
{
if ($this->getRequest()->isPost()) {
parent::noTemplate();
$aRecord = array();
$iLimit = $this->_request->getParam('rows') ? $this->_request->getParam('rows') : 10;
$iPage = $this->_request->getParam('page') ? $this->_request->getParam('page') : 0;
$oContribuinte = $this->_session->contribuinte;
$iIdContribuinte = $oContribuinte->getIdUsuarioContribuinte();
$aGuias = Contribuinte_Model_Guia::consultaGuiasDesif($iIdContribuinte);
$aGuias = Contribuinte_Model_Guia::atualizaSituacaoGuias($aGuias);
$oPaginatorAdapter = new DBSeller_Controller_PaginatorArray($aGuias);
$aResultado = new Zend_Paginator($oPaginatorAdapter);
$aResultado->setItemCountPerPage($iLimit);
$aResultado->setCurrentPageNumber($iPage);
$iTotal = $aResultado->getTotalItemCount();
$iTotalPages = $aResultado->getPages()->pageCount;
foreach ($aResultado as $oResultado) {
$sSituacaoLabel = null;
switch ($oResultado->getSituacao()) {
case 'a':
$sSituacaoLabel = 'label label-warning';
break;
case 'p':
$sSituacaoLabel = 'label label-success';
break;
case 'c':
$sSituacaoLabel = 'label label-important';
break;
case 'd':
case 'x':
default:
$sSituacaoLabel = 'label';
}
$oGuia = new StdClass();
$oGuia->id = $oResultado->getId();
$oGuia->competencia = $oResultado->getAnoComp() . $oResultado->getMesComp();
$oGuia->competencia_label = $oResultado->getAnoComp() . '/' . $oResultado->getMesComp();
$oGuia->data_vencimento = $oResultado->getVencimento()->format('d/m/Y');
$oGuia->valor_corrigido = DBSeller_Helper_Number_Format::toMoney($oResultado->getValorCorrigido(), 2, 'R$');
$oGuia->valor_historico = DBSeller_Helper_Number_Format::toMoney($oResultado->getValorHistorico(), 2, 'R$');
$oGuia->situacao = $oResultado->getSituacao();
$oGuia->situacao_label = "<span class='" . $sSituacaoLabel . "'>";
$oGuia->situacao_label .= Contribuinte_Model_Guia::$SITUACAO[$oResultado->getSituacao()] . "</span>";
$aRecord[] = $oGuia;
}
/**
* Parametros de retorno do AJAX
*/
$aRetornoJson = array('total' => $iTotalPages, 'page' => $iPage, 'records' => $iTotal, 'rows' => $aRecord);
echo $this->getHelper('json')->sendJson($aRetornoJson);
}
}
示例7: testGetsPagesForPageTwo
public function testGetsPagesForPageTwo()
{
$expected = new \stdClass();
$expected->pageCount = 11;
$expected->itemCountPerPage = 10;
$expected->first = 1;
$expected->current = 2;
$expected->last = 11;
$expected->previous = 1;
$expected->next = 3;
$expected->pagesInRange = array_combine(range(1, 10), range(1, 10));
$expected->firstPageInRange = 1;
$expected->lastPageInRange = 10;
$expected->currentItemCount = 10;
$expected->totalItemCount = 101;
$expected->firstItemNumber = 11;
$expected->lastItemNumber = 20;
$this->_paginator->setCurrentPageNumber(2);
$actual = $this->_paginator->getPages();
$this->assertEquals($expected, $actual);
}
示例8: consultarAction
/**
* Consulta os cancelamentos solicitados pelos contribuintes
*/
public function consultarAction()
{
if ($this->getRequest()->isPost()) {
parent::noTemplate();
$aSolicitacoes = array();
$aParametros = $this->getAllParams();
$iLimit = $aParametros['rows'];
$iPage = $aParametros['page'];
$aFiltros = array('rejeitado' => NULL, 'autorizado' => NULL);
$aOrdem = array('dt_solicitacao' => 'DESC');
$aSolicatacoesCancelamento = Contribuinte_Model_SolicitacaoCancelamento::getByAttributes($aFiltros, $aOrdem);
$oPaginatorAdapter = new DBSeller_Controller_PaginatorArray($aSolicatacoesCancelamento);
$aResultado = new Zend_Paginator($oPaginatorAdapter);
$aResultado->setItemCountPerPage($iLimit);
$aResultado->setCurrentPageNumber($iPage);
$iTotal = $aResultado->getTotalItemCount();
$iTotalPages = $aResultado->getPages()->pageCount;
foreach ($aResultado as $oSolicatacaoCancelamento) {
$sMotivo = $this->getMotivoDescricaoCancelamento($oSolicatacaoCancelamento->getMotivo());
$sData = $oSolicatacaoCancelamento->getDtSolicitacao()->format("d/m/Y");
$sRazaoSocial = $oSolicatacaoCancelamento->getNota()->getP_razao_social();
$sCpfCnpj = DBSeller_Helper_Number_Format::maskCPF_CNPJ($oSolicatacaoCancelamento->getNota()->getP_cnpjcpf());
$iNota = $oSolicatacaoCancelamento->getNota()->getNota();
// Montado objeto que será retorna à grid
$oSolicitacao = new StdClass();
$oSolicitacao->id = $oSolicatacaoCancelamento->getId();
$oSolicitacao->motivo_label = is_string($sMotivo) ? $sMotivo : "-";
$oSolicitacao->dt_solicitacao = $sData;
$oSolicitacao->nome_contribuinte = $sRazaoSocial;
$oSolicitacao->nota = $iNota;
$oSolicitacao->cnpj = $sCpfCnpj;
$aSolicitacoes[] = $oSolicitacao;
}
/**
* Parametros de retorno do AJAX
*/
$aRetornoJson = array('total' => $iTotalPages, 'page' => $iPage, 'records' => $iTotal, 'rows' => $aSolicitacoes);
echo $this->getHelper('json')->sendJson($aRetornoJson);
}
}
示例9: indexAction
/**
* List all sound files
*/
public function indexAction()
{
$this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Configure"), $this->view->translate("Sound Files")));
$this->view->url = $this->getFrontController()->getBaseUrl() . "/" . $this->getRequest()->getControllerName();
$db = Zend_Registry::get('db');
$select = $db->select()->from("sounds")->where("tipo = 'AST'")->order('arquivo');
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}%'");
}
$objInspector = new Snep_Inspector('Permissions');
$inspect = $objInspector->getInspects();
$this->view->error = $inspect['Permissions'];
$stmt = $db->query($select);
$files = $stmt->fetchAll();
foreach ($files as $id => $file) {
$info = Snep_SoundFiles_Manager::verifySoundFiles($file['arquivo']);
$_files[] = array_merge($file, $info);
}
$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_Array($_files);
$paginator = new Zend_Paginator($paginatorAdapter);
$paginator->setCurrentPageNumber($this->view->page);
$paginator->setItemCountPerPage(Zend_Registry::get('config')->ambiente->linelimit);
$this->view->files = $paginator;
$this->view->pages = $paginator->getPages();
$this->view->PAGE_URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/";
$opcoes = array("arquivo" => $this->view->translate("Filename"), "descricao" => $this->view->translate("Description"));
$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 Sound File"), "css" => "include"));
}
示例10: indexAction
/**
* List all Billing
*/
public function indexAction()
{
$this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Carrier"), $this->view->translate("Billing")));
$this->view->url = $this->getFrontController()->getBaseUrl() . "/" . $this->getRequest()->getControllerName();
/*$select = $db->select()
->from("tarifas_valores", array('DATE_FORMAT(data,\'%d/%m/%Y %T\') as data', 'vcel', 'vfix'))
->from("billing")
->from("carrier", array('nome'))
->where("operadoras.codigo = tarifas.operadora")
->where("tarifas_valores.codigo = tarifas.codigo");
*/
$billing = new Snep_Billing_Manager();
Zend_Debug::dump($billing->select()->from('billing'));
exit(1);
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->billing = $paginator;
$this->view->pages = $paginator->getPages();
$this->view->PAGE_URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/";
$opcoes = array("nome" => $this->view->translate("Carrier"), "pais" => $this->view->translate("Country"), "estado" => $this->view->translate("State"), "cidade" => $this->view->translate("City"), "prefixo" => $this->view->translate("Prefix"), "ddd" => $this->view->translate("City Code"));
$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 Billing"), "css" => "include"));
}
示例11: indexAction
/**
* List all Contact Groups
*/
public function indexAction()
{
$this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Contact Group")));
$this->view->url = $this->getFrontController()->getBaseUrl() . "/" . $this->getRequest()->getControllerName();
$db = Zend_Registry::get('db');
$select = $db->select()->from("contact_group");
if ($this->_request->getPost('campo') == 'id_contact_group') {
$field = pg_escape_string($this->_request->getPost('campo'));
$query = pg_escape_string($this->_request->getPost('filtro'));
if (preg_match('/^[0-9]+$/', $query)) {
$select->where("{$field} = '{$query}'");
}
} else {
if ($this->_request->getPost('campo') == 'ds_name') {
$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 = pg_escape_string($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->contactgroups = $paginator;
$this->view->pages = $paginator->getPages();
$this->view->PAGE_URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/";
$opcoes = array("id_contact_group" => $this->view->translate("Code"), "ds_name" => $this->view->translate("Name"));
$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 Group"), "css" => "include"));
}
示例12: indexAction
public function indexAction()
{
$this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Extensions")));
$this->view->url = $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName();
$extension = new Snep_Extensions();
$extensions = array();
foreach ($extension->fetchAll() as $ext) {
$peer = $ext->findParentRow('Snep_Peer_Manager');
$group = $ext->findParentRow('Snep_ExtensionsGroups_Manager');
array_push($extensions, array('id_extension' => $ext->id_extension, 'ds_channel' => $peer->ds_channel, 'ds_callerid' => $peer->ds_callerid, 'ds_group' => $group->ds_name));
}
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_Array($extensions);
$paginator = new Zend_Paginator($paginatorAdapter);
$paginator->setCurrentPageNumber($this->view->page);
$paginator->setItemCountPerPage(Zend_Registry::get('config')->ambiente->linelimit);
$this->view->extensions = $paginator;
$this->view->pages = $paginator->getPages();
$this->view->PAGE_URL = "/snep/index.php/extensions/index/";
$options = array("name" => $this->view->translate("Extension"), "callerid" => $this->view->translate("Name"), "group" => $this->view->translate("Group"));
$baseUrl = $this->getFrontController()->getBaseUrl();
// Formulário de filtro.
$filter = new Snep_Form_Filter();
$filter->setAction($baseUrl . '/extensions/index');
$filter->setValue($this->_request->getPost('campo'));
$filter->setFieldOptions($options);
$filter->setFieldValue($this->_request->getParam('filtro'));
$filter->setResetUrl("{$this->getFrontController()->getBaseUrl()}/" . "{$this->getRequest()->getControllerName()}/index/page/{$page}");
$this->view->form_filter = $filter;
$this->view->filter = array(array("url" => $baseUrl . "/extensions/multiadd", "display" => $this->view->translate("Add Multiple Extensions"), "css" => "includes"), array("url" => $baseUrl . "/extensions/add", "display" => $this->view->translate("Add Extension"), "css" => "include"));
}
示例13: createNavigator
/**
* ナビゲータの生成
*/
public function createNavigator($datas, $limit = 10)
{
// 現在のページ数を保存するためのセッション
$module_name = $this->getRequest()->getModuleName();
$class_name = $this->getRequest()->getControllerName();
$list_path = '/' . $module_name . '/' . $class_name . '/list';
$session = new Zend_Session_Namespace($list_path);
$paginator = null;
if (get_class($datas) === 'Zend_Db_Table_Select') {
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbTableSelect($datas));
} elseif (get_class($datas) === 'Zend_Db_Select') {
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($datas));
} else {
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($datas));
}
// リミットの設定
if ($this->getRequest()->getParam('limit')) {
$limit = $this->getRequest()->getParam('limit');
}
$session->limit = $limit;
// ページング
$paginator->setItemCountPerPage($limit);
if ($paginator->count() && $this->getRequest()->getParam('page')) {
$page = $this->getRequest()->getParam('page');
$session->page = $page;
$paginator->setCurrentPageNumber($page);
if ($page === '1') {
$this->view->assign('first_page', true);
} else {
$this->view->assign('first_page', false);
}
} else {
$session->page = 1;
$this->view->assign('first_page', true);
}
$this->view->assign('pages', $paginator->getPages());
$this->view->assign('paginator', $paginator);
}
示例14: indexAction
/**
* List all Cost Center's
*/
public function indexAction()
{
$this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Manage"), $this->view->translate("Cost Center")));
$this->view->url = $this->getFrontController()->getBaseUrl() . "/" . $this->getRequest()->getControllerName();
$db = Zend_Registry::get('db');
$select = $db->select()->from("cost_center", array("id_costcenter", "cd_code", "cd_type", "ds_name", "ds_description"));
if ($this->_request->getPost('filtro')) {
$field = mysql_escape_string($this->_request->getPost('campo'));
$query = mysql_escape_string($this->_request->getPost('filtro'));
if ($field == 'cd_type') {
$types = array($this->view->translate('Incoming') => 'E', $this->view->translate('Outgoing') => 'S', $this->view->translate('Others') => 'O');
$query = $types[$query];
}
$select->where("{$field} LIKE '%{$query}%'");
}
$this->view->types = array('E' => $this->view->translate('Incoming'), 'S' => $this->view->translate('Outgoing'), 'O' => $this->view->translate('Others'));
$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->costcenter = $paginator;
$this->view->pages = $paginator->getPages();
$this->view->PAGE_URL = "{$this->getFrontController()->getBaseUrl()}/{$this->getRequest()->getControllerName()}/index/";
$opcoes = array("cd_code" => $this->view->translate("Code"), "ds_name" => $this->view->translate("Name"), "ds_description" => $this->view->translate("Description"));
$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 Cost Center"), "css" => "include"));
}
示例15: getPaginator
/**
* Возвращает массив опций для построения постраничной навигации
* Необходимо дергать сразу после выполнения SQL-запроса с SQL_CAL_FOUND_ROWS
*
* @param array $options - Массив опций
*
* @return object
*/
function getPaginator($options = array())
{
$Paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Null($this->_db->fetchOne('SELECT FOUND_ROWS()')));
$Paginator->setItemCountPerPage(isset($options['perpage']) ? $options['perpage'] : $this->getPerPage());
if (isset($options['widgetid'])) {
$Paginator->setCurrentPageNumber($this->getCurrentPage($options['widgetid']));
} else {
$Paginator->setCurrentPageNumber($this->getCurrentPage());
}
$out = $Paginator->getPages();
$pageidentity = $this->getPageIdentity();
// Кроме стандартных параметров Zend_Paginator::getPages() возвращаем доп. параметры
// Полный путь без GET-запроса
$UrlInfo = parse_url($this->_request->getRequestUri());
$out->ClearUrl = $UrlInfo['path'];
// Обрабатываем GET-запрос
$query = $this->_request->getQuery();
if (isset($query[$pageidentity])) {
unset($query[$pageidentity]);
}
if (isset($query['widget'])) {
unset($query['widget']);
}
// Строим строку выражения
if (!empty($query)) {
$out->Query = http_build_query($query);
}
// Фактически, ссылку на первую страницу (без page и widget)
$out->FullUrl = isset($out->Query) ? $out->ClearUrl . '?' . $out->Query : $out->ClearUrl;
// Добавляем к выражению Id виджета
$widget = isset($options['widgetid']) ? 'widget=' . (int) $options['widgetid'] . '&' : '';
// Полную ссылку к которой в конце надо только добавить номер страницы
$out->PageUrl = isset($out->Query) ? $out->FullUrl . '&' . $widget . $pageidentity . '=' : $out->FullUrl . '?' . $widget . $pageidentity . '=';
return $out;
}