| 1 | <?php |
|---|
| 2 | ############################################################################### |
|---|
| 3 | # Gregarius - A PHP based RSS aggregator. |
|---|
| 4 | # Copyright (C) 2003 - 2006 Marco Bonetti |
|---|
| 5 | # |
|---|
| 6 | ############################################################################### |
|---|
| 7 | # This program is free software and open source software; you can redistribute |
|---|
| 8 | # it and/or modify it under the terms of the GNU General Public License as |
|---|
| 9 | # published by the Free Software Foundation; either version 2 of the License, |
|---|
| 10 | # or (at your option) any later version. |
|---|
| 11 | # |
|---|
| 12 | # This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 13 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 14 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 15 | # more details. |
|---|
| 16 | # |
|---|
| 17 | # You should have received a copy of the GNU General Public License along |
|---|
| 18 | # with this program; if not, write to the Free Software Foundation, Inc., |
|---|
| 19 | # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit |
|---|
| 20 | # http://www.gnu.org/licenses/gpl.html |
|---|
| 21 | # |
|---|
| 22 | ############################################################################### |
|---|
| 23 | # E-mail: mbonetti at gmail dot com |
|---|
| 24 | # Web page: http://gregarius.net/ |
|---|
| 25 | # |
|---|
| 26 | ############################################################################### |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | class RDFItemList { |
|---|
| 30 | |
|---|
| 31 | var $baselink; |
|---|
| 32 | var $resource; |
|---|
| 33 | var $items; |
|---|
| 34 | |
|---|
| 35 | function RDFItemList($items) { |
|---|
| 36 | $this -> items = $items; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | function render($title) { |
|---|
| 40 | // trash the output, just in case |
|---|
| 41 | @ ob_end_clean(); |
|---|
| 42 | ob_start(); |
|---|
| 43 | header('Content-Type: text/xml'); |
|---|
| 44 | |
|---|
| 45 | echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" |
|---|
| 46 | ."<rdf:RDF\n"."\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" |
|---|
| 47 | ."\txmlns=\"http://purl.org/rss/1.0/\"\n" |
|---|
| 48 | ."\txmlns:taxo=\"http://purl.org/rss/1.0/modules/taxonomy/\"\n" |
|---|
| 49 | ."\txmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n" |
|---|
| 50 | ."\txmlns:syn=\"http://purl.org/rss/1.0/modules/syndication/\"\n" |
|---|
| 51 | ."\txmlns:admin=\"http://webns.net/mvcb/\"\n" |
|---|
| 52 | .">\n\n"; |
|---|
| 53 | |
|---|
| 54 | echo "<channel rdf:about=\"".$this->baselink.$this->resource."\">\n" |
|---|
| 55 | ."\t<title>".htmlentities($title, ENT_QUOTES, 'UTF-8') |
|---|
| 56 | ."</title>\n"."\t<link>".$this->baselink.$this->resource."</link>\n" |
|---|
| 57 | ."\t<description></description>\n" |
|---|
| 58 | ."</channel>\n\n"; |
|---|
| 59 | |
|---|
| 60 | if ($this -> items) { |
|---|
| 61 | foreach ($this -> items -> feeds as $feed) { |
|---|
| 62 | foreach($feed->items as $item) { |
|---|
| 63 | $xmlTitle = htmlentities($item->title, ENT_QUOTES, 'UTF-8'); |
|---|
| 64 | echo "<item rdf:about=\"".$item->url."\">\n"."\t<title>$xmlTitle</title>\n"."\t<link>".$item->url."</link>\n" |
|---|
| 65 | // http://www.jschreiber.com/archives/2004/03/php_and_timesta_1.html |
|---|
| 66 | ."\t<dc:date>".rss_date('Y-m-d\TH:i:sO', $item->date)."</dc:date>\n" |
|---|
| 67 | ."\t<dc:subject>$xmlTitle</dc:subject>\n"; |
|---|
| 68 | |
|---|
| 69 | if (count($item -> tags)) { |
|---|
| 70 | echo "\t<taxo:topics>\n"."\t\t<rdf:Bag>\n"; |
|---|
| 71 | foreach ($item -> tags as $tag) { |
|---|
| 72 | echo "\t\t\t<rdf:li rdf:resource=\"".$this->baselink.$tag."\" />\n"; |
|---|
| 73 | } |
|---|
| 74 | echo "\t\t</rdf:Bag>\n". |
|---|
| 75 | "\t</taxo:topics>\n"; |
|---|
| 76 | |
|---|
| 77 | } |
|---|
| 78 | echo "</item>\n\n"; |
|---|
| 79 | } |
|---|
| 80 | } |
|---|
| 81 | } |
|---|
| 82 | echo "</rdf:RDF>\n"; |
|---|
| 83 | } |
|---|
| 84 | } |
|---|
| 85 | ?> |
|---|