From e406d3054ee1e5765bb57f10284d66ef070ca230 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 9 Sep 2003 19:05:08 +0000 Subject: [PATCH] - Added support for the optional element in our node RSS feeds. This could help reduce the number of HTTP requests and fixes some annoyances with RSS clients. --- modules/node.module | 25 ++++++++++++++++++++++--- modules/node/node.module | 25 ++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/modules/node.module b/modules/node.module index f8c663212ba..978b0183912 100644 --- a/modules/node.module +++ b/modules/node.module @@ -980,9 +980,28 @@ function node_feed($nodes = 0, $channel = array()) { } while ($node = db_fetch_object($nodes)) { + /* + ** Load the specified node: + */ + $item = node_load(array("nid" => $node->nid)); - $link = url(node_url($node)); - $items .= format_rss_item($item->title, $link, ($item->teaser ? $item->teaser : $item->body)); + + /* + ** Transform the node information into an RSS item: + */ + + $items .= format_rss_item($item->title, url(node_url($node)), ($item->teaser ? $item->teaser : $item->body)); + + /* + ** Determine the publication date: + */ + + if ($item->updated > $pubdate) { + $pubdate = $item->updated; + } + if ($item->created > $pubdate) { + $pubdate = $item->created; + } } $output .= "\n"; @@ -994,7 +1013,7 @@ function node_feed($nodes = 0, $channel = array()) { foreach ($languages as $key => $value) break; if (!$channel["language"]) $channel["language"] = $key ? $key : "en"; $output .= "\n"; - $output .= format_rss_channel($channel["title"], $channel["link"], $channel["description"], $items, $channel["language"]); + $output .= format_rss_channel($channel["title"], $channel["link"], $channel["description"], $items, $channel["language"], array("pubdate" => date("r", $pubdate))); $output .= "\n"; header("Content-Type: text/xml"); diff --git a/modules/node/node.module b/modules/node/node.module index f8c663212ba..978b0183912 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -980,9 +980,28 @@ function node_feed($nodes = 0, $channel = array()) { } while ($node = db_fetch_object($nodes)) { + /* + ** Load the specified node: + */ + $item = node_load(array("nid" => $node->nid)); - $link = url(node_url($node)); - $items .= format_rss_item($item->title, $link, ($item->teaser ? $item->teaser : $item->body)); + + /* + ** Transform the node information into an RSS item: + */ + + $items .= format_rss_item($item->title, url(node_url($node)), ($item->teaser ? $item->teaser : $item->body)); + + /* + ** Determine the publication date: + */ + + if ($item->updated > $pubdate) { + $pubdate = $item->updated; + } + if ($item->created > $pubdate) { + $pubdate = $item->created; + } } $output .= "\n"; @@ -994,7 +1013,7 @@ function node_feed($nodes = 0, $channel = array()) { foreach ($languages as $key => $value) break; if (!$channel["language"]) $channel["language"] = $key ? $key : "en"; $output .= "\n"; - $output .= format_rss_channel($channel["title"], $channel["link"], $channel["description"], $items, $channel["language"]); + $output .= format_rss_channel($channel["title"], $channel["link"], $channel["description"], $items, $channel["language"], array("pubdate" => date("r", $pubdate))); $output .= "\n"; header("Content-Type: text/xml");