You are here

function theme_pagerer_link in Pagerer 7

Alternative to standard theme_pager_link().

Needed as theme_pagerer_adaptive() handles additional paging parameters in the querystring. The standard function would override the 'page_ak' portion of the querystring from the url which is not acceptable as pagerer has to change it programmatically.

See also

http://drupal.org/node/1588138

2 theme calls to theme_pagerer_link()
_pagerer_itemize_link in ./pagerer.module
Return link/button to first/previous/next/last element in the pager.
_pagerer_itemize_page_links in ./pagerer.module
Return rendered items representing the links to 'page' elements in the pager.

File

./pagerer.module, line 1967
Pagerer

Code

function theme_pagerer_link($variables) {
  $text = $variables['text'];
  $page_new = $variables['page_new'];
  $element = $variables['element'];
  $parameters = $variables['parameters'];
  $attributes = $variables['attributes'];
  $page = isset($_GET['page']) ? $_GET['page'] : '';
  if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
    $parameters['page'] = $new_page;
  }
  $query = array();
  if (count($parameters)) {
    $query = drupal_get_query_parameters($parameters, array());
  }
  if ($query_pager = pager_get_query_parameters()) {

    // @see http://drupal.org/node/1588138
    $query = array_merge($query_pager, $query);
  }

  // Set each pager link title
  if (!isset($attributes['title'])) {
    static $titles = NULL;
    if (!isset($titles)) {
      $titles = array(
        t('« first') => t('Go to first page'),
        t('‹ previous') => t('Go to previous page'),
        t('next ›') => t('Go to next page'),
        t('last »') => t('Go to last page'),
      );
    }
    if (isset($titles[$text])) {
      $attributes['title'] = $titles[$text];
    }
    elseif (is_numeric($text)) {
      $attributes['title'] = t('Go to page @number', array(
        '@number' => $text,
      ));
    }
  }

  // @todo l() cannot be used here, since it adds an 'active' class based on the
  //   path only (which is always the current path for pager links). Apparently,
  //   none of the pager links is active at any time - but it should still be
  //   possible to use l() here.
  // @see http://drupal.org/node/1410574
  $attributes['href'] = url($_GET['q'], array(
    'query' => $query,
  ));
  return '<a' . drupal_attributes($attributes) . '>' . check_plain($text) . '</a>';
}