You are here

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

Modify the query for paging

This is called during the build phase and can directly modify the query.

Overrides views_plugin_pager::query

File

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

Class

views_plugin_pager_full
The plugin to handle full pager.

Code

public function query() {
  if ($this
    ->items_per_page_exposed()) {
    if (!empty($_GET['items_per_page']) && $_GET['items_per_page'] > 0) {
      $this->options['items_per_page'] = (int) $_GET['items_per_page'];
    }
    elseif (!empty($_GET['items_per_page']) && $_GET['items_per_page'] == 'All' && $this->options['expose']['items_per_page_options_all']) {
      $this->options['items_per_page'] = 0;
    }
  }
  if ($this
    ->offset_exposed()) {
    if (isset($_GET['offset']) && $_GET['offset'] >= 0) {
      $this->options['offset'] = (int) $_GET['offset'];
    }
  }
  $limit = $this
    ->get_items_per_page();
  $offset = $this->current_page * $limit + $this
    ->get_offset();
  if (!empty($this->options['total_pages'])) {
    if ($this->current_page >= $this->options['total_pages']) {
      $offset = $this->options['total_pages'] * $limit;
    }
  }
  $this->view->query
    ->set_limit($limit);
  $this->view->query
    ->set_offset($offset);
}