,parameters>]]
Examples:
displays the feed of the pmwiki pages with the defauft layout and number of lines:
[[$RSS http://www.pmichaud.com/wiki/Pm/AllRecentChanges?action=rss]]
displays the pmwiki feed in long layout and the top 5 lines
[[$RSS http://www.pmichaud.com/wiki/Pm/AllRecentChanges?action=rss,long,5]]
displays the pmwiki feed in short layout and all lines in the feed
[[$RSS http://www.pmichaud.com/wiki/Pm/AllRecentChanges?action=rss,short,-1]]
$Log: rssdisplay.php,v $
Revision 1.4 2004/01/12 15:41:55 pts00065
Script now uses the Keep function (pmwiki 0.5.27)
This allows to use html-syntax instead of wiki-markup
Revision 1.3 2004/01/12 15:00:44 pts00065
XHTML (
)
Revision 1.2 2004/01/12 07:42:06 pts00065
Added simple, long and marquee display types.
*/
$DoubleBrackets['/\[\[\$RSS *([^\]]*)\]\]/e']= " RSS('\$1') ";
define('MAGPIE_CACHE_AGE', 60*60);
define('MAGPIE_CACHE_DIR', 'cache');
define('MAGPIE_FETCH_TIME_OUT', 15);
function RSS($regex) {
global $action;
$line="";
if ( $regex == '' ) {
$line.="Empty parameter in \$RSS ";
} else {
$tokens=explode(",",$regex);
$url =$tokens[0];
$what =$tokens[1];
$num_items=$tokens[2];
if ( $what == '' ) {
$what='short';
}
if ( $num_items == 0 ) {
$num_items=10;
}
if ( $action && ( $action == 'rss' ) ) {
# this is important
#pmwiki processes DoubleBrackets in the rss module
#recursion untill the server blows
$line.= "RSS Feed : $url";
} else {
include_once('./local/magpie/rss_fetch.inc');
$rss = fetch_rss($url);
#if fetch_rss fails magpie will produce some error message
# we won't handle a check here
if ( $num_items > 0 ) {
$items = array_slice($rss->items, 0, $num_items);
} else {
$items = $rss->items;
}
foreach ($items as $item) {
$href = $item['link'];
$title = $item['title'];
$description = $item['description'];
$link="$title";
if ( $what == 'short' ) {
$line .= "- $link\n";
}
if ( $what == 'long' ) {
$line .= "$link
\n";
$line .= $description . "
";
}
if ( $what == 'marquee' ) {
$line .= "$link \n";
}
}
}
}
if ( $what == 'marquee' ) {
$line="";
}
if ( $what == 'short' ) {
$line="";
}
$line="";
#requires 0.5.27
return Keep($line);
}
?>