You are here

function _pagerer_get_neighborhood_pages in Pagerer 7

Return an array of 'pages' in the neighborhood of the current one.

This is in fact generating the same list of pages as standard Drupal pager. The neighborhood is centered on the current page, with ($variables['quantity'] / 2) pages falling aside left and right of the current, provided there are enough pages.

Parameters

array $variables: theme's variables

array $markers: precalculated markers for the pager

Return value

array associative array of pages, with key = page and value an array having 'text' and 'interval' (the offset from current page) keys/values

1 call to _pagerer_get_neighborhood_pages()
_pagerer_theme_handler in ./pagerer.module
Pagerer's theme handler.

File

./pagerer.module, line 1457
Pagerer

Code

function _pagerer_get_neighborhood_pages($variables, $markers) {

  // Prepare for generation loop.
  $i = $markers['pager_first'];

  // Adjust "center" if at end of query.
  if ($markers['pager_last'] > $markers['pager_max']) {
    $i = $i + ($markers['pager_max'] - $markers['pager_last']);
    $markers['pager_last'] = $markers['pager_max'];
  }

  // Adjust "center" if at start of query.
  if ($i <= 0) {
    $markers['pager_last'] = $markers['pager_last'] + (1 - $i);
    $i = 1;
  }
  $pages = array();
  $c = $markers['pager_current'] - 1;
  $m = $markers['pager_max'] - 1;
  for (; $i <= $markers['pager_last'] && $i <= $markers['pager_max']; $i++) {
    $offset = $i - $markers['pager_current'];
    $pages[$i - 1]['interval'] = $offset;
    list($pages[$i - 1]['text'], $pages[$i - 1]['text_title']) = _pagerer_get_page_text($variables, $markers, $offset);
  }
  return $pages;
}