Zend Framework  1.12
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Zend_Paginator Class Reference

Public Member Functions

 __construct ($adapter)
 Constructor.
 
 __toString ()
 Serializes the object as a string.
 
 setCacheEnabled ($enable)
 Enables/Disables the cache for this instance.
 
 count ()
 Returns the number of pages.
 
 getTotalItemCount ()
 Returns the total number of items available.
 
 clearPageItemCache ($pageNumber=null)
 Clear the page item cache.
 
 getAbsoluteItemNumber ($relativeItemNumber, $pageNumber=null)
 Returns the absolute item number for the specified item.
 
 getAdapter ()
 Returns the adapter.
 
 getCurrentItemCount ()
 Returns the number of items for the current page.
 
 getCurrentItems ()
 Returns the items for the current page.
 
 getCurrentPageNumber ()
 Returns the current page number.
 
 setCurrentPageNumber ($pageNumber)
 Sets the current page number.
 
 getFilter ()
 Get the filter.
 
 setFilter (Zend_Filter_Interface $filter)
 Set a filter chain.
 
 getItem ($itemNumber, $pageNumber=null)
 Returns an item from a page.
 
 getItemCountPerPage ()
 Returns the number of items per page.
 
 setItemCountPerPage ($itemCountPerPage=-1)
 Sets the number of items per page.
 
 getItemCount ($items)
 Returns the number of items in a collection.
 
 getItemsByPage ($pageNumber)
 Returns the items for a given page.
 
 getIterator ()
 Returns a foreach-compatible iterator.
 
 getPageRange ()
 Returns the page range (see property declaration above).
 
 setPageRange ($pageRange)
 Sets the page range (see property declaration above).
 
 getPages ($scrollingStyle=null)
 Returns the page collection.
 
 getPagesInRange ($lowerBound, $upperBound)
 Returns a subset of pages within a given range.
 
 getPageItemCache ()
 Returns the page item cache.
 
 getView ()
 Retrieves the view instance.
 
 setView (Zend_View_Interface $view=null)
 Sets the view object.
 
 normalizeItemNumber ($itemNumber)
 Brings the item number in range of the page.
 
 normalizePageNumber ($pageNumber)
 Brings the page number in range of the paginator.
 
 render (Zend_View_Interface $view=null)
 Renders the paginator.
 
 toJson ()
 Returns the items of the current page as JSON.
 

Static Public Member Functions

static addAdapterPrefixPath ($prefix, $path)
 Adds an adapter prefix path to the plugin loader.
 
static addAdapterPrefixPaths (array $prefixPaths)
 Adds an array of adapter prefix paths to the plugin loader.
 
static addScrollingStylePrefixPath ($prefix, $path)
 Adds a scrolling style prefix path to the plugin loader.
 
static addScrollingStylePrefixPaths (array $prefixPaths)
 Adds an array of scrolling style prefix paths to the plugin loader.
 
static factory ($data, $adapter=self::INTERNAL_ADAPTER, array $prefixPaths=null)
 Factory.
 
static getAdapterLoader ()
 Returns the adapter loader.
 
static setConfig (Zend_Config $config)
 Set a global config.
 
static getDefaultScrollingStyle ()
 Returns the default scrolling style.
 
static getDefaultItemCountPerPage ()
 Get the default item count per page.
 
static setDefaultItemCountPerPage ($count)
 Set the default item count per page.
 
static getDefaultPageRange ()
 Get the default page range.
 
static setDefaultPageRange ($count)
 Set the default page range.
 
static setCache (Zend_Cache_Core $cache)
 Sets a cache object.
 
static setDefaultScrollingStyle ($scrollingStyle= 'Sliding')
 Sets the default scrolling style.
 
static getScrollingStyleLoader ()
 Returns the scrolling style loader.
 

Public Attributes

const INTERNAL_ADAPTER = 'Zend_Paginator_Adapter_Internal'
 
const CACHE_TAG_PREFIX = 'Zend_Paginator_'
 The cache tag prefix used to namespace Paginator results in the cache.
 

Protected Member Functions

 _cacheEnabled ()
 Tells if there is an active cache object and if the cache has not been desabled.
 
 _getCacheId ($page=null)
 Makes an Id for the cache Depends on the adapter object and the page number.
 
 _getCacheInternalId ()
 Get the internal cache id Depends on the adapter and the item count per page.
 
 _calculatePageCount ()
 Calculates the page count.
 
 _createPages ($scrollingStyle=null)
 Creates the page collection.
 
 _loadScrollingStyle ($scrollingStyle=null)
 Loads a scrolling style.
 

