diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index b9d8b02..538d6b3 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -676,6 +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]->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 b983cf2..86017f7 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -363,11 +363,13 @@ function editForumVocabulary() { * The created taxonomy term data. */ function createForum($type, $parent = 0) { - // Generate a random name. + // Generate a random name/description. $name = $this->randomName(10); + $description = $this->randomName(100); $edit = array( 'name' => $name, + 'description[value]' => $description, 'parent[0]' => $parent, 'weight' => '0', ); @@ -385,7 +387,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", array(':vid' => \Drupal::config('forum.settings')->get('vocabulary'), ':name' => $name))->fetchAssoc(); + $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'); // Verify forum hierarchy. diff --git a/core/modules/forum/templates/forum-list.html.twig b/core/modules/forum/templates/forum-list.html.twig index fa49dbe..5b41f6a 100644 --- a/core/modules/forum/templates/forum-list.html.twig +++ b/core/modules/forum/templates/forum-list.html.twig @@ -15,6 +15,8 @@ * - 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. @@ -57,6 +59,9 @@ {{ 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/taxonomy/taxonomy.install b/core/modules/taxonomy/taxonomy.install index 7b7799a..99c174b 100644 --- a/core/modules/taxonomy/taxonomy.install +++ b/core/modules/taxonomy/taxonomy.install @@ -7,20 +7,6 @@ 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(). @@ -427,112 +413,3 @@ function taxonomy_update_8010() { ); db_change_field('taxonomy_term_data', 'format', 'description__format', $format); } - -/** - * Create new field for term descriptions. - */ -function taxonomy_update_8011() { - $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_8012(&$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(); - } - - if ($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_8013() { - 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 92f74dc..27ca966 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -950,54 +950,3 @@ 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/profiles/standard/standard.install b/core/profiles/standard/standard.install index 56a5dd6..8718567 100644 --- a/core/profiles/standard/standard.install +++ b/core/profiles/standard/standard.install @@ -81,11 +81,4 @@ 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 34c7215..30c61a2 100644 --- a/core/scripts/generate-d7-content.sh +++ b/core/scripts/generate-d7-content.sh @@ -141,7 +141,6 @@ 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.