diff --git a/docs/NEWS b/docs/NEWS index 6543d4c0..8427e279 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -8,6 +8,8 @@ Version 2.0 () Version 1.7 () ------------------------------------------------------------------------ + * Improved RSS sidebarplugin to support Atom + * Bundled simplepie * For Blogs running on a non-UTF-8 language, set a Smarty constant diff --git a/plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php b/plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php index ae143b11..56956670 100644 --- a/plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php +++ b/plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php @@ -251,7 +251,7 @@ class serendipity_plugin_remoterss extends serendipity_plugin { $propbag->add('description', PLUGIN_REMOTERSS_BLAHBLAH); $propbag->add('stackable', true); $propbag->add('author', 'Udo Gerhards, Richard Thomas Harrison'); - $propbag->add('version', '1.13'); + $propbag->add('version', '1.20'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', @@ -312,7 +312,7 @@ class serendipity_plugin_remoterss extends serendipity_plugin { break; case 'feedtype': - $select = array('rss' => 'RSS', 'opml' => 'OPML'); + $select = array('rss' => 'RSS', 'opml' => 'OPML', 'atom' => 'ATOM'); $propbag->add('type', 'select'); $propbag->add('name', PLUGIN_REMOTERSS_FEEDTYPE); $propbag->add('description', PLUGIN_REMOTERSS_FEEDTYPE_BLAHBLAH); @@ -556,6 +556,108 @@ class serendipity_plugin_remoterss extends serendipity_plugin { } + if ($smarty) { + $smarty_items['items'][$i] = $item; + $smarty_items['items'][$i]['css_class'] = preg_replace('@[^a-z0-9]@imsU', '', $rss_element); + foreach($item AS $key => $val) { + $smarty_items['items'][$i]['decoded_' . str_replace(':', '_', $key)] = $this->decode($key); + } + } + $content .= ''; // end of rss_item + ++$i; + } elseif ($feedtype == 'atom') { + $this->debug('URLCheck succeeded. Touching ' . $feedcache); + // Touching the feedcache file will prevent loops of death when the RSS target is the same URI than our blog. + @touch($feedcache); + + require_once S9Y_PEAR_PATH . '/simplepie/simplepie.inc'; + + $this->debug('Running simplepie Parser'); + + $simplefeed = new SimplePie(); + $simplefeed->cache=false; + $simplefeed->set_feed_url($rssuri); + $success = $simplefeed->init(); + $simplefeed->set_output_encoding($charset); + $simplefeed->handle_content_type(); + $this->encoding = $charset; + + $use_rss_link = serendipity_db_bool($this->get_config('use_rss_link')); + $rss_elements = explode(',', $this->get_config('show_rss_element')); + $escape_rss = serendipity_db_bool($this->get_config('escape_rss')); + $i = 0; + $content = ''; + $smarty_items = array(); + + foreach($simplefeed->get_items() as $simpleitem) { + // map SimplePie items to s9y items + $item['title'] = $simpleitem->get_title(); + $item['link'] = $simpleitem->get_permalink(); + $item['pubdate'] = $simpleitem->get_date('U'); + + $item['date'] = $simpleitem->get_date('U'); + $item['description'] = $simpleitem->get_description(); + $item['content'] = $simpleitem->get_content(); + $item['author'] = $simpleitem->get_author(); + + if (!$showAll && $i > $number) break; + + if (empty($item['title'])) { + continue; + } + + $content .= '