Source for file pagination.php
Documentation is available at pagination.php
* @package Joomla.Libraries
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Pagination Class. Provides a common interface for content pagination for the Joomla! CMS.
* @package Joomla.Libraries
* @var integer The record number to start displaying from.
* @var integer Number of rows to display per page.
* @var integer Total number of rows.
* @var integer Prefix used for request variables.
* @var integer Value pagination object begins at
* @var integer Value pagination object ends at
* @var integer Current page
* @var integer Total number of pages
* @var boolean View all flag
* Additional URL parameters to be added to the pagination URLs generated by the class. These
* may be useful for filters and extra values when dealing with lists and GET requests.
* @param integer $total The total number of items.
* @param integer $limitstart The offset of the item to start at.
* @param integer $limit The number of items to display per page.
* @param string $prefix The prefix used for request variables.
public function __construct($total, $limitstart, $limit, $prefix =
'')
$this->total = (int)
$total;
* If limitstart is greater than total (i.e. we are asked to display records that don't exist)
* then set limitstart to display the last natural page of results
// Set the total pages and current page values.
// Set the pagination iteration loop values.
// If we are viewing all records set the view all flag to true.
* Method to set an additional URL parameter to be added to all pagination class generated
* @param string $key The name of the URL parameter for which to set a value.
* @param mixed $value The value to set for the URL parameter.
* @return mixed The old value for the parameter.
// Get the old value to return and set the new one for the URL parameter.
// If the passed parameter value is null unset the parameter, otherwise set it to the given value.
* Method to get an additional URL parameter (if it exists) to be added to
* all pagination class generated links.
* @param string $key The name of the URL parameter for which to get the value.
* @return mixed The value if it exists or null if it does not.
* Return the rationalised offset for a row with a given index.
* @param integer $index The row index
* @return integer Rationalised offset for a row with a given index.
* Return the pagination data object, only creating it if it doesn't already exist.
* @return object Pagination data object.
* Create and return the pagination pages counter string, ie. Page 2 of 4.
* @return string Pagination pages counter string.
* Create and return the pagination result set counter string, e.g. Results 1-10 of 42
* @return string Pagination result set counter string.
// If the limit is reached before the end of the list.
$toResult =
$this->total;
// If there are results found.
$html .=
"\n" .
JText::_('JLIB_HTML_NO_RECORDS_FOUND');
* Create and return the pagination page list string, ie. Previous, Next, 1 2 3 ... x.
* @return string Pagination page list string.
// Build the page navigation list.
$list['prefix'] =
$this->prefix;
$chromePath =
JPATH_THEMES .
'/' .
$app->getTemplate() .
'/html/pagination.php';
include_once $chromePath;
if ($data->all->base !==
null)
$list['all']['active'] =
true;
$list['all']['active'] =
false;
if ($data->start->base !==
null)
$list['start']['active'] =
true;
$list['start']['active'] =
false;
if ($data->previous->base !==
null)
$list['previous']['active'] =
true;
$list['previous']['active'] =
false;
$list['pages'] =
array();
foreach ($data->pages as $i =>
$page)
if ($page->base !==
null)
$list['pages'][$i]['active'] =
true;
$list['pages'][$i]['active'] =
false;
if ($data->next->base !==
null)
$list['next']['active'] =
true;
$list['next']['active'] =
false;
if ($data->end->base !==
null)
$list['end']['active'] =
true;
$list['end']['active'] =
false;
* Return the pagination footer.
* @return string Pagination footer.
$list['prefix'] =
$this->prefix;
$list['limit'] =
$this->limit;
$list['total'] =
$this->total;
$chromePath =
JPATH_THEMES .
'/' .
$app->getTemplate() .
'/html/pagination.php';
include_once $chromePath;
* Creates a dropdown box for selecting how many records to show per page.
* @return string The HTML for the limit # input box.
for ($i =
5; $i <=
30; $i +=
5)
$limits[] =
JHtml::_('select.option', "$i");
$limits[] =
JHtml::_('select.option', '50', JText::_('J50'));
$limits[] =
JHtml::_('select.option', '100', JText::_('J100'));
$limits[] =
JHtml::_('select.option', '0', JText::_('JALL'));
// Build the select list.
'class="inputbox input-mini" size="1" onchange="Joomla.submitform();"',
'class="inputbox input-mini" size="1" onchange="this.form.submit()"',
* Return the icon to move an item UP.
* @param integer $i The row index.
* @param boolean $condition True to show the icon.
* @param string $task The task to fire.
* @param string $alt The image alternative text string.
* @param boolean $enabled An optional setting for access control on the action.
* @param string $checkbox An optional prefix for checkboxes.
* @return string Either the icon to move an item up or a space.
public function orderUpIcon($i, $condition =
true, $task =
'orderup', $alt =
'JLIB_HTML_MOVE_UP', $enabled =
true, $checkbox =
'cb')
if (($i >
0 ||
($i +
$this->limitstart >
0)) &&
$condition)
return JHtml::_('jgrid.orderUp', $i, $task, '', $alt, $enabled, $checkbox);
* Return the icon to move an item DOWN.
* @param integer $i The row index.
* @param integer $n The number of items in the list.
* @param boolean $condition True to show the icon.
* @param string $task The task to fire.
* @param string $alt The image alternative text string.
* @param boolean $enabled An optional setting for access control on the action.
* @param string $checkbox An optional prefix for checkboxes.
* @return string Either the icon to move an item down or a space.
public function orderDownIcon($i, $n, $condition =
true, $task =
'orderdown', $alt =
'JLIB_HTML_MOVE_DOWN', $enabled =
true, $checkbox =
'cb')
if (($i <
$n -
1 ||
$i +
$this->limitstart <
$this->total -
1) &&
$condition)
return JHtml::_('jgrid.orderDown', $i, $task, '', $alt, $enabled, $checkbox);
* Create the HTML for a list footer
* @param array $list Pagination list data structure.
* @return string HTML for a list footer
$html =
"<div class=\"list-footer\">\n";
$html .=
"\n<div class=\"limit\">" .
JText::_('JGLOBAL_DISPLAY_NUM') .
$list['limitfield'] .
"</div>";
$html .=
$list['pageslinks'];
$html .=
"\n<div class=\"counter\">" .
$list['pagescounter'] .
"</div>";
$html .=
"\n<input type=\"hidden\" name=\"" .
$list['prefix'] .
"limitstart\" value=\"" .
$list['limitstart'] .
"\" />";
* Create the html for a list footer
* @param array $list Pagination list data structure.
* @return string HTML for a list start, previous, next,end
// Reverse output rendering for right-to-left display.
$html .=
'<li class="pagination-start">' .
$list['start']['data'] .
'</li>';
$html .=
'<li class="pagination-prev">' .
$list['previous']['data'] .
'</li>';
foreach ($list['pages'] as $page)
$html .=
'<li>' .
$page['data'] .
'</li>';
$html .=
'<li class="pagination-next">' .
$list['next']['data'] .
'</li>';
$html .=
'<li class="pagination-end">' .
$list['end']['data'] .
'</li>';
* Method to create an active pagination link to the item
* @param JPaginationObject $item The object with which to make an active link.
* @return string HTML link
JHtml::_('bootstrap.tooltip');
$title =
' title="' .
$item->text .
'"';
return '<a' .
$title .
' href="#" onclick="document.adminForm.' .
$this->prefix
.
'limitstart.value=' .
($item->base >
0 ?
$item->base :
'0') .
'; Joomla.submitform();return false;">' .
$item->text .
'</a>';
return '<a' .
$title .
' href="' .
$item->link .
'" class="' .
$class .
'pagenav">' .
$item->text .
'</a>';
* Method to create an inactive pagination string
* @param JPaginationObject $item The item to be processed
return '<span>' .
$item->text .
'</span>';
return '<span class="pagenav">' .
$item->text .
'</span>';
* Create and return the pagination data object.
* @return object Pagination data object.
// Build the additional URL parameters string.
$params .=
'&' .
$key .
'=' .
$value;
$data->all->link =
JRoute::_($params .
'&' .
$this->prefix .
'limitstart=');
// Set the start and previous data objects.
// Set the empty for removal from route
// @todo remove code: $page = $page == 0 ? '' : $page;
$data->start->base =
'0';
$data->start->link =
JRoute::_($params .
'&' .
$this->prefix .
'limitstart=0');
$data->previous->base =
$page;
$data->previous->link =
JRoute::_($params .
'&' .
$this->prefix .
'limitstart=' .
$page);
// Set the next and end data objects.
$data->next->base =
$next;
$data->next->link =
JRoute::_($params .
'&' .
$this->prefix .
'limitstart=' .
$next);
$data->end->link =
JRoute::_($params .
'&' .
$this->prefix .
'limitstart=' .
$end);
$offset =
($i -
1) *
$this->limit;
$data->pages[$i]->base =
$offset;
$data->pages[$i]->link =
JRoute::_($params .
'&' .
$this->prefix .
'limitstart=' .
$offset);
$data->pages[$i]->active =
true;
* Modifies a property of the object, creating it if it does not already exist.
* @param string $property The name of the property.
* @param mixed $value The value of the property to set.
* @deprecated 4.0 Access the properties directly.
public function set($property, $value =
null)
JLog::add('JPagination::set() is deprecated. Access the properties directly.', JLog::WARNING, 'deprecated');
$this->$property =
$value;
* Returns a property of the object or the default value if the property is not set.
* @param string $property The name of the property.
* @param mixed $default The default value.
* @return mixed The value of the property.
* @deprecated 4.0 Access the properties directly.
public function get($property, $default =
null)
JLog::add('JPagination::get() is deprecated. Access the properties directly.', JLog::WARNING, 'deprecated');
if (isset
($this->$property))
Documentation generated on Tue, 19 Nov 2013 15:10:08 +0100 by phpDocumentor 1.4.3