Protected Attributes

 $_cacheEnabled = true
 
 $_adapter = null
 
 $_currentItemCount = null
 
 $_currentItems = null
 
 $_currentPageNumber = 1
 
 $_filter = null
 
 $_itemCountPerPage = null
 
 $_pageCount = null
 
 $_pageRange = null
 
 $_pages = null
 
 $_view = null
 

Static Protected Attributes

static $_adapterLoader = null
 
static $_config = null
 
static $_defaultScrollingStyle = 'Sliding'
 
static $_defaultItemCountPerPage = 10
 
static $_defaultPageRange = 10
 
static $_scrollingStyleLoader = null
 
static $_cache
 

Constructor & Destructor Documentation

__construct (   $adapter)

Member Function Documentation

__toString ( )

Serializes the object as a string.

Proxies to render().

Returns
string
_cacheEnabled ( )
protected

Tells if there is an active cache object and if the cache has not been desabled.

Returns
bool
_calculatePageCount ( )
protected

Calculates the page count.

Returns
integer
_createPages (   $scrollingStyle = null)
protected

Creates the page collection.

Parameters
string$scrollingStyleScrolling style
Returns
stdClass
_getCacheId (   $page = null)
protected

Makes an Id for the cache Depends on the adapter object and the page number.

Used to store item in cache from that Paginator instance and that current page

Parameters
int$page
Returns
string
_getCacheInternalId ( )
protected

Get the internal cache id Depends on the adapter and the item count per page.

Used to tag that unique Paginator instance in cache

Returns
string
_loadScrollingStyle (   $scrollingStyle = null)
protected

Loads a scrolling style.

Parameters
string$scrollingStyle
Returns
Zend_Paginator_ScrollingStyle_Interface
See Also
Zend_View_Exception
Zend_View_Exception
static addAdapterPrefixPath (   $prefix,
  $path 
)
static

Adds an adapter prefix path to the plugin loader.

Parameters
string$prefix
string$path
static addAdapterPrefixPaths ( array  $prefixPaths)
static

Adds an array of adapter prefix paths to the plugin loader.

$prefixPaths = array( 'My_Paginator_Adapter' => 'My/Paginator/Adapter/', 'Your_Paginator_Adapter' => 'Your/Paginator/Adapter/' );

Parameters
array$prefixPaths
static addScrollingStylePrefixPath (   $prefix,
  $path 
)
static

Adds a scrolling style prefix path to the plugin loader.

Parameters
string$prefix
string$path
static addScrollingStylePrefixPaths ( array  $prefixPaths)
static

Adds an array of scrolling style prefix paths to the plugin loader.

$prefixPaths = array( 'My_Paginator_ScrollingStyle' => 'My/Paginator/ScrollingStyle/', 'Your_Paginator_ScrollingStyle' => 'Your/Paginator/ScrollingStyle/' );

Parameters
array$prefixPaths
clearPageItemCache (   $pageNumber = null)

Clear the page item cache.

Parameters
int$pageNumber
Returns
Zend_Paginator
count ( )

Returns the number of pages.

Returns
integer
static factory (   $data,
  $adapter = self::INTERNAL_ADAPTER,
array  $prefixPaths = null 
)
static

Factory.

Parameters
mixed$data
string$adapter
array$prefixPaths
Returns
Zend_Paginator
See Also
Zend_Paginator_Exception
getAbsoluteItemNumber (   $relativeItemNumber,
  $pageNumber = null 
)

Returns the absolute item number for the specified item.

Parameters
integer$relativeItemNumberRelative item number
integer$pageNumberPage number
Returns
integer
getAdapter ( )

Returns the adapter.

Returns
Zend_Paginator_Adapter_Interface
static getAdapterLoader ( )
static

Returns the adapter loader.

If it doesn't exist it's created.

Returns
Zend_Loader_PluginLoader
getCurrentItemCount ( )

Returns the number of items for the current page.

Returns
integer
getCurrentItems ( )

Returns the items for the current page.

Returns
Traversable
getCurrentPageNumber ( )

Returns the current page number.

Returns
integer
static getDefaultItemCountPerPage ( )
static

Get the default item count per page.

Returns
int
static getDefaultPageRange ( )
static

Get the default page range.

Returns
int
static getDefaultScrollingStyle ( )
static

Returns the default scrolling style.

Returns
string
getFilter ( )

Get the filter.

Returns
Zend_Filter_Interface
getItem (   $itemNumber,
  $pageNumber = null 
)

