Skip to content
Full.php 3.06 KiB
Newer Older
Earl Miles's avatar
Earl Miles committed
<?php

/**
 * @file
 * Contains \Drupal\views\Plugin\views\pager\Full.
namespace Drupal\views\Plugin\views\pager;
Earl Miles's avatar
Earl Miles committed
/**
 * The plugin to handle full pager.
 *
 * @ingroup views_pager_plugins
Bram Goffings's avatar
Bram Goffings committed
 *   id = "full",
 *   title = @Translation("Paged output, full pager"),
 *   short_title = @Translation("Full"),
 *   help = @Translation("Paged output, full Drupal style"),
 *   theme = "pager",
 *   register_theme = FALSE
  /**
   * Overrides \Drupal\views\Plugin\views\SqlBase::defineOptions().
   */
  protected function defineOptions() {
    $options = parent::defineOptions();
Earl Miles's avatar
Earl Miles committed
    // Use the same default quantity that core uses by default.
    $options['quantity'] = array('default' => 9);

    $options['tags']['contains']['first'] = array('default' => $this->t('« First'));
    $options['tags']['contains']['last'] = array('default' => $this->t('Last »'));
Earl Miles's avatar
Earl Miles committed
    return $options;
  }

  /**
   * Overrides \Drupal\views\Plugin\views\SqlBase::buildOptionsForm().
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
Earl Miles's avatar
Earl Miles committed

    $form['quantity'] = array(
      '#type' => 'number',
      '#title' => $this->t('Number of pager links visible'),
      '#description' => $this->t('Specify the number of links to pages to display in the pager.'),
Earl Miles's avatar
Earl Miles committed
      '#default_value' => $this->options['quantity'],
    );

    $form['tags']['first'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('First page link text'),
Earl Miles's avatar
Earl Miles committed
      '#default_value' => $this->options['tags']['first'],
Earl Miles's avatar
Earl Miles committed
    );

    $form['tags']['last'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('Last page link text'),
Earl Miles's avatar
Earl Miles committed
      '#default_value' => $this->options['tags']['last'],
  /**
   * Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::summaryTitle().
   */
  public function summaryTitle() {
    if (!empty($this->options['offset'])) {
      return $this->formatPlural($this->options['items_per_page'], '@count item, skip @skip', 'Paged, @count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']));
    return $this->formatPlural($this->options['items_per_page'], '@count item', 'Paged, @count items', array('@count' => $this->options['items_per_page']));
    // The 0, 1, 3, 4 indexes are correct. See the template_preprocess_pager()
    // documentation.
Earl Miles's avatar
Earl Miles committed
    $tags = array(
      0 => $this->options['tags']['first'],
      1 => $this->options['tags']['previous'],
      3 => $this->options['tags']['next'],
      4 => $this->options['tags']['last'],
    );
      '#tags' => $tags,
      '#element' => $this->options['id'],
      '#parameters' => $input,
      '#quantity' => $this->options['quantity'],
      '#route_name' => !empty($this->view->live_preview) ? '<current>' : '<none>',