You are here

function phptemplate_pager_link in Clean Pagination 5

Override theme for a pager link

File

./cleanpager.module, line 98

Code

function phptemplate_pager_link($text, $page_new, $element, $parameters = array(), $attributes = array()) {
  if (!cleanpager_check_match()) {
    $q = $_GET['q'];
    $page = isset($_GET['page']) ? $_GET['page'] : '';
    if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
      $parameters['page'] = $new_page;
    }
  }
  else {
    $new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)));
    $arguments = explode('/', $_GET['q']);
    if ($_GET['page'] > 0) {
      array_pop($arguments);
    }
    $pre_page_q = implode('/', $arguments);

    //echo $pre_page_q;
    $q .= $pre_page_q;
    if ($new_page) {
      $q .= '/' . $new_page;
    }
  }
  $query = array();
  if (count($parameters)) {
    $query[] = drupal_query_string_encode($parameters, array());
  }
  $querystring = pager_get_querystring();
  if ($querystring != '') {
    $query[] = $querystring;
  }

  // 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];
    }
    else {
      if (is_numeric($text)) {
        $attributes['title'] = t('Go to page @number', array(
          '@number' => $text,
        ));
      }
    }
    if (is_numeric($text) && $q && variable_get('cleanpager_use_seo_links', '') == 1) {
      $text = 'Visit ' . $pre_page_q . ' Page ' . ($new_page + 1);
    }
  }
  return l($text, $q, $attributes, count($query) ? implode('&', $query) : NULL);
}