rdf_preprocess_username

Versions
mediamosa-21
rdf_preprocess_username(&$variables)

Implements MODULE_preprocess_HOOK().

Code

modules/rdf/rdf.module, line 570

<?php
function rdf_preprocess_username(&$variables) {
  // Because xml:lang is set on the HTML element that wraps the page, the
  // username inherits this language attribute. However, since the username
  // might not be transliterated to the same language that the content is in,
  // we do not want it to inherit the language attribute, so we set the
  // attribute to an empty string.
  if (empty($variables['attributes_array']['xml:lang'])) {
    $variables['attributes_array']['xml:lang'] = '';
  }

  // $variables['account'] is a pseudo account object, and as such, does not
  // contain the rdf mappings for the user; in the case of nodes and comments,
  // it contains the mappings for the node or comment object instead. However
  // while the rdf mappings are available from a full user_load(), this should
  // be avoided for performance reasons. Since the type and bundle for
  // users is already known, call rdf_mapping_load() directly.
  $rdf_mapping = rdf_mapping_load('user', 'user');

  // The profile URI is used to identify the user account. The about attribute
  // is used to set the URI as the default subject of the predicates embedded
  // as RDFa in the child elements. Even if the user profile is not accessible
  // to the current user, we use its URI in order to identify the user in RDF.
  // We do not use this attribute for the anonymous user because we do not have
  // a user profile URI for it (only a homepage which cannot be used as user
  // profile in RDF).
  if ($variables['uid'] > 0) {
    $variables['attributes_array']['about'] = url('user/' . $variables['uid']);
  }

  $attributes = array();
  // The 'typeof' attribute specifies the RDF type(s) of this resource. They
  // are defined in the 'rdftype' property of the user RDF mapping.
  if (!empty($rdf_mapping['rdftype'])) {
    $attributes['typeof'] = $rdf_mapping['rdftype'];
  }
  // Annotate the user name in RDFa. The attribute 'property' is used here
  // because the user name is a literal.
  if (!empty($rdf_mapping['name'])) {
    $attributes['property'] = $rdf_mapping['name']['predicates'];
  }
  // Add the homepage RDFa markup if present.
  if (!empty($variables['homepage']) && !empty($rdf_mapping['homepage'])) {
    $attributes['rel'] = $rdf_mapping['homepage']['predicates'];
  }
  // The remaining attributes can have multiple values listed, with whitespace
  // separating the values in the RDFa attribute
  // (http://www.w3.org/TR/rdfa-syntax/#rdfa-attributes).
  // Therefore, merge rather than override so as not to clobber values set by
  // earlier preprocess functions.
  $variables['attributes_array'] = array_merge_recursive($variables['attributes_array'], $attributes);
}
?>