Commit c2ab077c authored by catch's avatar catch

Issue #1598886 by bleen18, dodorama, sun: Clean up pager theme functions.

parent afc4b899
......@@ -193,10 +193,46 @@ function theme_pager($variables) {
}
// End of generation loop preparation.
$li_first = theme('pager_first', array('text' => (isset($tags[0]) ? $tags[0] : t('« first')), 'element' => $element, 'parameters' => $parameters));
$li_previous = theme('pager_previous', array('text' => (isset($tags[1]) ? $tags[1] : t('‹ previous')), 'element' => $element, 'interval' => 1, 'parameters' => $parameters));
$li_next = theme('pager_next', array('text' => (isset($tags[3]) ? $tags[3] : t('next ›')), 'element' => $element, 'interval' => 1, 'parameters' => $parameters));
$li_last = theme('pager_last', array('text' => (isset($tags[4]) ? $tags[4] : t('last »')), 'element' => $element, 'parameters' => $parameters));
$li_first = '';
$li_previous = '';
$li_next = '';
$li_last = '';
// Create the "first" and "previous" links if we are not on the first page.
if ($pager_page_array[$element] > 0) {
$li_first = theme('pager_link__first', array(
'text' => (isset($tags[0]) ? $tags[0] : t('« first')),
'page_new' => pager_load_array(0, $element, $pager_page_array),
'element' => $element,
'parameters' => $parameters,
'attributes' => array('rel' => 'first'),
));
$li_previous = theme('pager_link__previous', array(
'text' => isset($tags[1]) ? $tags[1] : t('‹ previous'),
'page_new' => pager_load_array($pager_page_array[$element] - 1, $element, $pager_page_array),
'element' => $element,
'parameters' => $parameters,
'attributes' => array('rel' => 'prev'),
));
}
// Create the "last" and "next" links if we are not on the last page.
if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
$li_next = theme('pager_link__next', array(
'text' => isset($tags[3]) ? $tags[3] : t('next ›'),
'page_new' => pager_load_array($pager_page_array[$element] + 1, $element, $pager_page_array),
'element' => $element,
'parameters' => $parameters,
'attributes' => array('rel' => 'next'),
));
$li_last = theme('pager_link__last', array(
'text' => (isset($tags[4]) ? $tags[4] : t('last »')),
'page_new' => pager_load_array($pager_total[$element] - 1, $element, $pager_page_array),
'element' => $element,
'parameters' => $parameters,
'attributes' => array('rel' => 'last'),
));
}
if ($pager_total[$element] > 1) {
if ($li_first) {
......@@ -225,7 +261,13 @@ function theme_pager($variables) {
if ($i < $pager_current) {
$items[] = array(
'class' => array('pager-item'),
'data' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => ($pager_current - $i), 'parameters' => $parameters)),
'data' => theme('pager_link', array(
'text' => $i,
'page_new' => pager_load_array($i - 1, $element, $pager_page_array),
'element' => $element,
'interval' => ($pager_current - $i),
'parameters' => $parameters,
)),
);
}
if ($i == $pager_current) {
......@@ -237,7 +279,13 @@ function theme_pager($variables) {
if ($i > $pager_current) {
$items[] = array(
'class' => array('pager-item'),
'data' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => ($i - $pager_current), 'parameters' => $parameters)),
'data' => theme('pager_link', array(
'text' => $i,
'page_new' => pager_load_array($i - 1, $element, $pager_page_array),
'element' => $element,
'interval' => ($i - $pager_current),
'parameters' => $parameters,
)),
);
}
}
......@@ -268,149 +316,6 @@ function theme_pager($variables) {
}
}
/**
* @defgroup pagerpieces Pager pieces
* @{
* Theme functions for customizing pager elements.
*
* Note that you should NOT modify this file to customize your pager.
*/
/**
* Returns HTML for the "first page" link in a query pager.
*
* @param $variables
* An associative array containing:
* - text: The name (or image) of the link.
* - element: An optional integer to distinguish between multiple pagers on
* one page.
* - parameters: An associative array of query string parameters to append to
* the pager links.
*
* @ingroup themeable
*/
function theme_pager_first($variables) {
$text = $variables['text'];
$element = $variables['element'];
$parameters = $variables['parameters'];
global $pager_page_array;
$output = '';
// If we are anywhere but the first page
if ($pager_page_array[$element] > 0) {
$output = theme('pager_link', array('text' => $text, 'page_new' => pager_load_array(0, $element, $pager_page_array), 'element' => $element, 'parameters' => $parameters, 'attributes' => array('rel' => 'first')));
}
return $output;
}
/**
* Returns HTML for the "previous page" link in a query pager.
*
* @param $variables
* An associative array containing:
* - text: The name (or image) of the link.
* - element: An optional integer to distinguish between multiple pagers on
* one page.
* - interval: The number of pages to move backward when the link is clicked.
* - parameters: An associative array of query string parameters to append to
* the pager links.
*
* @ingroup themeable
*/
function theme_pager_previous($variables) {
$text = $variables['text'];
$element = $variables['element'];
$interval = $variables['interval'];
$parameters = $variables['parameters'];
global $pager_page_array;
$output = '';
// If we are anywhere but the first page
if ($pager_page_array[$element] > 0) {
$page_new = pager_load_array($pager_page_array[$element] - $interval, $element, $pager_page_array);
// If the previous page is the first page, mark the link as such.
if ($page_new[$element] == 0) {
$output = theme('pager_first', array('text' => $text, 'element' => $element, 'parameters' => $parameters));
}
// The previous page is not the first page.
else {
$output = theme('pager_link', array('text' => $text, 'page_new' => $page_new, 'element' => $element, 'parameters' => $parameters, 'attributes' => array('rel' => 'prev')));
}
}
return $output;
}
/**
* Returns HTML for the "next page" link in a query pager.
*
* @param $variables
* An associative array containing:
* - text: The name (or image) of the link.
* - element: An optional integer to distinguish between multiple pagers on
* one page.
* - interval: The number of pages to move forward when the link is clicked.
* - parameters: An associative array of query string parameters to append to
* the pager links.
*
* @ingroup themeable
*/
function theme_pager_next($variables) {
$text = $variables['text'];
$element = $variables['element'];
$interval = $variables['interval'];
$parameters = $variables['parameters'];
global $pager_page_array, $pager_total;
$output = '';
// If we are anywhere but the last page
if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
$page_new = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array);
// If the next page is the last page, mark the link as such.
if ($page_new[$element] == ($pager_total[$element] - 1)) {
$output = theme('pager_last', array('text' => $text, 'element' => $element, 'parameters' => $parameters));
}
// The next page is not the last page.
else {
$output = theme('pager_link', array('text' => $text, 'page_new' => $page_new, 'element' => $element, 'parameters' => $parameters, 'attributes' => array('rel' => 'next')));
}
}
return $output;
}
/**
* Returns HTML for the "last page" link in query pager.
*
* @param $variables
* An associative array containing:
* - text: The name (or image) of the link.
* - element: An optional integer to distinguish between multiple pagers on
* one page.
* - parameters: An associative array of query string parameters to append to
* the pager links.
*
* @ingroup themeable
*/
function theme_pager_last($variables) {
$text = $variables['text'];
$element = $variables['element'];
$parameters = $variables['parameters'];
global $pager_page_array, $pager_total;
$output = '';
// If we are anywhere but the last page
if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
$output = theme('pager_link', array('text' => $text, 'page_new' => pager_load_array($pager_total[$element] - 1, $element, $pager_page_array), 'element' => $element, 'parameters' => $parameters, 'attributes' => array('rel' => 'last')));
}
return $output;
}
/**
* Returns HTML for a link to a specific query result page.
*
......@@ -481,10 +386,6 @@ function theme_pager_link($variables) {
return '<a' . new Attribute($attributes) . '>' . check_plain($text) . '</a>';
}
/**
* @} End of "defgroup pagerpieces".
*/
/**
* Helper function
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment