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) {
unset($categories['page'], $categories['exposed']);
// 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(
'title' => t('Path settings'),
......
......@@ -395,7 +395,7 @@ public function defaultableSections($section = NULL) {
'css_class' => array('css_class'),
'use_ajax' => array('use_ajax'),
'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'),
'query' => array('query'),
'use_more' => array('use_more', 'use_more_always', 'use_more_text'),
......@@ -458,7 +458,7 @@ protected function defineOptions() {
'display_description' => FALSE,
'use_ajax' => TRUE,
'hide_attachment_summary' => TRUE,
'hide_admin_links' => FALSE,
'show_admin_links' => TRUE,
'pager' => TRUE,
'use_more' => TRUE,
'use_more_always' => TRUE,
......@@ -513,8 +513,8 @@ protected function defineOptions() {
'default' => FALSE,
'bool' => TRUE,
),
'hide_admin_links' => array(
'default' => FALSE,
'show_admin_links' => array(
'default' => TRUE,
'bool' => TRUE,
),
'use_more' => array(
......@@ -1133,10 +1133,10 @@ public function optionsSummary(&$categories, &$options) {
);
}
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',
'title' => t('Hide contextual links'),
'value' => $this->getOption('hide_admin_links') ? t('Yes') : t('No'),
'title' => t('Display contextual links'),
'value' => $this->getOption('show_admin_links') ? t('Yes') : t('No'),
'desc' => t('Change whether or not to display contextual links for this view.'),
);
}
......@@ -1405,12 +1405,12 @@ public function buildOptionsForm(&$form, &$form_state) {
'#default_value' => $this->getOption('hide_attachment_summary') ? 1 : 0,
);
break;
case 'hide_admin_links':
$form['#title'] .= t('Hide contextual links on this view.');
$form['hide_admin_links'] = array(
case 'show_admin_links':
$form['#title'] .= t('Show contextual links on this view.');
$form['show_admin_links'] = array(
'#type' => 'radios',
'#options' => array(1 => t('Yes'), 0 => t('No')),
'#default_value' => $this->getOption('hide_admin_links') ? 1 : 0,
'#options' => array(0 => t('No'), 1 => t('Yes')),
'#default_value' => $this->getOption('show_admin_links'),
);
break;
case 'use_more':
......@@ -2212,8 +2212,8 @@ public function submitOptionsForm(&$form, &$form_state) {
break;
case 'use_ajax':
case 'hide_attachment_summary':
case 'hide_admin_links':
$this->setOption($section, (bool)$form_state['values'][$section]);
case 'show_admin_links':
$this->setOption($section, (bool) $form_state['values'][$section]);
break;
case 'use_more':
$this->setOption($section, intval($form_state['values'][$section]));
......@@ -2523,9 +2523,7 @@ public function preExecute() {
$extender->pre_execute();
}
if ($this->getOption('hide_admin_links')) {
$this->view->hide_admin_links = TRUE;
}
$this->view->setShowAdminLinks($this->getOption('show_admin_links'));
}
/**
......
......@@ -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.
*
......@@ -2094,4 +2101,25 @@ public function setItemOption($display_id, $type, $id, $option, $value) {
$item[$option] = $value;
$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) {
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
// links.
if (empty($view->hide_admin_links)) {
if ($view->getShowAdminLinks()) {
// Also do not do anything if the display plugin has not defined any
// contextual links that are intended to be displayed in the requested
// location.
......
......@@ -237,7 +237,7 @@ function views_ui_cache_set(ViewUI $view) {
function views_ui_preprocess_views_view(&$vars) {
$view = $vars['view'];
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) {
if (!empty($vars[$section])) {
$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