You are here

views_litepager_plugin_pager_lite.inc in Views Litepager 7.3

Same filename and directory in other branches
  1. 6.3 views_litepager_plugin_pager_lite.inc

Extend Full Pager plugin to create Lite pager.

File

views_litepager_plugin_pager_lite.inc
View source
<?php

/**
 * @file
 * Extend Full Pager plugin to create Lite pager.
 */
class views_litepager_plugin_pager_lite extends views_plugin_pager_full {
  function summary_title() {
    if (!empty($this->options['offset'])) {
      return format_plural($this->options['items_per_page'], 'Lite pager, @count item, skip @skip', 'Lite pager, @count items, skip @skip', array(
        '@count' => $this->options['items_per_page'],
        '@skip' => $this->options['offset'],
      ));
    }
    return format_plural($this->options['items_per_page'], 'Lite pager, @count item', 'Lite pager, @count items', array(
      '@count' => $this->options['items_per_page'],
    ));
  }
  function use_count_query() {
    return FALSE;
  }
  function query() {
    parent::query();
    $next_page = TRUE;
    if (!empty($this->options['total_pages'])) {
      if ($this->current_page + 1 >= $this->options['total_pages']) {
        $next_page = FALSE;
      }
    }
    if ($next_page) {
      $limit = $this->options['items_per_page'];
      $this->view->query
        ->set_limit($limit + 1);
    }
  }
  function pre_render(&$result) {
    if (count($result) > $this->options['items_per_page']) {
      array_pop($result);
      $this->next_page = TRUE;
      global $pager_page_array, $pager_total, $pager_total_items;
      if ($pager_page_array[$this->options['id']] == -1) {
        $this
          ->set_current_page();
      }
      $pager_total[$this->options['id']] = $pager_page_array[$this->options['id']] + 1;
    }
    else {
      $this
        ->set_current_page();
    }
  }
  function render($input) {
    global $pager_page_array, $pager_total, $pager_total_items;
    if (empty($pager_page_array[$this->options['id']]) && (!isset($this->next_page) || $this->next_page != TRUE)) {
      return '';
    }
    $pager_theme = views_theme_functions('pager_lite', $this->view, $this->display);
    $output = theme($pager_theme, array(
      'parameters' => $input,
      'element' => $this->options['id'],
      'tags' => $this->options['tags'],
    ));
    return $output;
  }

}

Classes

Namesort descending Description
views_litepager_plugin_pager_lite @file Extend Full Pager plugin to create Lite pager.