Returns an item from a page.

The current page is used if there's no page sepcified.

Parameters
integer$itemNumberItem number (1 to itemCountPerPage)
integer$pageNumber
Returns
mixed
See Also
Zend_Paginator_Exception
Zend_Paginator_Exception
getItemCount (   $items)

Returns the number of items in a collection.

Parameters
mixed$itemsItems
Returns
integer
getItemCountPerPage ( )

Returns the number of items per page.

Returns
integer
getItemsByPage (   $pageNumber)

Returns the items for a given page.

Returns
Traversable
getIterator ( )

Returns a foreach-compatible iterator.

Returns
Traversable
getPageItemCache ( )

Returns the page item cache.

Returns
array
getPageRange ( )

Returns the page range (see property declaration above).

Returns
integer
getPages (   $scrollingStyle = null)

Returns the page collection.

Parameters
string$scrollingStyleScrolling style
Returns
array
getPagesInRange (   $lowerBound,
  $upperBound 
)

Returns a subset of pages within a given range.

Parameters
integer$lowerBoundLower bound of the range
integer$upperBoundUpper bound of the range
Returns
array
static getScrollingStyleLoader ( )
static

Returns the scrolling style loader.

If it doesn't exist it's created.

Returns
Zend_Loader_PluginLoader
getTotalItemCount ( )

Returns the total number of items available.

Uses cache if caching is enabled.

Returns
integer
getView ( )

Retrieves the view instance.

If none registered, attempts to pull f rom ViewRenderer.

Returns
Zend_View_Interface|null
See Also
Zend_Controller_Action_HelperBroker
normalizeItemNumber (   $itemNumber)

Brings the item number in range of the page.

Parameters
integer$itemNumber
Returns
integer
normalizePageNumber (   $pageNumber)

Brings the page number in range of the paginator.

Parameters
integer$pageNumber
Returns
integer
render ( Zend_View_Interface  $view = null)

Renders the paginator.

Parameters
Zend_View_Interface$view
Returns
string
static setCache ( Zend_Cache_Core  $cache)
static

Sets a cache object.

Parameters
Zend_Cache_Core$cache
setCacheEnabled (   $enable)

Enables/Disables the cache for this instance.

Parameters
bool$enable
Returns
Zend_Paginator
static setConfig ( Zend_Config  $config)
static

Set a global config.

Parameters
Zend_Config$config
setCurrentPageNumber (   $pageNumber)

Sets the current page number.

Parameters
integer$pageNumberPage number
Returns
Zend_Paginator $this
static setDefaultItemCountPerPage (   $count)
static

Set the default item count per page.

Parameters
int$count
static setDefaultPageRange (   $count)
static

Set the default page range.

Parameters
int$count
static setDefaultScrollingStyle (   $scrollingStyle = 'Sliding')
static

Sets the default scrolling style.

Parameters
string$scrollingStyle
setFilter ( Zend_Filter_Interface  $filter)

Set a filter chain.

Parameters
Zend_Filter_Interface$filter
Returns
Zend_Paginator
setItemCountPerPage (   $itemCountPerPage = -1)

Sets the number of items per page.

Parameters
integer$itemCountPerPage
Returns
Zend_Paginator $this
setPageRange (   $pageRange)

Sets the page range (see property declaration above).

Parameters
integer$pageRange
Returns
Zend_Paginator $this
setView ( Zend_View_Interface  $view = null)

Sets the view object.

Parameters
Zend_View_Interface$view
Returns
Zend_Paginator
toJson ( )

Returns the items of the current page as JSON.

Returns
string

Member Data Documentation

$_adapter = null
protected
$_adapterLoader = null
staticprotected
$_cache
staticprotected
$_cacheEnabled = true
protected
$_config = null
staticprotected
$_currentItemCount = null
protected
$_currentItems = null
protected
$_currentPageNumber = 1
protected
$_defaultItemCountPerPage = 10
staticprotected
$_defaultPageRange = 10
staticprotected
$_defaultScrollingStyle = 'Sliding'
staticprotected
$_filter = null
protected
$_itemCountPerPage = null
protected
$_pageCount = null
protected
$_pageRange = null
protected
$_pages = null
protected
$_scrollingStyleLoader = null
staticprotected
$_view = null
protected
const CACHE_TAG_PREFIX = 'Zend_Paginator_'

The cache tag prefix used to namespace Paginator results in the cache.

const INTERNAL_ADAPTER = 'Zend_Paginator_Adapter_Internal'