diff options
author | David Rothstein <drothstein@gmail.com> | 2013-03-10 15:19:33 -0400 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2013-03-10 15:19:33 -0400 |
commit | a9ec210f7a651bdd8dce8c3879f016ed64b429ff (patch) | |
tree | d86eb7c15d591ec35204bcf62a3f2716b3d585fe | |
parent | 63fc6b8f75663588327cec1f645a1826c75f4400 (diff) | |
download | brdo-a9ec210f7a651bdd8dce8c3879f016ed64b429ff.tar.gz brdo-a9ec210f7a651bdd8dce8c3879f016ed64b429ff.tar.bz2 |
Issue #1848464 by scor | jneubert: Fixed Make RDFa markup upward compatible with RDFa 1.1.
-rw-r--r-- | CHANGELOG.txt | 2 | ||||
-rw-r--r-- | modules/rdf/rdf.module | 9 | ||||
-rw-r--r-- | modules/rdf/rdf.test | 12 |
3 files changed, 15 insertions, 8 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 70ed4a4ea..e8f99829d 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,8 @@ Drupal 7.22, xxxx-xx-xx (development version) ----------------------- +- Added an empty "datatype" attribute to taxonomy term and username links to + make the RDFa markup upward compatible with RDFa 1.1 (minor markup addition). - Fixed a bug which caused the denial-of-service protection added in Drupal 7.20 to break certain valid image URLs that had an extra slash in them. - Fixed a bug with update queries in the SQLite database driver that prevented diff --git a/modules/rdf/rdf.module b/modules/rdf/rdf.module index e491c31d1..e22d5a93f 100644 --- a/modules/rdf/rdf.module +++ b/modules/rdf/rdf.module @@ -646,10 +646,12 @@ function rdf_preprocess_username(&$variables) { if (!empty($rdf_mapping['rdftype'])) { $attributes['typeof'] = $rdf_mapping['rdftype']; } - // Annotate the user name in RDFa. The property attribute is used here - // because the user name is a literal. + // Annotate the username in RDFa. A property attribute is used with an empty + // datatype attribute to ensure the username is parsed as a plain literal + // in RDFa 1.0 and 1.1. if (!empty($rdf_mapping['name'])) { $attributes['property'] = $rdf_mapping['name']['predicates']; + $attributes['datatype'] = ''; } // Add the homepage RDFa markup if present. if (!empty($variables['homepage']) && !empty($rdf_mapping['homepage'])) { @@ -757,7 +759,10 @@ function rdf_field_attach_view_alter(&$output, $context) { $element[$delta]['#options']['attributes']['typeof'] = $term->rdf_mapping['rdftype']; } if (!empty($term->rdf_mapping['name']['predicates'])) { + // A property attribute is used with an empty datatype attribute so + // the term name is parsed as a plain literal in RDFa 1.0 and 1.1. $element[$delta]['#options']['attributes']['property'] = $term->rdf_mapping['name']['predicates']; + $element[$delta]['#options']['attributes']['datatype'] = ''; } } } diff --git a/modules/rdf/rdf.test b/modules/rdf/rdf.test index b8aeb90a1..ca2057f2b 100644 --- a/modules/rdf/rdf.test +++ b/modules/rdf/rdf.test @@ -195,12 +195,12 @@ class RdfRdfaMarkupTestCase extends DrupalWebTestCase { $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); // Ensures the RDFa markup for the relationship between the node and its // tags is correct. - $term_rdfa_meta = $this->xpath('//div[@about=:node-url and contains(@typeof, "sioc:Item") and contains(@typeof, "foaf:Document")]//ul[@class="links"]/li[@rel="dc:subject"]/a[@typeof="skos:Concept" and text()=:term-name]', array( + $term_rdfa_meta = $this->xpath('//div[@about=:node-url and contains(@typeof, "sioc:Item") and contains(@typeof, "foaf:Document")]//ul[@class="links"]/li[@rel="dc:subject"]/a[@typeof="skos:Concept" and @datatype="" and text()=:term-name]', array( ':node-url' => url('node/' . $node->nid), ':term-name' => $tag1, )); $this->assertTrue(!empty($term_rdfa_meta), t('Property dc:subject is present for the tag1 field item.')); - $term_rdfa_meta = $this->xpath('//div[@about=:node-url and contains(@typeof, "sioc:Item") and contains(@typeof, "foaf:Document")]//ul[@class="links"]/li[@rel="dc:subject"]/a[@typeof="skos:Concept" and text()=:term-name]', array( + $term_rdfa_meta = $this->xpath('//div[@about=:node-url and contains(@typeof, "sioc:Item") and contains(@typeof, "foaf:Document")]//ul[@class="links"]/li[@rel="dc:subject"]/a[@typeof="skos:Concept" and @datatype="" and text()=:term-name]', array( ':node-url' => url('node/' . $node->nid), ':term-name' => $tag2, )); @@ -384,7 +384,7 @@ class RdfMappingDefinitionTestCase extends TaxonomyWebTestCase { $this->drupalGet('node/' . $node->nid); // Ensures the default bundle mapping for user is used on the Authored By // information on the node. - $author_about = $this->xpath('//a[@typeof="sioc:UserAccount" and @about=:account-uri and @property="foaf:name" and contains(@xml:lang, "")]', array( + $author_about = $this->xpath('//a[@typeof="sioc:UserAccount" and @about=:account-uri and @property="foaf:name" and @datatype="" and contains(@xml:lang, "")]', array( ':account-uri' => $account_uri, )); $this->assertTrue(!empty($author_about), t('RDFa markup found on author information on post. xml:lang on username is set to empty string.')); @@ -502,7 +502,7 @@ class RdfCommentAttributesTestCase extends CommentHelperCase { // Tests comment #2 as anonymous user. $this->_testBasicCommentRdfaMarkup($comment2, $anonymous_user); // Tests the RDFa markup for the homepage (specific to anonymous comments). - $comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[contains(@class, "username") and @typeof="sioc:UserAccount" and @property="foaf:name" and @href="http://example.org/" and contains(@rel, "foaf:page")]'); + $comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[contains(@class, "username") and @typeof="sioc:UserAccount" and @property="foaf:name" and @datatype="" and @href="http://example.org/" and contains(@rel, "foaf:page")]'); $this->assertTrue(!empty($comment_homepage), t('RDFa markup for the homepage of anonymous user found.')); // There should be no about attribute on anonymous comments. $comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[@about]'); @@ -513,7 +513,7 @@ class RdfCommentAttributesTestCase extends CommentHelperCase { $this->drupalGet('node/' . $this->node2->nid); $this->_testBasicCommentRdfaMarkup($comment2, $anonymous_user); // Tests the RDFa markup for the homepage (specific to anonymous comments). - $comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[contains(@class, "username") and @typeof="sioc:UserAccount" and @property="foaf:name" and @href="http://example.org/" and contains(@rel, "foaf:page")]'); + $comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[contains(@class, "username") and @typeof="sioc:UserAccount" and @property="foaf:name" and @datatype="" and @href="http://example.org/" and contains(@rel, "foaf:page")]'); $this->assertTrue(!empty($comment_homepage), t("RDFa markup for the homepage of anonymous user found.")); // There should be no about attribute on anonymous comments. $comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[@about]'); @@ -564,7 +564,7 @@ class RdfCommentAttributesTestCase extends CommentHelperCase { $comment_date = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//*[contains(@property, "dc:date") and contains(@property, "dc:created")]'); $this->assertTrue(!empty($comment_date), t("RDFa markup for the date of the comment found.")); // The author tag can be either a or span - $comment_author = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/*[contains(@class, "username") and @typeof="sioc:UserAccount" and @property="foaf:name"]'); + $comment_author = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/*[contains(@class, "username") and @typeof="sioc:UserAccount" and @property="foaf:name" and @datatype=""]'); $name = empty($account["name"]) ? $this->web_user->name : $account["name"] . " (not verified)"; $this->assertEqual((string)$comment_author[0], $name, t("RDFa markup for the comment author found.")); $comment_body = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//div[@class="content"]//div[contains(@class, "comment-body")]//div[@property="content:encoded"]'); |