Closed (fixed)
Project:
Atom
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
3 Nov 2004 at 14:19 UTC
Updated:
12 May 2005 at 12:59 UTC
Please update atom.module for 4.5.0
<?php
// $Id: atom.module,v 1.10 2004/06/28 05:08:50 dries Exp $
function atom_help($section) {
$output = "";
switch ($section) {
case "admin/modules#description":
$output = t("Provides an Atom 0.3 feed");
break;
}
return $output;
}
function atom_menu() {
$items = array();
drupal_set_html_head("<link rel=\"alternate\" type=\"application/atom+xml\" title=\"Atom\" href=\"". url("atom/feed") ."\" />");
$items[] = array('path' => 'atom/feed', 'title' => t('atom feed'),
'callback' => 'atom_feed',
'access' => user_access('access content'),
'type' => MENU_CALLBACK);
return $items;
}
function atom_feed() {
global $base_url;
$output = "";
$last_mod = 0;
$nodes = db_query_range("SELECT n.nid, u.uid, u.name FROM {node} n, {users} u WHERE n.uid = u.uid AND n.promote = '1' AND n.status = '1' ORDER BY n.created DESC", 0, 15);
while ($node = db_fetch_object($nodes)) {
$item = node_load(array("nid" => $node->nid));
$link = url("node/$node->nid", NULL, NULL, true);
$output .= " <entry>\n";
$output .= " <title>". $item->title ."</title>\n";
$output .= " <link rel=\"alternate\" type=\"text/html\" href=\"". $link ."\" />\n";
$output .= " <id>$link</id>\n";
$output .= " <issued>". _atom_timestamp2w3dtf($item->created) ."</issued>\n";
$output .= " <modified>". _atom_timestamp2w3dtf($item->changed) ."</modified>\n";
$last_mod = $item->changed;
$output .= " <author>\n";
if ($node->name) {
$output .= " <name>". $node->name ."</name>\n";
}
else {
$output .= " <name>". variable_get('anonymous', 'Anonymous') ."</name>\n";
}
$output .= " </author>\n";
$output .= " </entry>\n";
}
header("Content-Type: application/xml");
print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
print "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\">\n";
print " <title>". variable_get("site_name", "drupal") ." - ". variable_get("site_slogan", "") ."</title>\n";
print " <link rel=\"alternate\" type=\"text/html\" href=\"". $base_url. "\"/>\n";
print " <modified>". _atom_timestamp2w3dtf($last_mod) ."</modified>\n";
print $output;
print "</feed>\n";
}
function _atom_timestamp2w3dtf($timestamp) {
$tz = date("O", $timestamp);
return date("Y-m-d", $timestamp) ."T". date("H:i:s", $timestamp) . substr($tz, 0, 3) . ":" . substr($tz, 3, 2);
}
?>
Comments
Comment #1
Uwe Hermann commentedComment #2
menesis commentedThis code is identical to what is atom.module version 4.5
Comment #3
(not verified) commented