Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.765 diff -u -F^function -r1.765 common.inc --- includes/common.inc 6 May 2008 12:18:45 -0000 1.765 +++ includes/common.inc 10 May 2008 00:41:41 -0000 @@ -2915,6 +2915,9 @@ function drupal_common_theme() { 'pager' => array( 'arguments' => array('tags' => array(), 'limit' => 10, 'element' => 0, 'parameters' => array()), ), + 'pager_info' => array( + 'arguments' => array('text' => NULL), + ), 'pager_first' => array( 'arguments' => array('text' => NULL, 'limit' => NULL, 'element' => 0, 'parameters' => array()), ), Index: includes/pager.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/pager.inc,v retrieving revision 1.63 diff -u -F^function -r1.63 pager.inc --- includes/pager.inc 6 Dec 2007 09:58:30 -0000 1.63 +++ includes/pager.inc 10 May 2008 00:42:00 -0000 @@ -107,13 +107,16 @@ function pager_get_querystring() { * An associative array of query string parameters to append to the pager links. * @param $quantity * The number of pages in the list. + * @param $show_info + * An optional argument that indicates whether pager information (i.e. + * "Items x - y of z") should be displayed. Defaults to FALSE. * @return * An HTML string that generates the query pager. * * @ingroup themeable */ -function theme_pager($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 9) { - global $pager_page_array, $pager_total; +function theme_pager($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 9, $show_info = FALSE) { + global $pager_page_array, $pager_total, $pager_total_items; // Calculate various markers within this pager piece: // Middle is used to "center" pages around the current page. @@ -147,6 +150,9 @@ function theme_pager($tags = array(), $l $li_next = theme('pager_next', (isset($tags[3]) ? $tags[3] : t('next ›')), $limit, $element, 1, $parameters); $li_last = theme('pager_last', (isset($tags[4]) ? $tags[4] : t('last »')), $limit, $element, $parameters); + $pager_list = ''; + $pager_info = ''; + if ($pager_total[$element] > 1) { if ($li_first) { $items[] = array( @@ -210,8 +216,31 @@ function theme_pager($tags = array(), $l 'data' => $li_last, ); } - return theme('item_list', $items, NULL, 'ul', array('class' => 'pager')); + $pager_list = theme('item_list', $items, NULL, 'ul', array('class' => 'pager')); } + + if ($show_info) { + // Prepare additional information about the current paging status. + $from = $pager_page_array[$element] * $limit + 1; + $to = min(($pager_page_array[$element] + 1) * $limit, $pager_total_items[$element]); + if ($pager_total_items[$element] == 1) { + $pager_info = t('1 item'); + } + elseif ($pager_total_items[$element] > 1) { + if ($from == $to) { + $pager_info = t('Item @to of @total', array('@to' => $to, '@total' => $pager_total_items[$element])); + } + elseif ($pager_total_items[$element] <= $limit) { + $pager_info = t('@total items', array('@total' => $pager_total_items[$element])); + } + else { + $pager_info = t('Items @from - @to of @total', array('@from' => $from, '@to' => $to, '@total' => $pager_total_items[$element])); + } + } + $pager_info = theme('pager_info', $pager_info); + } + + return $pager_info . $pager_list; } @@ -223,6 +252,18 @@ function theme_pager($tags = array(), $l */ /** + * Format the "information" part of the pager. + * + * @param $text + * The pager information text to display. + * @return + * An HTML string that generates this piece of the query pager. + */ +function theme_pager_info($text) { + return '
' . $text . '
'; +} + +/** * Format a "first page" link. * * @param $text Index: modules/search/search.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/search/search.pages.inc,v retrieving revision 1.5 diff -u -F^function -r1.5 search.pages.inc --- modules/search/search.pages.inc 14 Apr 2008 17:48:41 -0000 1.5 +++ modules/search/search.pages.inc 10 May 2008 00:46:58 -0000 @@ -63,7 +63,7 @@ function template_preprocess_search_resu foreach ($variables['results'] as $result) { $variables['search_results'] .= theme('search_result', $result, $variables['type']); } - $variables['pager'] = theme('pager', NULL, 10, 0); + $variables['pager'] = theme('pager', NULL, 10, 0, array(), 9, TRUE); // Provide alternate search results template. $variables['template_files'][] = 'search-results-' . $variables['type']; }