You are here

views_xhtml.module in Views Datasource 5

Same filename and directory in other branches
  1. 6 views_xhtml.module
  2. 7 views_xhtml.module

Provides Views plugin for rendering node content as XHTML microformats.

File

views_xhtml.module
View source
<?php

/**
 * @file
 * Provides Views plugin for rendering node content as XHTML microformats.
 */

/**
 * Implementation of hook_views_style_plugins
 * @return array with style plugin declarations. 
 */
function views_xhtml_views_style_plugins() {
  return array(
    'views_xhtml_hcard' => array(
      'name' => t('Views XHTML: hCard XHTML data document'),
      'theme' => 'views_xhtml_hcard',
      'needs_table_header' => TRUE,
      'needs_fields' => TRUE,
      'even_empty' => TRUE,
    ),
    'views_xhtml_hcalendar' => array(
      'name' => t('Views XHTML: hCalendar XHTML data document'),
      'theme' => 'views_xhtml_hcalendar',
      'needs_table_header' => TRUE,
      'needs_fields' => TRUE,
      'even_empty' => TRUE,
    ),
  );
}

/*
 * Implementation of hook_views_arguments to add the XHTML argument selectors.
 * @returns array of arguments
 */
function views_xhtml_views_arguments() {
  $arguments = array(
    'xhtml_hcard' => array(
      'name' => t('Views XHTML: hCard data document selector'),
      'handler' => 'views_xhtml_hcard_handler',
      'option' => 'string',
      'help' => t('This argument specifies a document selector; it will only provide a method for rendering the current view as a XHTML hCard document.'),
    ),
    'xhtml_hcalendar' => array(
      'name' => t('Views XHTML: hCalendar data document selector'),
      'handler' => 'views_xhtml_hcalendar_handler',
      'option' => 'string',
      'help' => t('This argument specifies a document selector; it will only provide a method for rendering the current view as a XHTML hCalendar document.'),
    ),
  );
  return $arguments;
}

/**
 * handler for our own XHTML hCard argument handler
 */
function views_xhtml_hcard_handler($op, &$query, $argtype, $arg = '') {
  if ($op == 'filter') {
    views_xhtml_hcard_views_argument('argument', $GLOBALS['current_view'], $arg);
  }
}

/**
 * handler for our own XHTML hCalendar argument handler
 */
function views_xhtml_hcalendar_handler($op, &$query, $argtype, $arg = '') {
  if ($op == 'filter') {
    views_xhtml_hcalendar_views_argument('argument', $GLOBALS['current_view'], $arg);
  }
}

/**
 * argument hook that will display the hCard data document or display export icons.
 */
function views_xhtml_hcard_views_argument($op, &$view, $arg) {
  if ($op == 'argument' && $arg == 'xhtml_hcard') {
    $view->page_type = 'views_' . $arg;
  }
  else {
    if ($op == 'post_view' && $view->build_type != 'block') {
      $args = views_post_view_make_args($view, $arg, $arg);
      $url = views_get_url($view, $args);
      $title = views_get_title($view, 'page', $args);
      $links = array();
      if ($arg == 'xhtml_hcard') {
        if ($image = theme('image', drupal_get_path('module', 'views_xhtml') . '/hcard.png', t('hCard'), t('Show @title as a hCard document.', array(
          '@title' => $title,
        )))) {
          $links[] = l($image, $url, array(
            'class' => 'xhtml-icon',
          ), $url_filter, NULL, FALSE, TRUE);
          return implode('&nbsp;&nbsp;', $links);
        }
      }
    }
  }
}

/**
 * argument hook that will display the hCalendar data document or display export icons.
 */
function views_xhtml_hcalendar_views_argument($op, &$view, $arg) {
  if ($op == 'argument' && $arg == 'xhtml_hcalendar') {
    $view->page_type = 'views_' . $arg;
  }
  else {
    if ($op == 'post_view' && $view->build_type != 'block') {
      $args = views_post_view_make_args($view, $arg, $arg);
      $url = views_get_url($view, $args);
      $title = views_get_title($view, 'page', $args);
      $links = array();
      if ($arg == 'xhtml_hcalendar') {
        if ($image = theme('image', drupal_get_path('module', 'views_xhtml') . '/hcalendar.png', t('hCalendar'), t('Show @title as a hCalendar document.', array(
          '@title' => $title,
        )))) {
          $links[] = l($image, $url, array(
            'class' => 'xhtml-icon',
          ), $url_filter, NULL, FALSE, TRUE);
          return implode('&nbsp;&nbsp;', $links);
        }
      }
    }
  }
}

