You are here

function theme_pager_list in Drupal 4

Same name and namespace in other branches
  1. 5 includes/pager.inc \theme_pager_list()

Format a list of nearby pages with additional query results.

Parameters

$limit: The number of query results to display per page.

$element: An optional integer to distinguish between multiple pagers on one page.

$quantity: The number of pages in the list.

$text: A string of text to display before the page list.

$parameters: An associative array of query string parameters to append to the pager links.

Return value

An HTML string that generates this piece of the query pager.

Related topics

1 theme call to theme_pager_list()
theme_pager in includes/pager.inc
Format a query pager.

File

includes/pager.inc, line 294
Functions to aid in presenting database results as a set of pages.

Code

function theme_pager_list($limit, $element = 0, $quantity = 5, $text = '', $parameters = array()) {
  global $pager_page_array, $pager_total;
  $output = '<span class="pager-list">';

  // Calculate various markers within this pager piece:
  // Middle is used to "center" pages around the current page.
  $pager_middle = ceil($quantity / 2);

  // current is the page we are currently paged to
  $pager_current = $pager_page_array[$element] + 1;

  // first is the first page listed by this pager piece (re quantity)
  $pager_first = $pager_current - $pager_middle + 1;

  // last is the last page listed by this pager piece (re quantity)
  $pager_last = $pager_current + $quantity - $pager_middle;

  // max is the maximum page number
  $pager_max = $pager_total[$element];

  // End of marker calculations.
  // Prepare for generation loop.
  $i = $pager_first;
  if ($pager_last > $pager_max) {

    // Adjust "center" if at end of query.
    $i = $i + ($pager_max - $pager_last);
    $pager_last = $pager_max;
  }
  if ($i <= 0) {

    // Adjust "center" if at start of query.
    $pager_last = $pager_last + (1 - $i);
    $i = 1;
  }

  // End of generation loop preparation.
  // When there is more than one page, create the pager list.
  if ($i != $pager_max) {
    $output .= $text;
    if ($i > 1) {
      $output .= '<span class="pager-ellipsis">…</span>';
    }

    // Now generate the actual pager piece.
    for (; $i <= $pager_last && $i <= $pager_max; $i++) {
      if ($i < $pager_current) {
        $output .= theme('pager_previous', $i, $limit, $element, $pager_current - $i, $parameters);
      }
      if ($i == $pager_current) {
        $output .= '<strong class="pager-current">' . $i . '</strong>';
      }
      if ($i > $pager_current) {
        $output .= theme('pager_next', $i, $limit, $element, $i - $pager_current, $parameters);
      }
    }
    if ($i < $pager_max) {
      $output .= '<span class="pager-ellipsis">…</span>';
    }
  }
  $output .= '</span>';
  return $output;
}