4 * Copyright 2003 Arnaud Fontaine
6 * This file is part of PhpWiki.
8 * PhpWiki is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * PhpWiki is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with PhpWiki; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * @author: Arnaud Fontaine
25 include("lib/RssParser.php");
27 class WikiPlugin_RssFeed
30 // Five required functions in a WikiPlugin.
35 function getDescription () {
36 return _("Simple RSS Feed aggregator Plugin");
40 function getVersion() {
41 return preg_replace("/[Revision: $]/", '',
45 // Establish default values for each of this plugin's arguments.
46 function getDefaultArguments() {
47 return array('feed' => "",
49 'url' => "", //"http://phpwiki.org/RecentChanges?format=rss",
55 function run($dbi, $argstr, &$request, $basepage) {
56 extract($this->getArgs($argstr, $request));
58 if (defined('CHARSET'))
59 $rss_parser = new RSSParser(CHARSET);
61 $rss_parser = new RSSParser();
64 $rss_parser->parse_url( $url, $debug );
66 if (!empty($rss_parser->channel['title'])) $feed = $rss_parser->channel['title'];
67 if (!empty($rss_parser->channel['link'])) $url = $rss_parser->channel['link'];
68 if (!empty($rss_parser->channel['description']))
69 $description = $rss_parser->channel['description'];
73 $titre = HTML::span(HTML::a(array('href'=>$rss_parser->channel['link']),
74 $rss_parser->channel['title']));
76 $titre = HTML::span($rss_parser->channel['title']);
78 $th = HTML::div(array('class'=> 'feed'), $titre);
79 if (!empty($description))
80 $th->pushContent(HTML::p(array('class' => 'chandesc'),
81 HTML::raw($description)));
86 if (!empty($rss_parser->channel['date']))
87 $th->pushContent(HTML::raw("<!--".$rss_parser->channel['date']."-->"));
88 $html = HTML::div(array('class'=> 'rss'), $th);
89 if ($rss_parser->items) {
92 $rss_parser->items = array_slice($rss_parser->items, 0, $maxitem);
93 foreach ($rss_parser->items as $item) {
94 $cell = HTML::div(array('class'=> 'rssitem'));
95 if ($item['link'] and empty($item['title']))
96 $item['title'] = $item['link'];
97 $cell_title = HTML::div(array('class'=> 'itemname'),
98 HTML::a(array('href'=>$item['link']),
99 HTML::raw($item['title'])));
100 $cell->pushContent($cell_title);
101 if (!empty($item['description']))
102 $cell->pushContent(HTML::div(array('class'=> 'itemdesc'),
103 HTML::raw($item['description'])));
104 $html->pushContent($cell);
107 $html = HTML::div(array('class'=> 'rss'), HTML::em(_("no RSS items")));
109 if (!check_php_version(5))
110 $rss_parser->__destruct();
114 function box($args=false, $request=false, $basepage=false) {
115 if (!$request) $request =& $GLOBALS['request'];
117 if (empty($title)) $title = _("RssFeed");
118 if (empty($url)) $url = 'http://phpwiki.sourceforge.net/phpwiki/RecentChanges?format=rss';
119 $argstr = "url=$url";
120 if (isset($maxitem) and is_numeric($maxitem)) $argstr .= " maxitem=$maxitem";
121 return $this->makeBox($title,
122 $this->run($request->_dbi, $argstr, $request, $basepage));
132 // c-hanging-comment-ender-p: nil
133 // indent-tabs-mode: nil