/** * * Kilka dodatkowych statycznych inicjaliacji * */ public function _initStatics() { $config = $this->getApplication()->getOptions(); /** * Ustawienie konfigu na rejestrze dla kompatybilnosci z poprzednmi rozwiazaniami (resouce plugin dla ACL) */ Zend_Registry::set('config', $config); if (isset($config['general']['pluginloader']) and $config['general']['pluginloader']) { $classFileIncCache = APPLICATION_PATH . '/../tmp/pluginLoaderCache.php'; if (file_exists($classFileIncCache)) { include_once $classFileIncCache; } Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache); } /** * Ustawienie fallback tak by klasy bez namespacu tez dzialaly */ Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true)->pushAutoloader(NULL, 'Smarty_'); /** * Domyslny rozmiar strony paginatora */ Zend_Paginator::setDefaultItemCountPerPage($config['paginator']['DefaultItemCountPerPage']); Zend_View_Helper_PaginationControl::setDefaultViewPartial('/common/paginator_footer.phtml'); Zend_Controller_Action_HelperBroker::addPrefix('Base_Controller_Action_Helper'); Zend_Markup::addRendererPath('Logic', 'Logic/'); Base_Logic_Abstract::setUsePreexecuteHooks($config['general']['usepreexecutehooks']); }
protected function _initPaginator() { $options = $this->getOptions(); if (array_key_exists('cache', $options) && $options['cache']) { // ensure the cache is initialized... $this->getBootstrap()->bootstrap('cachemanager'); // get the cache manager object $manager = $this->getBootstrap()->getResource('cachemanager'); // get the paginator cache object $cache = $manager->getCache(self::PAGINATOR_CACHE); if (!is_null($cache)) { Zend_Paginator::setCache($cache); } } if (!empty($options['scrollingType'])) { Zend_Paginator::setDefaultScrollingStyle($options['scrollingType']); } else { Zend_Paginator::setDefaultScrollingStyle(self::DEFAULT_SCROLLING_TYPE); } if (!empty($options['recordsPerPage'])) { Zend_Paginator::setDefaultItemCountPerPage($options['recordsPerPage']); } else { Zend_Paginator::setDefaultItemCountPerPage(self::DEFAULT_RECORDS_PER_PAGE); } if (!empty($options['viewScript'])) { Zend_View_Helper_PaginationControl::setDefaultViewPartial($options['viewScript']); } }
/** * 初始化Zend_Paginator */ protected function _initPaginator() { Zend_Paginator::setDefaultItemCountPerPage(15); Zend_View_Helper_PaginationControl::setDefaultViewPartial('paginator.phtml'); $view = $this->bootstrap('view')->getResource('view'); $view->addScriptPath(realpath(__DIR__) . '/layouts'); }
/** * Constructor. * * @param Doctrine_Query $select The select query */ public function __construct(Doctrine_Query $select) { $this->_select = $select; // Set default paginator options Zend_Paginator::setDefaultScrollingStyle('Sliding'); Zend_Paginator::setDefaultItemCountPerPage(8); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml'); }
public function __construct() { $this->bootstrap = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); Zend_Registry::set('config', $this->bootstrap->getOptions()); $config = Zend_Registry::get('config'); Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true); //Zend_Loader::loadClass('Base_Controller_Action_Helper_Messenger_Abstract'); Zend_Paginator::setDefaultItemCountPerPage($config['paginator']['DefaultItemCountPerPage']); Zend_Validate::addDefaultNamespaces('Base_Form_Validate'); }
/** * 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; }
/** * @group ZF-5785 */ public function testGetSetDefaultItemCountPerPage() { Zend_Paginator::setConfig(new Zend_Config(array())); $paginator = Zend_Paginator::factory(range(1, 10)); $this->assertEquals(10, $paginator->getItemCountPerPage()); Zend_Paginator::setDefaultItemCountPerPage(20); $this->assertEquals(20, Zend_Paginator::getDefaultItemCountPerPage()); $paginator = Zend_Paginator::factory(range(1, 10)); $this->assertEquals(20, $paginator->getItemCountPerPage()); $this->_restorePaginatorDefaults(); }
protected function _initPaginator() { Zend_Paginator::setDefaultScrollingStyle('Sliding'); Zend_Paginator::setDefaultItemCountPerPage(3); Zend_View_Helper_PaginationControl::setDefaultViewPartial('partials/pagination.phtml'); }
/** * @param $baseSelect * @param int $page * @param null $countSelect * @return Zend_Paginator */ protected function _paginator($baseSelect, $page = 0, $countSelect = null) { $adapter = new Zend_Paginator_Adapter_DbTableSelect($baseSelect); if (null != $countSelect) { $adapter->setRowCount($countSelect); } $paginator = new Zend_Paginator($adapter); $paginator->setDefaultItemCountPerPage($this->_maxItemsOnPage); if (!empty($page)) { $paginator->setCurrentPageNumber($page); } return $paginator; }
public function _initPaginator() { Zend_Paginator::setDefaultItemCountPerPage(3); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml'); }
public function fetchAll($model, $where=null, $order=null, $count=null, $offset=null) { //TODO validate model? if (!is_object($model)) { throw new $this->_exceptionClass("Invalid model passed to fetchAll function"); } //$db = $this->getDbTable()->getAdapter(); if (is_object($where)) { $select = $where; } else { $select = $this->getDbTable()->select(); //$select = $db->select(); //$select->from($this->getTableName()); if (!empty($where)) { $select->where($where); } } $select->order($order); //echo $select->__tostring(); //echo "<br />"; $adapter = new Shinymayhem_Paginator_Adapter_DbSelect($select); $adapter->setModel($model); $paginator = new Zend_Paginator($adapter); //default to fetch all, fetch paginated on demand $paginator->setDefaultItemCountPerPage(-1); return $paginator; }