class Mini

The plugin to handle mini pager.

Plugin annotation


@Plugin(
  id = "mini",
  title = @Translation("Paged output, mini pager"),
  short_title = @Translation("Mini"),
  help = @Translation("A simple pager containing previous and next links."),
  theme = "views_mini_pager"
)

Hierarchy

Expanded class hierarchy of Mini

Related topics

1 string reference to 'Mini'
PagerTest::testStorePagerSettings in drupal/core/modules/views/lib/Drupal/views/Tests/Plugin/PagerTest.php
Pagers was sometimes not stored.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/pager/Mini.php, line 26
Definition of Drupal\views\Plugin\views\pager\Mini.

Namespace

Drupal\views\Plugin\views\pager
View source
class Mini extends SqlBase {

  /**
   * Overrides \Drupal\views\Plugin\views\pager\PagerPlugin::defineOptions().
   *
   * Provides sane defaults for the next/previous links.
   */
  public function defineOptions() {
    $options = parent::defineOptions();
    $options['tags']['contains']['previous']['default'] = '‹‹';
    $options['tags']['contains']['next']['default'] = '››';
    return $options;
  }

  /**
   * Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::summaryTitle().
   */
  public function summaryTitle() {
    if (!empty($this->options['offset'])) {
      return format_plural($this->options['items_per_page'], 'Mini pager, @count item, skip @skip', 'Mini pager, @count items, skip @skip', array(
        '@count' => $this->options['items_per_page'],
        '@skip' => $this->options['offset'],
      ));
    }
    return format_plural($this->options['items_per_page'], 'Mini pager, @count item', 'Mini pager, @count items', array(
      '@count' => $this->options['items_per_page'],
    ));
  }

  /**
   * Overrides \Drupal\views\Plugin\views\pager\SqlBase::query().
   */
  public function query() {
    parent::query();

    // Don't query for the next page if we have a pager that has a limited
    // amount of pages.
    if (empty($this->options['total_pages']) || $this
      ->getCurrentPage() < $this->options['total_pages']) {

      // Increase the items in the query in order to be able to find out whether
      // there is another page.
      $limit = $this->view->query
        ->getLimit();
      $limit += 1;
      $this->view->query
        ->setLimit($limit);
    }
  }

  /**
   * Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::useCountQuery().
   */
  public function useCountQuery() {
    return FALSE;
  }

  /**
   * Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::postExecute().
   */
  public function postExecute(&$result) {

    // In query() one more item might have been retrieved than necessary. If so,
    // the next link needs to be displayed and the item removed.
    if (count($result) > $this
      ->getItemsPerPage()) {
      array_pop($result);

      // Make sure the pager shows the next link by setting the total items to
      // the biggest possible number but prevent failing calculations like
      // ceil(PHP_INT_MAX) we take PHP_INT_MAX / 2.
      pager_default_initialize(PHP_INT_MAX / 2, $this
        ->getItemsPerPage(), $this->options['id']);
    }
  }

  /**
   * Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::render().
   */
  function render($input) {

    // The 1, 3 index are correct, see theme_pager().
    $tags = array(
      1 => $this->options['tags']['previous'],
      3 => $this->options['tags']['next'],
    );
    $output = theme($this
      ->themeFunctions(), array(
      'parameters' => $input,
      'element' => $this->options['id'],
      'tags' => $tags,
    ));
    return $output;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContainerFactoryPluginBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create 11
Mini::defineOptions public function Overrides \Drupal\views\Plugin\views\pager\PagerPlugin::defineOptions(). Overrides SqlBase::defineOptions
Mini::postExecute public function Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::postExecute(). Overrides PagerPluginBase::postExecute
Mini::query public function Overrides \Drupal\views\Plugin\views\pager\SqlBase::query(). Overrides SqlBase::query
Mini::render function Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::render(). Overrides PagerPluginBase::render
Mini::summaryTitle public function Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::summaryTitle(). Overrides PagerPluginBase::summaryTitle
Mini::useCountQuery public function Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::useCountQuery(). Overrides PagerPluginBase::useCountQuery
PagerPluginBase::$current_page property
PagerPluginBase::$total_items property
PagerPluginBase::$usesOptions protected property Overrides Drupal\views\Plugin\Plugin::$usesOptions. Overrides PluginBase::$usesOptions
PagerPluginBase::executeCountQuery public function Execute the count query, which will be done just prior to the query itself being executed. 1
PagerPluginBase::exposedFormSubmit public function
PagerPluginBase::getCurrentPage public function Get the current page.
PagerPluginBase::getItemsPerPage public function Get how many items per page this pager will display. 1
PagerPluginBase::getOffset public function Get the page offset, or how many items to skip.
PagerPluginBase::getPagerId public function Get the pager id, if it exists
PagerPluginBase::getTotalItems public function Get the total number of items.
PagerPluginBase::hasMoreRecords public function Determine if there are more records available.
PagerPluginBase::preExecute public function Perform any needed actions just prior to the query executing.
PagerPluginBase::pre_render function Perform any needed actions just before rendering.
PagerPluginBase::setItemsPerPage public function Set how many items per page this pager will display.
PagerPluginBase::setOffset public function Set the page offset, or how many items to skip.
PagerPluginBase::submitOptionsForm public function Provide the default form form for submitting options Overrides PluginBase::submitOptionsForm
PagerPluginBase::usePager public function Determine if this pager actually uses a pager. 2
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$definition public property Plugins's definition
PluginBase::$displayHandler public property The display object this plugin is for.
PluginBase::$options public property Options for this plugin will be held here.
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::$view public property The top object of a view. 1
PluginBase::destroy public function Clears a plugin. 2
PluginBase::getAvailableGlobalTokens public function Returns an array of available token replacements.
PluginBase::getPluginDefinition public function Returns the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
PluginBase::getPluginId public function Returns the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::globalTokenForm public function Adds elements for available core tokens to a form.
PluginBase::globalTokenReplace public function Returns a string with any core tokens replaced.
PluginBase::init public function Initialize the plugin. 8
PluginBase::pluginTitle public function Return the human readable name of the display.
PluginBase::setOptionDefaults protected function Fills up the options of the plugin with defaults.
PluginBase::themeFunctions public function Provide a full list of possible theme templates used by this style. 1
PluginBase::unpackOptions public function Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.
PluginBase::usesOptions public function Returns the usesOptions property. 8
PluginBase::validate public function Validate that the plugin is correct and can be saved. 4
PluginBase::__construct public function Constructs a Plugin object. Overrides PluginBase::__construct
SqlBase::buildOptionsForm public function Provide the default form for setting options. Overrides PluginBase::buildOptionsForm 1
SqlBase::exposedFormAlter public function Overrides PagerPluginBase::exposedFormAlter
SqlBase::exposedFormValidate public function Overrides PagerPluginBase::exposedFormValidate
SqlBase::getPagerTotal public function
SqlBase::isOffsetExposed protected function Overrides PagerPluginBase::isOffsetExposed
SqlBase::itemsPerPageExposed protected function Overrides PagerPluginBase::itemsPerPageExposed
SqlBase::setCurrentPage public function Set the current page. Overrides PagerPluginBase::setCurrentPage
SqlBase::updatePageInfo public function Update global paging info. Overrides PagerPluginBase::updatePageInfo
SqlBase::usesExposed public function Overrides PagerPluginBase::usesExposed
SqlBase::validateOptionsForm public function Provide the default form form for validating options Overrides PagerPluginBase::validateOptionsForm