Commit 7d3972ec authored by slv_'s avatar slv_ Committed by tim.plunkett
Browse files

Issue #1756784 by slv_ | tim.plunkett: Move use_pager() and use_more() from...

Issue #1756784 by slv_ | tim.plunkett: Move use_pager() and use_more() from plugin annotation to a class property.
parent 6e0f3ffe
......@@ -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');
}
}
......@@ -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"
......
......@@ -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"
* )
......
......@@ -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();
......
......@@ -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"
* )
......
......@@ -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);
......
......@@ -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"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment