]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/RssWriter2.php
simplify RSS: add RSS2 link (rss tag only, new content-type)
[SourceForge/phpwiki.git] / lib / RssWriter2.php
1 <?php rcs_id('$Id: RssWriter2.php,v 1.1 2004-12-06 19:29:23 rurban Exp $');
2 /*
3  * Code for creating RSS 2.0
4  * Author: Reini Urban for PhpWiki
5  */
6
7 // Encoding for RSS output.
8 define('RSS_ENCODING', $GLOBALS['charset']);
9 include_once("lib/RssWriter.php");
10
11 /**
12  * A class for writing RSS 2.0 with xml-rpc notifier
13  *
14  * @see http://blogs.law.harvard.edu/tech/rss,
15  *      http://www.usemod.com/cgi-bin/mb.pl?ModWiki
16  * no namespace! 
17  * http://sourceforge.net/mailarchive/forum.php?thread_id=4872845&forum_id=37467
18  */
19 class RssWriter2 extends RssWriter
20 {
21     function RssWriter2 () {
22         $this->XmlElement('rss',
23                           array('version' => "2.0"));
24
25         // not used. no namespaces should be used.
26         $this->_modules = array(
27             //Standards
28             'content'   => "http://purl.org/rss/1.0/modules/content/",
29             'dc'        => "http://purl.org/dc/elements/1.1/",
30             'sy'        => "http://purl.org/rss/1.0/modules/syndication/",
31             //Proposed
32             'wiki'      => "http://purl.org/rss/1.0/modules/wiki/",
33             'ag'        => "http://purl.org/rss/1.0/modules/aggregation/",
34             'annotate'  => "http://purl.org/rss/1.0/modules/annotate/",
35             'audio'     => "http://media.tangent.org/rss/1.0/",
36             'cp'        => "http://my.theinfo.org/changed/1.0/rss/",
37             'rss091'    => "http://purl.org/rss/1.0/modules/rss091/",
38             'slash'     => "http://purl.org/rss/1.0/modules/slash/",
39             'taxo'      => "http://purl.org/rss/1.0/modules/taxonomy/",
40             'thr'       => "http://purl.org/rss/1.0/modules/threading/"
41             );
42         $this->_uris_seen = array();
43         $this->_items = array();
44     }
45
46     // Required args: (applying defaults)
47     //  'domain', 'port', 'path', 'registerProcedure', 'protocol'
48     // Optional args:
49     //  none
50     function cloud($properties) {
51         // xml-rpc or soap or http-post
52         if (!isset($properties['protocol'])) $properties['protocol'] = 'xml-rpc'; 
53         if (!isset($properties['registerProcedure'])) 
54             $properties['registerProcedure'] = 'rssPleaseNotify';
55         if (!isset($properties['path'])) $properties['path'] = DATA_PATH.'/RPC2.php';
56         if (!isset($properties['port'])) 
57             $properties['port'] = !SERVER_PORT 
58                 ? '80' 
59                 : (SERVER_PROTOCOL == 'https' ? '443' : '80');
60         if (!isset($properties['domain'])) $properties['domain'] = SERVER_NAME;
61         $this->_cloud = $this->__node('cloud', $properties);
62     }
63
64     /**
65      * Write output to HTTP client.
66      */
67     function __spew() {
68         header("Content-Type: application/rss+xml; charset=" . RSS_ENCODING);
69         printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", RSS_ENCODING);
70         printf("<!-- generator=\"PhpWiki-%s\" -->\n", PHPWIKI_VERSION);
71         //RSS2 really is 0.92
72         //<!DOCTYPE rss SYSTEM "http://my.netscape.com/publish/formats/rss-0.92.dtd">
73         echo "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">\n";
74         echo "              %HTMLlat1;]>\n";
75         $this->printXML();
76     }
77
78 };
79
80 // (c-file-style: "gnu")
81 // Local Variables:
82 // mode: php
83 // tab-width: 8
84 // c-basic-offset: 4
85 // c-hanging-comment-ender-p: nil
86 // indent-tabs-mode: nil
87 // End:   
88 ?>