The plugin to handle mini pager.
@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"
)
Expanded class hierarchy of Mini
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;
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SqlBase:: |
public | function |
Provide the default form form for validating options Overrides PagerPluginBase:: |
|
SqlBase:: |
public | function |
Overrides PagerPluginBase:: |
|
SqlBase:: |
public | function |
Update global paging info. Overrides PagerPluginBase:: |
|
SqlBase:: |
public | function |
Set the current page. Overrides PagerPluginBase:: |
|
SqlBase:: |
protected | function |
Overrides PagerPluginBase:: |
|
SqlBase:: |
protected | function |
Overrides PagerPluginBase:: |
|
SqlBase:: |
public | function | ||
SqlBase:: |
public | function |
Overrides PagerPluginBase:: |
|
SqlBase:: |
public | function |
Overrides PagerPluginBase:: |
|
SqlBase:: |
public | function |
Provide the default form for setting options. Overrides PluginBase:: |
1 |
PluginBase:: |
public | function |
Constructs a Plugin object. Overrides PluginBase:: |
|
PluginBase:: |
public | function | Validate that the plugin is correct and can be saved. | 4 |
PluginBase:: |
public | function | Returns the usesOptions property. | 8 |
PluginBase:: |
public | function | Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away. | |
PluginBase:: |
public | function | Provide a full list of possible theme templates used by this style. | 1 |
PluginBase:: |
protected | function | Fills up the options of the plugin with defaults. | |
PluginBase:: |
public | function | Return the human readable name of the display. | |
PluginBase:: |
public | function | Initialize the plugin. | 8 |
PluginBase:: |
public | function | Returns a string with any core tokens replaced. | |
PluginBase:: |
public | function | Adds elements for available core tokens to a form. | |
PluginBase:: |
public | function |
Returns the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function |
Returns the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Returns an array of available token replacements. | |
PluginBase:: |
public | function | Clears a plugin. | 2 |
PluginBase:: |
public | property | The top object of a view. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
protected | property | The plugin implementation definition. | |
PluginBase:: |
public | property | Options for this plugin will be held here. | |
PluginBase:: |
public | property | The display object this plugin is for. | |
PluginBase:: |
public | property | Plugins's definition | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PagerPluginBase:: |
public | function | Determine if this pager actually uses a pager. | 2 |
PagerPluginBase:: |
public | function |
Provide the default form form for submitting options Overrides PluginBase:: |
|
PagerPluginBase:: |
public | function | Set the page offset, or how many items to skip. | |
PagerPluginBase:: |
public | function | Set how many items per page this pager will display. | |
PagerPluginBase:: |
function | Perform any needed actions just before rendering. | ||
PagerPluginBase:: |
public | function | Perform any needed actions just prior to the query executing. | |
PagerPluginBase:: |
public | function | Determine if there are more records available. | |
PagerPluginBase:: |
public | function | Get the total number of items. | |
PagerPluginBase:: |
public | function | Get the pager id, if it exists | |
PagerPluginBase:: |
public | function | Get the page offset, or how many items to skip. | |
PagerPluginBase:: |
public | function | Get how many items per page this pager will display. | 1 |
PagerPluginBase:: |
public | function | Get the current page. | |
PagerPluginBase:: |
public | function | ||
PagerPluginBase:: |
public | function | Execute the count query, which will be done just prior to the query itself being executed. | 1 |
PagerPluginBase:: |
protected | property |
Overrides Drupal\views\Plugin\Plugin::$usesOptions. Overrides PluginBase:: |
|
PagerPluginBase:: |
property | |||
PagerPluginBase:: |
property | |||
Mini:: |
public | function |
Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::useCountQuery(). Overrides PagerPluginBase:: |
|
Mini:: |
public | function |
Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::summaryTitle(). Overrides PagerPluginBase:: |
|
Mini:: |
function |
Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::render(). Overrides PagerPluginBase:: |
||
Mini:: |
public | function |
Overrides \Drupal\views\Plugin\views\pager\SqlBase::query(). Overrides SqlBase:: |
|
Mini:: |
public | function |
Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::postExecute(). Overrides PagerPluginBase:: |
|
Mini:: |
public | function |
Overrides \Drupal\views\Plugin\views\pager\PagerPlugin::defineOptions(). Overrides SqlBase:: |
|
ContainerFactoryPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
11 |