Definition at line 34 of file Toolbar.php.
_construct | ( | ) | [protected] |
Init Toolbar
Reimplemented from Mage_Page_Block_Html_Pager.
Definition at line 120 of file Toolbar.php.
00121 { 00122 parent::_construct(); 00123 $this->_orderField = Mage::getStoreConfig( 00124 Mage_Catalog_Model_Config::XML_PATH_LIST_DEFAULT_SORT_BY 00125 ); 00126 00127 $this->_availableOrder = $this->_getConfig()->getAttributeUsedForSortByArray(); 00128 00129 switch (Mage::getStoreConfig('catalog/frontend/list_mode')) { 00130 case 'grid': 00131 $this->_availableMode = array('grid' => $this->__('Grid')); 00132 break; 00133 00134 case 'list': 00135 $this->_availableMode = array('list' => $this->__('List')); 00136 break; 00137 00138 case 'grid-list': 00139 $this->_availableMode = array('grid' => $this->__('Grid'), 'list' => $this->__('List')); 00140 break; 00141 00142 case 'list-grid': 00143 $this->_availableMode = array('list' => $this->__('List'), 'grid' => $this->__('Grid')); 00144 break; 00145 } 00146 $this->setTemplate('catalog/product/list/toolbar.phtml'); 00147 }
_getConfig | ( | ) | [protected] |
Retrieve Catalog Config object
Definition at line 111 of file Toolbar.php.
00112 { 00113 return Mage::getSingleton('catalog/config'); 00114 }
addOrderToAvailableOrders | ( | $ | order, | |
$ | value | |||
) |
Add order to available orders
string | $order | |
string | $value |
Definition at line 286 of file Toolbar.php.
addPagerLimit | ( | $ | mode, | |
$ | value, | |||
$ | label = '' | |||
) |
Add new limit to pager for mode
string | $mode | |
string | $value | |
string | $label |
Definition at line 496 of file Toolbar.php.
00497 { 00498 if (!isset($this->_availableLimit[$mode])) { 00499 $this->_availableLimit[$mode] = array(); 00500 } 00501 $this->_availableLimit[$mode][$value] = empty($label) ? $value : $label; 00502 return $this; 00503 }
disableExpanded | ( | ) |
disableViewSwitcher | ( | ) |
enableExpanded | ( | ) |
enableViewSwitcher | ( | ) |
getAvailableLimit | ( | ) |
Retrieve available limits for current view mode
Reimplemented from Mage_Page_Block_Html_Pager.
Definition at line 510 of file Toolbar.php.
00511 { 00512 if ($this->getCurrentMode() == 'list') { 00513 if (isset($this->_availableLimit['list'])) { 00514 return $this->_availableLimit['list']; 00515 } 00516 $perPageValues = (string)Mage::getStoreConfig('catalog/frontend/list_per_page_values'); 00517 $perPageValues = explode(',', $perPageValues); 00518 $perPageValues = array_combine($perPageValues, $perPageValues); 00519 return ($perPageValues + array('all'=>$this->__('All'))); 00520 } 00521 elseif ($this->getCurrentMode() == 'grid') { 00522 if (isset($this->_availableLimit['grid'])) { 00523 return $this->_availableLimit['grid']; 00524 } 00525 $perPageValues = (string)Mage::getStoreConfig('catalog/frontend/grid_per_page_values'); 00526 $perPageValues = explode(',', $perPageValues); 00527 $perPageValues = array_combine($perPageValues, $perPageValues); 00528 return ($perPageValues + array('all'=>$this->__('All'))); 00529 } 00530 return parent::getAvailableLimit(); 00531 }
getAvailableOrders | ( | ) |
getCurrentDirection | ( | ) |
Retrieve current direction
Definition at line 218 of file Toolbar.php.
00219 { 00220 if ($dir = (string) $this->getRequest()->getParam($this->getDirectionVarName())) { 00221 $dir = strtolower($dir); 00222 if (in_array($dir, array('asc', 'desc'))) { 00223 return $dir; 00224 } 00225 } 00226 return $this->_direction; 00227 }
getCurrentMode | ( | ) |
Retrieve current View mode
Definition at line 340 of file Toolbar.php.
00341 { 00342 $mode = $this->getRequest()->getParam($this->getModeVarName()); 00343 if ($mode) { 00344 Mage::getSingleton('catalog/session')->setDisplayMode($mode); 00345 } 00346 else { 00347 $mode = Mage::getSingleton('catalog/session')->getDisplayMode(); 00348 } 00349 00350 if ($mode && isset($this->_availableMode[$mode])) { 00351 return $mode; 00352 } 00353 return current(array_keys($this->_availableMode)); 00354 }
getCurrentOrder | ( | ) |
Retrieve current order field
Definition at line 199 of file Toolbar.php.
00200 { 00201 $order = $this->getRequest()->getParam($this->getOrderVarName()); 00202 $orders = $this->getAvailableOrders(); 00203 if ($order && isset($orders[$order])) { 00204 return $order; 00205 } 00206 if ($this->_orderField && isset($orders[$this->_orderField])) { 00207 return $this->_orderField; 00208 } 00209 $keys = array_keys($orders); 00210 return $keys[0]; 00211 }
getDefaultPerPageValue | ( | ) |
Retrieve default per page values
Definition at line 471 of file Toolbar.php.
00472 { 00473 if ($this->getCurrentMode() == 'list') { 00474 if ($default = $this->getDefaultListPerPage()) { 00475 return $default; 00476 } 00477 return Mage::getStoreConfig('catalog/frontend/list_per_page'); 00478 } 00479 elseif ($this->getCurrentMode() == 'grid') { 00480 if ($default = $this->getDefaultGridPerPage()) { 00481 return $default; 00482 } 00483 return Mage::getStoreConfig('catalog/frontend/grid_per_page'); 00484 } 00485 return 0; 00486 }
getDirectionVarName | ( | ) |
getLimit | ( | ) |
Retrieve current limit per page
Reimplemented from Mage_Page_Block_Html_Pager.
Definition at line 538 of file Toolbar.php.
00539 { 00540 $limits = $this->getAvailableLimit(); 00541 $limit = $this->getRequest()->getParam($this->getLimitVarName()); 00542 00543 if ($limit && isset($limits[$limit])) { 00544 Mage::getSingleton('catalog/session')->setLimitPage($limit); 00545 } else { 00546 $limit = Mage::getSingleton('catalog/session')->getLimitPage(); 00547 } 00548 if (isset($limits[$limit])) { 00549 return $limit; 00550 } 00551 if ($limit = $this->getDefaultPerPageValue()) { 00552 if (isset($limits[$limit])) { 00553 return $limit; 00554 } 00555 } 00556 00557 $limits = array_keys($limits); 00558 return $limits[0]; 00559 }
getLimitUrl | ( | $ | limit | ) |
Retrieve Limit Pager URL
int | $limit |
Reimplemented from Mage_Page_Block_Html_Pager.
Definition at line 567 of file Toolbar.php.
00568 { 00569 return $this->getPagerUrl(array( 00570 $this->getLimitVarName() => $limit, 00571 $this->getPageVarName() => null 00572 )); 00573 }
getModes | ( | ) |
getModeUrl | ( | $ | mode | ) |
Retrive URL for view mode
string | $mode |
Definition at line 397 of file Toolbar.php.
00398 { 00399 return $this->getPagerUrl( array($this->getModeVarName()=>$mode, $this->getPageVarName() => null) ); 00400 }
getModeVarName | ( | ) |
getOrderUrl | ( | $ | order, | |
$ | direction | |||
) |
Retrieve Pager URL
string | $order | |
string | $direction |
Definition at line 323 of file Toolbar.php.
00324 { 00325 if (is_null($order)) { 00326 $order = $this->getCurrentOrder() ? $this->getCurrentOrder() : $this->_availableOrder[0]; 00327 } 00328 return $this->getPagerUrl(array( 00329 $this->getOrderVarName()=>$order, 00330 $this->getDirectionVarName()=>$direction, 00331 $this->getPageVarName() => null 00332 )); 00333 }
getOrderVarName | ( | ) |
isEnabledViewSwitcher | ( | ) |
isExpanded | ( | ) |
isModeActive | ( | $ | mode | ) |
Compare defined view mode with current active mode
string | $mode |
Definition at line 362 of file Toolbar.php.
00363 { 00364 return $this->getCurrentMode() == $mode; 00365 }
isOrderCurrent | ( | $ | order | ) |
Compare defined order field vith current order field
string | $order |
Definition at line 311 of file Toolbar.php.
00312 { 00313 return ($order == $this->getCurrentOrder()); 00314 }
removeOrderFromAvailableOrders | ( | $ | order | ) |
Remove order from available orders if exists
string | $order | |
Mage_Catalog_Block_Product_List_Toolbar |
Definition at line 297 of file Toolbar.php.
00298 { 00299 if (isset($this->_availableOrder[$order])) { 00300 unset($this->_availableOrder[$order]); 00301 } 00302 return $this; 00303 }
setAvailableOrders | ( | $ | orders | ) |
Set Available order fields list
array | $orders |
Definition at line 273 of file Toolbar.php.
00274 { 00275 $this->_availableOrder = $orders; 00276 return $this; 00277 }
setCollection | ( | $ | collection | ) |
Set collection to pager
Varien_Data_Collection | $collection |
Reimplemented from Mage_Page_Block_Html_Pager.
Definition at line 155 of file Toolbar.php.
00156 { 00157 parent::setCollection($collection); 00158 if ($this->getCurrentOrder()) { 00159 $this->getCollection()->setOrder($this->getCurrentOrder(), $this->getCurrentDirection()); 00160 } 00161 return $this; 00162 }
setDefaultDirection | ( | $ | dir | ) |
Set default sort direction
string | $dir |
Definition at line 249 of file Toolbar.php.
00250 { 00251 if (in_array(strtolower($dir), array('asc', 'desc'))) { 00252 $this->_direction = strtolower($dir); 00253 } 00254 return $this; 00255 }
setDefaultOrder | ( | $ | field | ) |
Set default Order field
string | $field |
Definition at line 235 of file Toolbar.php.
00236 { 00237 if (isset($this->_availableOrder[$field])) { 00238 $this->_orderField = $field; 00239 } 00240 return $this; 00241 }
setModes | ( | $ | modes | ) |
Set available view modes list
array | $modes |
Definition at line 383 of file Toolbar.php.
00384 { 00385 if(!isset($this->_availableMode)){ 00386 $this->_availableMode = $modes; 00387 } 00388 return $this; 00389 }
$_availableMode = array() [protected] |
Definition at line 69 of file Toolbar.php.
$_availableOrder = array() [protected] |
Definition at line 62 of file Toolbar.php.
$_direction = 'asc' [protected] |
Definition at line 97 of file Toolbar.php.
$_directionVarName = 'dir' [protected] |
Definition at line 48 of file Toolbar.php.
$_enableViewSwitcher = true [protected] |
Definition at line 76 of file Toolbar.php.
$_isExpanded = true [protected] |
Definition at line 83 of file Toolbar.php.
$_modeVarName = 'mode' [protected] |
Definition at line 55 of file Toolbar.php.
$_orderField = null [protected] |
Definition at line 90 of file Toolbar.php.
$_orderVarName = 'order' [protected] |
Definition at line 41 of file Toolbar.php.
$_viewMode = null [protected] |
Definition at line 104 of file Toolbar.php.