function theme_calendar_ical_feed in Calendar 5.2
Same name and namespace in other branches
- 5 calendar_ical.module \theme_calendar_ical_feed()
plugin that actually displays an ical feed
File
- ./
calendar_ical.module, line 311 - Adds ical functionality to Calendar.
Code
function theme_calendar_ical_feed($view, $items, $type) {
if ($type == 'block') {
return;
}
drupal_set_header('Content-Type: text/calendar; charset=utf-8');
drupal_set_header('Content-Disposition: attachment; filename="calendar.ics"; ');
$display_formats = variable_get('calendar_display_format_' . $view->name, array(
'year' => 'calendar',
'month' => 'calendar',
'week' => 'calendar',
'day' => 'calendar',
'block' => 'calendar',
));
$events = array();
include_once './' . drupal_get_path('module', 'date_api') . '/date_api_ical.inc';
include_once './' . drupal_get_path('module', 'calendar') . '/calendar.inc';
$items = calendar_build_nodes($view, $items, $display_formats[$view->calendar_type]);
foreach ($items as $time) {
foreach ($time as $node) {
$event = array();
// Allow modules to affect item fields
node_invoke_nodeapi($node, 'ical item');
if (!$node->remote) {
$real_node = node_load($node->nid);
$node->teaser = $real_node->teaser;
}
$event['start'] = $node->calendar_start_date;
$event['end'] = $node->calendar_end_date;
$event['location'] = $node->calendar_location;
$event['summary'] = $node->title;
$event['description'] = $node->teaser;
$event['url'] = $node->url ? $node->url : calendar_get_node_link($node);
$event['uid'] = !empty($node->date_id) ? $node->date_id : $event['url'];
$events[] = $event;
}
}
$headertitle = filter_xss_admin(views_get_title($view, 'page'));
$title = variable_get('site_name', 'Drupal');
$description = $headertitle . ($title ? ' | ' . $title : '');
print date_ical_export($events, $description);
module_invoke_all('exit');
exit;
}