You are here

function _pagerer_override_theme_pager in Pagerer 7

Pagerer's wrapper for overriden standard 'pager' theme calls.

When Pagerer is set in admin to override Drupal built-in pager, theme('pager', ...) calls are redirected here via _pagerer_override_theme_pager(). In turn, this wrapper is then invoking theme_pagerer() after having fetched the configuration setup in the pagerer variable via admin.

1 string reference to '_pagerer_override_theme_pager'
pagerer_theme_registry_alter in ./pagerer.module
Implements hook_theme_registry_alter().

File

./pagerer.module, line 448
Pagerer

Code

function _pagerer_override_theme_pager($v) {

  // If configured to use core pager, call it and return straight away.
  if (_pagerer_get_variable('core_override_preset') == 'core') {
    return _pagerer_execute_overriden_theme_pager($v);
  }

  // Pass incoming and configuration variables to 'pagerer' theme $variables.
  $variables = array();
  $variables['element'] = $v['element'];
  $variables['parameters'] = $v['parameters'];

  // Get preset panes setup.
  $variables = array_merge($variables, _pagerer_get_preset(_pagerer_get_variable('core_override_preset')));

  // Supercede 'quantity' for standard pager if set from theme call.
  if (isset($v['quantity'])) {
    if (!isset($variables['left_pane']['theme_variables']['quantity']) and $variables['left_pane']['theme_name'] == 'pagerer_standard') {
      $variables['left_pane']['theme_variables']['quantity'] = $v['quantity'];
    }
    if (!isset($variables['center_pane']['theme_variables']['quantity']) and $variables['center_pane']['theme_name'] == 'pagerer_standard') {
      $variables['center_pane']['theme_variables']['quantity'] = $v['quantity'];
    }
    if (!isset($variables['right_pane']['theme_variables']['quantity']) and $variables['right_pane']['theme_name'] == 'pagerer_standard') {
      $variables['right_pane']['theme_variables']['quantity'] = $v['quantity'];
    }
  }

  // Tags, if set from theme call, need to be mapped to pagerer tags structure.
  if (isset($v['tags']) and !empty($v['tags'])) {
    if ($variables['left_pane']['theme_name'] != 'none') {
      $variables['left_pane']['theme_variables']['tags']['first'] = $v['tags'][0];
      $variables['left_pane']['theme_variables']['tags']['previous'] = $v['tags'][1];
      $variables['left_pane']['theme_variables']['tags']['next'] = $v['tags'][3];
      $variables['left_pane']['theme_variables']['tags']['last'] = $v['tags'][4];
    }
    if ($variables['center_pane']['theme_name'] != 'none') {
      $variables['center_pane']['theme_variables']['tags']['first'] = $v['tags'][0];
      $variables['center_pane']['theme_variables']['tags']['previous'] = $v['tags'][1];
      $variables['center_pane']['theme_variables']['tags']['next'] = $v['tags'][3];
      $variables['center_pane']['theme_variables']['tags']['last'] = $v['tags'][4];
    }
    if ($variables['right_pane']['theme_name'] != 'none') {
      $variables['right_pane']['theme_variables']['tags']['first'] = $v['tags'][0];
      $variables['right_pane']['theme_variables']['tags']['previous'] = $v['tags'][1];
      $variables['right_pane']['theme_variables']['tags']['next'] = $v['tags'][3];
      $variables['right_pane']['theme_variables']['tags']['last'] = $v['tags'][4];
    }
  }

  // Do not use preset name when invoking theme_pagerer, to avoid overwrites.
  $variables['preset'] = NULL;
  return theme('pagerer', $variables);
}