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
35 function getDescription()
37 return _("Simple RSS Feed aggregator.");
41 // Establish default values for each of this plugin's arguments.
42 function getDefaultArguments()
44 return array('feed' => "",
46 'url' => "", //"http://phpwiki.org/RecentChanges?format=rss",
53 function run($dbi, $argstr, &$request, $basepage)
55 extract($this->getArgs($argstr, $request));
57 $rss_parser = new RSSParser();
60 $rss_parser->parse_url($url, $debug);
62 if (!empty($rss_parser->channel['title'])) $feed = $rss_parser->channel['title'];
63 if (!empty($rss_parser->channel['link'])) $url = $rss_parser->channel['link'];
64 if (!empty($rss_parser->channel['description']))
65 $description = $rss_parser->channel['description'];
69 $titre = HTML::span(HTML::a(array('href' => $rss_parser->channel['link']),
70 $rss_parser->channel['title']));
72 $titre = HTML::span($rss_parser->channel['title']);
74 $th = HTML::div(array('class' => 'feed'), $titre);
75 if (!empty($description))
76 $th->pushContent(HTML::p(array('class' => 'chandesc'),
77 HTML::raw($description)));
82 if (!empty($rss_parser->channel['date']))
83 $th->pushContent(HTML::raw("<!--" . $rss_parser->channel['date'] . "-->"));
84 $html = HTML::div(array('class' => 'rss'), $th);
85 if ($rss_parser->items) {
88 $rss_parser->items = array_slice($rss_parser->items, 0, $maxitem);
89 foreach ($rss_parser->items as $item) {
90 $cell = HTML::div(array('class' => 'rssitem'));
91 if ($item['link'] and empty($item['title']))
92 $item['title'] = $item['link'];
93 $cell_title = HTML::div(array('class' => 'itemname'),
94 HTML::a(array('href' => $item['link']),
95 HTML::raw($item['title'])));
96 $cell->pushContent($cell_title);
97 $cell_author = HTML::raw($item['author']);
98 $cell_pubDate = HTML::raw($item['pubDate']);
99 $cell_authordate = HTML::div(array('class' => 'authordate'),
100 $cell_author, HTML::raw(" - "), $cell_pubDate);
101 $cell->pushContent($cell_authordate);
102 if ((!$titleonly) && (!empty($item['description'])))
103 $cell->pushContent(HTML::div(array('class' => 'itemdesc'),
104 HTML::raw($item['description'])));
105 $html->pushContent($cell);
108 $html = HTML::div(array('class' => 'rss'), HTML::em(_("no RSS items")));
113 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));
131 // c-hanging-comment-ender-p: nil
132 // indent-tabs-mode: nil