rdf_preprocess_comment

Versions
mediamosa-21
rdf_preprocess_comment(&$variables)

Implements MODULE_preprocess_HOOK().

Code

modules/rdf/rdf.module, line 625

<?php
function rdf_preprocess_comment(&$variables) {
  $comment = $variables['comment'];
  if (!empty($comment->rdf_mapping['rdftype'])) {
    // Adds RDFa markup to the comment container. The about attribute specifies
    // the URI of the resource described within the HTML element, while the
    // typeof attribute indicates its RDF type (e.g. sioc:Post, etc.).
    $variables['attributes_array']['about'] = url('comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid));
    $variables['attributes_array']['typeof'] = $comment->rdf_mapping['rdftype'];
  }

  // Adds RDFa markup for the date of the comment.
  if (!empty($comment->rdf_mapping['created'])) {
    $date_attributes_array = $comment->rdf_data['date'];
    $variables['rdf_template_variable_attributes_array']['created'] = $date_attributes_array;
  }
  // Adds RDFa markup for the relation between the comment and its author.
  if (!empty($comment->rdf_mapping['uid'])) {
    $variables['rdf_template_variable_attributes_array']['author']['rel'] = $comment->rdf_mapping['uid']['predicates'];
  }
  if (!empty($comment->rdf_mapping['title'])) {
    // Adds RDFa markup to the subject of the comment. Because the RDFa markup is
    // added to an h3 tag which might contain HTML code, we specify an empty
    // datatype to ensure the value of the title read by the RDFa parsers is a
    // literal.
    $variables['title_attributes_array']['property'] = $comment->rdf_mapping['title']['predicates'];
    $variables['title_attributes_array']['datatype'] = '';
  }

  // Annotates the parent relationship between the current comment and the node
  // it belongs to. If available, the parent comment is also annotated.
  if (!empty($comment->rdf_mapping['pid'])) {
    // Relation to parent node.
    $parent_node_attributes['rel'] = $comment->rdf_mapping['pid']['predicates'];
    $parent_node_attributes['resource'] = $comment->rdf_data['nid_uri'];
    $variables['rdf_metadata_attributes_array'][] = $parent_node_attributes;

    // Relation to parent comment if it exists.
    if ($comment->pid != 0) {
      $parent_comment_attributes['rel'] = $comment->rdf_mapping['pid']['predicates'];
      $parent_comment_attributes['resource'] = $comment->rdf_data['pid_uri'];
      $variables['rdf_metadata_attributes_array'][] = $parent_comment_attributes;
    }
  }
}
?>