You are here

function _pagerer_get_page_text in Pagerer 7

Return textual elements for a 'page' element in the pager.

Value returned is dependent on what's being displayed in the pager via the $variable['display'] and the $page_mode selected ['absolute'|'relative'].

Parameters

array $variables: theme's variables

array $markers: precalculated markers for the pager

int $offset: offset of page to be rendered, from current page

string $page_tag: page tag [page|first|previous|next|last]

string $page_mode: ['absolute'|'relative']

  • 'absolute' returns the page/item/item range at offset
  • 'relative' returns the offset (pages/items) from current

string $title_tag: title tag [page|first|previous|next|last]

Return value

array 0 => qualified page text to be displayed on the page 1 => qualified page text to be used as the HTML title

5 calls to _pagerer_get_page_text()
_pagerer_get_adaptive_pages in ./pagerer.module
Return an array of 'pages' using an adaptive logic.
_pagerer_get_neighborhood_pages in ./pagerer.module
Return an array of 'pages' in the neighborhood of the current one.
_pagerer_get_progressive_pages in ./pagerer.module
Return an array of 'pages' progressively more distant from current.
_pagerer_itemize_link in ./pagerer.module
Return link/button to first/previous/next/last element in the pager.
_pagerer_theme_handler in ./pagerer.module
Pagerer's theme handler.

File

./pagerer.module, line 1618
Pagerer

Code

function _pagerer_get_page_text($variables, $markers, $offset, $page_tag = 'page', $page_mode = 'absolute', $title_tag = 'page') {
  $pager_limits = $GLOBALS['pager_limits'];
  $c = $markers['pager_current'] - 1;
  $m = $markers['pager_max'] - 1;

  // Determine the text to be used to render the link. That is dependent
  // on the display mode and on the page mode.
  switch ($variables['display']) {
    case 'item_ranges':
      $min = ($c + $offset) * $pager_limits[$variables['element']] + 1;
      $max = min(($c + $offset + 1) * $pager_limits[$variables['element']], $markers['pager_item_max']);
      $absolute_page_num = t("@min@separator@max", array(
        '@min' => $min,
        '@separator' => $variables['range_separator'],
        '@max' => $max,
      ));
      $relative_page_num = abs($offset * $pager_limits[$variables['element']]);
      break;
    case 'items':
      $absolute_page_num = ($c + $offset) * $pager_limits[$variables['element']] + 1;
      $relative_page_num = abs($offset * $pager_limits[$variables['element']]);
      break;
    case 'pages':
    default:
      $absolute_page_num = $c + $offset + 1;
      $relative_page_num = abs($offset);
      break;
  }
  if ($page_mode == 'relative') {

    // Use a progressive page tag.
    $page_tag_relative = $offset > 0 ? $variables['tags']['next_progr'] : $variables['tags']['previous_progr'];
    $text = format_string($page_tag_relative, array(
      '@number' => $relative_page_num,
      '@total' => _pagerer_get_total($variables, $markers),
    ));
  }
  else {

    // Use the normal page tag.
    $text = format_string($variables['tags'][$page_tag], array(
      '@number' => $absolute_page_num,
      '@total' => _pagerer_get_total($variables, $markers),
    ));
  }

  // Format the HTML title, used by the browser to display microhelp text.
  $text_title = format_string($variables['tags'][$title_tag . '_title'], array(
    '@number' => $absolute_page_num,
    '@total' => _pagerer_get_total($variables, $markers),
  ));
  return array(
    $text,
    $text_title,
  );
}