diff options
author | Andrew Dolgov <[email protected]> | 2006-10-12 04:27:03 +0100 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2006-10-12 04:27:03 +0100 |
commit | ed313cdea970b1e113e80dacc229417b7ab7f3bc (patch) | |
tree | b7457b3069012de55f2c0503d6362e30e4a17751 /functions.php | |
parent | a422968f92f877186ecafdf8b59fa155b028cb97 (diff) |
use FeedCreator to generate syndicated feeds
Diffstat (limited to 'functions.php')
-rw-r--r-- | functions.php | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/functions.php b/functions.php index 8b13bed98..97ad0c6c4 100644 --- a/functions.php +++ b/functions.php @@ -19,6 +19,8 @@ require_once 'simplepie/simplepie.inc'; } + require_once "feedcreator.class.php"; + define('MAGPIE_OUTPUT_ENCODING', 'UTF-8'); function purge_feed($link, $feed_id, $purge_interval, $debug = false) { @@ -2360,7 +2362,7 @@ } function generate_syndicated_feed($link, $feed, $is_cat, - $search, $search_mode, $match_on) { + $search, $search_mode, $match_on, $output_format = "RSS2.0") { $qfh_ret = queryFeedHeadlines($link, $feed, 30, false, $is_cat, $search, $search_mode, $match_on, "updated DESC"); @@ -2370,31 +2372,23 @@ $feed_site_url = $qfh_ret[2]; $last_error = $qfh_ret[3]; - print "<rss version=\"2.0\"> - <channel> - <title>$feed_title</title> - <link>$feed_site_url</link> - <generator>Tiny Tiny RSS v".VERSION."</generator>"; - - while ($line = db_fetch_assoc($result)) { - print "<item>"; - print "<id>" . htmlspecialchars($line["guid"]) . "</id>"; - print "<link>" . htmlspecialchars($line["link"]) . "</link>"; + $rss = new UniversalFeedCreator(); - $rfc822_date = date('r', strtotime($line["updated"])); + $rss->title = $feed_title; + $rss->link = $feed_site_url; - print "<pubDate>$rfc822_date</pubDate>"; - - print "<title>" . - htmlspecialchars($line["title"]) . "</title>"; + while ($line = db_fetch_assoc($result)) { - print "<description>" . - htmlspecialchars($line["content_preview"]) . "</description>"; + $item = new FeedItem(); + $item->title = $line["title"]; + $item->description = $line["content_preview"]; + $item->date = strtotime($line["updated"]); + $item->id = $line["guid"]; - print "</item>"; + $rss->addItem($item); } - print "</channel></rss>"; + print $rss->createFeed($output_format); } |