/**
 * post view to display the render icons
 */
function views_xhtml_views_post_view($view, $items, $output) {
  $links = '';
  foreach ($view->argument as $id => $argument) {
    if ($argument['type'] == 'xhtml_hcard') {
      $links .= views_xhtml_hcard_views_argument('post_view', $view, $argument['type'], '');
    }
    if ($argument['type'] == 'xhtml_hcalendar') {
      $links .= views_xhtml_hcalendar_views_argument('post_view', $view, $argument['type'], '');
    }
  }
  return $links;
}

/*
 * describes how to theme an XHTML hCard view
 */
function theme_views_xhtml_hcard($view, $nodes, $type) {
  return views_xhtml_hcard_render($view->vid, $nodes, $type);
}

/*
 * describes how to theme an XHTML hCalendar view
 */
function theme_views_xhtml_hcalendar($view, $nodes, $type) {
  return views_xhtml_hcalendar_render($view->vid, $nodes, $type);
}
function views_xhtml_hCard_render($vid, $nodes, $type) {
  $view = views_load_view($vid);
  $fields = _views_get_fields();
  $xhtml = "\r\n";
  $xhtml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
  $xhtml .= '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"' . ">\r\n";
  $xhtml .= '<head>' . "\r\n";
  $xhtml .= '  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\r\n";
  $xhtml .= '  <meta name="KEYWORDS" content="hCards" />' . "\r\n";
  $xhtml .= '  <title>hCards</title>' . "\r\n";
  $xhtml .= '</head>' . "\r\n";
  $xhtml .= '<body>' . "\r\n";
  foreach ($nodes as $node) {
    $hcard = array(
      'adr' => array(
        'type' => '',
        'post-office-box' => '',
        'street-address' => array(),
        'extended-address' => '',
        'region' => '',
        'locality' => '',
        'postal-code' => '',
        'country-name' => '',
      ),
      'agent' => array(),
      'bday' => '',
      'class' => '',
      'category' => array(),
      'email' => array(),
      'fn' => '',
      'n' => array(
        'honorific-prefix' => '',
        'given-name' => '',
        'additional-name' => '',
        'family-name' => '',
        'honorific-suffix' => '',
      ),
      'nickname' => '',
      'org' => array(
        'organization-name' => '',
        'organization-unit' => array(),
      ),
      'photo' => '',
      'tel' => array(),
    );
    foreach ($view->field as $field) {
      if ($fields[$field['id']]['visible'] !== false) {
        $label = $field['label'] ? $field['label'] : $fields[$field['fullname']]['name'];

        /*strip illegal XML characters*/
        $label = views_xhtml_strip_illegal_chars($label);
        $value = views_xhtml_strip_illegal_chars(views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view));
        if (is_null($value) || $value === '') {
          continue;
        }
        if (stripos($label, 'address-type') !== FALSE) {
          $hcard['adr']['type'] = $value;
        }
        if (stripos($label, 'post-office-box') !== FALSE) {
          $hcard['adr']['post-office-box'] = $value;
        }
        if (stripos($label, 'street-address') !== FALSE) {
          $hcard['adr']['street-address'][] = $value;
        }
        if (stripos($label, 'extended-address') !== FALSE) {
          $hcard['adr']['extended-address'] = $value;
        }
        if (stripos($label, 'region') !== FALSE) {
          $hcard['adr']['region'] = $value;
        }
        if (stripos($label, 'locality') !== FALSE) {
          $hcard['adr']['locality'] = $value;
        }
        if (stripos($label, 'postal-code') !== FALSE) {
          $hcard['adr']['postal-code'] = $value;
        }
        if (stripos($label, 'country-name') !== FALSE) {
          $hcard['adr']['country-name'] = $value;
        }
        if (stripos($label, 'agent') !== FALSE) {
          $hcard['agent'][] = $value;
        }
        if (stripos($label, 'bday') !== FALSE) {
          if (preg_match('/\\d/', $value)) {
            if (strtotime($value)) {
              $value = date(DATE_ISO8601, strtotime($value));
            }
          }
          $hcard['bday'] = $value;
        }
        if (stripos($label, 'class') !== FALSE) {
          $hcard['class'] = $value;
        }
        if (stripos($label, 'category') !== FALSE) {
          $hcard['category'][] = $value;
        }
        if (stripos($label, 'email') !== FALSE) {
          $hcard['email'][$label] = $value;
        }
        if (stripos($label, 'honorific-prefix') !== FALSE) {
          $hcard['n']['honorific-prefix'] = $value;
        }
        if (stripos($label, 'given-name') !== FALSE) {
          $hcard['n']['given-name'] = $value;
        }
        if (stripos($label, 'additional-name') !== FALSE) {
          $hcard['n']['additional-name'] = $value;
        }
        if (stripos($label, 'family-name') !== FALSE) {
          $hcard['n']['family-name'] = $value;
        }
        if (stripos($label, 'honorific-suffix') !== FALSE) {
          $hcard['n']['honorific-suffix'] = $value;
        }
        if (stripos($label, 'fn') !== FALSE) {
          $hcard['fn'] = $value;
        }
        if (stripos($label, 'nickname') !== FALSE) {
          $hcard['nickname'] = $value;
        }
        if (stripos($label, 'organization-name') !== FALSE) {
          $hcard['org']['organization-name'] = $value;
        }
        if (stripos($label, 'organization-unit') !== FALSE) {
          $hcard['org']['organization-unit'][] = $value;
        }
        if (stripos($label, 'photo') !== FALSE) {
          $hcard['photo'] = $value;
        }
        if (stripos(trim(str_ireplace("Profile:", '', $label)), 'tel') === 0) {
          $hcard['tel'][$label] = $value;
        }
      }
      else {
        continue;
      }
    }
    $xhtml .= '<div class = "vcard">' . "\r\n";
    if ($hcard['photo'] != '') {
      $xhtml .= '  <img class="photo" alt="photo" title="photo" style="height:96px;width:96px" src="' . $hcard['photo'] . '"/>' . "<br/>\r\n";
    }
    if ($hcard['fn']) {
      $xhtml .= '  <span class="fn">' . $hcard['fn'] . '</span>' . "<br/>\r\n";
    }
    if ($hcard['nickname']) {
      $xhtml .= '  <span class="nickname">' . $hcard['nickname'] . '</span>' . "<br/>\r\n";
    }
    $name = $hcard['n'];
    if ($hcard['fn']) {
      $xhtml .= '  <span class = "n">' . "\r\n";
    }
    else {
      $xhtml .= '  <span class = "fn n">' . "\r\n";
    }
    if ($name['honorific-prefix'] !== '') {
      $xhtml .= '    <span class="honorific-prefix">' . $name['honorific-prefix'] . '</span>' . "\r\n";
    }
    if ($name['given-name'] !== '') {
      $xhtml .= '    <span class="given-name">' . $name['given-name'] . '</span>' . "\r\n";
    }
    if ($name['additional-name'] !== '') {
      $xhtml .= '    <span class="additional-name">' . $name['additional-name'] . '</span>' . "\r\n";
    }
    if ($name['family-name'] !== '') {
      $xhtml .= '    <span class="family-name">' . $name['family-name'] . '</span>' . "\r\n";
    }
    if ($name['honorific-suffix'] !== '') {
      $xhtml .= '    <span class="honorific-suffix">' . $name['honorific-suffix'] . '</span>' . "\r\n";
    }
    $xhtml .= '  </span><br/>' . "\r\n";
    if ($hcard['nickname'] !== '') {
      $xhtml .= '    <span class="nickname">' . $hcard['nickname'] . '</span><br/>' . "\r\n";
    }
    $org = $hcard['org'];
    $xhtml .= '  <span class="org">' . "\r\n";
    if ($org['organization-name'] !== '') {
      $xhtml .= '    <span class="organization name">' . $org['organization-name'] . '</span><br/>' . "\r\n";
    }
    $org_units = $org['organization-unit'];
    foreach ($org_units as $org_unit) {
      $xhtml .= '    <span class="organization-unit">' . $org_unit . '</span>' . "<br/>\r\n";
    }
    $xhtml .= '  </span>' . "\r\n";
    $address = $hcard['adr'];
    $xhtml .= '  <span class = "adr">' . "\r\n";
    if ($address['type'] !== '') {
      $xhtml .= '    <span class="type">' . $address['type'] . '</span>' . "<br/>\r\n";
    }
    if ($address['post-office-box'] !== '') {
      $xhtml .= '    <span class="post-office-box">' . $address['post-office-box'] . '</span>' . "<br/>\r\n";
    }
    $street_addresses = $address['street-address'];
    foreach ($street_addresses as $street_address) {
      $xhtml .= '    <span class="street-address">' . $street_address . '</span>' . "<br/>\r\n";
    }
    if ($address['extended-address'] !== '') {
      $xhtml .= '    <span class="extended-address">' . $address['extended-address'] . '</span>' . "<br/>\r\n";
    }
    if ($address['region'] !== '') {
      $xhtml .= '    <span class="region">' . $address['region'] . '</span>' . "<br/>\r\n";
    }
    if ($address['locality'] !== '') {
      $xhtml .= '    <span class="locality">' . $address['locality'] . '</span>' . "<br/>\r\n";
    }
    if ($address['postal-code'] !== '') {
      $xhtml .= '    <span class="postal-code">' . $address['postal-code'] . '</span>' . "<br/>\r\n";
    }
    if ($address['country-name'] !== '') {
      $xhtml .= '    <span class="country-name">' . $address['country-name'] . '</span>' . "\r\n";
    }
    $xhtml .= '  </span><br/>' . "\r\n";
    $agents = $hcard['agent'];
    foreach ($agents as $agent) {
      $xhtml .= '  <span class="agent">' . $agent . '</span>' . "<br/>\r\n";
    }
    $birthday = $hcard['bday'];
    $birthday_timestamp = false;
    if ($birthday !== '') {
      $birthday_timestamp = strtotime($birthday);
      if ($birthday_timestamp) {
        $xhtml .= '  <span class="bday" title="' . date(DATE_ISO8601, $birthday_timestamp) . '">' . $birthday . '</span>' . "<br/>\r\n";
      }
      else {
        $xhtml .= '  <span class="bday">' . $birthday . '</span>' . "<br/>\r\n";
      }
    }
    $class = $hcard['class'];
    if ($class !== '') {
      $xhtml .= '  <span class="class">' . $class . '</span>' . "<br/>\r\n";
    }
    $categories = $hcard['category'];
    foreach ($categories as $category) {
      $xhtml .= '  <span class="category">' . $category . '</span>' . "<br/>\r\n";
    }
    if ($hcard['email']) {
      $email_addrs = $hcard['email'];
      foreach ($email_addrs as $email_type => $email_addr) {
        $xhtml .= '  <span class="email">' . "\r\n" . '    <span class="type">' . trim(str_ireplace("Profile:", '', $email_type)) . ': </span>' . "\r\n" . '    <a class="value" href="mailto:' . $email_addr . '">' . $email_addr . '</a>' . "\r\n" . '  </span>' . "<br/>\r\n";
      }
    }
    if ($hcard['tel']) {
      $tel_nos = $hcard['tel'];
      foreach ($tel_nos as $tel_no_type => $tel_no) {
        $xhtml .= '  <span class="tel">' . '<span class="type">' . trim(str_ireplace("Profile:", '', $tel_no_type)) . ': </span>' . '<span class="value">' . $tel_no . '</span>' . '</span>' . "<br/>\r\n";
      }
    }
    $xhtml .= '</div>' . "\r\n";
  }
  $xhtml .= '</body>' . "\r\n";
  $xhtml .= '</html>' . "\r\n";
  drupal_set_header('Content-Type: text/html');

  //var_dump($view);
  print $xhtml;
  module_invoke_all('exit');
  exit;

  //return $xhtml;
}
function views_xhtml_hCalendar_render($vid, $nodes, $type) {
  $view = views_load_view($vid);
  $fields = _views_get_fields();
  $xhtml = "\r\n";
  $xhtml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
  $xhtml .= '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"' . ">\r\n";
  $xhtml .= '<head>' . "\r\n";
  $xhtml .= '  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\r\n";
  $xhtml .= '  <meta name="KEYWORDS" content="hCalendars" />' . "\r\n";
  $xhtml .= '  <title>hCards</title>' . "\r\n";
  $xhtml .= '</head>' . "\r\n";
  $xhtml .= '<body>' . "\r\n";
  foreach ($nodes as $node) {
    $hcalendar = array();
    foreach ($view->field as $field) {
      if ($fields[$field['id']]['visible'] === false) {
        continue;
      }

      //$label = $field['label'] ? $field['label'] : $fields[$field['fullname']]['name'];

      //$label = views_xhtml_strip_illegal_chars($label); /*strip illegal XML characters*/

      //$label = str_replace("Profile", '', $label); //strip out Profile: from profile fields

      //$value = views_xhtml_strip_illegal_chars(views_xhtml_is_date(views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view)));

      //$value = views_xhtml_strip_illegal_chars(views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view));
      $label = views_xhtml_strip_illegal_chars($field['label'] ? $field['label'] : $fields[$field['fullname']]['name']);
      $value = views_xhtml_strip_illegal_chars(views_xhtml_is_date(views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view)));
      $label = str_replace("Profile", '', $label);

      //strip out Profile: from profile fields
      if (is_null($value) || $value === '') {
        continue;
      }
      if (stripos($label, 'class') !== FALSE) {
        $hcalendar['class'] = $value;
      }
      if (stripos($label, 'category') !== FALSE) {
        $hcalendar['category'][] = $value;
      }
      if (stripos($label, 'description') !== FALSE) {
        $hcalendar['description'] = $value;
      }
      if (stripos($label, 'summary') !== FALSE) {
        $hcalendar['summary'] = $value;
      }
      if (stripos($label, 'dtstart') !== FALSE || stripos($label, 'event_start') !== FALSE || stripos($label, 'eventstarttime') !== FALSE) {
        if (preg_match('/\\d/', $value)) {
          if (strtotime($value)) {
            $value = date(DATE_ISO8601, strtotime($value));
          }
        }
        $hcalendar['dtstart'] = $value;
      }
      if (stripos($label, 'dtend') !== FALSE || stripos($label, 'event_end') !== FALSE || stripos($label, 'eventendtime') !== FALSE) {
        if (preg_match('/\\d/', $value)) {
          if (strtotime($value)) {
            $value = date(DATE_ISO8601, strtotime($value));
          }
        }
        $hcalendar['dtend'] = $value;
      }
      if (stripos($label, 'duration') !== FALSE) {
        $hcalendar['duration'] = $value;
      }
      if (stripos($label, 'geo_latitude') !== FALSE) {
        $hcalendar['geo']['latitude'] = $value;
      }
      if (stripos($label, 'geo_longitude') !== FALSE) {
        $hcalendar['geo']['longitude'] = $value;
      }
      if (stripos($label, 'location') !== FALSE) {
        $hcalendar['location'] = $value;
      }
      if (stripos($label, 'status') !== FALSE) {
        $hcalendar['status'] = $value;
      }
      if (stripos($label, 'uid') !== FALSE) {
        $hcalendar['uid'] = $value;
      }
      if (stripos($label, 'url') !== FALSE) {
        $hcalendar['url'] = $value;
      }
      if (stripos($label, 'last_modified') !== FALSE) {
        if (strtotime($value)) {
          $hcalendar['last-modified'] = date(DATE_ISO8601, strtotime($value));
        }
        else {
          $hcalendar['last-modified'] = $value;
        }
      }
      if (stripos($label, 'address_type') !== FALSE) {
        $hcalendar['adr']['type'] = $value;
      }
      if (stripos($label, 'post_office_box') !== FALSE) {
        $hcalendar['adr']['post-office-box'] = $value;
      }
      if (stripos($label, 'street_address') !== FALSE) {
        $hcalendar['adr']['street-address'][] = $value;
      }
      if (stripos($label, 'extended_address') !== FALSE) {
        $hcalendar['adr']['extended-address'] = $value;
      }
      if (stripos($label, 'region') !== FALSE) {
        $hcalendar['adr']['region'] = $value;
      }
      if (stripos($label, 'locality') !== FALSE) {
        $hcalendar['adr']['locality'] = $value;
      }
      if (stripos($label, 'postal_code') !== FALSE) {
        $hcalendar['adr']['postal-code'] = $value;
      }
      if (stripos($label, 'country_name') !== FALSE) {
        $hcalendar['adr']['country-name'] = $value;
      }
    }
    $xhtml .= '<div class = "vevent">' . "\r\n";
    $class = $hcalendar['class'];
    if ($class) {
      $xhtml .= '  <span class="class">' . $class . '</span>' . "<br/>\r\n";
    }
    $categories = $hcalendar['category'];
    if ($categories) {
      foreach ($categories as $category) {
        $xhtml .= '  <span class="category">' . $category . '</span>' . "<br/>\r\n";
      }
    }
    $description = $hcalendar['description'];
    if ($description) {
      $xhtml .= '  <span class="description">' . $description . '</span>' . "<br/>\r\n";
    }
    $summary = $hcalendar['summary'];
    if ($summary) {
      $xhtml .= '  <span class="summary">' . $summary . '</span>' . "<br/>\r\n";
    }
    $dtstart = $hcalendar['dtstart'];
    if ($dtstart) {
      $xhtml .= '  <span class="dtstart">' . $dtstart . '</span>' . "<br/>\r\n";
    }
    $dtend = $hcalendar['dtend'];
    if ($dtend) {
      $xhtml .= '  <span class="dtend">' . $dtend . '</span>' . "<br/>\r\n";
    }
    $location = $hcalendar['location'];
    if ($location) {
      $xhtml .= '  <span class="location">' . $location . '</span>' . "<br/>\r\n";
    }
    if ($hcalendar['geo']) {
      $geo_latitude = $hcalendar['geo']['latitude'];
      $geo_longitude = $hcalendar['geo']['longitude'];
      if ($geo_latitude || $geo_longitude) {
        $xhtml .= "  <div class=\"geo\">\n";
        if ($location) {
          $xhtml .= "    {$location}: ";
        }
        if ($geo_latitude) {
          $xhtml .= "    <span class=\"latitude\">{$geo_latitude}</span>; ";
        }
        if ($geo_longitude) {
          $xhtml .= "    <span class=\"longitude\">{$geo_longitude}</span>";
        }
        $xhtml .= "  </div>\n";
      }
    }
    $status = $hcalendar['status'];
    if ($status) {
      $xhtml .= '  <span class="status">' . $status . '</span>' . "<br/>\r\n";
    }
    $duration = $hcalendar['duration'];
    if ($duration) {
      $xhtml .= '  <span class="duration">' . $duration . '</span>' . "<br/>\r\n";
    }
    $uid = $hcalendar['uid'];
    if ($uid) {
      $xhtml .= '  <span class="uid">' . $uid . '</span>' . "<br/>\r\n";
    }
    $url = $hcalendar['url'];
    if ($url) {
      $xhtml .= '  <span class="url">' . $url . '</span>' . "<br/>\r\n";
    }
    $last_modified = $hcalendar['last-modified'];
    if ($last_modified) {
      $xhtml .= '  <span class="last-modified">' . $last_modified . '</span>' . "<br/>\r\n";
    }
    $adr = $hcalendar['adr'];
    if ($adr) {
      $xhtml .= "  <div class=\"adr\">\n";
      $adr_type = $adr['type'];
      if ($adr_type) {
        $xhtml .= '    <span class="address-type">' . $adr_type . '</span>' . "<br/>\r\n";
      }
      $country_name = $adr['country-name'];
      if ($country_name) {
        $xhtml .= '    <span class="country-name">' . $country_name . '</span>' . "<br/>\r\n";
      }
      $extended_address = $adr['extended-address'];
      if ($extended_address) {
        $xhtml .= '    <span class="extended-address">' . $extended_address . '</span>' . "<br/>\r\n";
      }
      $locality = $adr['locality'];
      if ($locality) {
        $xhtml .= '    <span class="locality">' . $locality . '</span>' . "<br/>\r\n";
      }
      $postal_code = $adr['postal-code'];
      if ($postal_code) {
        $xhtml .= '    <span class="postal-code">' . $postal_code . '</span>' . "<br/>\r\n";
      }
      $post_office_box = $adr['post-office-box'];
      if ($post_office_box) {
        $xhtml .= '    <span class="post-office-box">' . $post_office_box . '</span>' . "<br/>\r\n";
      }
      $region = $adr['region'];
      if ($region) {
        $xhtml .= '    <span class="region">' . $region . '</span>' . "<br/>\r\n";
      }
      $street_addresses = $hcalendar['adr']['street-address'];
      if ($street_addresses) {
        foreach ($street_addresses as $street_address) {
          $xhtml .= '    <span class="street-address">' . $street_address . '</span>' . "<br/>\r\n";
        }
      }
      $xhtml .= "  </div>\r\n";
    }
    $xhtml .= '</div>' . "\r\n";
  }
  $xhtml .= '</body>' . "\r\n";
  $xhtml .= '</html>' . "\r\n";
  drupal_set_header('Content-Type: text/html');

  //var_dump($view);
  print $xhtml;

  //var_dump($hcalendar);
  module_invoke_all('exit');
  exit;
}

