diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php index adee17d..4e9d7ec 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php @@ -17,7 +17,7 @@ class NodeAccessBaseTableTest extends NodeTestBase { * * @var array */ - public static $modules = array('node_access_test'); + public static $modules = array('node_access_test', 'views'); /** * The installation profile to use with this test. diff --git a/core/modules/node/node.module b/core/modules/node/node.module index fbdf07d..eb50d76 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -2341,7 +2341,6 @@ function node_search_validate($form, &$form_state) { * default setting for number of posts to show on node listing pages. * * @see node_page_default() - * @see taxonomy_term_page() * @see node_form_system_site_information_settings_form_submit() */ function node_form_system_site_information_settings_form_alter(&$form, &$form_state, $form_id) { diff --git a/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php b/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php index db711b9..d4c70d0 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php @@ -17,7 +17,7 @@ class PathTaxonomyTermTest extends PathTestBase { * * @var array */ - public static $modules = array('taxonomy'); + public static $modules = array('taxonomy', 'views'); public static function getInfo() { return array( diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyAttributesTest.php index 99390d3..325a34d 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyAttributesTest.php @@ -19,7 +19,7 @@ class TaxonomyAttributesTest extends TaxonomyTestBase { * * @var array */ - public static $modules = array('rdf'); + public static $modules = array('rdf', 'views'); public static function getInfo() { return array( diff --git a/core/modules/taxonomy/config/views.view.taxonomy_term.yml b/core/modules/taxonomy/config/views.view.taxonomy_term.yml new file mode 100644 index 0000000..2624512 --- /dev/null +++ b/core/modules/taxonomy/config/views.view.taxonomy_term.yml @@ -0,0 +1,251 @@ +base_field: nid +base_table: node +core: '8' +description: 'Customize the default taxonomy/term display.' +status: '1' +display: + default: + id: default + display_title: Master + display_plugin: default + position: '1' + display_options: + query: + type: views_query + options: + query_comment: '0' + disable_sql_rewrite: '0' + distinct: '0' + slave: '0' + query_tags: { } + access: + type: perm + options: + perm: 'access content' + cache: + type: none + options: { } + exposed_form: + type: basic + options: + submit_button: Apply + reset_button: '0' + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: '1' + sort_asc_label: Asc + sort_desc_label: Desc + pager: + type: mini + options: + items_per_page: '10' + offset: '0' + id: '0' + total_pages: '' + expose: + items_per_page: '0' + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 20, 40, 60' + items_per_page_options_all: '0' + items_per_page_options_all_label: '- All -' + offset: '0' + offset_label: Offset + tags: + previous: ‹‹ + next: ›› + sorts: + sticky: + id: sticky + table: node_field_data + field: sticky + order: DESC + plugin_id: standard + relationship: none + group_type: group + admin_label: '' + exposed: '0' + expose: + label: '' + created: + id: created + table: node_field_data + field: created + order: DESC + plugin_id: date + relationship: none + group_type: group + admin_label: '' + exposed: '0' + expose: + label: '' + granularity: second + arguments: + term_node_tid_depth: + id: term_node_tid_depth + table: node + field: term_node_tid_depth + default_action: 'not found' + exception: + title_enable: '1' + title_enable: '1' + title: '%1' + default_argument_type: fixed + summary: + format: default_summary + specify_validation: '1' + validate: + type: taxonomy_term + depth: '0' + break_phrase: '1' + plugin_id: taxonomy_index_tid_depth + relationship: none + group_type: group + admin_label: '' + breadcrumb_enable: '0' + breadcrumb: '' + default_argument_options: { } + default_argument_skip_url: '0' + summary_options: { } + validate_options: { } + set_breadcrumb: '1' + use_taxonomy_term_path: '0' + filters: + status_extra: + id: status_extra + table: node_field_data + field: status_extra + group: '0' + expose: + operator: '0' + plugin_id: node_status + style: + type: default + options: + grouping: { } + row_class: '' + default_row_class: '1' + row_class_special: '1' + uses_fields: '0' + row: + type: 'entity:node' + options: + view_mode: teaser + links: '1' + comments: '0' + header: + entity_taxonomy_term: + id: entity_taxonomy_term + table: views + field: entity_taxonomy_term + relationship: none + group_type: group + admin_label: '' + label: '' + empty: '1' + entity_id: '!1' + view_mode: full + tokenize: '1' + plugin_id: entity + footer: { } + empty: { } + relationships: { } + fields: { } + page_1: + id: page_1 + display_title: Page + display_plugin: page + position: '2' + display_options: + query: + type: views_query + options: { } + path: taxonomy/term/%/list + pager: + type: full + options: + items_per_page: '10' + offset: '0' + id: '0' + total_pages: '' + tags: + previous: ‹‹ + next: ›› + first: '« first' + last: 'last »' + expose: + items_per_page: '0' + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 20, 40, 60' + items_per_page_options_all: '0' + items_per_page_options_all_label: '- All -' + offset: '0' + offset_label: Offset + quantity: '9' + defaults: + pager: '0' + pager_options: '0' + pager_options: '' + menu: + type: 'default tab' + title: View + description: '' + name: admin + weight: '0' + context: '0' + tab_options: + type: normal + title: 'Taxonomy term' + description: '' + name: admin + weight: '0' + feed_1: + id: feed_1 + display_title: Feed + display_plugin: feed + position: '3' + display_options: + query: + type: views_query + options: { } + pager: + type: full + options: + items_per_page: '15' + offset: '0' + id: '0' + total_pages: '' + expose: + items_per_page: '0' + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 20, 40, 60' + items_per_page_options_all: '0' + items_per_page_options_all_label: '- All -' + offset: '0' + offset_label: Offset + tags: + previous: '‹ previous' + next: 'next ›' + first: '« first' + last: 'last »' + quantity: '9' + path: taxonomy/term/%/feed + displays: + page: page + default: '0' + style: + type: rss + options: + description: '' + grouping: { } + uses_fields: '0' + row: + type: node_rss + options: + relationship: none + item_length: default + links: '0' +label: 'Taxonomy term' +module: taxonomy +id: taxonomy_term +tag: default +langcode: en diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTid.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTid.php index 3979196..24de5dc 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTid.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTid.php @@ -40,6 +40,7 @@ public function setBreadcrumb(&$breadcrumb) { return; } + module_load_include('inc', 'taxonomy', 'taxonomy.views'); return views_taxonomy_set_breadcrumb($breadcrumb, $this); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTidDepth.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTidDepth.php index 169d49e..651961f 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTidDepth.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTidDepth.php @@ -28,7 +28,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; } @@ -55,17 +54,6 @@ public function buildOptionsForm(&$form, &$form_state) { '#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); } @@ -74,6 +62,7 @@ public function setBreadcrumb(&$breadcrumb) { return; } + module_load_include('inc', 'taxonomy', 'taxonomy.views'); return views_taxonomy_set_breadcrumb($breadcrumb, $this); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php index 8fa30c3..1bf5f7f 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php @@ -206,6 +206,7 @@ function testTaxonomyIndex() { * Tests that there is a link to the parent term on the child term page. */ function testTaxonomyTermHierarchyBreadcrumbs() { + module_enable(array('views')); // Create two taxonomy terms and set term2 as the parent of term1. $term1 = $this->createTerm($this->vocabulary); $term2 = $this->createTerm($this->vocabulary); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php index caf5397..ede3ef0 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -289,6 +289,7 @@ function testTermAutocompletion() { * Save, edit and delete a term using the user interface. */ function testTermInterface() { + module_enable(array('views')); $edit = array( 'name' => $this->randomName(12), 'description[value]' => $this->randomName(100), diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index c21b665..2e4b768 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -248,20 +248,6 @@ function taxonomy_menu() { 'file' => 'taxonomy.admin.inc', ); - $items['taxonomy/term/%taxonomy_term'] = array( - 'title' => 'Taxonomy term', - 'title callback' => 'taxonomy_term_title', - 'title arguments' => array(2), - 'page callback' => 'taxonomy_term_page', - 'page arguments' => array(2), - 'access callback' => 'entity_page_access', - 'access arguments' => array(2, 'view'), - 'file' => 'taxonomy.pages.inc', - ); - $items['taxonomy/term/%taxonomy_term/view'] = array( - 'title' => 'View', - 'type' => MENU_DEFAULT_LOCAL_TASK, - ); $items['taxonomy/term/%taxonomy_term/edit'] = array( 'title' => 'Edit', 'page callback' => 'entity_get_form', @@ -286,17 +272,6 @@ function taxonomy_menu() { 'weight' => 20, 'file' => 'taxonomy.admin.inc', ); - $items['taxonomy/term/%taxonomy_term/feed'] = array( - 'title' => 'Taxonomy term', - 'title callback' => 'taxonomy_term_title', - 'title arguments' => array(2), - 'page callback' => 'taxonomy_term_feed', - 'page arguments' => array(2), - 'access callback' => 'entity_page_access', - 'access arguments' => array(2, 'view'), - 'type' => MENU_CALLBACK, - 'file' => 'taxonomy.pages.inc', - ); $items['taxonomy/autocomplete/%'] = array( 'title' => 'Autocomplete taxonomy', 'page callback' => 'taxonomy_autocomplete', @@ -1025,19 +1000,6 @@ function taxonomy_allowed_values(FieldDefinitionInterface $field_definition, Ent } /** - * Title callback for term pages. - * - * @param Drupal\taxonomy\Plugin\Core\Entity\Term $term - * A taxonomy term entity. - * - * @return - * The term name to be used as the page title. - */ -function taxonomy_term_title(Term $term) { - return $term->label(); -} - -/** * Form element validate handler for taxonomy term autocomplete element. */ function taxonomy_autocomplete_validate($element, &$form_state) { diff --git a/core/modules/taxonomy/taxonomy.pages.inc b/core/modules/taxonomy/taxonomy.pages.inc index d70b8fd..d5471ac 100644 --- a/core/modules/taxonomy/taxonomy.pages.inc +++ b/core/modules/taxonomy/taxonomy.pages.inc @@ -10,76 +10,6 @@ use Symfony\Component\HttpFoundation\JsonResponse; /** - * Menu callback; displays all nodes associated with a term. - * - * @param Drupal\taxonomy\Plugin\Core\Entity\Term $term - * The taxonomy term entity. - */ -function taxonomy_term_page(Term $term) { - // Assign the term name as the page title. - drupal_set_title($term->label()); - - // @todo This overrides any other possible breadcrumb and is a pure hard-coded - // presumption. Make this behavior configurable per vocabulary or term. - $breadcrumb = array(); - $current = $term; - while ($parents = taxonomy_term_load_parents($current->id())) { - $current = array_shift($parents); - $breadcrumb[] = l($current->label(), 'taxonomy/term/' . $current->id()); - } - $breadcrumb[] = l(t('Home'), NULL); - $breadcrumb = array_reverse($breadcrumb); - drupal_set_breadcrumb($breadcrumb); - drupal_add_feed('taxonomy/term/' . $term->id() . '/feed', 'RSS - ' . $term->label()); - - foreach ($term->uriRelationships() as $rel) { - $uri = $term->uri($rel); - // Set the term path as the canonical URL to prevent duplicate content. - drupal_add_html_head_link(array('rel' => $rel, 'href' => url($uri['path'], $uri['options'])), TRUE); - - if ($rel == 'canonical') { - // Set the non-aliased canonical path as a default shortlink. - drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE); - } - } - - $build['taxonomy_terms'] = taxonomy_term_view_multiple(array($term->id() => $term)); - if ($nids = taxonomy_select_nodes($term->id(), TRUE, config('node.settings')->get('items_per_page'))) { - $nodes = node_load_multiple($nids); - $build['nodes'] = node_view_multiple($nodes); - $build['pager'] = array( - '#theme' => 'pager', - '#weight' => 5, - ); - } - else { - $build['no_content'] = array( - '#prefix' => '
', - '#markup' => t('There is currently no content classified with this term.'), - '#suffix' => '
', - ); - } - return $build; -} - -/** - * Generate the content feed for a taxonomy term. - * - * @param Drupal\taxonomy\Plugin\Core\Entity\Term $term - * The taxonomy term entity. - */ -function taxonomy_term_feed(Term $term) { - $channel['link'] = url('taxonomy/term/' . $term->id(), array('absolute' => TRUE)); - $channel['title'] = config('system.site')->get('name') . ' - ' . $term->label(); - // Only display the description if we have a single term, to avoid clutter and confusion. - // HTML will be removed from feed description. - $channel['description'] = check_markup($term->description->value, $term->format->value, '', TRUE); - $nids = taxonomy_select_nodes($term->id(), FALSE, config('system.rss')->get('items.limit')); - - return node_feed($nids, $channel); -} - -/** * Page callback: Outputs JSON for taxonomy autocomplete suggestions. * * This callback outputs term name suggestions in response to Ajax requests diff --git a/core/modules/taxonomy/taxonomy.views.inc b/core/modules/taxonomy/taxonomy.views.inc index 5646268..4e17bce 100644 --- a/core/modules/taxonomy/taxonomy.views.inc +++ b/core/modules/taxonomy/taxonomy.views.inc @@ -401,27 +401,21 @@ function taxonomy_field_views_data_views_data_alter(&$data, $field) { /** * Helper function to set a breadcrumb for taxonomy. + * + * @param array &$breadcrumb + * An array reference containing a reference to + * $view->build_info['breadcrumb']. + * @param \Drupal\views\Plugin\views\argument\ArgumentPluginBase $argument + * The argument handler instance to get the argument from. + * */ function views_taxonomy_set_breadcrumb(&$breadcrumb, &$argument) { - if (empty($argument->options['set_breadcrumb'])) { - return; - } - - $args = $argument->view->args; - $parents = taxonomy_get_parents_all($argument->argument); - foreach (array_reverse($parents) as $parent) { - // Unfortunately parents includes the current argument. Skip. - if ($parent->id() == $argument->argument) { - continue; - } - if (!empty($argument->options['use_taxonomy_term_path'])) { - $path = $parent->uri(); - $path = $path['path']; - } - else { - $args[$argument->position] = $parent->id(); - $path = $argument->view->getUrl($args); - } - $breadcrumb[$path] = check_plain($parent->label()); + $breadcrumb = array(); + $current = taxonomy_term_load($argument->argument); + while ($parents = taxonomy_term_load_parents($current->id())) { + $current = array_shift($parents); + $uri = $current->uri(); + $breadcrumb[$uri['path']] = $current->label(); } + $breadcrumb = array_reverse($breadcrumb); } diff --git a/core/modules/views/config/views.view.taxonomy_term.yml b/core/modules/views/config/views.view.taxonomy_term.yml deleted file mode 100644 index 7dda43d..0000000 --- a/core/modules/views/config/views.view.taxonomy_term.yml +++ /dev/null @@ -1,225 +0,0 @@ -base_field: nid -base_table: node -core: '8' -description: 'Customize the default taxonomy/term display.' -status: '0' -display: - default: - id: default - display_title: Master - display_plugin: default - position: '1' - display_options: - query: - type: views_query - options: - query_comment: '0' - disable_sql_rewrite: '0' - distinct: '0' - slave: '0' - query_tags: { } - access: - type: none - options: { } - cache: - type: none - options: { } - exposed_form: - type: basic - options: - submit_button: Apply - reset_button: '0' - reset_button_label: Reset - exposed_sorts_label: 'Sort by' - expose_sort_order: '1' - sort_asc_label: Asc - sort_desc_label: Desc - pager: - type: mini - options: - items_per_page: '10' - offset: '0' - id: '0' - total_pages: '' - expose: - items_per_page: '0' - items_per_page_label: 'Items per page' - items_per_page_options: '5, 10, 20, 40, 60' - items_per_page_options_all: '0' - items_per_page_options_all_label: '- All -' - offset: '0' - offset_label: Offset - tags: - previous: ‹‹ - next: ›› - sorts: - sticky: - id: sticky - table: node_field_data - field: sticky - order: DESC - plugin_id: standard - relationship: none - group_type: group - admin_label: '' - exposed: '0' - expose: - label: '' - created: - id: created - table: node_field_data - field: created - order: DESC - plugin_id: date - relationship: none - group_type: group - admin_label: '' - exposed: '0' - expose: - label: '' - granularity: second - arguments: - term_node_tid_depth: - id: term_node_tid_depth - table: node - field: term_node_tid_depth - default_action: 'not found' - exception: - title_enable: '1' - title_enable: '1' - title: '%1' - default_argument_type: fixed - summary: - format: default_summary - specify_validation: '1' - validate: - type: taxonomy_term - depth: '0' - break_phrase: '1' - plugin_id: taxonomy_index_tid_depth - relationship: none - group_type: group - admin_label: '' - breadcrumb_enable: '0' - breadcrumb: '' - default_argument_options: { } - default_argument_skip_url: '0' - summary_options: { } - validate_options: { } - set_breadcrumb: '0' - use_taxonomy_term_path: '0' - term_node_tid_depth_modifier: - id: term_node_tid_depth_modifier - table: node - field: term_node_tid_depth_modifier - exception: - title_enable: '1' - default_argument_type: fixed - summary: - format: default_summary - specify_validation: '1' - plugin_id: taxonomy_index_tid_depth_modifier - relationship: none - group_type: group - admin_label: '' - default_action: ignore - title_enable: '0' - title: '' - breadcrumb_enable: '0' - breadcrumb: '' - default_argument_options: { } - default_argument_skip_url: '0' - summary_options: { } - validate: - type: none - fail: 'not found' - validate_options: { } - filters: - status_extra: - id: status_extra - table: node_field_data - field: status_extra - group: '0' - expose: - operator: '0' - plugin_id: node_status - style: - type: default - options: - grouping: { } - row_class: '' - default_row_class: '1' - row_class_special: '1' - uses_fields: '0' - row: - type: 'entity:node' - options: - view_mode: teaser - links: '1' - comments: '0' - header: { } - footer: { } - empty: { } - relationships: { } - fields: { } - page_1: - id: page_1 - display_title: Page - display_plugin: page - position: '2' - display_options: - query: - type: views_query - options: { } - path: taxonomy/term/% - feed_1: - id: feed_1 - display_title: Feed - display_plugin: feed - position: '3' - display_options: - query: - type: views_query - options: { } - pager: - type: full - options: - items_per_page: '15' - offset: '0' - id: '0' - total_pages: '' - expose: - items_per_page: '0' - items_per_page_label: 'Items per page' - items_per_page_options: '5, 10, 20, 40, 60' - items_per_page_options_all: '0' - items_per_page_options_all_label: '- All -' - offset: '0' - offset_label: Offset - tags: - previous: '‹ previous' - next: 'next ›' - first: '« first' - last: 'last »' - quantity: '9' - path: taxonomy/term/%/%/feed - displays: - page: page - default: '0' - style: - type: rss - options: - description: '' - grouping: { } - uses_fields: '0' - row: - type: node_rss - options: - relationship: none - item_length: default - links: '0' -label: 'Taxonomy term' -module: taxonomy -id: taxonomy_term -tag: default -langcode: en diff --git a/core/modules/views/lib/Drupal/views/ViewExecutable.php b/core/modules/views/lib/Drupal/views/ViewExecutable.php index 25c387e..c5ed856 100644 --- a/core/modules/views/lib/Drupal/views/ViewExecutable.php +++ b/core/modules/views/lib/Drupal/views/ViewExecutable.php @@ -1669,9 +1669,18 @@ public function getBreadcrumb($set = FALSE) { } } + // Breadcrumb setting presently using legacy system [2026073]. if ($set) { - if ($base && $current_breadcrumbs = drupal_set_breadcrumb()) { - $breadcrumb = array_merge($current_breadcrumbs, $breadcrumb); + // Allow legacy breadcrumb system to be used to alter the breadcrumb. + if ($base) { + if ($current_breadcrumbs = drupal_set_breadcrumb()) { + $breadcrumb = array_merge($current_breadcrumbs, $breadcrumb); + } + // If the frontpage is not in the trail, and there was no + // legacy breadcrumb set add the frontpage. + else { + array_unshift($breadcrumb, l(t('Home'), '')); + } } drupal_set_breadcrumb($breadcrumb); }