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 along
19 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 * @author: Arnaud Fontaine
25 include 'lib/RssParser.php';
27 class WikiPlugin_RssFeed
30 function getDescription()
32 return _("Simple RSS Feed aggregator.");
35 // Establish default values for each of this plugin's arguments.
36 function getDefaultArguments()
38 return array('feed' => "",
40 'url' => "", //"http://phpwiki.org/RecentChanges?format=rss",
47 function run($dbi, $argstr, &$request, $basepage)
49 extract($this->getArgs($argstr, $request));
51 $rss_parser = new RSSParser();
54 $rss_parser->parse_url($url, $debug);
56 if (!empty($rss_parser->channel['title'])) $feed = $rss_parser->channel['title'];
57 if (!empty($rss_parser->channel['link'])) $url = $rss_parser->channel['link'];
58 if (!empty($rss_parser->channel['description']))
59 $description = $rss_parser->channel['description'];
63 $titre = HTML::span(HTML::a(array('href' => $rss_parser->channel['link']),
64 $rss_parser->channel['title']));
66 $titre = HTML::span($rss_parser->channel['title']);
68 $th = HTML::div(array('class' => 'feed'), $titre);
69 if (!empty($description))
70 $th->pushContent(HTML::p(array('class' => 'chandesc'),
71 HTML::raw($description)));
76 if (!empty($rss_parser->channel['date']))
77 $th->pushContent(HTML::raw("<!--" . $rss_parser->channel['date'] . "-->"));
78 $html = HTML::div(array('class' => 'rss'), $th);
79 if ($rss_parser->items) {
82 $rss_parser->items = array_slice($rss_parser->items, 0, $maxitem);
83 foreach ($rss_parser->items as $item) {
84 $cell = HTML::div(array('class' => 'rssitem'));
85 if ($item['link'] and empty($item['title']))
86 $item['title'] = $item['link'];
87 $cell_title = HTML::div(array('class' => 'itemname'),
88 HTML::a(array('href' => $item['link']),
89 HTML::raw($item['title'])));
90 $cell->pushContent($cell_title);
91 $cell_author = HTML::raw($item['author']);
92 $cell_pubDate = HTML::raw($item['pubDate']);
93 $cell_authordate = HTML::div(array('class' => 'authordate'),
94 $cell_author, HTML::raw(" - "), $cell_pubDate);
95 $cell->pushContent($cell_authordate);
96 if ((!$titleonly) && (!empty($item['description'])))
97 $cell->pushContent(HTML::div(array('class' => 'itemdesc'),
98 HTML::raw($item['description'])));
99 $html->pushContent($cell);
102 $html = HTML::div(array('class' => 'rss'), HTML::em(_("no RSS items")));
107 function box($args = false, $request = false, $basepage = false)
109 if (!$request) $request =& $GLOBALS['request'];
111 if (empty($title)) $title = _("RssFeed");
112 if (empty($url)) $url = 'http://phpwiki.sourceforge.net/phpwiki/RecentChanges?format=rss';
113 $argstr = "url=$url";
114 if (isset($maxitem) and is_numeric($maxitem)) $argstr .= " maxitem=$maxitem";
115 return $this->makeBox($title,
116 $this->run($request->_dbi, $argstr, $request, $basepage));
125 // c-hanging-comment-ender-p: nil
126 // indent-tabs-mode: nil