Rss Feed Plugin /Code Php

Le code actuel de Rss Feed (affiché par le plugin Php Highlight? qui n'est pas tout à fait au point) :

Voir aussi le code de ma librairie rss pour le RSSParser.

C'est bien entendu diffusé sous Licence Libre Gnu Gpl.

<?php // -*-php-*-

include("lib/rss.php");

class 
WikiPlugin_RssFeed
extends WikiPlugin
{
    
// Five required functions in a WikiPlugin.

    
function getName () {
        return 
_("RssFeed");
    }

    function 
getDescription () {
        return 
_("Simple RSS Feed aggregator Plugin");

    }

    function 
getVersion() {
        return 
preg_replace("/[Revision: $]/"'',
                            
"\$Revision: 0.2 $");
    }

    
// Establish default values for each of this plugin's arguments.
    
function getDefaultArguments() {
        return array(
'feed' => "",
                     
'description' => "",
                     
'url' => "",
                     
'maxitem' => 0);
   }

    function 
run($dbi$argstr$request) {
        
extract($this->getArgs($argstr$request));

        
$xml_parser xml_parser_create();
        
$rss_parser = new RSSParser();
        if(!empty(
$url))
           
$rss_parser->parse_results$xml_parser, &$rss_parser$url );

        if (!empty(
$rss_parser->channel['title'])) $feed $rss_parser->channel['title'];
        if (!empty(
$rss_parser->channel['link'])) $url $rss_parser->channel['link'];
        if (!empty(
$rss_parser->channel['description'])) $description $rss_parser->channel['description'];

        if(!empty(
$feed)) {
            if(!empty(
$url)) {
                
$titre HTML::span(HTML::a(array('href'=>$rss_parser->channel['link']),$rss_parser->channel['title'])); }
               else
            {
                
$titre HTML::span($rss_parser->channel['title']);
            }
               
$th HTML::div(array('class'=> 'feed'),$titre);
               if(!empty(
$description))
                  
$th->pushContent(HTML::p(array('class' => 'chandesc'),HTML::raw($description)));
        }

        if(!empty(
$rss_parser->channel['date']))
          
$th->pushContent(HTML::raw("<!--".$rss_parser->channel['date']."-->"));
        
$html HTML::div(array('class'=> 'rss'),$th);

        
// limitation du nombre d'items affichs
        
if($maxitem 0$rss_parser->items array_slice($rss_parser->items0$maxitem);

        foreach(
$rss_parser->items as $item) {
          
$cell_title HTML::div(array('class'=> 'itemname'),HTML::a(array('href'=>$item['link']),HTML::raw($item['title'])));
          
$cell_content HTML::div(array('class'=> 'itemdesc'),HTML::raw($item['description']));
          
$cell HTML::div(array('class'=> 'rssitem'));
          
$cell->pushContent($cell_title);
          
$cell->pushContent($cell_content);
          
$html->pushContent($cell);
        }
        return 
$html;
    }
};

?>

Dernière modification le jeudi 2 octobre 2003 18:21:22

Éditer HistoriqueDeLaPage Diff  InfosSurLaPage