diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php index b1fb656..6e48d26 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php @@ -269,6 +269,13 @@ function testNonInitializedFields() { * Tests hiding the view modes fieldset when there's only one available. */ function testSingleViewMode() { + // Create a test field. + $edit = array( + 'fields[_add_new_field][label]' => 'Test', + 'fields[_add_new_field][field_name]' => 'test', + ); + $this->fieldUIAddNewField('admin/structure/taxonomy/manage/' . $this->vocabulary, $edit); + $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary . '/display'); $this->assertNoText('Use custom display settings for the following view modes', 'Custom display settings fieldset found.'); diff --git a/core/modules/forum/config/entity.form_display.taxonomy_term.forums.default.yml b/core/modules/forum/config/entity.form_display.taxonomy_term.forums.default.yml index b3d15bf..e59af25 100644 --- a/core/modules/forum/config/entity.form_display.taxonomy_term.forums.default.yml +++ b/core/modules/forum/config/entity.form_display.taxonomy_term.forums.default.yml @@ -7,5 +7,9 @@ status: true content: name: weight: -5 - description: - weight: 0 + forum_description: + type: text_textarea + weight: '1' + settings: + rows: '5' + placeholder: '' diff --git a/core/modules/forum/config/field.field.taxonomy_term.forum_description.yml b/core/modules/forum/config/field.field.taxonomy_term.forum_description.yml new file mode 100644 index 0000000..166c994 --- /dev/null +++ b/core/modules/forum/config/field.field.taxonomy_term.forum_description.yml @@ -0,0 +1,13 @@ +id: taxonomy_term.forum_description +uuid: 19f95967-fe48-4f52-8e36-546303f4d589 +status: true +langcode: en +name: forum_description +entity_type: taxonomy_term +type: text_long +settings: { } +module: text +locked: false +cardinality: 1 +translatable: false +indexes: { } diff --git a/core/modules/forum/config/field.instance.taxonomy_term.forums.forum_description.yml b/core/modules/forum/config/field.instance.taxonomy_term.forums.forum_description.yml new file mode 100644 index 0000000..f5bfcac --- /dev/null +++ b/core/modules/forum/config/field.instance.taxonomy_term.forums.forum_description.yml @@ -0,0 +1,16 @@ +id: taxonomy_term.forums.forum_description +uuid: 4b8963a1-63f5-48d3-9600-a718cca6ea8f +status: true +langcode: en +field_uuid: 19f95967-fe48-4f52-8e36-546303f4d589 +field_name: forum_description +entity_type: taxonomy_term +bundle: forums +label: Description +description: '' +required: false +default_value: { } +default_value_function: '' +settings: + text_processing: '1' +field_type: text_long diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 538d6b3..01c1555 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -676,7 +676,7 @@ function template_preprocess_forum_list(&$variables) { $row = 0; // Sanitize each forum so that the template can safely print the data. foreach ($variables['forums'] as $id => $forum) { - $variables['forums'][$id]->description = filter_xss_admin($forum->description->value); + $variables['forums'][$id]->description = filter_xss_admin($forum->forum_description->value); $variables['forums'][$id]->link = url("forum/" . $forum->id()); $variables['forums'][$id]->name = check_plain($forum->label()); $variables['forums'][$id]->is_container = !empty($forum->forum_container->value); diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php index 86017f7..9178b26 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -43,17 +43,17 @@ class ForumTest extends WebTestBase { protected $web_user; /** - * An array representing a forum container. + * A taxonomy term representing a forum container. */ protected $forumContainer; /** - * An array representing a forum. + * A taxonomy term representing a forum. */ protected $forum; /** - * An array representing a root forum. + * A taxonomy term representing a root forum. */ protected $root_forum; @@ -124,7 +124,7 @@ function testForum() { // active forum topics list. $this->drupalLogin($this->web_user); // Verify that this user is shown a message that they may not post content. - $this->drupalGet('forum/' . $this->forum['tid']); + $this->drupalGet('forum/' . $this->forum->id()); $this->assertText(t('You are not allowed to post new content in the forum'), "Authenticated user without permission to post forum content is shown message in local tasks to that effect."); @@ -145,7 +145,7 @@ function testForum() { // Verify that this user is shown a local task to add new forum content. $this->drupalGet('forum'); $this->assertLink(t('Add new Forum topic')); - $this->drupalGet('forum/' . $this->forum['tid']); + $this->drupalGet('forum/' . $this->forum->id()); $this->assertLink(t('Add new Forum topic')); // Login a user with permission to edit any forum content. @@ -157,7 +157,7 @@ function testForum() { $this->drupalGet('forum'); // Verify row for testing forum. - $forum_arg = array(':forum' => 'forum-list-' . $this->forum['tid']); + $forum_arg = array(':forum' => 'forum-list-' . $this->forum->id()); // Topics cell contains number of topics and number of unread topics. $xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="topics"]', $forum_arg); @@ -166,13 +166,13 @@ function testForum() { $this->assertEqual($topics, '6', 'Number of topics found.'); // Verify the number of unread topics. - $unread_topics = $this->container->get('forum_manager')->unreadTopics($this->forum['tid'], $this->edit_any_topics_user->id()); + $unread_topics = $this->container->get('forum_manager')->unreadTopics($this->forum->id(), $this->edit_any_topics_user->id()); $unread_topics = format_plural($unread_topics, '1 new post', '@count new posts'); $xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="topics"]//a', $forum_arg); $this->assertFieldByXPath($xpath, $unread_topics, 'Number of unread topics found.'); // Verify that the forum name is in the unread topics text. $xpath = $this->buildXPathQuery('//tr[@id=:forum]//em[@class="placeholder"]', $forum_arg); - $this->assertFieldByXpath($xpath, $this->forum['name'], 'Forum name found in unread topics text.'); + $this->assertFieldByXpath($xpath, $this->forum->label(), 'Forum name found in unread topics text.'); // Verify total number of posts in forum. $xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="posts"]', $forum_arg); @@ -194,14 +194,14 @@ function testForum() { // Test editing a forum topic that has a comment. $this->drupalLogin($this->edit_any_topics_user); - $this->drupalGet('forum/' . $this->forum['tid']); + $this->drupalGet('forum/' . $this->forum->id()); $this->drupalPostForm('node/' . $node->id() . '/edit', array(), t('Save')); $this->assertResponse(200); // Test the root forum page title change. $this->drupalGet('forum'); $this->assertTitle(t('Forums | Drupal')); - $vocabulary = entity_load('taxonomy_vocabulary', $this->forum['vid']); + $vocabulary = entity_load('taxonomy_vocabulary', $this->forum->vid->value); $vocabulary->set('name', 'Discussions'); $vocabulary->save(); $this->drupalGet('forum'); @@ -266,7 +266,7 @@ private function doAdminTests($user) { $this->clickLink('edit container'); $this->assertRaw('Edit container', 'Followed the link to edit the container'); // Create forum inside the forum container. - $this->forum = $this->createForum('forum', $this->forumContainer['tid']); + $this->forum = $this->createForum('forum', $this->forumContainer->id()); // Verify the "edit forum" link exists and functions correctly. $this->drupalGet('admin/structure/forum'); $this->clickLink('edit forum'); @@ -274,12 +274,12 @@ private function doAdminTests($user) { // Navigate back to forum structure page. $this->drupalGet('admin/structure/forum'); // Create second forum in container. - $this->delete_forum = $this->createForum('forum', $this->forumContainer['tid']); + $this->delete_forum = $this->createForum('forum', $this->forumContainer->id()); // Save forum overview. $this->drupalPostForm('admin/structure/forum/', array(), t('Save')); $this->assertRaw(t('The configuration options have been saved.')); // Delete this second forum. - $this->deleteForum($this->delete_forum['tid']); + $this->deleteForum($this->delete_forum->id()); // Create forum at the top (root) level. $this->root_forum = $this->createForum('forum'); @@ -289,7 +289,7 @@ private function doAdminTests($user) { $this->assertNoFieldByName('op', t('Delete'), 'Delete button not found.'); // Test term edit form alterations. - $this->drupalGet('taxonomy/term/' . $this->forumContainer['tid'] . '/edit'); + $this->drupalGet('taxonomy/term/' . $this->forumContainer->id() . '/edit'); // Test parent field been hidden by forum module. $this->assertNoField('parent[]', 'Parent field not found.'); @@ -369,7 +369,7 @@ function createForum($type, $parent = 0) { $edit = array( 'name' => $name, - 'description[value]' => $description, + 'forum_description[0][value]' => $description, 'parent[0]' => $parent, 'weight' => '0', ); @@ -387,11 +387,15 @@ function createForum($type, $parent = 0) { ); // Verify forum. - $term = db_query("SELECT * FROM {taxonomy_term_data} t WHERE t.vid = :vid AND t.name = :name AND t.description__value = :desc", array(':vid' => \Drupal::config('forum.settings')->get('vocabulary'), ':name' => $name, ':desc' => $description))->fetchAssoc(); - $this->assertTrue(!empty($term), 'The ' . $type . ' exists in the database'); + $tids = \Drupal::service('entity.query')->get('taxonomy_term') + ->condition('vid', \Drupal::config('forum.settings')->get('vocabulary')) + ->condition('forum_description', $description) + ->execute(); + $tid = reset($tids); + $this->assertTrue(!empty($tid), 'The ' . $type . ' exists in the database'); // Verify forum hierarchy. - $tid = $term['tid']; + $term = entity_load('taxonomy_term', $tid); $parent_tid = db_query("SELECT t.parent FROM {taxonomy_term_hierarchy} t WHERE t.tid = :tid", array(':tid' => $tid))->fetchField(); $this->assertTrue($parent == $parent_tid, 'The ' . $type . ' is linked to its container'); @@ -463,7 +467,7 @@ function testForumWithNewPost() { // Login as the first user. $this->drupalLogin($this->admin_user); // Check that forum renders properly. - $this->drupalGet("forum/{$this->forum['tid']}"); + $this->drupalGet("forum/{$this->forum->id()}"); $this->assertResponse(200); } @@ -487,7 +491,7 @@ function createForumTopic($forum, $container = FALSE) { 'title[0][value]' => $title, 'body[0][value]' => $body, ); - $tid = $forum['tid']; + $tid = $forum->id(); // Create the forum topic, preselecting the forum ID via a URL parameter. $this->drupalPostForm('node/add/forum', $edit, t('Save'), array('query' => array('forum_id' => $tid))); @@ -495,12 +499,12 @@ function createForumTopic($forum, $container = FALSE) { $type = t('Forum topic'); if ($container) { $this->assertNoRaw(t('@type %title has been created.', array('@type' => $type, '%title' => $title)), 'Forum topic was not created'); - $this->assertRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum['name'])), 'Error message was shown'); + $this->assertRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum->label())), 'Error message was shown'); return; } else { $this->assertRaw(t('@type %title has been created.', array('@type' => $type, '%title' => $title)), 'Forum topic was created'); - $this->assertNoRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum['name'])), 'No error message was shown'); + $this->assertNoRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum->label())), 'No error message was shown'); } // Retrieve node object, ensure that the topic was created and in the proper forum. @@ -551,8 +555,8 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) { $breadcrumb_build = array( l(t('Home'), NULL), l(t('Forums'), 'forum'), - l($this->forumContainer['name'], 'forum/' . $this->forumContainer['tid']), - l($this->forum['name'], 'forum/' . $this->forum['tid']), + l($this->forumContainer->label(), 'forum/' . $this->forumContainer->id()), + l($this->forum->label(), 'forum/' . $this->forum->id()), ); $breadcrumb = array( '#theme' => 'breadcrumb', @@ -573,7 +577,7 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) { $edit['title[0][value]'] = 'node/' . $node->id(); $edit['body[0][value]'] = $this->randomName(256); // Assume the topic is initially associated with $forum. - $edit['taxonomy_forums'] = $this->root_forum['tid']; + $edit['taxonomy_forums'] = $this->root_forum->id(); $edit['shadow'] = TRUE; $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->assertRaw(t('Forum topic %title has been updated.', array('%title' => $edit['title[0][value]'])), 'Forum node was edited'); @@ -583,7 +587,7 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) { ':nid' => $node->id(), ':vid' => $node->getRevisionId(), ))->fetchField(); - $this->assertTrue($forum_tid == $this->root_forum['tid'], 'The forum topic is linked to a different forum'); + $this->assertTrue($forum_tid == $this->root_forum->id(), 'The forum topic is linked to a different forum'); // Delete forum node. $this->drupalPostForm('node/' . $node->id() . '/delete', array(), t('Delete')); @@ -602,16 +606,16 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) { */ private function verifyForumView($forum, $parent = NULL) { // View forum page. - $this->drupalGet('forum/' . $forum['tid']); + $this->drupalGet('forum/' . $forum->id()); $this->assertResponse(200); - $this->assertTitle($forum['name'] . ' | Drupal'); + $this->assertTitle($forum->label() . ' | Drupal'); $breadcrumb_build = array( l(t('Home'), NULL), l(t('Forums'), 'forum'), ); if (isset($parent)) { - $breadcrumb_build[] = l($parent['name'], 'forum/' . $parent['tid']); + $breadcrumb_build[] = l($parent->label(), 'forum/' . $parent->id()); } $breadcrumb = array( diff --git a/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php b/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php index c483d9e..fb448b3 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php @@ -48,10 +48,8 @@ function setUp() { function testTermAlias() { // Create a term in the default 'Tags' vocabulary with URL alias. $vocabulary = entity_load('taxonomy_vocabulary', 'tags'); - $description = $this->randomName(); $edit = array( 'name' => $this->randomName(), - 'description[value]' => $description, 'path[alias]' => $this->randomName(), ); $this->drupalPostForm('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add', $edit, t('Save')); @@ -59,7 +57,7 @@ function testTermAlias() { // Confirm that the alias works. $this->drupalGet($edit['path[alias]']); - $this->assertText($description, 'Term can be accessed on URL alias.'); + $this->assertText($edit['name'], 'Term can be accessed on URL alias.'); // Confirm the 'canonical' and 'shortlink' URLs. $elements = $this->xpath("//link[contains(@rel, 'canonical') and contains(@href, '" . $edit['path[alias]'] . "')]"); @@ -74,11 +72,11 @@ function testTermAlias() { // Confirm that the changed alias works. $this->drupalGet($edit2['path[alias]']); - $this->assertText($description, 'Term can be accessed on changed URL alias.'); + $this->assertText($edit['name'], 'Term can be accessed on changed URL alias.'); // Confirm that the old alias no longer works. $this->drupalGet($edit['path[alias]']); - $this->assertNoText($description, 'Old URL alias has been removed after altering.'); + $this->assertNoText($edit['name'], 'Old URL alias has been removed after altering.'); $this->assertResponse(404, 'Old URL alias returns 404.'); // Remove the term's URL alias. @@ -88,7 +86,7 @@ function testTermAlias() { // Confirm that the alias no longer works. $this->drupalGet($edit2['path[alias]']); - $this->assertNoText($description, 'Old URL alias has been removed after altering.'); + $this->assertNoText($edit['name'], 'Old URL alias has been removed after altering.'); $this->assertResponse(404, 'Old URL alias returns 404.'); } } diff --git a/core/modules/taxonomy/css/taxonomy.module.css b/core/modules/taxonomy/css/taxonomy.module.css index 1f80d52..543666a 100644 --- a/core/modules/taxonomy/css/taxonomy.module.css +++ b/core/modules/taxonomy/css/taxonomy.module.css @@ -8,6 +8,3 @@ .taxonomy-term-divider-bottom { border-top: 1px dotted #ccc; } -.taxonomy-term-description { - margin: 5px 0 20px; -} diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php index b28a6d9..d8c7d44 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php @@ -81,20 +81,6 @@ class Term extends ContentEntityBase implements TermInterface { public $name; /** - * Description of the term. - * - * @var \Drupal\Core\Field\FieldItemListInterface - */ - public $description; - - /** - * The text format name for the term's description. - * - * @var \Drupal\Core\Field\FieldItemListInterface - */ - public $format; - - /** * The weight of this term. * * This property stores the weight of this term in relation to other terms of @@ -219,11 +205,6 @@ public static function baseFieldDefinitions($entity_type) { ->setLabel(t('Name')) ->setDescription(t('The term name.')); - $fields['description'] = FieldDefinition::create('text_long') - ->setLabel(t('Description')) - ->setDescription(t('A description of the term.')) - ->setSetting('text_processing', 1); - $fields['weight'] = FieldDefinition::create('integer') ->setLabel(t('Weight')) ->setDescription(t('The weight of this term in relation to other terms.')) diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php index 925d83c..2fba8dc 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php @@ -70,13 +70,6 @@ public function form(array $form, array &$form_state) { '#weight' => -5, ); - $form['description'] = array( - '#type' => 'text_format', - '#title' => $this->t('Description'), - '#default_value' => $term->description->value, - '#format' => $term->description->format, - '#weight' => 0, - ); $language_configuration = $this->moduleHandler->moduleExists('language') ? language_get_default_configuration('taxonomy_term', $vocabulary->id()) : FALSE; $form['langcode'] = array( '#type' => 'language_select', @@ -174,12 +167,6 @@ public function buildEntity(array $form, array &$form_state) { // Prevent leading and trailing spaces in term names. $term->name->value = trim($term->name->value); - // Convert text_format field into values expected by - // \Drupal\Core\Entity\Entity::save() method. - $description = $form_state['values']['description']; - $term->description->value = $description['value']; - $term->description->format = $description['format']; - // Assign parents with proper delta values starting from 0. $term->parent = array_keys($form_state['values']['parent']); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermViewBuilder.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermViewBuilder.php index fbf29ea..048ca6e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermViewBuilder.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermViewBuilder.php @@ -17,28 +17,7 @@ class TermViewBuilder extends EntityViewBuilder { /** - * {@inheritdoc} - */ - public function buildContent(array $entities, array $displays, $view_mode, $langcode = NULL) { - parent::buildContent($entities, $displays, $view_mode, $langcode); - - foreach ($entities as $entity) { - // Add the description if enabled. - // @todo Remove this when base fields are able to use formatters. - // https://drupal.org/node/2144919 - $display = $displays[$entity->bundle()]; - if (!empty($entity->description->value) && $display->getComponent('description')) { - $entity->content['description'] = array( - '#markup' => $entity->description->processed, - '#prefix' => '