3 namespace Drupal\views\Plugin\views\pager;
6 * The plugin to handle mini pager.
8 * @ingroup views_pager_plugins
12 * title = @Translation("Paged output, mini pager"),
13 * short_title = @Translation("Mini"),
14 * help = @Translation("A simple pager containing previous and next links."),
15 * theme = "views_mini_pager"
18 class Mini extends SqlBase {
21 * Overrides \Drupal\views\Plugin\views\pager\PagerPlugin::defineOptions().
23 * Provides sane defaults for the next/previous links.
25 public function defineOptions() {
26 $options = parent::defineOptions();
28 $options['tags']['contains']['previous']['default'] = '‹‹';
29 $options['tags']['contains']['next']['default'] = '››';
37 public function summaryTitle() {
38 if (!empty($this->options['offset'])) {
39 return $this->formatPlural($this->options['items_per_page'], 'Mini pager, @count item, skip @skip', 'Mini pager, @count items, skip @skip', ['@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']]);
41 return $this->formatPlural($this->options['items_per_page'], 'Mini pager, @count item', 'Mini pager, @count items', ['@count' => $this->options['items_per_page']]);
47 public function query() {
50 // Only modify the query if we don't want to do a total row count
51 if (!$this->view->get_total_rows) {
52 // Don't query for the next page if we have a pager that has a limited
54 if ($this->getItemsPerPage() > 0 && (empty($this->options['total_pages']) || ($this->getCurrentPage() < $this->options['total_pages']))) {
55 // Increase the items in the query in order to be able to find out
56 // whether there is another page.
57 $limit = $this->view->query->getLimit();
59 $this->view->query->setLimit($limit);
67 public function useCountQuery() {
74 public function postExecute(&$result) {
75 // Only modify the result if we didn't do a total row count
76 if (!$this->view->get_total_rows) {
77 $this->total_items = $this->getCurrentPage() * $this->getItemsPerPage() + count($result);
78 // query() checks if we need a next link by setting limit 1 record past
79 // this page If we got the extra record we need to remove it before we
81 if ($this->getItemsPerPage() > 0 && count($result) > $this->getItemsPerPage()) {
90 public function render($input) {
91 // The 1, 3 indexes are correct, see template_preprocess_pager().
93 1 => $this->options['tags']['previous'],
94 3 => $this->options['tags']['next'],
97 '#theme' => $this->themeFunctions(),
99 '#element' => $this->options['id'],
100 '#parameters' => $input,
101 '#route_name' => !empty($this->view->live_preview) ? '<current>' : '<none>',