cvs: php-master-web /scripts rss_parser
| From: | Hannes Magnusson | Date: | Sun, 18 Feb 2007 16:26:37 +0000 |
| Subject: | cvs: php-master-web /scripts rss_parser | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-34349@lists.php.net to get a copy of this message | ||
bjori Sun Feb 18 16:26:37 2007 UTC
Modified files:
/php-master-web/scripts rss_parser
Log:
Add dc:subject into our feed
#Usage <!-- SUBJECT: name -->
http://cvs.php.net/viewvc.cgi/php-master-web/scripts/rss_parser?r1=1.19&r2=1.20&diff_format=u
Index: php-master-web/scripts/rss_parser
diff -u php-master-web/scripts/rss_parser:1.19 php-master-web/scripts/rss_parser:1.20
--- php-master-web/scripts/rss_parser:1.19 Sun Feb 11 23:30:19 2007
+++ php-master-web/scripts/rss_parser Sun Feb 18 16:26:37 2007
@@ -68,7 +68,7 @@
function ParseNews ($index_page = "", $aboutLink) {
// Remove commented items
- $index_page = preg_replace("/<!--[\w\W]*?-->/", "", $index_page);
+ //$index_page = preg_replace("/<!--[\w\W]*?-->/", "", $index_page);
// Split the file by newlines
$lines = preg_split("/\n/", $index_page);
@@ -123,6 +123,10 @@
$headlines[$headlineid]['date'] = mktime(1,1,1, $mos[$matches[2]],
$matches[1], $matches[3]);
#DEBUG# print "Date: $matches[1] $matches[2] $matches[3]<br />";
+ // Subjects (i.e RDF category)
+ } elseif (preg_match("/<!-- SUBJECT: (.*?) -->/", $line, $matches)) {
+ $headlines[$headlineid]['subject'] = $matches[1];
+
// Everything else is part of the headline text
} else {
if (!preg_match('/^\s*\?>\s*$/', $line)) {
@@ -181,10 +185,16 @@
}
// Add an RSS item's information to $RSS
-function GenerateRSSItem($href, $title, $text, $date, &$RSS) {
+function GenerateRSSItem($href, $title, $text, $date, $subject, &$RSS) {
+ if($subject) {
+ $s = "\t<dc:subject>$subject</dc:subject>\n";
+ } else {
+ $s = "";
+ }
$RSS .= "\n<item rdf:about=\"$href\">\n" .
"\t<title>$title</title>\n" .
"\t<link>$href</link>\n" .
+ $s .
"\t<description>$text</description>\n" .
"\t<dc:date>" . $date . "</dc:date>\n" .
"</item>\n";
@@ -208,7 +218,7 @@
// Add every news item to the feed
foreach ($hlines as $hline) {
- GenerateRSSItem($hline['link'], $hline['title'], $hline['text'],
$hline['date'], $RSS);
+ GenerateRSSItem($hline['link'], $hline['title'], $hline['text'],
$hline['date'], isset($hline['subject']) ? $hline['subject'] : false,
$RSS);
}
// Add end separator