You are here

function _pagerer_get_progressive_pages in Pagerer 7

Return an array of 'pages' progressively more distant from current.

Parameters

array $variables: theme's variables

array $markers: precalculated markers for the pager

array $pages: array of pages already enlisted, to prevent override

int $scale_factor: scale factor to be used in the progressive series

int $ratio: ratio to be used in the progressive series

int $limit: (optional) to be used to limit the quantity of pages enlisted

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; a key 'progressive' set to TRUE is also added as a marker

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

File

./pagerer.module, line 1504
Pagerer

Code

function _pagerer_get_progressive_pages($variables, $markers, $pages, $scale_factor, $ratio, $limit = NULL) {

  // Avoid endless loop in converging series.
  if ($ratio < 1) {
    $ratio = 1;
  }
  $offset = 0;
  $c = $markers['pager_current'] - 1;
  $m = $markers['pager_max'] - 1;
  for ($i = 0; TRUE; $i++) {

    // Breaks if limit reached.
    if ($limit and $i > $limit - 1) {
      break;
    }

    // Offset for this cycle.
    $offset = intval($scale_factor * pow($ratio, $i));

    // Breaks if offset > than total pages.
    if ($offset > $markers['pager_max']) {
      break;
    }

    // Negative offset.
    if ($c - $offset > 0 and !isset($pages[$c - $offset])) {
      $pages[$c - $offset]['progressive'] = TRUE;
      $pages[$c - $offset]['interval'] = -$offset;
      list($pages[$c - $offset]['text'], $pages[$c - $offset]['text_title']) = _pagerer_get_page_text($variables, $markers, -$offset, 'page', $variables['progr_links']);
    }

    // Positive offset.
    if ($c + $offset < $markers['pager_max'] and !isset($pages[$c + $offset])) {
      $pages[$c + $offset]['progressive'] = TRUE;
      $pages[$c + $offset]['interval'] = $offset;
      list($pages[$c + $offset]['text'], $pages[$c + $offset]['text_title']) = _pagerer_get_page_text($variables, $markers, $offset, 'page', $variables['progr_links']);
    }
  }
  return $pages;
}