Mage_Page_Block_Html_Pager Class Reference

Inheritance diagram for Mage_Page_Block_Html_Pager:

Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object Mage_Catalog_Block_Product_List_Toolbar Mage_Catalog_Block_Seo_Sitemap_Tree_Pager

List of all members.

Public Member Functions

 getCurrentPage ()
 getLimit ()
 setCollection ($collection)
 getCollection ()
 setPageVarName ($varName)
 getPageVarName ()
 setShowPerPage ($varName)
 getShowPerPage ()
 setLimitVarName ($varName)
 getLimitVarName ()
 setAvailableLimit (array $limits)
 getAvailableLimit ()
 getFirstNum ()
 getLastNum ()
 getTotalNum ()
 isFirstPage ()
 getLastPageNum ()
 isLastPage ()
 isLimitCurrent ($limit)
 isPageCurrent ($page)
 getPages ()
 getFirstPageUrl ()
 getPreviousPageUrl ()
 getNextPageUrl ()
 getLastPageUrl ()
 getPageUrl ($page)
 getLimitUrl ($limit)
 getPagerUrl ($params=array())

Protected Member Functions

 _construct ()

Protected Attributes

 $_collection = null
 $_pageVarName = 'p'
 $_limitVarName = 'limit'
 $_availableLimit = array(10=>10,20=>20,50=>50)
 $_dispersion = 3
 $_displayPages = 5
 $_showPerPage = true


Detailed Description

Definition at line 36 of file Pager.php.


Member Function Documentation

_construct (  )  [protected]

Internal constructor, that is called from real constructor

Please override this one instead of overriding real __construct constructor

Please override this one instead of overriding real __construct constructor

Reimplemented from Mage_Core_Block_Abstract.

Reimplemented in Mage_Catalog_Block_Product_List_Toolbar.

Definition at line 46 of file Pager.php.

00047     {
00048         parent::_construct();
00049         $this->setTemplate('page/html/pager.phtml');
00050     }

getAvailableLimit (  ) 

Reimplemented in Mage_Catalog_Block_Product_List_Toolbar.

Definition at line 132 of file Pager.php.

00133     {
00134         return $this->_availableLimit;
00135     }

getCollection (  ) 

Returns:
Mage_Core_Model_Mysql4_Collection_Abstract

Reimplemented in Mage_Catalog_Block_Seo_Sitemap_Tree_Pager.

Definition at line 87 of file Pager.php.

00088     {
00089         return $this->_collection;
00090     }

getCurrentPage (  ) 

Definition at line 52 of file Pager.php.

00053     {
00054         if ($page = (int) $this->getRequest()->getParam($this->getPageVarName())) {
00055             return $page;
00056         }
00057         return 1;
00058     }

getFirstNum (  ) 

Reimplemented in Mage_Catalog_Block_Seo_Sitemap_Tree_Pager.

Definition at line 137 of file Pager.php.

00138     {
00139         $collection = $this->getCollection();
00140         return $collection->getPageSize()*($collection->getCurPage()-1)+1;
00141     }

getFirstPageUrl (  ) 

Definition at line 216 of file Pager.php.

00217     {
00218         return $this->getPageUrl(1);
00219     }

getLastNum (  ) 

Reimplemented in Mage_Catalog_Block_Seo_Sitemap_Tree_Pager.

Definition at line 143 of file Pager.php.

00144     {
00145         $collection = $this->getCollection();
00146         return $collection->getPageSize()*($collection->getCurPage()-1)+$collection->count();
00147     }

getLastPageNum (  ) 

Reimplemented in Mage_Catalog_Block_Seo_Sitemap_Tree_Pager.

Definition at line 159 of file Pager.php.

00160     {
00161         return $this->getCollection()->getLastPageNumber();
00162     }

getLastPageUrl (  ) 

Reimplemented in Mage_Catalog_Block_Seo_Sitemap_Tree_Pager.

Definition at line 231 of file Pager.php.

00232     {
00233         return $this->getPageUrl($this->getCollection()->getLastPageNumber());
00234     }

getLimit (  ) 

Reimplemented in Mage_Catalog_Block_Product_List_Toolbar, and Mage_Catalog_Block_Seo_Sitemap_Tree_Pager.

Definition at line 60 of file Pager.php.

00061     {
00062         $limits = $this->getAvailableLimit();
00063         if ($limit = $this->getRequest()->getParam($this->getLimitVarName())) {
00064             if (isset($limits[$limit])) {
00065                 return $limit;
00066             }
00067         }
00068         $limits = array_keys($limits);
00069         return $limits[0];
00070     }

getLimitUrl ( limit  ) 

Reimplemented in Mage_Catalog_Block_Product_List_Toolbar.

Definition at line 241 of file Pager.php.

00242     {
00243         return $this->getPagerUrl(array($this->getLimitVarName()=>$limit));
00244     }

getLimitVarName (  ) 

Definition at line 122 of file Pager.php.

00123     {
00124         return $this->_limitVarName;
00125     }

getNextPageUrl (  ) 

Reimplemented in Mage_Catalog_Block_Seo_Sitemap_Tree_Pager.

Definition at line 226 of file Pager.php.

00227     {
00228         return $this->getPageUrl($this->getCollection()->getCurPage(+1));
00229     }

getPagerUrl ( params = array()  ) 

Definition at line 246 of file Pager.php.

00247     {
00248         $urlParams = array();
00249         $urlParams['_current']  = true;
00250         $urlParams['_escape']   = true;
00251         $urlParams['_use_rewrite']   = true;
00252         $urlParams['_query']    = $params;
00253         return $this->getUrl('*/*/*', $urlParams);
00254     }

