Commit 14bf431e authored by catch's avatar catch

Issue #2061913 by AndreyMaximov, damiankloip, jibran: Remove...

Issue #2061913 by AndreyMaximov, damiankloip, jibran: Remove drupal_set_breadcrumb and LegacyBreadcrumbBuilder in Views module.
parent e4db5cd4
......@@ -163,8 +163,6 @@ display:
title: All
title_enable: '0'
title: ''
breadcrumb_enable: '0'
breadcrumb: ''
default_argument_type: fixed
default_argument_options:
argument: ''
......
......@@ -19,30 +19,6 @@
*/
class IndexTid extends ManyToOne {
protected function defineOptions() {
$options = parent::defineOptions();
$options['set_breadcrumb'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
$form['set_breadcrumb'] = array(
'#type' => 'checkbox',
'#title' => t("Set the breadcrumb for the term parents"),
'#description' => t('If selected, the breadcrumb trail will include all parent terms, each one linking to this view. Note that this only works if just one term was received.'),
'#default_value' => !empty($this->options['set_breadcrumb']),
);
}
public function setBreadcrumb(&$breadcrumb) {
if (empty($this->options['set_breadcrumb']) || !is_numeric($this->argument)) {
return;
}
return views_taxonomy_set_breadcrumb($breadcrumb, $this);
}
public function titleQuery() {
$titles = array();
$result = db_select('taxonomy_term_data', 'td')
......
......@@ -27,7 +27,6 @@ protected function defineOptions() {
$options['depth'] = array('default' => 0);
$options['break_phrase'] = array('default' => FALSE, 'bool' => TRUE);
$options['set_breadcrumb'] = array('default' => FALSE, 'bool' => TRUE);
$options['use_taxonomy_term_path'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
......@@ -48,35 +47,9 @@ public function buildOptionsForm(&$form, &$form_state) {
'#default_value' => !empty($this->options['break_phrase']),
);
$form['set_breadcrumb'] = array(
'#type' => 'checkbox',
'#title' => t("Set the breadcrumb for the term parents"),
'#description' => t('If selected, the breadcrumb trail will include all parent terms, each one linking to this view. Note that this only works if just one term was received.'),
'#default_value' => !empty($this->options['set_breadcrumb']),
);
$form['use_taxonomy_term_path'] = array(
'#type' => 'checkbox',
'#title' => t("Use Drupal's taxonomy term path to create breadcrumb links"),
'#description' => t('If selected, the links in the breadcrumb trail will be created using the standard drupal method instead of the custom views method. This is useful if you are using modules like taxonomy redirect to modify your taxonomy term links.'),
'#default_value' => !empty($this->options['use_taxonomy_term_path']),
'#states' => array(
'visible' => array(
':input[name="options[set_breadcrumb]"]' => array('checked' => TRUE),
),
),
);
parent::buildOptionsForm($form, $form_state);
}
public function setBreadcrumb(&$breadcrumb) {
if (empty($this->options['set_breadcrumb']) || !is_numeric($this->argument)) {
return;
}
return views_taxonomy_set_breadcrumb($breadcrumb, $this);
}
/**
* Override defaultActions() to remove summary actions.
*/
......
......@@ -152,8 +152,6 @@ display:
title: All
title_enable: '0'
title: ''
breadcrumb_enable: '0'
breadcrumb: ''
default_argument_type: fixed
default_argument_options:
argument: ''
......
......@@ -271,12 +271,7 @@ views_argument:
title:
type: label
label: 'Title'
breadcrumb_enable:
type: boolean
label: 'Override breadcrumb'
breadcrumb:
type: label
label: 'Breadcrumb'
label: 'Overridden title'
default_argument_type:
type: string
label: 'Type'
......
......@@ -237,8 +237,6 @@ display:
admin_label: ''
title_enable: false
title: ''
breadcrumb_enable: false
breadcrumb: ''
default_argument_skip_url: false
summary_options: { }
validate:
......@@ -356,8 +354,6 @@ display:
admin_label: ''
title_enable: false
title: ''
breadcrumb_enable: false
breadcrumb: ''
default_argument_skip_url: false
validate:
type: none
......
......@@ -102,14 +102,10 @@ display:
relationship: none
group_type: group
admin_label: ''
breadcrumb_enable: false
breadcrumb: ''
default_argument_options: { }
default_argument_skip_url: false
summary_options: { }
validate_options: { }
set_breadcrumb: '0'
use_taxonomy_term_path: '0'
provider: taxonomy
term_node_tid_depth_modifier:
id: term_node_tid_depth_modifier
......@@ -128,8 +124,6 @@ display:
default_action: ignore
title_enable: false
title: ''
breadcrumb_enable: false
breadcrumb: ''
default_argument_options: { }
default_argument_skip_url: false
summary_options: { }
......
......@@ -479,8 +479,6 @@ display:
group_type: group
admin_label: ''
default_action: ignore
breadcrumb_enable: false
breadcrumb: ''
default_argument_options: { }
default_argument_skip_url: false
summary_options: { }
......
......@@ -77,25 +77,6 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
}
}
/**
* Give an argument the opportunity to modify the breadcrumb, if it wants.
* This only gets called on displays where a breadcrumb is actually used.
*
* The breadcrumb will be in the form of an array, with the keys being
* the path and the value being the already sanitized title of the path.
*/
public function setBreadcrumb(&$breadcrumb) { }
/**
* Determine if the argument can generate a breadcrumb
*
* @return TRUE/FALSE
*/
public function usesBreadcrumb() {
$info = $this->defaultActions($this->options['default_action']);
return !empty($info['breadcrumb']);
}
public function isException($arg = NULL) {
if (!isset($arg)) {
$arg = isset($this->argument) ? $this->argument : NULL;
......@@ -135,8 +116,6 @@ protected function defineOptions() {
);
$options['title_enable'] = array('default' => FALSE, 'bool' => TRUE);
$options['title'] = array('default' => '', 'translatable' => TRUE);
$options['breadcrumb_enable'] = array('default' => FALSE, 'bool' => TRUE);
$options['breadcrumb'] = array('default' => '', 'translatable' => TRUE);
$options['default_argument_type'] = array('default' => 'fixed');
$options['default_argument_options'] = array('default' => array());
$options['default_argument_skip_url'] = array('default' => FALSE, 'bool' => TRUE);
......@@ -262,26 +241,6 @@ public function buildOptionsForm(&$form, &$form_state) {
'#fieldset' => 'argument_present',
);
$form['breadcrumb_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Override breadcrumb'),
'#default_value' => $this->options['breadcrumb_enable'],
'#fieldset' => 'argument_present',
);
$form['breadcrumb'] = array(
'#type' => 'textfield',
'#title' => t('Provide breadcrumb'),
'#title_display' => 'invisible',
'#default_value' => $this->options['breadcrumb'],
'#description' => t('Enter a breadcrumb name you would like to use. See "Title" for percent substitutions.'),
'#states' => array(
'visible' => array(
':input[name="options[breadcrumb_enable]"]' => array('checked' => TRUE),
),
),
'#fieldset' => 'argument_present',
);
$form['specify_validation'] = array(
'#type' => 'checkbox',
'#title' => t('Specify validation criteria'),
......@@ -447,7 +406,6 @@ protected function defaultActions($which = NULL) {
'ignore' => array(
'title' => t('Display all results for the specified field'),
'method' => 'defaultIgnore',
'breadcrumb' => TRUE, // generate a breadcrumb to here
),
'default' => array(
'title' => t('Provide default value'),
......@@ -455,7 +413,6 @@ protected function defaultActions($which = NULL) {
'form method' => 'defaultArgumentForm',
'has default argument' => TRUE,
'default only' => TRUE, // this can only be used for missing argument, not validation failure
'breadcrumb' => TRUE, // generate a breadcrumb to here
),
'not found' => array(
'title' => t('Hide view'),
......@@ -467,17 +424,14 @@ protected function defaultActions($which = NULL) {
'method' => 'defaultSummary',
'form method' => 'defaultSummaryForm',
'style plugin' => TRUE,
'breadcrumb' => TRUE, // generate a breadcrumb to here
),
'empty' => array(
'title' => t('Display contents of "No results found"'),
'method' => 'defaultEmpty',
'breadcrumb' => TRUE, // generate a breadcrumb to here
),
'access denied' => array(
'title' => t('Display "Access Denied"'),
'method' => 'defaultAccessDenied',
'breadcrumb' => FALSE, // generate a breadcrumb to here
),
);
......
......@@ -68,9 +68,8 @@ public function isDefaultDisplay() { return TRUE; }
* This illustrates that render is smart enough to call build and execute
* if these items have not already been accomplished.
*
* Note that execute also must accomplish other tasks, such
* as setting page titles, breadcrumbs, and generating exposed filter
* data if necessary.
* Note that execute also must accomplish other tasks, such as setting page
* titles, and generating exposed filter data if necessary.
*/
public function execute() {
return $this->view->render($this->display['id']);
......
......@@ -782,13 +782,6 @@ public function getUrl() {
return $this->view->getUrl();
}
/**
* Check to see if the display needs a breadcrumb
*
* By default, displays do not need breadcrumbs
*/
public function usesBreadcrumb() { return FALSE; }
/**
* Determine if a given option is set to use the default display or the
* current display
......
......@@ -37,13 +37,6 @@ class Page extends PathPluginBase {
*/
protected $usesAttachments = TRUE;
/**
* Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::usesBreadcrumb().
*/
public function usesBreadcrumb() {
return TRUE;
}
/**
* Overrides \Drupal\views\Plugin\views\display\PathPluginBase::defineOptions().
*/
......@@ -84,8 +77,6 @@ public function execute() {
// Let the world know that this is the page view we're using.
views_set_page_view($this->view);
$this->view->getBreadcrumb(TRUE);
// And now render the view.
$render = $this->view->render();
......
......@@ -92,7 +92,6 @@ public function testViewElement() {
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate' => array(
......
......@@ -901,16 +901,12 @@ protected function _buildArguments() {
// build arguments.
$position = -1;
// Create a title for use in the breadcrumb trail.
$title = $this->display_handler->getOption('title');
$this->build_info['breadcrumb'] = array();
$breadcrumb_args = array();
$substitutions = array();
$status = TRUE;
// Get the title.
$title = $this->display_handler->getOption('title');
// Iterate through each argument and process.
foreach ($this->argument as $id => $arg) {
$position++;
......@@ -954,30 +950,10 @@ protected function _buildArguments() {
$substitutions['%' . ($position + 1)] = $arg_title;
$substitutions['!' . ($position + 1)] = strip_tags(decode_entities($arg));
// Since we're really generating the breadcrumb for the item above us,
// check the default action of this argument.
if ($this->display_handler->usesBreadcrumb() && $argument->usesBreadcrumb()) {
$path = $this->getUrl($breadcrumb_args);
if (strpos($path, '%') === FALSE) {
if (!empty($argument->options['breadcrumb_enable']) && !empty($argument->options['breadcrumb'])) {
$breadcrumb = $argument->options['breadcrumb'];
}
else {
$breadcrumb = $title;
}
$this->build_info['breadcrumb'][$path] = str_replace(array_keys($substitutions), $substitutions, $breadcrumb);
}
}
// Allow the argument to muck with this breadcrumb.
$argument->setBreadcrumb($this->build_info['breadcrumb']);
// Test to see if we should use this argument's title
if (!empty($argument->options['title_enable']) && !empty($argument->options['title'])) {
$title = $argument->options['title'];
}
$breadcrumb_args[] = $arg;
}
else {
// determine default condition and handle.
......@@ -1404,7 +1380,7 @@ public function render($display_id = NULL) {
* This function should NOT be used by anything external as this
* returns data in the format specified by the display. It can also
* have other side effects that are only intended for the 'proper'
* use of the display, such as setting page titles and breadcrumbs.
* use of the display, such as setting page titles.
*
* If you simply want to view the display, use View::preview() instead.
*/
......@@ -1723,40 +1699,6 @@ public function getPath() {
return $this->display_handler->getPath();
}
/**
* Get the breadcrumb used for this view.
*
* @param $set
* If true, use drupal_set_breadcrumb() to install the breadcrumb.
*/
public function getBreadcrumb($set = FALSE) {
// Now that we've built the view, extract the breadcrumb.
$base = TRUE;
$breadcrumb = array();
if (!empty($this->build_info['breadcrumb'])) {
foreach ($this->build_info['breadcrumb'] as $path => $title) {
// Check to see if the frontpage is in the breadcrumb trail; if it
// is, we'll remove that from the actual breadcrumb later.
if ($path == \Drupal::config('system.site')->get('page.front')) {
$base = FALSE;
$title = t('Home');
}
if ($title) {
$breadcrumb[] = l($title, $path, array('html' => TRUE));
}
}
if ($set) {
if ($base && $current_breadcrumbs = drupal_set_breadcrumb()) {
$breadcrumb = array_merge($current_breadcrumbs, $breadcrumb);
}
drupal_set_breadcrumb($breadcrumb);
}
}
return $breadcrumb;
}
/**
* Creates a duplicate ViewExecutable object.
*
......
......@@ -51,7 +51,6 @@ display:
wildcard: all
wildcard_substitution: All
title: ''
breadcrumb: ''
default_argument_type: fixed
default_argument: ''
validate:
......
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