diff --git a/core/includes/common.inc b/core/includes/common.inc index d6f9055..5b05285 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3482,12 +3482,6 @@ function drupal_pre_render_link($element) { // By default, link options to pass to l() are normally set in #options. $element += array('#options' => array()); - // The title might be a render array. Render it to pass a string to l(). - if (is_array($element['#title'])) { - $element['#title'] = drupal_render($element['#title']); - $element['#options']['html'] = TRUE; - } - // However, within the scope of renderable elements, #attributes is a valid // way to specify attributes, too. Take them into account, but do not override // attributes from #options. diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php new file mode 100644 index 0000000..95bf3c1 --- /dev/null +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php @@ -0,0 +1,109 @@ + 'Field formatter - taxonomy term reference', + 'description' => 'Tests RDFa output by taxonomy term reference field formatters.', + 'group' => 'RDF', + ); + } + + public function setUp() { + parent::setUp(); + + $vocabulary = entity_create('taxonomy_vocabulary', array( + 'name' => $this->randomName(), + 'vid' => drupal_strtolower($this->randomName()), + 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + )); + $vocabulary->save(); + + entity_create('field_entity', array( + 'field_name' => $this->fieldName, + 'type' => 'taxonomy_term_reference', + 'cardinality' => FIELD_CARDINALITY_UNLIMITED, + 'settings' => array( + 'allowed_values' => array( + array( + 'vocabulary' => $vocabulary->id(), + 'parent' => 0, + ), + ), + ), + ))->save(); + entity_create('field_instance', array( + 'entity_type' => 'node', + 'field_name' => $this->fieldName, + 'bundle' => 'test_node_type', + ))->save(); + $this->term = entity_create('taxonomy_term', array( + 'name' => $this->randomName(), + 'vid' => $vocabulary->id(), + 'langcode' => Language::LANGCODE_NOT_SPECIFIED, + )); + $this->term->save(); + + // Add the mapping. + $mapping = rdf_get_mapping('node', 'test_node_type'); + $mapping->setFieldMapping($this->fieldName, array( + 'properties' => array('schema:about'), + ))->save(); + + // Set up test values. + $this->entity = $this->drupalCreateNode(array('type' => 'test_node_type')); + $this->entity->get($this->fieldName)->offsetGet(0)->get('target_id')->setValue($this->term->id()); + $this->entity->save(); + $this->uri = $this->getAbsoluteUri($this->entity); + } + + /** + * Tests the plain formatter. + */ + public function testPlainFormatter() { + $term_uri = $this->getAbsoluteUri($this->term); + $this->assertFormatterRdfa('taxonomy_term_reference_plain', 'http://schema.org/about', $term_uri, 'uri'); + } + + /** + * Test the link formatter. + */ + public function testLinkFormatter() { + $term_uri = $this->getAbsoluteUri($this->term); + $this->assertFormatterRdfa('taxonomy_term_reference_link', 'http://schema.org/about', $term_uri, 'uri'); + } +} diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsUnitTest.php deleted file mode 100644 index c6300c4..0000000 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsUnitTest.php +++ /dev/null @@ -1,42 +0,0 @@ - 'Theme functions unit test', - 'description' => 'Tests common theme functions.', - 'group' => 'Theme', - ); - } - - /** - * Test the HTML data wrapper. - */ - public function testHtmlDataWrapper() { - $element = array( - '#theme' => 'html_data_wrapper', - '#attributes' => array('itemprop' => 'http://schema.org/name'), - 'children' => array('#markup' => 'test name'), - ); - - $rendered = drupal_render($element); - $expected = 'test name'; - $this->assertEqual($rendered, $expected, 'theme_html_data_wrapper produces expected output'); - } -} diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 0658913..dfa7bf4 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -191,9 +191,6 @@ function system_theme() { 'system_date_format_localize_form' => array( 'render element' => 'form', ), - 'html_data_wrapper' => array( - 'render element' => 'element', - ), )); } @@ -3288,12 +3285,6 @@ function theme_exposed_filters($variables) { return '
' . $output . '
'; } -function theme_html_data_wrapper($variables) { - $element = $variables['element']; - $attributes = new Attribute($element['#attributes']); - return "" . drupal_render_children($element) . ""; -} - /** * Implements hook_admin_paths(). */ diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php index 6ce9e53..cb1a40e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php @@ -50,6 +50,13 @@ public function viewElements(EntityInterface $entity, $langcode, FieldInterface '#href' => $uri['path'], '#options' => $uri['options'], ); + + if (!empty($item->html_data_attributes)) { + if (!isset($elements[$delta]['#options']['attributes'])) { + $elements[$delta]['#options']['attributes'] = array(); + } + $elements[$delta]['#options']['attributes'] += $item->html_data_attributes; + } } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php index a0ed35f..9ab8792 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php @@ -25,6 +25,8 @@ * unsets values for invalid terms that do not exist. */ public function prepareView(array $entities, $langcode, array $items) { + parent::prepareView($entities, $langcode, $items); + $tids = array(); // Collect every possible term attached to any of the fieldable entities. diff --git a/core/modules/text/lib/Drupal/text/Plugin/field/formatter/TextDefaultFormatter.php b/core/modules/text/lib/Drupal/text/Plugin/field/formatter/TextDefaultFormatter.php index 2d77f0f..688c569 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/field/formatter/TextDefaultFormatter.php +++ b/core/modules/text/lib/Drupal/text/Plugin/field/formatter/TextDefaultFormatter.php @@ -48,11 +48,10 @@ public function viewElements(EntityInterface $entity, $langcode, FieldInterface else { // Adds a wrapping element if attributes are specified for this item. $elements[$delta] = array( - '#theme' => 'html_data_wrapper', + '#type' => 'html_tag', + '#tag' => 'div', '#attributes' => $item->html_data_attributes, - 'children' => array( - '#markup' => $output, - ), + '#value' => $output, ); } } diff --git a/core/modules/text/lib/Drupal/text/Plugin/field/formatter/TextPlainFormatter.php b/core/modules/text/lib/Drupal/text/Plugin/field/formatter/TextPlainFormatter.php index 84575ee..c5af4c5 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/field/formatter/TextPlainFormatter.php +++ b/core/modules/text/lib/Drupal/text/Plugin/field/formatter/TextPlainFormatter.php @@ -46,11 +46,10 @@ public function viewElements(EntityInterface $entity, $langcode, FieldInterface else { // Adds a wrapping element if attributes are specified for this item. $elements[$delta] = array( - '#theme' => 'html_data_wrapper', + '#type' => 'html_tag', + '#tag' => 'span', '#attributes' => $item->html_data_attributes, - 'children' => array( - '#markup' => nl2br(check_plain($item->value)), - ), + '#value' => nl2br(check_plain($item->value)), ); } }