Implements hook_preprocess_HOOK() for user.tpl.php.
function rdf_preprocess_user(&$variables) {
$account = $variables['elements']['#user'];
$uri = $account
->uri();
// Adds RDFa markup to the user profile page. Fields displayed in this page
// will automatically describe the user.
if (!empty($account->rdf_mapping['rdftype'])) {
$variables['attributes']['typeof'] = $account->rdf_mapping['rdftype'];
$variables['attributes']['about'] = url($uri['path'], $uri['options']);
}
// If we are on the user account page, add the relationship between the
// sioc:UserAccount and the foaf:Person who holds the account.
if (current_path() == $uri['path']) {
$account_holder_meta = array(
'#tag' => 'meta',
'#attributes' => array(
'about' => url($uri['path'], array_merge($uri['options'], array(
'fragment' => 'me',
))),
'typeof' => array(
'foaf:Person',
),
'rel' => array(
'foaf:account',
),
'resource' => url($uri['path'], $uri['options']),
),
);
// Adds the markup for username as language neutral literal, see
// rdf_preprocess_username().
$username_meta = array(
'#tag' => 'meta',
'#attributes' => array(
'about' => url($uri['path'], $uri['options']),
'property' => $account->rdf_mapping['name']['predicates'],
'content' => $account->name,
'lang' => '',
),
);
drupal_add_html_head($account_holder_meta, 'rdf_user_account_holder');
drupal_add_html_head($username_meta, 'rdf_user_username');
}
}