You are here

function commons_origins_field__addressfield in Drupal Commons 7.3

Overrides theme_field__addressfield().

File

themes/commons/commons_origins/template.php, line 1175
Process theme data.

Code

function commons_origins_field__addressfield($variables) {
  $output = '';

  // Add Microformat classes to each address.
  foreach ($variables['items'] as &$address) {

    // Only display an address if it has been populated. We determine this by
    // validating that the administrative area has been populated.
    if (!empty($address['#address']['administrative_area'])) {
      _commons_origins_format_address($address);
    }
    else {

      // Deny access to incomplete addresses.
      $address['#access'] = FALSE;
    }
  }

  // Render the label, if it's not hidden.
  if (!$variables['label_hidden']) {
    $output .= '<div class="field-label"' . $variables['title_attributes'] . '>' . $variables['label'] . ':</div> ';
  }

  // Render the items.
  $output .= '<div class="field-items"' . $variables['content_attributes'] . '>';
  foreach ($variables['items'] as $delta => $item) {
    $classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even');
    $output .= '<div class="' . $classes . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</div>';
  }
  $output .= '</div>';

  // Render the top-level DIV.
  $output = '<div class="' . $variables['classes'] . '"' . $variables['attributes'] . '>' . $output . '</div>';
  return $output;
}