function theme_calendar_ical_feed in Calendar 5
Same name and namespace in other branches
- 5.2 calendar_ical.module \theme_calendar_ical_feed()
plugin that actually displays an ical feed
File
- ./
calendar_ical.module, line 414 - Adds ical functionality to Calendar.
Code
function theme_calendar_ical_feed($view, $items, $type) {
calendar_ical_load_date_ical();
if ($type == 'block') {
return;
}
$results = calendar_get_nodes($view, $items, $type);
$nodes = $results['nodes'];
// Unset empty nodes that might have been created to fill out empty calendars.
unset($nodes[0]);
$params = $results['params'];
foreach ((array) $nodes as $delta => $node) {
// switch our psuedo nids back to the right values
$tmp = explode(':', $node->nid);
$node->nid = $tmp[0];
$nodes[$delta] = $node;
}
foreach (module_implements('calendar_add_items') as $module) {
$function = $module . '_calendar_add_items';
$nodes += $function($view);
}
drupal_set_header('Content-Type: text/calendar; charset=utf-8');
drupal_set_header('Content-Disposition: attachment; filename="calendar.ics"; ');
$events = array();
foreach ($nodes as $node) {
$event = array();
// Allow modules to affect item fields
node_invoke_nodeapi($node, 'ical item');
$event['start'] = $node->calendar_start;
$event['end'] = $node->calendar_end;
$event['timezone'] = 'GMT';
$event['location'] = $node->calendar_location;
$event['summary'] = $node->title;
$event['description'] = $node->teaser;
$event['uid'] = $node->uid ? $node->uid : (is_numeric($node->nid) ? url("node/{$node->nid}", NULL, NULL, 1) : $node->nid);
$event['url'] = $node->url ? $node->url : (is_numeric($node->nid) ? url("node/{$node->nid}", NULL, NULL, 1) : $node->nid);
$events[] = $event;
}
$description = $headertitle . ($title ? ' | ' . $title : '');
print date_ical_export($events, $description);
module_invoke_all('exit');
exit;
}