Conference teaser on the front page
| From: | Hannes Magnusson | Date: | Mon, 12 Feb 2007 00:35:36 +0000 |
| Subject: | Conference teaser on the front page | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-34255@lists.php.net to get a copy of this message | ||
Hi all
Attached are patches that add a conference teaser on the front page &
splits the conference feed into two "categories" (dc:subject), "cfp" &
"conference".
Screenshot in fx: http://home.oslo.nith.no/~maghan/confs.rss.png
Screenshot in konq: http://home.oslo.nith.no/~maghan/confs.rss2.png
Objections?
-Hannes
Index: scripts/rss_parser =================================================================== RCS file: /repository/php-master-web/scripts/rss_parser,v retrieving revision 1.19 diff -u -r1.19 rss_parser --- scripts/rss_parser 11 Feb 2007 23:30:19 -0000 1.19 +++ scripts/rss_parser 11 Feb 2007 23:40:16 -0000 @@ -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
Index: scripts/rss_parser =================================================================== RCS file: /repository/php-master-web/scripts/rss_parser,v retrieving revision 1.19 diff -u -r1.19 rss_parser --- scripts/rss_parser 11 Feb 2007 23:30:19 -0000 1.19 +++ scripts/rss_parser 11 Feb 2007 23:40:16 -0000 @@ -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