Update of /cvsroot/php-blog/serendipity/plugins/serendipity_plugin_remoterss
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16556/plugins/serendipity_plugin_remoterss
Modified Files:
serendipity_plugin_remoterss.php
Log Message:
* OPML 1.0 feed (well...not that usefull but nice to have)
* RemoteRSS plugin upgraded to be able for OPML blogroll import
* New CSS classes for each sidebar plugin
Index: serendipity_plugin_remoterss.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- serendipity_plugin_remoterss.php 19 May 2004 09:27:29 -0000 1.2
+++ serendipity_plugin_remoterss.php 11 Jun 2004 12:19:06 -0000 1.3
@@ -1,164 +1,475 @@
-<?php
-
-// Contributed by Udo Gerhards <ud...@ba...>
-
-switch ($serendipity['lang']) {
- case 'de':
- @define('PLUGIN_REMOTERSS_TITLE', 'Fremder RSS Feed');
- @define('PLUGIN_REMOTERSS_BLAHBLAH', 'Zeigt Einträge eines externen RSS-Feeds an');
- @define('PLUGIN_REMOTERSS_NUMBER', 'Anzahl der Einträge');
- @define('PLUGIN_REMOTERSS_NUMBER_BLAHBLAH', 'Wieviele Einträge sollen angezeigt werden? (Standard: alle im Feed)');
- @define('PLUGIN_REMOTERSS_SIDEBARTITLE', 'Feed-Titel');
- @define('PLUGIN_REMOTERSS_SIDEBARTITLE_BLAHBLAH', 'Titel der Feed-Anzeige in der Sidebar des Blogs');
- @define('PLUGIN_REMOTERSS_RSSURI', 'RSS-URI');
- @define('PLUGIN_REMOTERSS_RSSURI_BLAHBLAH', 'URI des RSS-Feeds, der angezeigt werden soll');
- @define('PLUGIN_REMOTERSS_RSSTARGET', 'Link-Target');
- @define('PLUGIN_REMOTERSS_RSSTARGET_BLAHBLAH', 'Target des Links zu einem der angezeigten RSS-Einträge (Standard: _blank)');
- @define('PLUGIN_REMOTERSS_NOURI', 'Kein RSS-Feed gewählt');
- @define('PLUGIN_REMOTERSS_CACHETIME', 'Wann wird der Feed aktualisiert?');
- @define('PLUGIN_REMOTERSS_CACHETIME_BLAHBLAH', 'Die Inhalte des fremden Feeds werden gecached. Sobald der Cache älter ist als X Minuten wird er aktualisiert (Standard: 3 Stunden)');
- break;
-
- case 'en':
- case 'es':
- default:
- @define('PLUGIN_REMOTERSS_TITLE', 'Remote RSS Feed');
- @define('PLUGIN_REMOTERSS_BLAHBLAH', 'Show items of a remote RSS feed');
- @define('PLUGIN_REMOTERSS_NUMBER', 'Number of entries');
- @define('PLUGIN_REMOTERSS_NUMBER_BLAHBLAH', 'How many entries should be displayed? (Default: every entry of the feed)');
- @define('PLUGIN_REMOTERSS_SIDEBARTITLE', 'Feed-Title');
- @define('PLUGIN_REMOTERSS_SIDEBARTITLE_BLAHBLAH', 'Title of the feed in the blog sidebar');
- @define('PLUGIN_REMOTERSS_RSSURI', 'RSS URI');
- @define('PLUGIN_REMOTERSS_RSSURI_BLAHBLAH', 'URI of the RSS feed which you want to display');
- @define('PLUGIN_REMOTERSS_NOURI', 'No RSS feed selected');
- @define('PLUGIN_REMOTERSS_RSSTARGET', 'RSS target');
- @define('PLUGIN_REMOTERSS_RSSTARGET_BLAHBLAH', 'Target of the link to one of the displayed RSS items (Default: _blank)');
- @define('PLUGIN_REMOTERSS_CACHETIME', 'When to update the feed?');
- @define('PLUGIN_REMOTERSS_CACHETIME_BLAHBLAH', 'The contents of a feed are stored in a cache which will be updated as soon as its older than X minutes (Default: 3 hours)');
-
- break;
-}
-
-class serendipity_plugin_remoterss extends serendipity_plugin {
-
- function introspect(&$propbag) {
- $propbag->add('name', PLUGIN_REMOTERSS_TITLE);
- $propbag->add('description', PLUGIN_REMOTERSS_BLAHBLAH);
- $propbag->add('configuration', array('number', 'dateformat', 'sidebartitle', 'rssuri', 'target', 'cachetime'));
- }
-
- function introspect_config_item($name, &$propbag) {
- switch($name) {
- case 'number':
- $propbag->add('type', 'string');
- $propbag->add('name', PLUGIN_REMOTERSS_NUMBER);
- $propbag->add('description', PLUGIN_REMOTERSS_NUMBER_BLAHBLAH);
- break;
-
- case 'dateformat':
- $propbag->add('type', 'string');
- $propbag->add('name', GENERAL_PLUGIN_DATEFORMAT);
- $propbag->add('description', sprintf(GENERAL_PLUGIN_DATEFORMAT_BLAHBLAH, '%A, %B %e. %Y'));
- break;
-
- case 'sidebartitle':
- $propbag->add('type', 'string');
- $propbag->add('name', PLUGIN_REMOTERSS_SIDEBARTITLE);
- $propbag->add('description', PLUGIN_REMOTERSS_SIDEBARTITLE_BLAHBLAH);
- break;
-
- case 'rssuri':
- $propbag->add('type', 'string');
- $propbag->add('name', PLUGIN_REMOTERSS_RSSURI);
- $propbag->add('description', PLUGIN_REMOTERSS_RSSURI_BLAHBLAH);
- break;
-
- case 'target':
- $propbag->add('type', 'string');
- $propbag->add('name', PLUGIN_REMOTERSS_RSSTARGET);
- $propbag->add('description', PLUGIN_REMOTERSS_RSSTARGET_BLAHBLAH);
- break;
-
- case 'cachetime':
- $propbag->add('type', 'string');
- $propbag->add('name', PLUGIN_REMOTERSS_CACHETIME);
- $propbag->add('description', PLUGIN_REMOTERSS_CACHETIME_BLAHBLAH);
- break;
-
- default:
- return false;
- }
- return true;
- }
-
- function generate_content(&$title) {
- global $serendipity;
-
- $number = $this->get_config('number');
- $dateformat = $this->get_config('dateformat');
- $sidebartitle = $this->get_config('sidebartitle');
- $rssuri = $this->get_config('rssuri');
- $target = $this->get_config('target');
- $cachetime = $this->get_config('cachetime');
-
- $title = $sidebartitle;
-
- if (!$number || !is_numeric($number) || $number < 1) {
- $showAll = true;
- } else {
- $showAll = false;
- }
-
- if (!$dateformat || strlen($dateformat) < 1) {
- $dateformat = '%A, %B %e. %Y';
- }
-
- if (!$target || strlen($target) < 1) {
- $target = '_blank';
- }
-
- if (!$cachetime || !is_numeric($cachetime)) {
- $cachetime = 10800; // 3 hours in seconds
- }
-
- if (trim($rssuri)) {
- $feedcache = $serendipity['serendipityPath'] . 'archives/remoterss_cache_' . preg_replace('@[^a-z0-9]*@i', '', $rssuri) . '.dat';
- if (!file_exists($feedcache) || filemtime($feedcache) < (time() - $cachetime)) {
- require_once 'bundled-libs/Onyx/RSS.php';
- $c = &new Onyx_RSS();
- $c->parse($rssuri);
-
- $i = 0;
- $content = '';
- while (($showAll || ($i < $number)) && ($item = $c->getNextItem())) {
- $content .= '<a href="' . $item['link'] . '" target="'.$target.'">' . $item['title'] . "</a><br>\n";
- $item['timestamp'] = strtotime(isset($item['pubdate']) ? $item['pubdate'] : $item['dc:date']);
- if (!($item['timestamp'] == -1)) {
- $content .= '<div class="serendipitySideBarDate">'
- . htmlspecialchars(serendipity_formatTime($dateformat, $item['timestamp']))
- . '</div><br />';
-
- }
- ++$i;
- }
-
- $fp = @fopen($feedcache, 'w');
- if ($fp) {
- fwrite($fp, $content);
- fclose($fp);
- } else {
- echo '<!-- Cache failed to ' . $feedcache . ' in ' . getcwd() . ' --><br />';
- }
- } else {
- $content = file_get_contents($feedcache);
- }
-
- echo $content;
- } else {
- echo PLUGIN_REMOTERSS_NOURI;
- }
- }
-}
-
-/* vim: set sts=4 ts=4 expandtab : */
+<?php
+
+// Contributed by Udo Gerhards <ud...@ba...>
+// OPML Contributed by Richard Thomas Harrison <ri...@mi...>
+
+switch ($serendipity['lang']) {
+ case 'de':
+ @define('PLUGIN_REMOTERSS_TITLE', 'Fremder RSS/OPML-Blogroll Feed');
+ @define('PLUGIN_REMOTERSS_BLAHBLAH', 'Zeigt Einträge eines externen RSS/OPML-Feeds an (z.B. Blogroll)');
+ @define('PLUGIN_REMOTERSS_NUMBER', 'Anzahl der Einträge');
+ @define('PLUGIN_REMOTERSS_NUMBER_BLAHBLAH', 'Wieviele Einträge sollen angezeigt werden? (Standard: alle im Feed)');
+ @define('PLUGIN_REMOTERSS_SIDEBARTITLE', 'Feed-Titel');
+ @define('PLUGIN_REMOTERSS_SIDEBARTITLE_BLAHBLAH', 'Titel der Feed-Anzeige in der Sidebar des Blogs');
+ @define('PLUGIN_REMOTERSS_RSSURI', 'RSS/OPML-URI');
+ @define('PLUGIN_REMOTERSS_RSSURI_BLAHBLAH', 'URI des RSS/OPML-Feeds, der angezeigt werden soll');
+ @define('PLUGIN_REMOTERSS_RSSTARGET', 'Link-Target');
+ @define('PLUGIN_REMOTERSS_RSSTARGET_BLAHBLAH', 'Target des Links zu einem der angezeigten RSS-Einträge (Standard: _blank)');
+ @define('PLUGIN_REMOTERSS_NOURI', 'Kein RSS/OPML-Feed gewählt');
+ @define('PLUGIN_REMOTERSS_CACHETIME', 'Wann wird der Feed aktualisiert?');
+ @define('PLUGIN_REMOTERSS_CACHETIME_BLAHBLAH', 'Die Inhalte des fremden Feeds werden gecached. Sobald der Cache älter ist als X Minuten wird er aktualisiert (Standard: 3 Stunden)');
+ @define('PLUGIN_REMOTERSS_FEEDTYPE', 'Typ des Feeds');
+ @define('PLUGIN_REMOTERSS_FEEDTYPE_BLAHBLAH', 'Wählen Sie das Format des einzubindenden Feeds');
+ break;
+
+ case 'en':
+ case 'es':
+ default:
+ @define('PLUGIN_REMOTERSS_TITLE', 'Remote RSS/OPML-Blogroll Feed');
+ @define('PLUGIN_REMOTERSS_BLAHBLAH', 'Show items of a remote RSS/OPML feed (i.e. Blogroll)');
+ @define('PLUGIN_REMOTERSS_NUMBER', 'Number of entries');
+ @define('PLUGIN_REMOTERSS_NUMBER_BLAHBLAH', 'How many entries should be displayed? (Default: every entry of the feed)');
+ @define('PLUGIN_REMOTERSS_SIDEBARTITLE', 'Feed-Title');
+ @define('PLUGIN_REMOTERSS_SIDEBARTITLE_BLAHBLAH', 'Title of the feed in the blog sidebar');
+ @define('PLUGIN_REMOTERSS_RSSURI', 'RSS/OPML URI');
+ @define('PLUGIN_REMOTERSS_RSSURI_BLAHBLAH', 'URI of the RSS/OPML feed which you want to display');
+ @define('PLUGIN_REMOTERSS_NOURI', 'No RSS/OPML feed selected');
+ @define('PLUGIN_REMOTERSS_RSSTARGET', 'RSS/OPML linktarget');
+ @define('PLUGIN_REMOTERSS_RSSTARGET_BLAHBLAH', 'Target of the link to one of the displayed RSS items (Default: _blank)');
+ @define('PLUGIN_REMOTERSS_CACHETIME', 'When to update the feed?');
+ @define('PLUGIN_REMOTERSS_CACHETIME_BLAHBLAH', 'The contents of a feed are stored in a cache which will be updated as soon as its older than X minutes (Default: 3 hours)');
+ @define('PLUGIN_REMOTERSS_FEEDTYPE', 'Feedtype');
+ @define('PLUGIN_REMOTERSS_FEEDTYPE_BLAHBLAH', 'Choose the format of the remote Feed');
+
+ break;
+}
+
+class s9y_remoterss_XMLTree {
+ function GetChildren($vals, &$i) {
+ $children = array();
+ $cnt = sizeof($vals);
+ while (++$i < $cnt) {
+ // compare type
+ switch ($vals[$i]['type']) {
+ case 'cdata':
+ $children[] = $vals[$i]['value'];
+ break;
+
+ case 'complete':
+ $children[] = array(
+ 'tag' => $vals[$i]['tag'],
+ 'attributes' => $vals[$i]['attributes'],
+ 'value' => $vals[$i]['value']
+ );
+ break;
+
+ case 'open':
+ $children[] = array(
+ 'tag' => $vals[$i]['tag'],
+ 'attributes' => $vals[$i]['attributes'],
+ 'value' => $vals[$i]['value'],
+ 'children' => $this->GetChildren($vals, $i)
+ );
+ break;
+
+ case 'close':
+ return $children;
+ }
+ }
+ }
+
+ function GetXMLTree($file) {
+ $data = file_get_contents($file);
+
+ // Global replacements
+ // by: wa...@wh... - trim space around tags not within
+ $data = eregi_replace('>[[:space:]]+<', '><', $data);
+
+ // Flatten the input opml file to not have nested categories
+ $data = preg_replace('@<outline[^>]+[^/]>@imsU', '', $data);
+ $data = str_replace('</outline>', '', $data);
+
+ // XML functions
+ $p = xml_parser_create();
+ // by: an...@mo... - meets XML 1.0 specification
+ xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);
+ xml_parse_into_struct($p, $data, $vals, $index);
+ xml_parser_free($p);
+
+ $i = 0;
+ $tree = array();
+ $tree[] = array(
+ 'tag' => $vals[$i]['tag'],
+ 'attributes' => $vals[$i]['attributes'],
+ 'value' => $vals[$i]['value'],
+ 'children' => $this->GetChildren($vals, $i)
+ );
+
+ return $tree;
+ }
+}
+
+define('OPMLDEBUG', '0');
+
+class s9y_remoterss_OPML {
+ var $cacheOPMLHead;
+ var $cacheOPMLBody;
+ var $cacheOPMLOutline;
+
+ function s9y_remoterss_OPML() {
+ $this->cacheOPMLHead = array();
+ $this->cacheOPMLBody = array();
+ $this->cacheOPMLOutline = array();
+ }
+
+ function parseOPML($file) {
+ $xmltree = new s9y_remoterss_XMLTree();
+ $opmltree = $xmltree->GetXMLTree($file);
+
+ return $opmltree[0];
+ }
+
+ function findOPMLTag($arr, $tag) {
+ $i = 0;
+ $tagindex = false;
+ $children = $arr['children'];
+ $cnt = count($children);
+
+ while ($i < $cnt) {
+
+ if ($children[$i]['tag'] == $tag) {
+ $tagindex = $i;
+ break;
+ }
+
+ ++$i;
+ }
+
+ return $tagindex !== false ? $tagindex : false;
+ }
+
+ function getOPMLTag($tree, $tag) {
+ $tagindex = $this->findOPMLTag($tree, $tag);
+
+ if (OPMLDEBUG == 1) {
+ echo "\ngetOPMLTag('" . $tag . "') = " . $tagindex . "<pre>\n";
+ print_r($tree['children'][$tagindex]);
+ echo "\n</pre>\n";
+ }
+
+ return $tagindex !== false ? $tree['children'][$tagindex] : false;
+ }
+
+ function getOPMLHead($tree) {
+ $head = array();
+
+ if (isset($this->cacheOPMLHead) && count($this->cacheOPMLHead) != 0) {
+ $head = $this->cacheOPMLHead;
+ } else {
+
+ if (OPMLDEBUG == 1) {
+ echo "\ngetOPMLHead<br />\n";
+ }
+
+ $head = $this->getOPMLTag($tree, 'head');
+
+ if ($head !== false) {
+ $this->cacheOPMLHead = $head;
+
+ if (OPMLDEBUG == 1) {
+ echo "\nCaching head<pre>\n";
+ print_r($this->cacheOPMLHead);
+ echo "\n</pre>\n";
+ }
+ } elseif (OPMLDEBUG == 1) {
+ echo "\nfalse<br />\n";
+ }
+
+ }
+
+ return $head['tag'] == 'head' ? $head : false;
+ }
+
+ function getOPMLBody($tree) {
+ $body = array();
+
+ if (isset($this->cacheOPMLBody) && count($this->cacheOPMLBody) != 0) {
+ $body = $this->cacheOPMLBody;
+ } else {
+
+ if (OPMLDEBUG == 1) {
+ echo "\ngetOPMLBody<br />\n";
+ }
+
+ $body = $this->getOPMLTag($tree, 'body');
+
+ if ($body !== false) {
+ $this->cacheOPMLBody = $body;
+
+ if (OPMLDEBUG == 1) {
+ echo "\nCaching body<pre>\n";
+ print_r($this->cacheOPMLBody);
+ echo "\n</pre>\n";
+ }
+
+ } elseif (OPMLDEBUG == 1) {
+ echo "\nfalse<br />\n";
+ }
+ }
+
+ return $body['tag'] == 'body' ? $body : false;
+ }
+
+ function getOPMLOutline($tree, $index) {
+
+ if (isset($this->cacheOPMLOutline[$index])) {
+ return $this->cacheOPMLOutline[$index];
+ }
+
+ $body = $this->getOPMLBody($tree);
+
+ if (!$body) {
+ return false;
+ }
+
+ $outline = $body['children'][$index];
+
+ if ($outline['tag'] == 'outline') {
+ $this->cacheOPMLOutline[$index] = $outline;
+
+ if (OPMLDEBUG == 1) {
+ echo "\ngetOPMLOutline[" . $index . "]<br />\n";
+ echo "\nCaching outline[" . $index . "]<pre>\n";
+ print_r($this->cacheOPMLOutline[$index]);
+ echo "\n</pre>\n";
+ }
+
+ return $outline;
+ } else {
+ return false;
+ }
+ }
+
+ function getOPMLOutlineAttr($tree, $index) {
+ $outline = $this->getOPMLOutline($tree, $index);
+
+ return $outline != false ? $outline['attributes'] : false;
+ }
+
+}
+
+class serendipity_plugin_remoterss extends serendipity_plugin {
+
+ function introspect(&$propbag) {
+ $propbag->add('name', PLUGIN_REMOTERSS_TITLE);
+ $propbag->add('description', PLUGIN_REMOTERSS_BLAHBLAH);
+ $propbag->add('configuration', array('number', 'dateformat', 'sidebartitle', 'rssuri', 'target', 'cachetime', 'feedtype', 'markup'));
+ }
+
+ function introspect_config_item($name, &$propbag) {
+ switch($name) {
+ case 'markup':
+ $propbag->add('type', 'boolean');
+ $propbag->add('name', DO_MARKUP);
+ $propbag->add('description', DO_MARKUP_DESCRIPTION);
+ break;
+
+ case 'feedtype':
+ $select = array('rss' => 'RSS', 'opml' => 'OPML');
+ $propbag->add('type', 'select');
+ $propbag->add('name', PLUGIN_REMOTERSS_FEEDTYPE);
+ $propbag->add('description', PLUGIN_REMOTERSS_FEEDTYPE_BLAHBLAH);
+ $propbag->add('select_values', $select);
+ break;
+
+ case 'number':
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_REMOTERSS_NUMBER);
+ $propbag->add('description', PLUGIN_REMOTERSS_NUMBER_BLAHBLAH);
+ break;
+
+ case 'dateformat':
+ $propbag->add('type', 'string');
+ $propbag->add('name', GENERAL_PLUGIN_DATEFORMAT);
+ $propbag->add('description', sprintf(GENERAL_PLUGIN_DATEFORMAT_BLAHBLAH, '%A, %B %e. %Y'));
+ break;
+
+ case 'sidebartitle':
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_REMOTERSS_SIDEBARTITLE);
+ $propbag->add('description', PLUGIN_REMOTERSS_SIDEBARTITLE_BLAHBLAH);
+ break;
+
+ case 'rssuri':
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_REMOTERSS_RSSURI);
+ $propbag->add('description', PLUGIN_REMOTERSS_RSSURI_BLAHBLAH);
+ break;
+
+ case 'target':
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_REMOTERSS_RSSTARGET);
+ $propbag->add('description', PLUGIN_REMOTERSS_RSSTARGET_BLAHBLAH);
+ break;
+
+ case 'cachetime':
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_REMOTERSS_CACHETIME);
+ $propbag->add('description', PLUGIN_REMOTERSS_CACHETIME_BLAHBLAH);
+ break;
+
+ default:
+ return false;
+ }
+ return true;
+ }
+
+ function generate_content(&$title) {
+ global $serendipity;
+
+ $number = $this->get_config('number');
+ $dateformat = $this->get_config('dateformat');
+ $sidebartitle = $this->get_config('sidebartitle');
+ $rssuri = $this->get_config('rssuri');
+ $target = $this->get_config('target');
+ $cachetime = $this->get_config('cachetime');
+ $feedtype = $this->get_config('feedtype', 'rss');
+ $markup = $this->get_config('markup', 'false');
+
+ $title = $sidebartitle;
+
+ if (!$number || !is_numeric($number) || $number < 1) {
+ $showAll = true;
+ } else {
+ $showAll = false;
+ }
+
+ if (!$dateformat || strlen($dateformat) < 1) {
+ $dateformat = '%A, %B %e. %Y';
+ }
+
+ if (!$target || strlen($target) < 1) {
+ $target = '_blank';
+ }
+
+ if (!$cachetime || !is_numeric($cachetime)) {
+ $cachetime = 10800; // 3 hours in seconds
+ }
+
+ if (trim($rssuri)) {
+ $feedcache = $serendipity['serendipityPath'] . 'archives/remoterss_cache_' . preg_replace('@[^a-z0-9]*@i', '', $rssuri) . '.dat';
+ if (!file_exists($feedcache) || filesize($feedcache) == 0 || filemtime($feedcache) < (time() - $cachetime)) {
+
+ if ($feedtype == 'rss') {
+ require_once 'bundled-libs/Onyx/RSS.php';
+ $c = &new Onyx_RSS();
+ $c->parse($rssuri);
+
+ $i = 0;
+ $content = '';
+ while (($showAll || ($i < $number)) && ($item = $c->getNextItem())) {
+ $content .= '<a href="' . $item['link'] . '" target="'.$target.'">' . $item['title'] . "</a><br>\n";
+ $item['timestamp'] = strtotime(isset($item['pubdate']) ? $item['pubdate'] : $item['dc:date']);
+ if (!($item['timestamp'] == -1)) {
+ $content .= '<div class="serendipitySideBarDate">'
+ . htmlspecialchars(serendipity_formatTime($dateformat, $item['timestamp']))
+ . '</div><br />';
+
+ }
+ ++$i;
+ }
+
+ $fp = @fopen($feedcache, 'w');
+ if ($fp) {
+ fwrite($fp, $content);
+ fclose($fp);
+ } else {
+ echo '<!-- Cache failed to ' . $feedcache . ' in ' . getcwd() . ' --><br />';
+ }
+ } elseif ($feedtype == 'opml') {
+ $opml = new s9y_remoterss_OPML();
+ $opmltree = $opml->parseOPML($rssuri);
+
+ if (OPMLDEBUG == 1) {
+ echo "\n<pre>\n";
+ print_r($opmltree);
+ echo "\n</pre>\n";
+ }
+
+ if ($opmltree['tag'] === 'opml') {
+ $head = $opml->getOPMLHead($opmltree);
+ $ownerName = $opml->getOPMLTag($head, 'ownerName');
+ $blogrolling = $ownerName != false ? ($ownerName['value'] == 'Blogroll Owner' ? true : false) : false;
+
+ $i = 0;
+ $content = '';
+ while (($showAll || ($i < $number)) && ($item = $opml->getOPMLOutlineAttr($opmltree, $i))) {
+ if (!empty($item['url'])) {
+ $url = $item['url'];
+ } elseif (!empty($item['htmlUrl'])) {
+ $url = $item['htmlUrl'];
+ } elseif (!empty($item['xmlUrl'])) {
+ $url = $item['xmlUrl'];
+ } elseif (!empty($item['urlHTTP'])) {
+ $url = $item['urlHTTP'];
+ } else {
+ $url = '';
+ }
+
+ if (!empty($item['text'])) {
+ $text = htmlspecialchars($item['text']);
+ } elseif (!empty($item['title'])) {
+ $text = htmlspecialchars($item['title']);
+ } elseif (!empty($item['description'])) {
+ $text = htmlspecialchars($item['description']);
+ } else {
+ $text = '';
+ }
+
+ if ($blogrolling === true && (!empty($text) || !empty($url))) {
+ $content .= '• <a href="' . $url . '" target="' . $target . '" title="' . $text . '">' . htmlspecialchars($text) . "</a>";
+ if (isset($item['isRecent'])) {
+ $content .= ' <span style="color: Red; ">*</span>';
+ }
+ $content .= "<br />";
+ } elseif ((isset($item['type']) && $item['type'] == 'url') || !empty($url)) {
+ $content .= '• <a href="' .$url . '" target="' . $target . '" title="' . $text . '">' . $text . "</a>";
+ $content .= "<br />";
+ }
+ ++$i;
+ }
+
+ /* Pretend to be a html_nugget so we can apply markup events. */
+ if ($markup == 'true') {
+ $entry = array('html_nugget' => $content);
+ serendipity_plugin_api::hook_event('frontend_display', $entry);
+ $content = $entry['html_nugget'];
+ }
+
+ $fp = @fopen($feedcache, 'w');
+ if ($fp) {
+ fwrite($fp, $content);
+ fclose($fp);
+ } else {
+ echo '<!-- Cache failed to ' . $feedcache . ' in ' . getcwd() . ' --><br />';
+ }
+
+ } else {
+ echo '<!-- Not a valid OPML feed -->';
+ }
+ } else {
+ echo '<!-- no valid feedtype -->';
+ }
+ } else {
+ $content = file_get_contents($feedcache);
+ }
+
+ echo $content;
+ } else {
+ echo PLUGIN_REMOTERSS_NOURI;
+ }
+ }
+}
+
+/* vim: set sts=4 ts=4 expandtab : */
?>
\ No newline at end of file
|