Zeile 6 | Zeile 6 |
---|
* Website: http://www.mybboard.com * License: http://www.mybboard.com/eula.html *
|
* Website: http://www.mybboard.com * License: http://www.mybboard.com/eula.html *
|
* $Id: class_feedgeneration.php 1998 2006-07-19 07:05:51Z Kilroy $
| * $Id: class_feedgeneration.php 2724 2007-02-07 20:03:56Z CraKteR $
|
*/
class FeedGenerator
| */
class FeedGenerator
|
Zeile 16 | Zeile 16 |
---|
* * @var string */
|
* * @var string */
|
var $feed_format = 'rss0.92';
| var $feed_format = 'rss2.0';
|
/** * The XML to output.
| /** * The XML to output.
|
Zeile 46 | Zeile 46 |
---|
*/ function set_feed_format($feed_format) {
|
*/ function set_feed_format($feed_format) {
|
if($feed_format == 'rss2.0')
| if($feed_format == 'atom1.0')
|
{
|
{
|
$this->feed_format = 'rss2.0'; } elseif($feed_format == 'atom1.0') { $this->feed_format = 'atom1.0';
| $this->feed_format = 'atom1.0';
|
} else {
|
} else {
|
$this->feed_format = 'rss0.92';
| $this->feed_format = 'rss2.0';
|
} }
| } }
|
Zeile 66 | Zeile 62 |
---|
* @param array The channel information */ function set_channel($channel)
|
* @param array The channel information */ function set_channel($channel)
|
{
| {
|
$this->channel = $channel;
|
$this->channel = $channel;
|
}
| }
|
/** * Adds an item to the RSS feed.
| /** * Adds an item to the RSS feed.
|
Zeile 78 | Zeile 74 |
---|
function add_item($item) { $this->items[] = $item;
|
function add_item($item) { $this->items[] = $item;
|
}
| }
|
/** * Generate and echo XML for the feed. *
| /** * Generate and echo XML for the feed. *
|
Zeile 92 | Zeile 88 |
---|
{ // Ouput an Atom 1.0 formatted feed. case "atom1.0":
|
{ // Ouput an Atom 1.0 formatted feed. case "atom1.0":
|
$this->channel['date'] = date("Y-m-d\TH:i:s O", $this->channel['date']);
| $this->channel['date'] = date("Y-m-d\TH:i:s\Z", $this->channel['date']);
|
$this->xml .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $this->xml .= "<feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
|
$this->xml .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $this->xml .= "<feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
|
$this->xml .= "\t<title><![CDATA[".htmlspecialchars_uni($this->channel['title'])."]]></title>\n"; $this->xml .= "\t<id>".$this->channel['link']."</id>\n"; $this->xml .= "\t<link rel=\"alternate\" type=\"text/html\" href=\"".$this->channel['link']."\"/>\n"; $this->xml .= "\t<modified>".$this->channel['date']."</modified>\n";
| $this->xml .= "\t<title type=\"html\">".htmlspecialchars_uni($this->channel['title'])."</title>\n"; $this->xml .= "\t<subtitle type=\"html\">".htmlspecialchars_uni($this->channel['description'])."</subtitle>\n"; $this->xml .= "\t<link rel=\"self\" href=\"{$this->channel['link']}syndication.php\"/>\n"; $this->xml .= "\t<id>{$this->channel['link']}</id>\n"; $this->xml .= "\t<link rel=\"alternate\" type=\"text/html\" href=\"{$this->channel['link']}\"/>\n"; $this->xml .= "\t<updated>{$this->channel['date']}</updated>\n";
|
$this->xml .= "\t<generator uri=\"http://mybboard.com\">MyBB</generator>\n";
|
$this->xml .= "\t<generator uri=\"http://mybboard.com\">MyBB</generator>\n";
|
break;
| break;
|
// The default is the RSS 2.0 format. default: $this->channel['date'] = date("D, d M Y H:i:s O", $this->channel['date']); $this->xml .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
|
// The default is the RSS 2.0 format. default: $this->channel['date'] = date("D, d M Y H:i:s O", $this->channel['date']); $this->xml .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
|
$this->xml .= "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
| $this->xml .= "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
|
$this->xml .= "\t<channel>\n";
|
$this->xml .= "\t<channel>\n";
|
$this->xml .= "\t\t<title><![CDATA[".htmlspecialchars_uni($this->channel['title'])."]]></title>\n";
| $this->xml .= "\t\t<title>".htmlspecialchars_uni($this->channel['title'])."</title>\n";
|
$this->xml .= "\t\t<link>".$this->channel['link']."</link>\n"; $this->xml .= "\t\t<description>".htmlspecialchars_uni($this->channel['description'])."</description>\n"; $this->xml .= "\t\t<pubDate>".$this->channel['date']."</pubDate>\n";
| $this->xml .= "\t\t<link>".$this->channel['link']."</link>\n"; $this->xml .= "\t\t<description>".htmlspecialchars_uni($this->channel['description'])."</description>\n"; $this->xml .= "\t\t<pubDate>".$this->channel['date']."</pubDate>\n";
|
Zeile 116 | Zeile 114 |
---|
// Now loop through all of the items and add them to the feed XML. foreach($this->items as $item)
|
// Now loop through all of the items and add them to the feed XML. foreach($this->items as $item)
|
{
| {
|
if(!$item['date']) { $item['date'] = time();
| if(!$item['date']) { $item['date'] = time();
|
Zeile 126 | Zeile 124 |
---|
// Output Atom 1.0 format feed. case "atom1.0": $item['date'] = date("Y-m-d\TH:i:s\Z", $item['date']);
|
// Output Atom 1.0 format feed. case "atom1.0": $item['date'] = date("Y-m-d\TH:i:s\Z", $item['date']);
|
$this->xml .= "\t<entry>\n"; if($item['author'])
| $this->xml .= "\t<entry xmlns=\"http://www.w3.org/2005/Atom\">\n"; if(!empty($item['author']))
|
{ $this->xml .= "\t\t<author>\n";
|
{ $this->xml .= "\t\t<author>\n";
|
$this->xml .= "\t\t\t<name><![CDATA[".htmlspecialchars_uni($item['author'])."]]></name>\n";
| $this->xml .= "\t\t\t<name>".htmlspecialchars_uni($item['author'])."</name>\n";
|
$this->xml .= "\t\t</author>\n"; }
|
$this->xml .= "\t\t</author>\n"; }
|
$this->xml .= "\t\t<title type=\"text/html\" mode=\"escaped\"><![CDATA[".htmlspecialchars_uni($item['title'])."]]></title>\n"; $this->xml .= "\t\t<link rel=\"alternate\" type=\"text/html\" href=\"".$item['link']."\" />\n"; $this->xml .= "\t\t<id>".$item['link']."</id>\n"; $this->xml .= "\t\t<modified>{$item['date']}</modified>\n"; $this->xml .= "\t\t<issued>{$item['date']}</issued>\n"; $this->xml .= "\t\t<summary type=\"text/plain\" mode=\"escaped\"><![CDATA[".strip_tags($item['description'])."]]></summary>\n"; $this->xml .= "\t\t<content type=\"text/html\" mode=\"escaped\" xml:base=\"".$item['link']."\"><![CDATA[{$item['description']}]]></content>\n";
| $this->xml .= "\t\t<published>{$item['date']}</published>\n"; if(empty($item['updated'])) { $item['updated'] = $item['date']; } else { $item['updated'] = date("Y-m-d\TH:i:s\Z", $item['updated']);; } $this->xml .= "\t\t<updated>{$item['updated']}</updated>\n"; $this->xml .= "\t\t<link rel=\"alternate\" type=\"text/html\" href=\"{$item['link']}\" />\n"; $this->xml .= "\t\t<id>{$item['link']}</id>\n"; $this->xml .= "\t\t<title type=\"html\" xml:space=\"preserve\">".htmlspecialchars_uni($item['title'])."</title>\n"; $this->xml .= "\t\t<content type=\"html\" xml:space=\"preserve\" xml:base=\"{$item['link']}\"><![CDATA[".strip_tags($item['description'])."]]></content>\n"; $this->xml .= "\t\t<draft xmlns=\"http://purl.org/atom-blog/ns#\">false</draft>\n";
|
$this->xml .= "\t</entry>\n"; break;
| $this->xml .= "\t</entry>\n"; break;
|
Zeile 147 | Zeile 153 |
---|
default: $item['date'] = date("D, d M Y H:i:s O", $item['date']); $this->xml .= "\t\t<item>\n";
|
default: $item['date'] = date("D, d M Y H:i:s O", $item['date']); $this->xml .= "\t\t<item>\n";
|
$this->xml .= "\t\t\t<title><![CDATA[".htmlspecialchars_uni($item['title'])."]]></title>\n";
| $this->xml .= "\t\t\t<title>".htmlspecialchars_uni($item['title'])."</title>\n";
|
$this->xml .= "\t\t\t<link>".$item['link']."</link>\n"; $this->xml .= "\t\t\t<pubDate>".$item['date']."</pubDate>\n"; if($item['author']) {
|
$this->xml .= "\t\t\t<link>".$item['link']."</link>\n"; $this->xml .= "\t\t\t<pubDate>".$item['date']."</pubDate>\n"; if($item['author']) {
|
$this->xml .= "\t\t\t<dc:creator><![CDATA[".htmlspecialchars_uni($item['author'])."]]></dc:creator>\n";
| $this->xml .= "\t\t\t<dc:creator>".htmlspecialchars_uni($item['author'])."</dc:creator>\n";
|
} $this->xml .= "\t\t\t<guid isPermaLink=\"false\">".$item['link']."</guid>\n"; $this->xml .= "\t\t\t<description><![CDATA[".strip_tags($item['description'])."]]></description>\n"; $this->xml .= "\t\t\t<content:encoded><![CDATA[".$item['description']."]]></content:encoded>\n"; $this->xml .= "\t\t</item>\n"; break;
|
} $this->xml .= "\t\t\t<guid isPermaLink=\"false\">".$item['link']."</guid>\n"; $this->xml .= "\t\t\t<description><![CDATA[".strip_tags($item['description'])."]]></description>\n"; $this->xml .= "\t\t\t<content:encoded><![CDATA[".$item['description']."]]></content:encoded>\n"; $this->xml .= "\t\t</item>\n"; break;
|
| |
} }
// Now, neatly end the feed XML. switch($this->feed_format) {
|
} }
// Now, neatly end the feed XML. switch($this->feed_format) {
|
case "rss2.0": $this->xml .= "\t</channel>\n"; $this->xml .= "</rss>"; break;
| |
case "atom1.0": $this->xml .= "</feed>";
|
case "atom1.0": $this->xml .= "</feed>";
|
break;
| break;
|
default: $this->xml .= "\t</channel>\n"; $this->xml .= "</rss>";
| default: $this->xml .= "\t</channel>\n"; $this->xml .= "</rss>";
|
Zeile 187 | Zeile 188 |
---|
// Send an appropriate header to the browser. switch($this->feed_format) {
|
// Send an appropriate header to the browser. switch($this->feed_format) {
|
case "rss2.0": header("Content-Type: text/xml"); break;
| |
case "atom1.0":
|
case "atom1.0":
|
header("Content-Type: application/atom+xml");
| header("Content-Type: application/atom+xml; charset=utf-8");
|
break; default:
|
break; default:
|
header("Content-Type: text/xml");
| header("Content-Type: text/xml; charset=utf-8");
|
}
// Output the feed XML. If the feed hasn't been generated, do so.
| }
// Output the feed XML. If the feed hasn't been generated, do so.
|