summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-03-03 17:06:42 +0000
committerDries Buytaert <dries@buytaert.net>2010-03-03 17:06:42 +0000
commite824801b2be98a7c76662b328684b8edb1dc396b (patch)
treed33657a2d6347a0b28377924130311bcf888fc5f
parent02d6b122b5d9d92572812ee782aa0730849bf1d1 (diff)
downloadbrdo-e824801b2be98a7c76662b328684b8edb1dc396b.tar.gz
brdo-e824801b2be98a7c76662b328684b8edb1dc396b.tar.bz2
- Patch #701672 by linclark: associate a standardized foaf:Person URI to each user profile.
-rw-r--r--modules/rdf/rdf.module23
-rw-r--r--modules/rdf/rdf.test12
2 files changed, 31 insertions, 4 deletions
diff --git a/modules/rdf/rdf.module b/modules/rdf/rdf.module
index 34f7dac2d..857d44f63 100644
--- a/modules/rdf/rdf.module
+++ b/modules/rdf/rdf.module
@@ -495,12 +495,33 @@ function rdf_preprocess_field(&$variables) {
function rdf_preprocess_user_profile(&$variables) {
// Adds RDFa markup to the user profile page. Fields displayed in this page
// will automatically describe the user.
- // @todo move to user.module
$account = $variables['elements']['#account'];
if (!empty($account->rdf_mapping['rdftype'])) {
$variables['attributes_array']['typeof'] = $account->rdf_mapping['rdftype'];
$variables['attributes_array']['about'] = url('user/' . $account->uid);
}
+ // Adds the relationship between the sioc:User and the foaf:Person who holds
+ // the account.
+ $account_holder_meta = array(
+ '#tag' => 'meta',
+ '#attributes' => array(
+ 'about' => url('user/' . $account->uid, array('fragment' => 'me')),
+ 'typeof' => array('foaf:Person'),
+ 'rel' => array('foaf:account'),
+ 'resource' => url('user/' . $account->uid),
+ ),
+ );
+ // Adds the markup for username.
+ $username_meta = array(
+ '#tag' => 'meta',
+ '#attributes' => array(
+ 'about' => url('user/' . $account->uid),
+ 'property' => $account->rdf_mapping['name']['predicates'],
+ 'content' => $account->name,
+ )
+ );
+ drupal_add_html_head($account_holder_meta, 'rdf_user_account_holder');
+ drupal_add_html_head($username_meta, 'rdf_user_username');
}
/**
diff --git a/modules/rdf/rdf.test b/modules/rdf/rdf.test
index fa0c8c58f..5c487403a 100644
--- a/modules/rdf/rdf.test
+++ b/modules/rdf/rdf.test
@@ -307,14 +307,20 @@ class RdfMappingDefinitionTestCase extends DrupalWebTestCase {
// Create two users, one with access to user profiles.
$user1 = $this->drupalCreateUser(array('access user profiles'));
$user2 = $this->drupalCreateUser();
+ $username = $user2->name;
$this->drupalLogin($user1);
// Browse to the user profile page.
$this->drupalGet('user/' . $user2->uid);
// Ensure the default bundle mapping for user is used on the user profile
// page. These attributes come from the user default bundle definition.
- $profile_url = url('user/' . $user2->uid);
- $user2_profile_about = $this->xpath("//div[@class='profile' and @typeof='sioc:User' and @about='$profile_url']");
+ $account_uri = url('user/' . $user2->uid);
+ $person_uri = url('user/' . $user2->uid, array('fragment' => 'me'));
+ $user2_profile_about = $this->xpath("//div[@class='profile' and @typeof='sioc:User' and @about='$account_uri']");
$this->assertTrue(!empty($user2_profile_about), t('RDFa markup found on user profile page'));
+ $user_account_holder = $this->xpath("//meta[contains(@typeof, 'foaf:Person') and @about='$person_uri' and @resource='$account_uri' and contains(@rel, 'foaf:account')]");
+ $this->assertTrue(!empty($user_account_holder), t('URI created for account holder and username set on sioc:User.'));
+ $user_username = $this->xpath("//meta[@about='$account_uri' and contains(@property, 'foaf:name') and @content='$username']");
+ $this->assertTrue(!empty($user_username), t('foaf:name set on username.'));
// User 2 creates node.
$this->drupalLogin($user2);
@@ -323,7 +329,7 @@ class RdfMappingDefinitionTestCase extends DrupalWebTestCase {
$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:User' and @about='$profile_url' and @property='foaf:name' and contains(@xml:lang, '')]");
+ $author_about = $this->xpath("//a[@typeof='sioc:User' and @about='$account_uri' and @property='foaf:name' and contains(@xml:lang, '')]");
$this->assertTrue(!empty($author_about), t('RDFa markup found on author information on post. xml:lang on username is set to empty string.'));
}
}