Commit 8782843f authored by webchick's avatar webchick

Issue #1848464 by scor, jneubert: Fixed Make RDFa markup upward compatible with RDFa 1.1.

parent d500ed33
......@@ -123,7 +123,7 @@ public function testCommentRdfaMarkup() {
// 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), '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]');
......@@ -134,7 +134,7 @@ public function testCommentRdfaMarkup() {
$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), "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]');
......@@ -185,7 +185,7 @@ function _testBasicCommentRdfaMarkup($comment, $account = array()) {
$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), '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, '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"]');
......
......@@ -133,7 +133,7 @@ function testUserAttributesInMarkup() {
$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(@lang, "")]', array(
$author_about = $this->xpath('//a[@typeof="sioc:UserAccount" and @about=:account-uri and @property="foaf:name" and @datatype="" and contains(@lang, "")]', array(
':account-uri' => $account_uri,
));
$this->assertTrue(!empty($author_about), 'RDFa markup found on author information on post. The lang attribute on username is set to empty string.');
......
......@@ -174,12 +174,12 @@ function testAttributesInMarkupFile() {
$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), '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,
));
......
......@@ -679,10 +679,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'])) {
......@@ -790,7 +792,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'] = '';
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment