diff --git a/lib/Drupal/views/Plugin/views/display/Attachment.php b/lib/Drupal/views/Plugin/views/display/Attachment.php index a83a54b7b8ff95791531c8a24db55e32f7f6ad78..fb07f31e6af019abbaa39232d58153e92263402e 100644 --- a/lib/Drupal/views/Plugin/views/display/Attachment.php +++ b/lib/Drupal/views/Plugin/views/display/Attachment.php @@ -25,14 +25,19 @@ * help = @Translation("Attachments added to other displays to achieve multiple views in the same view."), * theme = "views_view", * contextual_links_locations = {""}, - * use_pager = FALSE, - * use_more = TRUE, * accept_attachments = FALSE, * help_topic = "display-attachment" * ) */ class Attachment extends DisplayPluginBase { + /** + * Whether the display allows the use of a pager or not. + * + * @var bool + */ + protected $usesPager = FALSE; + function option_definition() { $options = parent::option_definition(); @@ -247,7 +252,7 @@ function attach_to($display_id) { $view->set_arguments($args); $view->set_display($this->display->id); if ($this->get_option('inherit_pager')) { - $view->display_handler->use_pager = $this->view->display[$display_id]->handler->use_pager(); + $view->display_handler->usesPager = $this->view->display[$display_id]->handler->usesPager(); $view->display_handler->set_option('pager', $this->view->display[$display_id]->handler->get_option('pager')); } @@ -290,12 +295,8 @@ function displays_exposed() { return $this->options['inherit_exposed_filters'] ? FALSE : TRUE; } - function use_pager() { - return !empty($this->use_pager); - } - function render_pager() { - return !empty($this->use_pager) && $this->get_option('render_pager'); + return $this->usesPager() && $this->get_option('render_pager'); } } diff --git a/lib/Drupal/views/Plugin/views/display/Block.php b/lib/Drupal/views/Plugin/views/display/Block.php index e58b9e121cc5319474542613352c31933271c17c..f3e50753838b8e0228a86c9d20d51f07e1184321 100644 --- a/lib/Drupal/views/Plugin/views/display/Block.php +++ b/lib/Drupal/views/Plugin/views/display/Block.php @@ -22,8 +22,6 @@ * theme = "views_view", * uses_hook_block = TRUE, * contextual_links_locations = {"block"}, - * use_pager = TRUE, - * use_more = TRUE, * accept_attachments = TRUE, * admin = @Translation("Block"), * help_topic = "display-block" diff --git a/lib/Drupal/views/Plugin/views/display/DefaultDisplay.php b/lib/Drupal/views/Plugin/views/display/DefaultDisplay.php index 260a2ac16517c671c525a17783befb44ba678e31..28bb9c98b6be969f8012f2748200c5f55fabf083 100644 --- a/lib/Drupal/views/Plugin/views/display/DefaultDisplay.php +++ b/lib/Drupal/views/Plugin/views/display/DefaultDisplay.php @@ -21,8 +21,6 @@ * help = @Translation("Default settings for this view."), * theme = "views_view", * no_ui = TRUE, - * use_pager = TRUE, - * use_more = TRUE, * accept_attachments = TRUE, * help_topic = "display-default" * ) diff --git a/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index 6edd6a65764ae08eb82b67b9b733c497006ddae7..31014ddb2f82307a405121e4072991225237ff27 100644 --- a/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -64,6 +64,20 @@ abstract class DisplayPluginBase extends PluginBase { */ protected $usesAJAX = TRUE; + /** + * Whether the display allows the use of a pager or not. + * + * @var bool + */ + protected $usesPager = TRUE; + + /** + * Whether the display allows the use of a 'more' link or not. + * + * @var bool + */ + protected $usesMore = TRUE; + function init(&$view, &$display, $options = NULL) { $this->view = &$view; $this->display = &$display; @@ -213,20 +227,46 @@ function isAJAXEnabled() { } /** - * Does the display have a pager enabled? + * Whether the display allows the use of a pager or not. + * + * @return bool + */ + + function usesPager() { + return $this->usesPager; + } + + /** + * Whether the display is using a pager or not. + * + * @return bool */ - function use_pager() { - $pager = $this->get_plugin('pager'); - if ($pager) { - return $pager->use_pager(); + function isPagerEnabled() { + if ($this->usesPager()) { + $pager = $this->get_plugin('pager'); + if ($pager) { + return $pager->use_pager(); + } } + return FALSE; } /** - * Does the display have a more link enabled? + * Whether the display allows the use of a 'more' link or not. + * + * @return bool + */ + function usesMore() { + return $this->usesMore; + } + + /** + * Whether the display is using the 'more' link or not. + * + * @return bool */ - function use_more() { - if (!empty($this->definition['use_more'])) { + function isMoreEnabled() { + if ($this->usesMore()) { return $this->get_option('use_more'); } return FALSE; @@ -243,7 +283,7 @@ function use_group_by() { * Should the enabled display more link be shown when no more items? */ function use_more_always() { - if (!empty($this->definition['use_more'])) { + if ($this->usesMore()) { return $this->get_option('use_more_always'); } return FALSE; @@ -253,7 +293,7 @@ function use_more_always() { * Does the display have custom link text? */ function use_more_text() { - if (!empty($this->definition['use_more'])) { + if ($this->usesMore()) { return $this->get_option('use_more_text'); } return FALSE; @@ -328,7 +368,7 @@ function defaultable_sections($section = NULL) { ); // If the display cannot use a pager, then we cannot default it. - if (empty($this->definition['use_pager'])) { + if (!$this->usesPager()) { unset($sections['pager']); unset($sections['items_per_page']); } @@ -569,7 +609,7 @@ function option_definition() { ), ); - if (empty($this->definition['use_pager'])) { + if (!$this->usesPager()) { $options['defaults']['default']['use_pager'] = FALSE; $options['defaults']['default']['items_per_page'] = FALSE; $options['defaults']['default']['offset'] = FALSE; @@ -1131,7 +1171,7 @@ function options_summary(&$categories, &$options) { ); // If pagers aren't allowed, change the text of the item: - if (empty($this->definition['use_pager'])) { + if (!$this->usesPager()) { $options['pager']['title'] = t('Items to display'); } @@ -1139,7 +1179,7 @@ function options_summary(&$categories, &$options) { $options['pager']['links']['pager_options'] = t('Change settings for this pager type.'); } - if (!empty($this->definition['use_more'])) { + if ($this->usesMore()) { $options['use_more'] = array( 'category' => 'pager', 'title' => t('More link'), @@ -2026,7 +2066,7 @@ function options_form(&$form, &$form_state) { $pager = $this->get_option('pager'); $form['pager']['type'] = array( '#type' => 'radios', - '#options' => views_fetch_plugin_names('pager', empty($this->definition['use_pager']) ? 'basic' : NULL, array($this->view->base_table)), + '#options' => views_fetch_plugin_names('pager', !$this->usesPager() ? 'basic' : NULL, array($this->view->base_table)), '#default_value' => $pager['type'], ); @@ -2429,7 +2469,7 @@ function render_pager() { * Render the 'more' link */ function render_more_link() { - if ($this->use_more() && ($this->use_more_always() || (!empty($this->view->pager) && $this->view->pager->has_more_records()))) { + if ($this->usesMore() && ($this->use_more_always() || (!empty($this->view->pager) && $this->view->pager->has_more_records()))) { $path = $this->get_path(); if ($this->get_option('link_display') == 'custom_url' && $override_path = $this->get_option('link_url')) { @@ -2534,7 +2574,7 @@ function access($account = NULL) { */ function pre_execute() { $this->view->set_use_ajax($this->isAJAXEnabled()); - if ($this->use_more() && !$this->use_more_always()) { + if ($this->usesMore() && !$this->use_more_always()) { $this->view->get_total_rows = TRUE; } $this->view->init_handlers(); diff --git a/lib/Drupal/views/Plugin/views/display/Embed.php b/lib/Drupal/views/Plugin/views/display/Embed.php index 7bb9f2ce2e1b59230ff129de2a928d98f15ad785..f2507807914936d4175a46a7f996e7741aaff2f9 100644 --- a/lib/Drupal/views/Plugin/views/display/Embed.php +++ b/lib/Drupal/views/Plugin/views/display/Embed.php @@ -24,7 +24,6 @@ * help = @Translation("Provide a display which can be embedded using the views api."), * theme = "views_view", * uses_hook_menu = FALSE, - * use_pager = TRUE, * accept_attachments = FALSE, * help_topic = "display-embed" * ) diff --git a/lib/Drupal/views/Plugin/views/display/Feed.php b/lib/Drupal/views/Plugin/views/display/Feed.php index 0203afdbc31af86f5a06076803de7185a041c881..a9ec6b1cc9f9cedb6089b91f09c39df6613cb1f3 100644 --- a/lib/Drupal/views/Plugin/views/display/Feed.php +++ b/lib/Drupal/views/Plugin/views/display/Feed.php @@ -23,7 +23,6 @@ * title = @Translation("Feed"), * help = @Translation("Display the view as a feed, such as an RSS feed."), * uses_hook_menu = TRUE, - * use_pager = FALSE, * accept_attachments = FALSE, * admin = @Translation("Feed"), * help_topic = "display-feed" @@ -38,6 +37,13 @@ class Feed extends Page { */ protected $usesAJAX = FALSE; + /** + * Whether the display allows the use of a pager or not. + * + * @var bool + */ + protected $usesPager = FALSE; + function init(&$view, &$display, $options = NULL) { parent::init($view, $display, $options); diff --git a/lib/Drupal/views/Plugin/views/display/Page.php b/lib/Drupal/views/Plugin/views/display/Page.php index 3a442040ce7ed04fd85d4630ca55113fc0abe721..a9db7bac6505f629a9e20386e5357c258ce46a18 100644 --- a/lib/Drupal/views/Plugin/views/display/Page.php +++ b/lib/Drupal/views/Plugin/views/display/Page.php @@ -22,8 +22,6 @@ * uses_hook_menu = TRUE, * contextual_links_locations = {"page"}, * theme = "views_view", - * use_pager = TRUE, - * use_more = TRUE, * accept_attachments = TRUE, * admin = @Translation("Page"), * help_topic = "display-page"