[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/data/pager/ -> pager.class.php (sommaire)

(pas de description)

Poids: 290 lignes (7 kb)
Inclus ou requis:0 fois
Référencé: 5 fois
Nécessite: 0 fichiers

Définit 1 class

Pager:: (22 méthodes):
  Pager()
  setBaseUrl()
  getBaseUrl()
  getTotalRegs()
  getRegsForPage()
  getMaxPages()
  getTotalPages()
  getCurrentPage()
  getNextPage()
  getPrevPage()
  getStartPage()
  getEndPage()
  isFirstPage()
  isLastPage()
  getPageLinks()
  getNextPageLink()
  getPrevPageLink()
  getFirstPageLink()
  getLastPageLink()
  generateLinks()
  isEmpty()
  _init()


Classe: Pager  - X-Ref

\defgroup Pager

generic implementation of a pager. It doesn't take of generating SQL queries for paging or
anythign like that, it only takes care of generating the number of pages based on the number
of registers, keeping track of the current page, etc.

There also needs to be some display logic in order to get it to work fine.

At the PHP level, some code like this is necessary:

<pre>
$pager = new Pager( "?op=editPosts&amp;showStatus={$this->_showStatus}&amp;page=",
$this->_page,
$numPosts,
$this->_itemsPerPage );
$view->setValue( "pager", $pager );
</pre>

The first parameter passed to the constructor is the string that the pager class will use
to generate the page links. It will only append a page number, nothing else.

At the Smarty/template level, some code like this is necessary in order to display the links
properly, etc:

<pre>
{if !$pager->isFirstPage() && !$pager->isEmpty()}
&lt;a class="pagerLink" href="{$pager->getPrevPageLink()}"&gt;&laquo;Prev&lt;/a&gt;&nbsp;
{/if}
{foreach from=$pager->getPageLinks() item=pageLink key=pageId}
{if $pageId == $pager->getCurrentPage()}
&lt;span class="pagerCurrent"&gt;&nbsp;{$pageId}&nbsp;&gt;/span&lt;
{else}
&lt;a class="pagerLink" href="{$pageLink}"&gt;&nbsp;{$pageId}&nbsp;&lt;/a&gt;&nbsp;
{/if}
{/foreach}
{if !$pager->isLastPage() && !$pager->isEmpty()}
&lt;a class="pagerLink" href="{$pager->getNextPageLink()}"&gt;Next&raquo;&lt;/a&gt;&nbsp;
{/if}
</pre>

The display logic might look a bit complex but it is unavoidable...
Pager($baseUrl, $curPage, $totalRegs, $regsForPage = DEFAULT_PAGER_REGS_FOR_PAGE )   X-Ref
Constructor of the pager

param: baseUrl The base url that will be used to generate the different URLs to the pages
param: curPage The current page
param: totalRegs The total number of registers
param: regsForPage The maximum number of registers per page, defaults to

setBaseUrl($url)   X-Ref
Sets the base url

param: url The url

getBaseUrl()   X-Ref

return: returns the base url

getTotalRegs()   X-Ref

return: Returns the current total amount of registers

getRegsForPage()   X-Ref

return: Returns the current number of records per page

getMaxPages()   X-Ref

return: Returns the maximum number of pages

getTotalPages()   X-Ref

return: The total number of pages

getCurrentPage()   X-Ref

return: The current page

getNextPage()   X-Ref
returns the number of the next page

return: number of the next page

getPrevPage()   X-Ref
returns the number of the previous page

return: number of the previous page

getStartPage()   X-Ref

return: Returns the current start page, if any

getEndPage()   X-Ref

return: Returns the last page

isFirstPage()   X-Ref

return: True if the current page is the first page or false otherwise

isLastPage()   X-Ref

return: Returns true if the current page is the last one or false otherwise

getPageLinks()   X-Ref

return: Returns an array containing all the links to the different pages

getNextPageLink()   X-Ref

return: Returns a link to the next page

getPrevPageLink()   X-Ref

return: Returns a link to the previous page

getFirstPageLink()   X-Ref

return: returns the link to the first page

getLastPageLink()   X-Ref

return: returns the link to the last page

generateLinks()   X-Ref
generates the links to the different pages

return: An associative array

isEmpty()   X-Ref
returns true if the pager is empty (has no pages or links) or false otherwise

return: true if the pager is empty or false if not

_init()   X-Ref




Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics