10.04.2018 Views

Doctrine_manual-1-2-en

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 26: Utilities 348<br />

Listing<br />

26-20<br />

// Parses the template and returns the string of a processed page<br />

$this->processPage($options = array()); // Needs at least page_number<br />

offset in $options array<br />

// Protected methods, although very useful<br />

// Parse the template of a giv<strong>en</strong> page and return the processed template<br />

$this->_parseTemplate($options = array());<br />

// Parse the url mask to return the correct template dep<strong>en</strong>ding of the<br />

options s<strong>en</strong>t<br />

// Already process the mask replacem<strong>en</strong>ts assigned<br />

$this->_parseUrlTemplate($options = array());<br />

// Parse the mask replacem<strong>en</strong>ts of a giv<strong>en</strong> page<br />

$this->_parseReplacem<strong>en</strong>tsTemplate($options = array());<br />

// Parse the url mask of a giv<strong>en</strong> page and return the processed url<br />

$this->_parseUrl($options = array());<br />

// Parse the mask replacem<strong>en</strong>ts, changing from to-be replaced mask with new<br />

masks/values<br />

$this->_parseMaskReplacem<strong>en</strong>ts($str);<br />

Now that you have a small tip of useful methods to be used wh<strong>en</strong> ext<strong>en</strong>ding<br />

<strong>Doctrine</strong>_Pager_Layout, it's time to see our implem<strong>en</strong>ted class:<br />

class PagerLayoutWithArrows ext<strong>en</strong>ds <strong>Doctrine</strong>_Pager_Layout<br />

{<br />

public function display($options = array(), $return = false)<br />

{<br />

$pager = $this->getPager();<br />

$str = '';<br />

// First page<br />

$this->addMaskReplacem<strong>en</strong>t('page', '&laquo;', true);<br />

$options['page_number'] = $pager->getFirstPage();<br />

$str .= $this->processPage($options);<br />

// Previous page<br />

$this->addMaskReplacem<strong>en</strong>t('page', '&lsaquo;', true);<br />

$options['page_number'] = $pager->getPreviousPage();<br />

$str .= $this->processPage($options);<br />

// Pages listing<br />

$this->removeMaskReplacem<strong>en</strong>t('page');<br />

$str .= par<strong>en</strong>t::display($options, true);<br />

// Next page<br />

$this->addMaskReplacem<strong>en</strong>t('page', '&rsaquo;', true);<br />

$options['page_number'] = $pager->getNextPage();<br />

$str .= $this->processPage($options);<br />

// Last page<br />

$this->addMaskReplacem<strong>en</strong>t('page', '&raquo;', true);<br />

$options['page_number'] = $pager->getLastPage();<br />

$str .= $this->processPage($options);<br />

----------------- Brought to you by

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!