/**
 * Strips illegal Unicode characters and encodes entities in string
 *
 * @param string $input
 * @return string
 */
function views_xhtml_strip_illegal_chars($input) {

  //  $output = preg_replace('/[\x{80}-\x{A0}'. // Non-printable ISO-8859-1 + NBSP
  //        '\x{01}-\x{1F}'. //Non-printable ASCII characters
  //        '\x{AD}'. // Soft-hyphen
  //        '\x{2000}-\x{200F}'. // Various space characters
  //        '\x{2028}-\x{202F}'. // Bidirectional text overrides
  //        '\x{205F}-\x{206F}'. // Various text hinting characters
  //        '\x{FEFF}'. // Byte order mark
  //        '\x{FF01}-\x{FF60}'. // Full-width latin
  //        '\x{FFF9}-\x{FFFD}'. // Replacement characters
  //        '\x{0}]/u', // NULL byte
  //        '', $input);
  //  $output = str_replace('"', '&quot;', $output); //encode quote
  //  $output = str_replace('&', '&amp;', $output); //encode ampersand
  //  $output = str_replace("'", '&pos;', $output); //encode apostrophe
  //  $output = str_replace('<', '&lt;', $output); //encode left-angled bracket
  //  $output = str_replace('>', '&rt;', $output); //encode right-angled bracket
  //  return $output;
  return check_plain(strip_tags($input));
}
function views_xhtml_is_date($input) {
  if (strpos($input, 'a:3:{s:5:"month"') !== 0) {
    return $input;
  }
  else {

    //serialized date array
    $date = unserialize($input);
    return date(DATE_ISO8601, mktime(0, 0, 0, $date['month'], $date['day'], $date['year']));
  }
}

Functions

Namesort descending Description
theme_views_xhtml_hcalendar
theme_views_xhtml_hcard
views_xhtml_hcalendar_handler handler for our own XHTML hCalendar argument handler
views_xhtml_hCalendar_render
views_xhtml_hcalendar_views_argument argument hook that will display the hCalendar data document or display export icons.
views_xhtml_hcard_handler handler for our own XHTML hCard argument handler
views_xhtml_hCard_render
views_xhtml_hcard_views_argument argument hook that will display the hCard data document or display export icons.
views_xhtml_is_date
views_xhtml_strip_illegal_chars Strips illegal Unicode characters and encodes entities in string
views_xhtml_views_arguments
views_xhtml_views_post_view post view to display the render icons
views_xhtml_views_style_plugins Implementation of hook_views_style_plugins