You are here

function _pagerer_itemize_link in Pagerer 7

Return link/button to first/previous/next/last element in the pager.

Parameters

string $scope: target page [first|previous|next|last]

array $variables: theme's variables

array $markers: precalculated markers for the pager

string $type: 'anchor' returns a link via theme('pagerer_link', ...), 'button' returns a div that jQuery will transform in a ui button

Return value

array pre-rendered item

2 calls to _pagerer_itemize_link()
_pagerer_itemize_js_element in ./pagerer.module
Return HTML to an active js element for page navigation.
_pagerer_theme_handler in ./pagerer.module
Pagerer's theme handler.

File

./pagerer.module, line 1199
Pagerer

Code

function _pagerer_itemize_link($scope, $variables, $markers, $type = 'anchor') {
  global $pager_page_array;
  $current_page = $markers['pager_current'] - 1;
  $max_page = $markers['pager_max'] - 1;

  // Determine the offset to current page and whether the link is
  // active or not.
  switch ($scope) {
    case 'first':
      $offset = -$current_page;
      $active_link = $current_page > 0;
      break;
    case 'previous':
      $offset = -1;
      $active_link = $current_page > 0;
      break;
    case 'next':
      $offset = 1;
      $active_link = $current_page < $max_page;
      break;
    case 'last':
      $offset = $max_page - $current_page;
      $active_link = $current_page < $max_page;
      break;
  }
  list($text, $text_title) = _pagerer_get_page_text($variables, $markers, $offset, $scope, 'absolute', $scope);
  if ($active_link and $type == 'anchor') {
    $li_data = theme('pagerer_link', array(
      'text' => $text,
      'page_new' => pager_load_array($current_page + $offset, $variables['element'], $pager_page_array),
      'element' => $variables['element'],
      'parameters' => $variables['parameters'],
      'attributes' => array(
        'title' => $text_title,
      ),
    ));
    $li_active = TRUE;
  }
  elseif ($type == 'button') {
    $li_data = "<div class='pagerer-scrollpane-button pagerer-{$scope}' title='{$text_title}'>{$text}</div>";
    $li_active = FALSE;
  }
  else {
    $li_data = NULL;
    $li_active = FALSE;
  }
  return array(
    'class' => array(
      'pager-' . $scope,
      $li_active ? 'active' : NULL,
    ),
    'data' => $li_data ? _pagerer_resolve_link_data($li_data) : $text,
  );
}