You are here

public function views_plugin_pager_full::set_current_page in Views (for Drupal 7) 7.3

Same name and namespace in other branches
  1. 6.3 plugins/views_plugin_pager_full.inc \views_plugin_pager_full::set_current_page()

Set the current page.

Parameters

int $number: If provided, the page number will be set to this. If NOT provided, the page number will be set from the global page array.

Overrides views_plugin_pager::set_current_page

File

plugins/views_plugin_pager_full.inc, line 307
Definition of views_plugin_pager_full.

Class

views_plugin_pager_full
The plugin to handle full pager.

Code

public function set_current_page($number = NULL) {
  if (isset($number)) {
    $this->current_page = $number;
    return;
  }

  // If the current page number was not specified, extract it from the global
  // page array.
  global $pager_page_array;
  if (empty($pager_page_array)) {
    $pager_page_array = array();
  }

  // Fill in missing values in the global page array, in case the global page
  // array hasn't been initialized before.
  $page = isset($_GET['page']) ? explode(',', $_GET['page']) : array();
  $pager_id = $this
    ->get_pager_id();
  for ($i = 0; $i <= $pager_id || $i < count($pager_page_array); $i++) {
    $pager_page_array[$i] = empty($page[$i]) ? 0 : $page[$i];
  }
  $this->current_page = intval($pager_page_array[$pager_id]);
  if ($this->current_page < 0) {
    $this->current_page = 0;
  }
}