Commit ea38078c authored by webchick's avatar webchick

Issue #1877376 by damiankloip, dawehner, Bojhan: Change notice: Improve Views...

Issue #1877376 by damiankloip, dawehner, Bojhan: Change notice: Improve Views UI text for the contextual links display setting.
parent 2abc98f7
...@@ -174,7 +174,7 @@ public function optionsSummary(&$categories, &$options) { ...@@ -174,7 +174,7 @@ public function optionsSummary(&$categories, &$options) {
unset($categories['page'], $categories['exposed']); unset($categories['page'], $categories['exposed']);
// Hide some settings, as they aren't useful for pure data output. // Hide some settings, as they aren't useful for pure data output.
unset($options['hide_admin_links'], $options['analyze-theme']); unset($options['show_admin_links'], $options['analyze-theme']);
$categories['path'] = array( $categories['path'] = array(
'title' => t('Path settings'), 'title' => t('Path settings'),
......
...@@ -395,7 +395,7 @@ public function defaultableSections($section = NULL) { ...@@ -395,7 +395,7 @@ public function defaultableSections($section = NULL) {
'css_class' => array('css_class'), 'css_class' => array('css_class'),
'use_ajax' => array('use_ajax'), 'use_ajax' => array('use_ajax'),
'hide_attachment_summary' => array('hide_attachment_summary'), 'hide_attachment_summary' => array('hide_attachment_summary'),
'hide_admin_links' => array('hide_admin_links'), 'show_admin_links' => array('show_admin_links'),
'group_by' => array('group_by'), 'group_by' => array('group_by'),
'query' => array('query'), 'query' => array('query'),
'use_more' => array('use_more', 'use_more_always', 'use_more_text'), 'use_more' => array('use_more', 'use_more_always', 'use_more_text'),
...@@ -458,7 +458,7 @@ protected function defineOptions() { ...@@ -458,7 +458,7 @@ protected function defineOptions() {
'display_description' => FALSE, 'display_description' => FALSE,
'use_ajax' => TRUE, 'use_ajax' => TRUE,
'hide_attachment_summary' => TRUE, 'hide_attachment_summary' => TRUE,
'hide_admin_links' => FALSE, 'show_admin_links' => TRUE,
'pager' => TRUE, 'pager' => TRUE,
'use_more' => TRUE, 'use_more' => TRUE,
'use_more_always' => TRUE, 'use_more_always' => TRUE,
...@@ -513,8 +513,8 @@ protected function defineOptions() { ...@@ -513,8 +513,8 @@ protected function defineOptions() {
'default' => FALSE, 'default' => FALSE,
'bool' => TRUE, 'bool' => TRUE,
), ),
'hide_admin_links' => array( 'show_admin_links' => array(
'default' => FALSE, 'default' => TRUE,
'bool' => TRUE, 'bool' => TRUE,
), ),
'use_more' => array( 'use_more' => array(
...@@ -1133,10 +1133,10 @@ public function optionsSummary(&$categories, &$options) { ...@@ -1133,10 +1133,10 @@ public function optionsSummary(&$categories, &$options) {
); );
} }
if (!isset($this->definition['contextual links locations']) || !empty($this->definition['contextual links locations'])) { if (!isset($this->definition['contextual links locations']) || !empty($this->definition['contextual links locations'])) {
$options['hide_admin_links'] = array( $options['show_admin_links'] = array(
'category' => 'other', 'category' => 'other',
'title' => t('Hide contextual links'), 'title' => t('Display contextual links'),
'value' => $this->getOption('hide_admin_links') ? t('Yes') : t('No'), 'value' => $this->getOption('show_admin_links') ? t('Yes') : t('No'),
'desc' => t('Change whether or not to display contextual links for this view.'), 'desc' => t('Change whether or not to display contextual links for this view.'),
); );
} }
...@@ -1405,12 +1405,12 @@ public function buildOptionsForm(&$form, &$form_state) { ...@@ -1405,12 +1405,12 @@ public function buildOptionsForm(&$form, &$form_state) {
'#default_value' => $this->getOption('hide_attachment_summary') ? 1 : 0, '#default_value' => $this->getOption('hide_attachment_summary') ? 1 : 0,
); );
break; break;
case 'hide_admin_links': case 'show_admin_links':
$form['#title'] .= t('Hide contextual links on this view.'); $form['#title'] .= t('Show contextual links on this view.');
$form['hide_admin_links'] = array( $form['show_admin_links'] = array(
'#type' => 'radios', '#type' => 'radios',
'#options' => array(1 => t('Yes'), 0 => t('No')), '#options' => array(0 => t('No'), 1 => t('Yes')),
'#default_value' => $this->getOption('hide_admin_links') ? 1 : 0, '#default_value' => $this->getOption('show_admin_links'),
); );
break; break;
case 'use_more': case 'use_more':
...@@ -2212,8 +2212,8 @@ public function submitOptionsForm(&$form, &$form_state) { ...@@ -2212,8 +2212,8 @@ public function submitOptionsForm(&$form, &$form_state) {
break; break;
case 'use_ajax': case 'use_ajax':
case 'hide_attachment_summary': case 'hide_attachment_summary':
case 'hide_admin_links': case 'show_admin_links':
$this->setOption($section, (bool)$form_state['values'][$section]); $this->setOption($section, (bool) $form_state['values'][$section]);
break; break;
case 'use_more': case 'use_more':
$this->setOption($section, intval($form_state['values'][$section])); $this->setOption($section, intval($form_state['values'][$section]));
...@@ -2523,9 +2523,7 @@ public function preExecute() { ...@@ -2523,9 +2523,7 @@ public function preExecute() {
$extender->pre_execute(); $extender->pre_execute();
} }
if ($this->getOption('hide_admin_links')) { $this->view->setShowAdminLinks($this->getOption('show_admin_links'));
$this->view->hide_admin_links = TRUE;
}
} }
/** /**
......
...@@ -423,6 +423,13 @@ class ViewExecutable { ...@@ -423,6 +423,13 @@ class ViewExecutable {
), ),
); );
/**
* Should the admin links be shown on the rendered view.
*
* @var bool
*/
protected $showAdminLinks;
/** /**
* Constructs a new ViewExecutable object. * Constructs a new ViewExecutable object.
* *
...@@ -2094,4 +2101,25 @@ public function setItemOption($display_id, $type, $id, $option, $value) { ...@@ -2094,4 +2101,25 @@ public function setItemOption($display_id, $type, $id, $option, $value) {
$item[$option] = $value; $item[$option] = $value;
$this->setItem($display_id, $type, $id, $item); $this->setItem($display_id, $type, $id, $item);
} }
/**
* Enables admin links on the rendered view.
*
* @param bool $show_admin_links
* TRUE if the admin links should be shown.
*/
public function setShowAdminLinks($show_admin_links) {
$this->showAdminLinks = (bool) $show_admin_links;
}
/**
* Returns whether admin links should be rendered on the view.
*
* @return bool
* Returns TRUE if admin links should be rendered, else FALSE.
*/
public function getShowAdminLinks() {
return $this->showAdminLinks;
}
} }
...@@ -567,7 +567,7 @@ function views_contextual_links_view_alter(&$element, $items) { ...@@ -567,7 +567,7 @@ function views_contextual_links_view_alter(&$element, $items) {
function views_add_contextual_links(&$render_element, $location, ViewExecutable $view, $display_id) { function views_add_contextual_links(&$render_element, $location, ViewExecutable $view, $display_id) {
// Do not do anything if the view is configured to hide its administrative // Do not do anything if the view is configured to hide its administrative
// links. // links.
if (empty($view->hide_admin_links)) { if ($view->getShowAdminLinks()) {
// Also do not do anything if the display plugin has not defined any // Also do not do anything if the display plugin has not defined any
// contextual links that are intended to be displayed in the requested // contextual links that are intended to be displayed in the requested
// location. // location.
......
...@@ -237,7 +237,7 @@ function views_ui_cache_set(ViewUI $view) { ...@@ -237,7 +237,7 @@ function views_ui_cache_set(ViewUI $view) {
function views_ui_preprocess_views_view(&$vars) { function views_ui_preprocess_views_view(&$vars) {
$view = $vars['view']; $view = $vars['view'];
if (!empty($view->live_preview) && Drupal::moduleHandler()->moduleExists('contextual')) { if (!empty($view->live_preview) && Drupal::moduleHandler()->moduleExists('contextual')) {
$view->hide_admin_links = TRUE; $view->setShowAdminLinks(FALSE);
foreach (array('title', 'header', 'exposed', 'rows', 'pager', 'more', 'footer', 'empty', 'attachment_after', 'attachment_before') as $section) { foreach (array('title', 'header', 'exposed', 'rows', 'pager', 'more', 'footer', 'empty', 'attachment_after', 'attachment_before') as $section) {
if (!empty($vars[$section])) { if (!empty($vars[$section])) {
$vars[$section] = array( $vars[$section] = array(
......
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