You are here

function template_preprocess_date_display_single in Date 7.3

Same name and namespace in other branches
  1. 8 date.theme \template_preprocess_date_display_single()
  2. 7.2 date.theme \template_preprocess_date_display_single()

Template preprocess function for displaying a single date.

File

./date.theme, line 263
Theme functions.

Code

function template_preprocess_date_display_single(&$variables) {
  if ($variables['add_rdf'] || !empty($variables['add_microdata'])) {

    // Pass along the rdf mapping for this field, if any. Add some default rdf
    // attributes that will be used if not overridden by attributes passed in.
    $rdf_mapping = $variables['rdf_mapping'];
    $base_attributes = array(
      'property' => array(
        'dc:date',
      ),
      'datatype' => 'xsd:dateTime',
      'content' => $variables['dates']['value']['formatted_iso'],
    );
    $variables['attributes'] = $variables['attributes'] + $base_attributes;
  }

  // Pass along microdata attributes, or set display to FALSE if none are set.
  if (!empty($variables['add_microdata'])) {

    // Because the Entity API integration for Date has a variable data
    // structure depending on whether there is an end value, the attributes
    // could be attached to the field or to the value property.
    if (!empty($variables['microdata']['#attributes']['itemprop'])) {
      $variables['microdata']['value']['#attributes'] = $variables['microdata']['#attributes'];
    }

    // Add the machine readable time using the content attribute.
    if (!empty($variables['microdata']['value']['#attributes'])) {
      $variables['microdata']['value']['#attributes']['content'] = $variables['dates']['value']['formatted_iso'];
    }
    else {
      $variables['add_microdata'] = FALSE;
    }
  }
}