function views_xhtml_hCalendar_render in Views Datasource 5
File
- ./
views_xhtml.module, line 373 - Provides Views plugin for rendering node content as XHTML microformats.
Code
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;
}