1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
// si y a un order dans la requête, il prend la main
if (null !== ($order = $this->_getParam($this->_registry->config->urlParams->sorter->order))) {
if (
(null !== ($dir = $this->_getParam($this->_registry->config->urlParams->sorter->direction)))
and in_array(strtolower($dir), array('asc', 'desc'), true)
) {
$order .= ' ' . strtoupper($dir);
}
$select->reset(Zend_Db_Select::ORDER)
->order($order);
}
// si y a pas d'order dans la requête mais que y en a un dans le select
elseif (array() !== ($order = $select->getPart(Zend_Db_Select::ORDER))) {
$order = $order[0][0];
$this->_setParam($this->_registry->config->urlParams->sorter->order, $order);
$dir = explode(' ', trim($order));
if (1 < count($dir)) {
$this->_setParam($this->_registry->config->urlParams->sorter->direction, strtolower(end($dir)));
} else {
$this->_setParam($this->_registry->config->urlParams->sorter->direction, 'asc');
}
}
// si y a pas d'order dans la requête ni dans le select
else {
$order = $this->_model->info(Fxc_Db_Table_Abstract::ORDER_FIELD);
$this->_setParam($this->_registry->config->urlParams->sorter->order, $order);
$dir = $this->_model->info(Fxc_Db_Table_Abstract::ORDER_DIRECTION);
$this->_setParam($this->_registry->config->urlParams->sorter->direction, strtolower($dir));
$select->order($order . ' ' . $dir);
}
// filtrage
if ((null !== $this->_indexFilterHelperConfig) and is_array($this->_indexFilterHelperConfig) and !empty($this->_indexFilterHelperConfig)) {
$this->_indexFilterHelper = $this->_helper->getHelper('IndexFilter');
$this->_indexFilterHelper->setConfig($this->_indexFilterHelperConfig);
$this->_indexFilterHelper->applyFilter($select);
$this->view->filterHelper = $this->_indexFilterHelper;
}
$this->view->paginator = $this->getHelper('Paginator')->initPaginator($select, $itemsPerPage); |
Partager