de.bitfolge.feedcreator
de.bitfolge.feedcreator is a MidCOM library for adding RSS and Atom feeds into component output. It uses the LGPLd FeedCreator class library by Kai Blankenhorn.
Documentation:
Usage is relatively simple. First you need to include the library into the _autoload_libraries array of your component's interface class:
$this->_autoload_libraries = Array(
'midcom.helper.datamanager',
'de.bitfolge.feedcreator',
);
Then in your viewer class create a handler method for RSS output that skips regular style output:
$_MIDCOM->skip_page_style = true;
And finally in the RSS output's show method populate and show the feed (example from net.nemein.wiki):
$nap = new midcom_helper_nav();
$node = $nap->get_node($nap->get_current_node());
$_MIDCOM->cache->content->content_type("text/xml");
$_MIDCOM->header("Content-type: text/xml; charset=UTF-8");
$rss = new UniversalFeedCreator();
$rss->title = $node[MIDCOM_NAV_NAME];
$rss->link = $node[MIDCOM_NAV_FULLURL];
$rss->syndicationURL = "{$node[MIDCOM_NAV_FULLURL]}rss.xml";
$rss->cssStyleSheet = false;
$count = 20;
$wikipages = mgd_list_topic_articles($this->_topic->id, 'reverse revised');
if ($wikipages)
{
while ( $wikipages->fetch()
&& $count)
{
$wikipage = mgd_get_article($wikipages->id);
$author = mgd_get_person($wikipage->revisor);
$item = new FeedItem();
$item->title = $wikipage->title;
$item->link = "{$node[MIDCOM_NAV_FULLURL]}{$wikipage->name}/";
$item->date = $wikipage->revised;
$item->author = $author->name;
$item->description = $wikipage->content;
$rss->addItem($item);
$count--;
}
}
echo $rss->createFeed('RSS2.0');
debug_pop();
// This will exit
$_MIDCOM->finish();
