function activity_feed in Activity 6
Same name and namespace in other branches
- 5.4 activity.module \activity_feed()
- 5 activity.module \activity_feed()
- 5.2 activity.module \activity_feed()
- 5.3 activity.module \activity_feed()
Menu callback for displaying site or user activity as an RSS feed.
1 string reference to 'activity_feed'
- activity_menu in ./
activity.module - Implementation of hook_menu().
File
- ./
activity.module, line 896 - activity.module
Code
function activity_feed($arg) {
global $language;
if ($arg == ACTIVITY_ALL) {
$activities = activity_get_activity(ACTIVITY_ALL, NULL, variable_get('activity_page_pager', 20));
$url = url('activity/all', array(
'absolute' => TRUE,
));
$feed_title = t('All activity');
}
else {
if (is_object($arg)) {
$activities = activity_get_activity($arg->uid, NULL, variable_get('activity_page_pager', 20));
$url = url('activity/' . $arg->uid, array(
'absolute' => TRUE,
));
$feed_title = t('Activity for @username', array(
'@username' => $arg->name,
));
}
}
if (count($activities) > 0) {
foreach ($activities as $activity) {
$function = $activity['module'] . '_format_rss_item';
if (function_exists($function)) {
// Each module gets a chance to build its own feed item.
// They should use the $activity to prepare variables and
// call format_rss_item($title, $link, $item_text, $extra);
$items .= $function($activity);
}
else {
$message = activity_token_replace($activity);
$items .= format_rss_item(strip_tags($message), url('activity/' . $user->uid, array(
'absolute' => TRUE,
)), format_date($activity['created']) . '<p>' . $message . '</p>');
}
}
}
$channel = array(
'version' => '2.0',
'title' => variable_get('site_name', 'Drupal') . ' - ' . $feed_title,
'link' => $url,
'description' => variable_get('site_mission', ''),
'language' => $language,
);
// @todo Figure out what the right namespace should be.
$namespaces = array(
'xmlns:dc="http://purl.org/dc/elements/1.1/"',
);
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output .= "<rss version=\"" . $channel["version"] . "\" xml:base=\"" . $url . "\" " . implode(' ', $namespaces) . ">\n";
$output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']->language);
$output .= "</rss>\n";
drupal_set_header('Content-Type: application/rss+xml; charset=utf-8');
print $output;
}