You are here

public function views_plugin_pager_full::update_page_info 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::update_page_info()

Update global paging info.

This is called after the count query has been run to set the total items available and to update the current page if the requested page is out of range.

Overrides views_plugin_pager::update_page_info

File

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

Class

views_plugin_pager_full
The plugin to handle full pager.

Code

public function update_page_info() {
  if (!empty($this->options['total_pages'])) {
    if ($this->options['total_pages'] * $this->options['items_per_page'] < $this->total_items) {
      $this->total_items = $this->options['total_pages'] * $this->options['items_per_page'];
    }
  }

  // Don't set pager settings for items per page = 0.
  $items_per_page = $this
    ->get_items_per_page();
  if (!empty($items_per_page)) {

    // Dump information about what we already know into the globals.
    global $pager_page_array, $pager_total, $pager_total_items, $pager_limits;

    // Set the limit.
    $pager_id = $this
      ->get_pager_id();
    $pager_limits[$pager_id] = $this->options['items_per_page'];

    // Set the item count for the pager.
    $pager_total_items[$pager_id] = $this->total_items;

    // Calculate and set the count of available pages.
    $pager_total[$pager_id] = $this
      ->get_pager_total();

    // See if the requested page was within range.
    if ($this->current_page < 0) {
      $this->current_page = 0;
    }
    elseif ($this->current_page >= $pager_total[$pager_id]) {

      // Pages are numbered from 0 so if there are 10 pages, the last page is
      // 9.
      $this->current_page = $pager_total[$pager_id] - 1;
    }

    // Put this number in to guarantee that we do not generate notices when
    // the pager goes to look for it later.
    $pager_page_array[$pager_id] = $this->current_page;
  }
}