diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php index 6b7d00d..8e03579 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 0123692..f74a473 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -2389,7 +2389,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 2122b9a..e48e0c4 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( @@ -48,7 +48,7 @@ function setUp() { function testTermAlias() { // Create a term in the default 'Tags' vocabulary with URL alias. $vocabulary = taxonomy_vocabulary_load('tags'); - $description = $this->randomName();; + $description = $this->randomName(); $edit = array( 'name' => $this->randomName(), 'description[value]' => $description, diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyAttributesTest.php index 83e6ec9..1af7352 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/views/config/views.view.taxonomy_term.yml b/core/modules/taxonomy/config/views.view.taxonomy_term.yml similarity index 70% rename from core/modules/views/config/views.view.taxonomy_term.yml rename to core/modules/taxonomy/config/views.view.taxonomy_term.yml index 0cfeff2..0bbb3f0 100644 --- a/core/modules/views/config/views.view.taxonomy_term.yml +++ b/core/modules/taxonomy/config/views.view.taxonomy_term.yml @@ -1,12 +1,9 @@ langcode: en -status: '0' -module: taxonomy -id: taxonomy_term -description: 'Customize the default taxonomy/term display.' -tag: default +base_field: nid base_table: node -human_name: 'Taxonomy term' core: '8' +description: 'Customize the default taxonomy/term display.' +status: '1' display: default: id: default @@ -17,9 +14,11 @@ display: query: type: views_query options: - query_comment: false + query_comment: '0' access: - type: none + type: perm + options: + perm: 'access content' cache: type: none exposed_form: @@ -46,42 +45,46 @@ display: field: term_node_tid_depth default_action: 'not found' exception: - title_enable: 1 - title_enable: 1 + title_enable: '1' + title_enable: '1' title: '%1' default_argument_type: fixed summary: format: default_summary - specify_validation: 1 + specify_validation: '1' validate: type: taxonomy_term depth: '0' - break_phrase: 1 + break_phrase: '1' + set_breadcrumb: '1' plugin_id: taxonomy_index_tid_depth - 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 filters: status_extra: id: status_extra table: node field: status_extra - group: 0 + group: '0' expose: - operator: false + operator: '0' plugin_id: node_status style: type: default row: type: node + 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 page_1: id: page_1 display_title: Page @@ -104,12 +107,17 @@ display: pager: type: full options: - items_per_page: 15 - path: taxonomy/term/%/%/feed + items_per_page: '15' + path: taxonomy/term/%/feed displays: - page: page - default: 0 + page_1: page_1 + default: '0' style: type: rss row: type: node_rss +human_name: 'Taxonomy term' +module: taxonomy +id: taxonomy_term +tag: default +langcode: und 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 0cbcadd..81874cc 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 @@ -43,7 +43,8 @@ function set_breadcrumb(&$breadcrumb) { return; } - return views_taxonomy_set_breadcrumb($breadcrumb, $this); + module_load_include('inc', 'taxonomy', 'taxonomy.views'); + views_taxonomy_set_breadcrumb($breadcrumb, $this); } function title_query() { 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 c43c69e..9b08330 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 @@ -31,7 +31,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; } @@ -58,17 +57,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); } @@ -77,7 +65,8 @@ function set_breadcrumb(&$breadcrumb) { return; } - return views_taxonomy_set_breadcrumb($breadcrumb, $this); + module_load_include('inc', 'taxonomy', 'taxonomy.views'); + views_taxonomy_set_breadcrumb($breadcrumb, $this); } /** diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/HooksTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/HooksTest.php index edddd1a..3205c83 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/HooksTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/HooksTest.php @@ -68,10 +68,9 @@ function testTaxonomyTermHooks() { // View the term and ensure that hook_taxonomy_term_view() and // hook_entity_view() are invoked. $term = taxonomy_term_load($term->tid); - module_load_include('inc', 'taxonomy', 'taxonomy.pages'); - $term_build = taxonomy_term_page($term); - $this->assertFalse(empty($term_build['taxonomy_terms'][$term->tid]['taxonomy_test_term_view_check']), 'hook_taxonomy_term_view() was invoked when viewing the term.'); - $this->assertFalse(empty($term_build['taxonomy_terms'][$term->tid]['taxonomy_test_entity_view_check']), 'hook_entity_view() was invoked when viewing the term.'); + $term_build = taxonomy_term_view($term); + $this->assertFalse(empty($term_build['taxonomy_test_term_view_check']), 'hook_taxonomy_term_view() was invoked when viewing the term.'); + $this->assertFalse(empty($term_build['taxonomy_test_entity_view_check']), 'hook_entity_view() was invoked when viewing the term.'); // Delete the term. taxonomy_term_delete($term->tid); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php index 3d28ec0..4c3e3d3 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php @@ -17,7 +17,7 @@ class RssTest extends TaxonomyTestBase { * * @var array */ - public static $modules = array('node', 'field_ui'); + public static $modules = array('node', 'field_ui', 'views'); public static function getInfo() { return array( diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php index f9cba0d..223950d 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php @@ -205,6 +205,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 93cc8d4..09e27b9 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -284,6 +284,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 f894d6c..61ace54 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -276,20 +276,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', @@ -312,17 +298,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', @@ -1230,19 +1205,6 @@ function taxonomy_field_formatter_prepare_view($entity_type, $entities, $field, } /** - * 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 b6f1329..62b7e14 100644 --- a/core/modules/taxonomy/taxonomy.pages.inc +++ b/core/modules/taxonomy/taxonomy.pages.inc @@ -10,75 +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()); - - // Build breadcrumb based on the hierarchy of the term. - $current = (object) array( - 'tid' => $term->tid, - ); - // @todo This overrides any other possible breadcrumb and is a pure hard-coded - // presumption. Make this behavior configurable per vocabulary or term. - $breadcrumb = array(); - while ($parents = taxonomy_term_load_parents($current->tid)) { - $current = array_shift($parents); - $breadcrumb[] = l($current->label(), 'taxonomy/term/' . $current->tid); - } - $breadcrumb[] = l(t('Home'), NULL); - $breadcrumb = array_reverse($breadcrumb); - drupal_set_breadcrumb($breadcrumb); - drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->label()); - - $uri = $term->uri(); - - // Set the term path as the canonical URL to prevent duplicate content. - drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE); - // Set the non-aliased 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->tid, 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->tid, 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, $term->format, '', TRUE); - $nids = taxonomy_select_nodes($term->tid, 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 0644f82..f47ef68 100644 --- a/core/modules/taxonomy/taxonomy.views.inc +++ b/core/modules/taxonomy/taxonomy.views.inc @@ -401,27 +401,20 @@ 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->tid == $argument->argument) { - continue; - } - if (!empty($argument->options['use_taxonomy_term_path'])) { - $path = $parent->uri(); - $path = $path['path']; - } - else { - $args[$argument->position] = $parent->tid; - $path = $argument->view->getUrl($args); - } - $breadcrumb[$path] = check_plain($parent->name); + $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/lib/Drupal/views/ViewExecutable.php b/core/modules/views/lib/Drupal/views/ViewExecutable.php index 3246dde..987b4cb 100644 --- a/core/modules/views/lib/Drupal/views/ViewExecutable.php +++ b/core/modules/views/lib/Drupal/views/ViewExecutable.php @@ -1689,7 +1689,9 @@ public function getBreadcrumb($set = FALSE) { if ($set) { if ($base) { - $breadcrumb = array_merge(drupal_get_breadcrumb(), $breadcrumb); + // Just add the frontpage (so the first item of the breadcrumbs). + $existing_breadcrumb = drupal_get_breadcrumb(); + $breadcrumb = array_merge(array($existing_breadcrumb[0]), $breadcrumb); } drupal_set_breadcrumb($breadcrumb); }