getPages (  ) 

Reimplemented in Mage_Catalog_Block_Seo_Sitemap_Tree_Pager.

Definition at line 179 of file Pager.php.

00180     {
00181         $collection = $this->getCollection();
00182 
00183         $pages = array();
00184         if ($collection->getLastPageNumber() <= $this->_displayPages) {
00185             $pages = range(1, $collection->getLastPageNumber());
00186         }
00187         else {
00188             $half = ceil($this->_displayPages / 2);
00189             if ($collection->getCurPage() >= $half && $collection->getCurPage() <= $collection->getLastPageNumber() - $half) {
00190                 $start  = ($collection->getCurPage() - $half) + 1;
00191                 $finish = ($start + $this->_displayPages) - 1;
00192             }
00193             elseif ($collection->getCurPage() < $half) {
00194                 $start  = 1;
00195                 $finish = $this->_displayPages;
00196             }
00197             elseif ($collection->getCurPage() > ($collection->getLastPageNumber() - $half)) {
00198                 $finish = $collection->getLastPageNumber();
00199                 $start  = $finish - $this->_displayPages + 1;
00200             }
00201 
00202             $pages = range($start, $finish);
00203         }
00204         return $pages;
00205 
00206 //        $pages = array();
00207 //        for ($i=$this->getCollection()->getCurPage(-$this->_dispersion); $i <= $this->getCollection()->getCurPage(+($this->_dispersion-1)); $i++)
00208 //        {
00209 //
00210 //            $pages[] = $i;
00211 //        }
00212 //
00213 //        return $pages;
00214     }

getPageUrl ( page  ) 

Definition at line 236 of file Pager.php.

00237     {
00238         return $this->getPagerUrl(array($this->getPageVarName()=>$page));
00239     }

getPageVarName (  ) 

Definition at line 98 of file Pager.php.

00099     {
00100         return $this->_pageVarName;
00101     }

getPreviousPageUrl (  ) 

Reimplemented in Mage_Catalog_Block_Seo_Sitemap_Tree_Pager.

Definition at line 221 of file Pager.php.

00222     {
00223         return $this->getPageUrl($this->getCollection()->getCurPage(-1));
00224     }

getShowPerPage (  ) 

Definition at line 108 of file Pager.php.

00109     {
00110         if(sizeof($this->getAvailableLimit())<=1) {
00111             return false;
00112         }
00113         return $this->_showPerPage;
00114     }

getTotalNum (  ) 

Reimplemented in Mage_Catalog_Block_Seo_Sitemap_Tree_Pager.

Definition at line 149 of file Pager.php.

00150     {
00151         return $this->getCollection()->getSize();
00152     }

isFirstPage (  ) 

Reimplemented in Mage_Catalog_Block_Seo_Sitemap_Tree_Pager.

Definition at line 154 of file Pager.php.

00155     {
00156         return $this->getCollection()->getCurPage() == 1;
00157     }

isLastPage (  ) 

Reimplemented in Mage_Catalog_Block_Seo_Sitemap_Tree_Pager.

Definition at line 164 of file Pager.php.

00165     {
00166         return $this->getCollection()->getCurPage() >= $this->getLastPageNum();
00167     }

isLimitCurrent ( limit  ) 

Definition at line 169 of file Pager.php.

00170     {
00171         return $limit == $this->getLimit();
00172     }

isPageCurrent ( page  ) 

Definition at line 174 of file Pager.php.

00175     {
00176         return $page == $this->getCurrentPage();
00177     }

setAvailableLimit ( array limits  ) 

Definition at line 127 of file Pager.php.

00128     {
00129         $this->_availableLimit = $limits;
00130     }

setCollection ( collection  ) 

Reimplemented in Mage_Catalog_Block_Product_List_Toolbar, and Mage_Catalog_Block_Seo_Sitemap_Tree_Pager.

Definition at line 72 of file Pager.php.

00073     {
00074         $this->_collection = $collection
00075             ->setCurPage($this->getCurrentPage());
00076         // If not int - then not limit
00077         if ((int) $this->getLimit()) {
00078             $this->_collection->setPageSize($this->getLimit());
00079         }
00080 
00081         return $this;
00082     }

setLimitVarName ( varName  ) 

Definition at line 116 of file Pager.php.

00117     {
00118         $this->_limitVarName = $varName;
00119         return $this;
00120     }

setPageVarName ( varName  ) 

Definition at line 92 of file Pager.php.

00093     {
00094         $this->_pageVarName = $varName;
00095         return $this;
00096     }

setShowPerPage ( varName  ) 

Definition at line 103 of file Pager.php.

00104     {
00105         $this->_showPerPage=$varName;
00106     }


Member Data Documentation

$_availableLimit = array(10=>10,20=>20,50=>50) [protected]

Definition at line 41 of file Pager.php.

$_collection = null [protected]

Definition at line 38 of file Pager.php.

$_dispersion = 3 [protected]

Definition at line 42 of file Pager.php.

$_displayPages = 5 [protected]

Definition at line 43 of file Pager.php.

$_limitVarName = 'limit' [protected]

Definition at line 40 of file Pager.php.

$_pageVarName = 'p' [protected]

Definition at line 39 of file Pager.php.

$_showPerPage = true [protected]

Reimplemented in Mage_Catalog_Block_Seo_Sitemap_Tree_Pager.

Definition at line 44 of file Pager.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:30 2009 for Magento by  doxygen 1.5.8