function event_calendar_rss in Event 5
Same name and namespace in other branches
- 5.2 event.module \event_calendar_rss()
Creates an rss feed of events.
Parameters
$stamp The GMT starting date for the feed.:
$duration The number of days the feeds duration is.:
$types The content types to filter the feed by.:
$terms The taxonomy term tids to filter the feed by.:
$title The filter title to append to the channel description.:
Return value
A formatted rss feed.
Related topics
1 call to event_calendar_rss()
- event_page in ./
event.module - Displays a page containing event information. The page layout defaults to a graphical calendar.
File
- ./
event.module, line 703
Code
function event_calendar_rss($stamp, $duration, $types = NULL, $terms = NULL, $title = NULL) {
global $base_url, $locale;
$endstamp = $stamp + $duration * 86400;
$headertitle = t('!startmonth !startdate, !startyear - !endmonth !enddate, !endyear', array(
'!startmonth' => t(gmdate('F', $stamp)),
'!startdate' => gmdate('d', $stamp),
'!startyear' => gmdate('Y', $stamp),
'!endmonth' => t(gmdate('F', $endstamp)),
'!enddate' => gmdate('d', $endstamp),
'!endyear' => gmdate('Y', $endstamp),
));
$result = db_query(db_rewrite_sql('SELECT n.nid, e.event_start FROM {node} n INNER JOIN {event} e ON n.nid = e.nid WHERE n.status = 1 AND ((e.event_start > %d AND e.event_start < %d) OR (e.event_end > %d AND e.event_end < %d) OR (e.event_start < %d AND e.event_end > %d)) ORDER BY event_start '), $stamp, $endstamp, $stamp, $endstamp, $stamp, $endstamp);
$nodes = array();
while ($nid = db_fetch_object($result)) {
$node = node_load($nid->nid);
$nodes[] = $node;
}
$filtered = event_filter_nodes($nodes, $types, $terms);
foreach ($filtered as $node) {
$body = '<div class="start">' . t('Start') . ': ' . $node->start_format . '</div>' . "\n";
$body .= '<div class="end">' . t('End') . ': ' . $node->end_format . '</div>' . "\n";
$body .= check_markup($node->teaser);
$link = url("node/{$node->nid}", NULL, NULL, 1);
// Allow modules to add additional item fields
$extra = node_invoke_nodeapi($node, 'rss item');
$extra = array_merge($extra, array(
array(
'key' => 'pubDate',
'value' => date('r', $node->changed),
),
));
$items .= format_rss_item($node->title, $link, $body, $extra);
}
$description = $headertitle . ($title ? ' | ' . $title : '');
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
if (module_exists('location')) {
$output .= "<rss version=\"2.0\" xmlns:geo=\"http://www.w3.org/2003/01/geo/wgs84_pos#\" xmlns:geourl=\"http://geourl.org/rss/module/\" xmlns:icbm=\"http://postneo.com/icbm\" xml:base=\"" . $base_url . "\">\n";
}
else {
$output .= "<rss version=\"2.0\" xml:base=\"" . $base_url . "\">\n";
}
$output .= format_rss_channel(variable_get('site_name', 'drupal') . t(' - Events Feed'), url('event/feed', NULL, NULL, TRUE), $description, $items, $locale);
$output .= "</rss>\n";
return $output;
}