Commit e8cfe921 authored by Dries's avatar Dries

- Patch #694994 by Stefan Freudenberg: fixed the RDFa markup for number of comments on teasers.

parent d5ce7f52
......@@ -483,6 +483,12 @@ function rdf_preprocess_node(&$variables) {
$comment_count_attributes['property'] = $variables['node']->rdf_mapping['comment_count']['predicates'];
$comment_count_attributes['content'] = $variables['node']->comment_count;
$comment_count_attributes['datatype'] = $variables['node']->rdf_mapping['comment_count']['datatype'];
// According to RDFa parsing rule number 4, a new subject URI is created
// from the href attribute if no rel/rev attribute is present. To get
// the original node URL from the about attribute of the parent container
// we set an empty rel attribute which triggers rule number 5. See
// http://www.w3.org/TR/rdfa-syntax/#sec_5.5.
$comment_count_attributes['rel'] = '';
$variables['content']['links']['comment']['#links']['comment_comments']['attributes'] += $comment_count_attributes;
}
// In full node view, the number of comments is not displayed by
......
......@@ -371,6 +371,36 @@ class RdfMappingDefinitionTestCase extends DrupalWebTestCase {
}
}
class RdfCommentAttributesTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'RDF comment mapping',
'description' => 'Tests the RDFa markup of comments.',
'group' => 'RDF',
);
}
public function setUp() {
parent::setUp('rdf', 'rdf_test', 'comment');
// Enable anonymous posting of content.
user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
'create article content' => TRUE,
'access comments' => TRUE,
'post comments' => TRUE,
'post comments without approval' => TRUE,
));
}
public function testAttributesInTeaser() {
$node = $this->drupalCreateNode(array('type' => 'article', 'uid' => 1, 'promote' => 1));
CommentHelperCase::postComment($node, $this->randomName(), $this->randomName());
$this->drupalGet('');
$comment_count_link = $this->xpath('//div[@about=:url]//a[contains(@property, "sioc:num_replies") and @rel=""]', array(':url' => url("node/$node->nid")));
$this->assertTrue(!empty($comment_count_link), t('Empty rel attribute found in comment count link.'));
}
}
class RdfTrackerAttributesTestCase extends DrupalWebTestCase {
public static function getInfo() {
......
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