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 ca31aae..890f3b5 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 @@ -264,6 +264,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/forum.module b/core/modules/forum/forum.module index e860181..67db413 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -677,7 +677,6 @@ 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]->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 81d8d82..c2c3bef 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -360,13 +360,11 @@ function editForumVocabulary() { * The created taxonomy term data. */ function createForum($type, $parent = 0) { - // Generate a random name/description. + // Generate a random name. $name = $this->randomName(10); - $description = $this->randomName(100); $edit = array( 'name' => $name, - 'description[value]' => $description, 'parent[0]' => $parent, 'weight' => '0', ); @@ -384,7 +382,7 @@ 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 = :desc", array(':vid' => \Drupal::config('forum.settings')->get('vocabulary'), ':name' => $name, ':desc' => $description))->fetchAssoc(); + $term = db_query("SELECT * FROM {taxonomy_term_data} t WHERE t.vid = :vid AND t.name = :name", array(':vid' => \Drupal::config('forum.settings')->get('vocabulary'), ':name' => $name))->fetchAssoc(); $this->assertTrue(!empty($term), 'The ' . $type . ' exists in the database'); // Verify forum hierarchy. diff --git a/core/modules/forum/templates/forum-list.html.twig b/core/modules/forum/templates/forum-list.html.twig index 5b41f6a..fa49dbe 100644 --- a/core/modules/forum/templates/forum-list.html.twig +++ b/core/modules/forum/templates/forum-list.html.twig @@ -15,8 +15,6 @@ * - icon_title: Text alternative for the forum icon. * - name: The name of the forum. * - link: The URL to link to this forum. - * - description: The description field for the forum, containing: - * - value: The descriptive text for the forum. * - new_topics: A flag indicating if the forum contains unread posts. * - new_url: A URL to the forum's unread posts. * - new_text: Text for the above URL, which tells how many new posts. @@ -59,9 +57,6 @@ {{ forum.icon_title }}
{{ forum.label }}
- {% if forum.description.value %} -
{{ forum.description.value }}
- {% endif %} {% for i in 1..forum.depth if forum.depth > 0 %}{% endfor %} {% if forum.is_container == false %} 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/system/lib/Drupal/system/Tests/Upgrade/TaxonomyUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/TaxonomyUpgradePathTest.php new file mode 100644 index 0000000..ae9d4ab --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/TaxonomyUpgradePathTest.php @@ -0,0 +1,62 @@ + 'Taxonomy upgrade test', + 'description' => 'Taxonomy vocabulary and term upgrade tests.', + 'group' => 'Upgrade path', + ); + } + + public function setUp() { + $this->databaseDumpFiles = array( + drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.bare.standard_all.database.php.gz', + drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.taxonomy.database.php', + ); + parent::setUp(); + } + + /** + * Tests taxonomy description conversions after a successful upgrade. + */ + public function testTaxonomyUpgrade() { + $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); + + // Check the tags vocabulary. + $vocabulary = taxonomy_vocabulary_load('tags'); + $this->assertEqual($vocabulary->label(), 'Tags'); + $this->assertEqual($vocabulary->description, 'Use tags to group articles on similar topics into categories.'); + $this->assertTrue($vocabulary->uuid()); + + // Load the two prepared terms and assert them. + $term1 = taxonomy_term_load(5); + $this->assertEqual($term1->label(), 'A tag'); + $this->assertEqual($term1->vid->value, 'tags'); + $this->assertEqual($term1->bundle(), 'tags'); + $this->assertEqual($term1->description->value, 'Description of a tag'); + $this->assertEqual($term1->description->format, 'plain_text'); + + $term2 = taxonomy_term_load(6); + $this->assertEqual($term2->label(), 'Another tag'); + $this->assertEqual($term2->vid->value, 'tags'); + $this->assertEqual($term2->bundle(), 'tags'); + $this->assertEqual($term2->description->value, 'HTML Description'); + $this->assertEqual($term2->description->format, 'filtered_html'); + } + +} diff --git a/core/modules/system/tests/upgrade/drupal-7.taxonomy.database.php b/core/modules/system/tests/upgrade/drupal-7.taxonomy.database.php new file mode 100644 index 0000000..e22261c --- /dev/null +++ b/core/modules/system/tests/upgrade/drupal-7.taxonomy.database.php @@ -0,0 +1,32 @@ +fields(array('tid', 'vid', 'name', 'description', 'format', 'weight')) + ->values(array( + 'tid' => 5, + 'vid' => 1, + 'name' => 'A tag', + 'description' => 'Description of a tag', + 'format' => 'plain_text', + 'weight' => 10, + )) + ->values(array( + 'tid' => 6, + 'vid' => 1, + 'name' => 'Another tag', + 'description' => 'HTML Description', + 'format' => 'filtered_html', + 'weight' => 20, + )) + ->execute(); 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 033c5f1..5e065cb 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php @@ -84,20 +84,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 @@ -227,17 +213,6 @@ public static function baseFieldDefinitions($entity_type) { 'description' => t('The term name.'), 'type' => 'string_field', ); - $properties['description'] = array( - 'label' => t('Description'), - 'description' => t('A description of the term'), - 'type' => 'string_field', - ); - // @todo Combine with description. - $properties['format'] = array( - 'label' => t('Description format'), - 'description' => t('The filter format ID of the description.'), - 'type' => 'string_field', - ); $properties['weight'] = array( 'label' => t('Weight'), 'description' => t('The weight of this term in relation to other terms.'), diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php index fe6669b..f0b9776 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php @@ -106,6 +106,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $ if (!$update) { entity_invoke_bundle_hook('create', 'taxonomy_term', $this->id()); + taxonomy_add_description_field($this, 'Description'); } elseif ($this->getOriginalID() != $this->id()) { // Reflect machine name changes in the definitions of existing 'taxonomy' diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php index 8821b09..72745d8 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php @@ -75,13 +75,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->format->value, - '#weight' => 0, - ); $language_configuration = $this->moduleHandler->moduleExists('language') ? language_get_default_configuration('taxonomy_term', $vocabulary->id()) : FALSE; $form['langcode'] = array( '#type' => 'language_select', @@ -179,12 +172,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->format->value = $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 6e91524..2d910dc 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermViewBuilder.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermViewBuilder.php @@ -18,25 +18,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. - $display = $displays[$entity->bundle()]; - if (!empty($entity->description->value) && $display->getComponent('description')) { - $entity->content['description'] = array( - '#markup' => check_markup($entity->description->value, $entity->format->value, '', TRUE), - '#prefix' => '
', - '#suffix' => '
', - ); - } - } - } - - /** - * {@inheritdoc} + * Overrides \Drupal\Core\Entity\EntityViewBuilder::getBuildDefaults(). */ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) { $return = parent::getBuildDefaults($entity, $view_mode, $langcode); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php index 4ae4823..0e380ee 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php @@ -51,13 +51,8 @@ function createVocabulary() { * Returns a new term with random properties in vocabulary $vid. */ function createTerm($vocabulary) { - $filter_formats = filter_formats(); - $format = array_pop($filter_formats); $term = entity_create('taxonomy_term', array( 'name' => $this->randomName(), - 'description' => $this->randomName(), - // Use the first available text format. - 'format' => $format->format, 'vid' => $vocabulary->id(), 'langcode' => Language::LANGCODE_NOT_SPECIFIED, )); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php index 26f04ad..e35c4e9 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -291,7 +291,6 @@ function testTermAutocompletion() { function testTermInterface() { $edit = array( 'name' => $this->randomName(12), - 'description[value]' => $this->randomName(100), ); // Explicitly set the parents field to 'root', to ensure that // TermFormController::save() handles the invalid term ID correctly. @@ -313,11 +312,9 @@ function testTermInterface() { $this->clickLink(t('edit')); $this->assertRaw($edit['name'], 'The randomly generated term name is present.'); - $this->assertText($edit['description[value]'], 'The randomly generated term description is present.'); $edit = array( 'name' => $this->randomName(14), - 'description[value]' => $this->randomName(102), ); // Edit the term. @@ -335,15 +332,6 @@ function testTermInterface() { // View the term and check that it is correct. $this->drupalGet('taxonomy/term/' . $term->id()); $this->assertText($edit['name'], 'The randomly generated term name is present.'); - $this->assertText($edit['description[value]'], 'The randomly generated term description is present.'); - - // Did this page request display a 'term-listing-heading'? - $this->assertPattern('|class="taxonomy-term-description"|', 'Term page displayed the term description element.'); - // Check that it does NOT show a description when description is blank. - $term->description = ''; - $term->save(); - $this->drupalGet('taxonomy/term/' . $term->id()); - $this->assertNoPattern('|class="taxonomy-term-description"|', 'Term page did not display the term description when description was blank.'); // Check that the term feed page is working. $this->drupalGet('taxonomy/term/' . $term->id() . '/feed'); @@ -426,7 +414,6 @@ function testTermMultipleParentsInterface() { // Add a new term with multiple parents. $edit = array( 'name' => $this->randomName(12), - 'description[value]' => $this->randomName(100), 'parent[]' => array(0, $parent->id()), ); // Save the new term. @@ -437,7 +424,6 @@ function testTermMultipleParentsInterface() { $term = reset($terms); $this->assertNotNull($term, 'Term found in database.'); $this->assertEqual($edit['name'], $term->label(), 'Term name was successfully saved.'); - $this->assertEqual($edit['description[value]'], $term->description->value, 'Term description was successfully saved.'); // Check that the parent tid is still there. The other parent () is // not added by taxonomy_term_load_parents(). $parents = taxonomy_term_load_parents($term->id()); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php index be4ed53..5ceb4f0 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php @@ -88,7 +88,6 @@ function testTaxonomyTokenReplacement() { $tests = array(); $tests['[term:tid]'] = $term1->id(); $tests['[term:name]'] = check_plain($term1->name->value); - $tests['[term:description]'] = check_markup($term1->description->value, $term1->format->value); $tests['[term:url]'] = url('taxonomy/term/' . $term1->id(), array('absolute' => TRUE)); $tests['[term:node-count]'] = 0; $tests['[term:parent:name]'] = '[term:parent:name]'; @@ -103,7 +102,6 @@ function testTaxonomyTokenReplacement() { $tests = array(); $tests['[term:tid]'] = $term2->id(); $tests['[term:name]'] = check_plain($term2->name->value); - $tests['[term:description]'] = check_markup($term2->description->value, $term2->format->value); $tests['[term:url]'] = url('taxonomy/term/' . $term2->id(), array('absolute' => TRUE)); $tests['[term:node-count]'] = 1; $tests['[term:parent:name]'] = check_plain($term1->name->value); @@ -121,7 +119,6 @@ function testTaxonomyTokenReplacement() { // Generate and test unsanitized tokens. $tests['[term:name]'] = $term2->name->value; - $tests['[term:description]'] = $term2->description->value; $tests['[term:parent:name]'] = $term1->name->value; $tests['[term:vocabulary:name]'] = $this->vocabulary->name; diff --git a/core/modules/taxonomy/taxonomy.install b/core/modules/taxonomy/taxonomy.install index 845a44e..af12894 100644 --- a/core/modules/taxonomy/taxonomy.install +++ b/core/modules/taxonomy/taxonomy.install @@ -7,6 +7,20 @@ use Drupal\Core\Entity\FieldableDatabaseStorageController; use Drupal\field\Entity\Field; +use Drupal\Component\Uuid\Uuid; +use Drupal\Core\Language\Language; + +/** + * Implements hook_uninstall(). + */ +function taxonomy_uninstall() { + // Remove taxonomy_term bundles. + $config_names = config_get_storage_names_with_prefix('taxonomy.vocabulary.'); + foreach ($config_names as $config_name) { + $vid = substr($config_name, strlen('taxonomy.vocabulary.')); + entity_invoke_bundle_hook('delete', 'taxonomy_term', $vid); + } +} /** * Implements hook_schema(). @@ -48,18 +62,6 @@ function taxonomy_schema() { 'default' => '', 'description' => 'The term name.', ), - 'description' => array( - 'type' => 'text', - 'not null' => FALSE, - 'size' => 'big', - 'description' => 'A description of the term.', - ), - 'format' => array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => FALSE, - 'description' => 'The filter format ID of the description.', - ), 'weight' => array( 'type' => 'int', 'not null' => TRUE, @@ -396,3 +398,112 @@ function taxonomy_update_8008() { ); db_add_field('taxonomy_term_data', 'changed', $spec); } + +/** + * Create new field for term descriptions. + */ +function taxonomy_update_8009() { + $vocabularies = config_get_storage_names_with_prefix('taxonomy.vocabulary.'); + if (count($vocabularies)) { + // Create a new term description field. + $field = array( + 'name' => 'description', + 'entity_type' => 'taxonomy_term', + 'module' => 'text', + 'type' => 'text_long', + 'cardinality' => 1, + 'locked' => FALSE, + 'schema' => array( + 'columns' => array( + 'value' => array( + 'type' => 'text', + 'size' => 'big', + 'not null' => FALSE, + ), + 'format' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), + ), + 'foreign keys' => array( + 'format' => array( + 'table' => 'filter_format', + 'columns' => array('format' => 'format'), + ), + ), + 'indexes' => array(), + ), + ); + _update_8003_field_create_field($field); + + // Create instances for existing vocabularies. + foreach ($vocabularies as $vocabulary) { + $vocabulary = substr($vocabulary, drupal_strlen('taxonomy.vocabulary.')); + // Attaches the description field to each bundle. + $instance = array( + 'label' => 'Description', + 'description' => '', + 'entity_type' => 'taxonomy_term', + 'name' => 'description', + 'bundle' => $vocabulary, + 'required' => FALSE, + 'settings' => array('text_processing' => 1), + ); + _update_8003_field_create_instance($field, $instance); + } + } +} + +/** + * Move term descriptions in {term_data}.description into new field. + */ +function taxonomy_update_8010(&$sandbox) { + if (!isset($sandbox['progress'])) { + $sandbox['progress'] = 0; + $sandbox['current_tid'] = 0; + $sandbox['max'] = db_query('SELECT COUNT(DISTINCT tid) FROM {taxonomy_term_data} WHERE vid > 0')->fetchField(); + } + + $terms = db_query_range('SELECT t.tid, t.description, t.format, t.vid FROM {taxonomy_term_data} t WHERE tid > :tid ORDER BY tid ASC', 0, 100, array(':tid' => $sandbox['current_tid'])); + + $data = db_insert('taxonomy_term__description') + ->fields(array('bundle', 'entity_id', 'revision_id', 'langcode', 'delta', 'description_value', 'description_format')); + $revision = db_insert('taxonomy_term_revision__description') + ->fields(array('bundle', 'entity_id', 'revision_id', 'langcode', 'delta', 'description_value', 'description_format')); + foreach ($terms as $term) { + $data->values(array( + 'bundle' => $term->vid, + 'entity_id' => $term->tid, + 'revision_id' => $term->tid, + 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'delta' => 0, + 'description_value' => $term->description, + 'description_format' => $term->format, + )); + $revision->fields(array( + 'bundle' => $term->vid, + 'entity_id' => $term->tid, + 'revision_id' => $term->tid, + 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + 'delta' => 0, + 'description_value' => $term->description, + 'description_format' => $term->format, + )); + $sandbox['progress']++; + $sandbox['current_tid'] = $term->tid; + } + + $data->execute(); + $revision->execute(); + + $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']); +} + +/** + * Remove {term_data}.description and {term_data}.format. + */ +function taxonomy_update_8011() { + db_drop_field('taxonomy_term_data', 'description'); + db_drop_field('taxonomy_term_data', 'format'); +} diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 6aa3179..68bed3b 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -145,18 +145,6 @@ function taxonomy_field_extra_fields() { 'description' => t('Term name textfield'), 'weight' => -5, ), - 'description' => array( - 'label' => t('Description'), - 'description' => t('Term description textarea'), - 'weight' => 0, - ), - ), - 'display' => array( - 'description' => array( - 'label' => t('Description'), - 'description' => t('Term description'), - 'weight' => 0, - ), ), ); } @@ -1199,3 +1187,54 @@ function taxonomy_library_info() { return $libraries; } + +/** + * Adds the default description field to a taxonomy term type. + * + * @param \Drupal\taxonomy\VocabularyInterface $type + * A vocabulary type object. + * @param $label + * (Optional) The label for the description instance. + * @return + * A description field instance. + */ +function taxonomy_add_description_field(VocabularyInterface $type, $label = 'Description') { + // Add the description field as needed. + $field = field_info_field('taxonomy_term', 'description'); + $instance = field_info_instance('taxonomy_term', 'description', $type->id()); + + if (empty($field)) { + $field = entity_create('field_entity', array( + 'name' => 'description', + 'entity_type' => 'taxonomy_term', + 'type' => 'text_long', + )); + $field->save(); + } + if (empty($instance)) { + $instance = entity_create('field_instance', array( + 'field_name' => 'description', + 'entity_type' => 'taxonomy_term', + 'bundle' => $type->id(), + 'label' => $label, + 'settings' => array('text_processing' => 1), + )); + $instance->save(); + + entity_get_form_display('taxonomy_term', $type->id(), 'default') + ->setComponent('description', array( + 'type' => 'text_long', + )) + ->save(); + + // Assign display settings for the 'default' and 'teaser' view modes. + entity_get_display('taxonomy_term', $type->id(), 'default') + ->setComponent('description', array( + 'label' => 'hidden', + 'type' => 'text_default', + )) + ->save(); + } + + return $instance; +} \ No newline at end of file diff --git a/core/modules/taxonomy/taxonomy.pages.inc b/core/modules/taxonomy/taxonomy.pages.inc index fb88184..d3574b3 100644 --- a/core/modules/taxonomy/taxonomy.pages.inc +++ b/core/modules/taxonomy/taxonomy.pages.inc @@ -62,9 +62,6 @@ function taxonomy_term_page(Term $term) { function taxonomy_term_feed(Term $term) { $channel['link'] = url('taxonomy/term/' . $term->id(), array('absolute' => TRUE)); $channel['title'] = \Drupal::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, \Drupal::config('system.rss')->get('items.limit')); return node_feed($nids, $channel); diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc index ad0a1d4..de5d486 100644 --- a/core/modules/taxonomy/taxonomy.tokens.inc +++ b/core/modules/taxonomy/taxonomy.tokens.inc @@ -29,10 +29,6 @@ function taxonomy_token_info() { 'name' => t("Name"), 'description' => t("The name of the taxonomy term."), ); - $term['description'] = array( - 'name' => t("Description"), - 'description' => t("The optional description of the taxonomy term."), - ); $term['node-count'] = array( 'name' => t("Node count"), 'description' => t("The number of nodes tagged with the taxonomy term."), @@ -107,10 +103,6 @@ function taxonomy_tokens($type, $tokens, array $data = array(), array $options = $replacements[$original] = $sanitize ? check_plain($term->name->value) : $term->name->value; break; - case 'description': - $replacements[$original] = $sanitize ? check_markup($term->description->value, $term->format->value, '', TRUE) : $term->description->value; - break; - case 'url': $uri = $term->uri(); $replacements[$original] = url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE))); diff --git a/core/modules/taxonomy/taxonomy.views.inc b/core/modules/taxonomy/taxonomy.views.inc index 001c125..53e5c37 100644 --- a/core/modules/taxonomy/taxonomy.views.inc +++ b/core/modules/taxonomy/taxonomy.views.inc @@ -129,20 +129,6 @@ function taxonomy_views_data() { ), ); - // Term description - $data['taxonomy_term_data']['description'] = array( - 'title' => t('Term description'), - 'help' => t('The description associated with a taxonomy term.'), - 'field' => array( - 'id' => 'markup', - 'format' => array('field' => 'format'), - 'click sortable' => FALSE, - ), - 'filter' => array( - 'id' => 'string', - ), - ); - // Term vocabulary $data['taxonomy_term_data']['vid'] = array( 'title' => t('Vocabulary'), diff --git a/core/modules/taxonomy/templates/taxonomy-term.html.twig b/core/modules/taxonomy/templates/taxonomy-term.html.twig index a3986fa..3a834a6 100644 --- a/core/modules/taxonomy/templates/taxonomy-term.html.twig +++ b/core/modules/taxonomy/templates/taxonomy-term.html.twig @@ -6,7 +6,7 @@ * Available variables: * - url: URL of the current term. * - name: Name of the current term. - * - content: Items for the content of the term (fields and description). + * - content: Items for the content of the term fields. * Use 'content' to print them all, or print a subset such as * 'content.description'. Use the following code to temporarily suppress the * printing of a given element: diff --git a/core/profiles/standard/config/entity.form_display.taxonomy_term.tags.default.yml b/core/profiles/standard/config/entity.form_display.taxonomy_term.tags.default.yml new file mode 100644 index 0000000..2ff493b --- /dev/null +++ b/core/profiles/standard/config/entity.form_display.taxonomy_term.tags.default.yml @@ -0,0 +1,13 @@ +id: taxonomy_term.tags.default +uuid: db7383e4-7317-432c-a200-c5a87b55667b +targetEntityType: taxonomy_term +bundle: tags +mode: default +content: + description: + type: text_textarea + weight: 0 + settings: + rows: '5' + placeholder: '' +status: true diff --git a/core/profiles/standard/config/field.field.taxonomy_term.description.yml b/core/profiles/standard/config/field.field.taxonomy_term.description.yml new file mode 100644 index 0000000..51f5807 --- /dev/null +++ b/core/profiles/standard/config/field.field.taxonomy_term.description.yml @@ -0,0 +1,14 @@ +id: taxonomy_term.description +uuid: 132ab84f-764f-41ca-bc0c-12a16c85742a +status: true +langcode: en +name: description +entity_type: taxonomy_term +type: text_long +settings: { } +module: text +active: true +locked: false +cardinality: '1' +translatable: false +indexes: { } diff --git a/core/profiles/standard/config/field.instance.taxonomy_term.tags.description.yml b/core/profiles/standard/config/field.instance.taxonomy_term.tags.description.yml new file mode 100644 index 0000000..48e3b1e --- /dev/null +++ b/core/profiles/standard/config/field.instance.taxonomy_term.tags.description.yml @@ -0,0 +1,15 @@ +id: taxonomy_term.tags.description +uuid: d371ade7-286e-4504-8500-ce084609168e +status: true +langcode: en +field_uuid: 132ab84f-764f-41ca-bc0c-12a16c85742a +entity_type: taxonomy_term +bundle: tags +label: Description +description: '' +required: 0 +default_value: { } +default_value_function: '' +settings: + text_processing: '1' +field_type: text_long diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install index 5aa1dd7..082a619 100644 --- a/core/profiles/standard/standard.install +++ b/core/profiles/standard/standard.install @@ -86,4 +86,11 @@ function standard_install() { theme_enable(array('seven')); \Drupal::config('system.theme')->set('admin', 'seven')->save(); \Drupal::config('node.settings')->set('use_admin_theme', '1')->save(); + + // Configure the widget for the taxonomy term description field. + entity_get_form_display('taxonomy_term', 'tags', 'default') + ->setComponent('taxonomy_term_description', array( + 'type' => 'text_textarea', + )) + ->save(); } diff --git a/core/scripts/generate-d7-content.sh b/core/scripts/generate-d7-content.sh index bd24300..b007505 100644 --- a/core/scripts/generate-d7-content.sh +++ b/core/scripts/generate-d7-content.sh @@ -141,6 +141,7 @@ for ($j = 0; $j < $vocabulary->hierarchy + 1; $j++) { ++$term_id; $term = entity_create('taxonomy_term', array( + 'vid' => $voc_id, 'vocabulary_machine_name' => $vocabulary->machine_name, // For multiple parent vocabularies, omit the t0-t1 relation, otherwise // every parent in the vocabulary is a parent.