Doctrine 1.2.4
Doctrine_Pager_Range_Sliding Class Reference

Inherits Doctrine_Pager_Range.

Public Member Functions

 getChunkLength ()
 
 getOption ($option)
 
 getOptions ()
 
 getPager ()
 
 isInRange ($page)
 
 rangeAroundPage ()
 
 setPager ($pager)
 

Protected Member Functions

 _initialize ()
 
 _setChunkLength ($chunkLength)
 
 _setOptions ($options)
 

Detailed Description

Definition at line 33 of file Sliding.php.

Member Function Documentation

Doctrine_Pager_Range_Sliding::_initialize ( )
protected

_initialize

Initialize Doctrine_Pager_Range_Sliding and does custom assignments

Returns
void

Definition at line 47 of file Sliding.php.

{
if (isset($this->_options['chunk'])) {
$this->_setChunkLength($this->_options['chunk']);
} else {
throw new Doctrine_Pager_Exception('Missing parameter \'chunk\' that must be defined in options.');
}
}
Doctrine_Pager_Range_Sliding::_setChunkLength (   $chunkLength)
protected

_setChunkLength

Defines the size of the chunk

Parameters
$chunkLengthChunk length
Returns
void

Definition at line 76 of file Sliding.php.

{
$chunkLength = (int) $chunkLength;
if ( !$chunkLength) {
$chunkLength = 1;
} else {
$this->_chunkLength = $chunkLength;
}
}
Doctrine_Pager_Range::_setOptions (   $options)
protectedinherited

_setOptions

Defines the subclass implementation options

Parameters
$optionsCustom Doctrine_Pager_Range implementation options
Returns
void

Definition at line 132 of file Range.php.

{
$this->_options = $options;
}
Doctrine_Pager_Range_Sliding::getChunkLength ( )

getChunkLength

Returns the size of the chunk defined

Returns
int Chunk length

Definition at line 63 of file Sliding.php.

{
return $this->_chunkLength;
}
Doctrine_Pager_Range::getOption (   $option)
inherited

getOption

Returns the custom Doctrine_Pager_Range implementation offset option

Returns
array Custom Doctrine_Pager_Range implementation options

Definition at line 113 of file Range.php.

{
if (isset($this->_options[$option])) {
return $this->_options[$option];
}
'Cannot access unexistent option \'' . $option . '\' in Doctrine_Pager_Range class'
);
}
Doctrine_Pager_Range::getOptions ( )
inherited

getOptions

Returns the custom Doctrine_Pager_Range implementation options

Returns
array Custom Doctrine_Pager_Range implementation options

Definition at line 101 of file Range.php.

{
return $this->_options;
}
Doctrine_Pager_Range::getPager ( )
inherited

getPager

Returns the Doctrine_Pager object related to the pager range

Returns
Doctrine_Pager Doctrine_Pager object related to the pager range

Definition at line 70 of file Range.php.

{
return $this->pager;
}
Doctrine_Pager_Range::isInRange (   $page)
inherited

isInRange

Check if a given page is in the range

Parameters
$pagePage to be checked
Returns
boolean

Definition at line 145 of file Range.php.

{
return (array_search($page, $this->rangeAroundPage()) !== false);
}
Doctrine_Pager_Range_Sliding::rangeAroundPage ( )

rangeAroundPage

Calculate and returns an array representing the range around the current page

Returns
array

Definition at line 93 of file Sliding.php.

{
$pager = $this->getPager();
if ($pager->getExecuted()) {
$page = $pager->getPage();
$pages = $pager->getLastPage();
$chunk = $this->getChunkLength();
if ($chunk > $pages) {
$chunk = $pages;
}
$chunkStart = $page - (floor($chunk / 2));
$chunkEnd = $page + (ceil($chunk / 2)-1);
if ($chunkStart < 1) {
$adjust = 1 - $chunkStart;
$chunkStart = 1;
$chunkEnd = $chunkEnd + $adjust;
}
if ($chunkEnd > $pages) {
$adjust = $chunkEnd - $pages;
$chunkStart = $chunkStart - $adjust;
$chunkEnd = $pages;
}
return range($chunkStart, $chunkEnd);
}
'Cannot retrieve the range around the page of a not yet executed Pager query'
);
}
Doctrine_Pager_Range::setPager (   $pager)
inherited

setPager

Defines the Doctrine_Pager object related to the pager range and automatically (re-)initialize Doctrine_Pager_Range

Parameters
$pagerDoctrine_Pager object related to the pager range
Returns
void

Definition at line 84 of file Range.php.

{
$this->pager = $pager;
// Lazy-load initialization. It only should be called when all
// needed information data is ready (this can only happens when we have
// options stored and a Doctrine_Pager assocated)
$this->_initialize();
}

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