Subversion Repositories Sites.tela-botanica.org

Rev

Rev 393 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
/*
recentchangesrss.php

Copyright 2003,2007  David DELON, Jean-Pascal MILCENT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

if ($user = $this->GetUser()) {
        $max = $user['changescount'];
} else {
        $max = 50;
}

if ($comments = $this->LoadRecentComments($max)) {
        if (!($link = $this->GetParameter('link'))) $link = $this->GetConfigValue('root_page');
        if (!($format = $this->GetParameter('format'))) $format = 'rss1.0';

        // Création de la sortie pour le contenu xml
        $output = '<?xml version="1.0" encoding="iso-8859-1" ?>'."\n";
        
        // En-tĂȘte du contenu xml      
        switch ($format) {
                case 'rss1.0' :

                        $output .= '<!-- RSS v1.0 generated by Wikini -->'."\n";
                        $output .= '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n"; 
                    $output .= 'xmlns="http://purl.org/rss/1.0/">';
                 
                        $output .= '<channel rdf:about="'.$this->Href('', $link).'">'."\n";
                        $output .= '<title>Derniers commentaires sur '.$this->GetConfigValue('wakka_name').'</title>'."\n";
                        $output .= '<link>'.$this->Href('', $link).'</link>'."\n";
                        $output .= '<description>Derniers commentaires sur '.$this->GetConfigValue('wakka_name').'</description>'."\n";
                
                $output .= "<items>\n<rdf:Seq>\n";                      
                        break;
                case 'rss2.0' :
                        $output .= '<!-- RSS v2.0 generated by Wikini -->'."\n";
                        $output .= '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" >'."\n";
                        $output .= '<channel>'."\n";
                        $output .= '<title>Derniers commentaires sur '.$this->GetConfigValue('wakka_name').'</title>'."\n";
                        $output .= '<link>'.$this->Href('', $link).'</link>'."\n";
                        $output .= '<description>Derniers commentaires sur '.$this->GetConfigValue('wakka_name').'</description>'."\n";
                        break;
        }

        // Corps du contenu XML
    $items = '';
        foreach ($comments as $i => $comment) {
                list($day, $time) = explode(' ', $comment['time']);
                $day = preg_replace('/-/', ' ', $day);
                list($hh,$mm,$ss) = explode(':', $time);
        $itemurl = $this->Href('', $comment['comment_on'], 'show_comments=1#'.$comment['tag']);
                switch ($format) {
                        case 'rss1.0' :
                        $output .= '<rdf:li rdf:resource="' . $itemurl . '" />';
                        
                                $items .= '<item rdf:about="'.$itemurl.'">'."\n";
                                $items .= '<title>Commentaire '.$comment['tag'].' - page '.$comment['comment_on'].' --- par '.$comment['user'].' le '.$day.' - '.$hh.':'.$mm.'</title>'."\n";
                                $items .= '<description>'.'Modification du commentaire '.$comment['tag'].' sur la page '.$comment['comment_on'].' --- par '.$comment['user'].' le '.$day.' - '.$hh.':'.$mm.'</description>'."\n";
                                $items .= '<link>'.$itemurl.'</link>'."\n";
                                $items .= '</item>'."\n";
                                break;
                        case 'rss2.0' :
                                $output .= '<item>'."\n";
                                $output .= '<title>Commentaire '.$comment['tag'].' - page '.$comment['comment_on'].' --- par '.$comment['user'].' le '.$day.' - '.$hh.':'.$mm.'</title>'."\n";
                                $output .= '<link>'.$itemurl.'</link>'."\n";
                                $output .= '<guid>'.$itemurl.'</guid>'."\n";
                                $output .= '<description>'.htmlentities($this->Format($comment['body'])).'</description>'."\n";
                                $output .= '<content:encoded>'.htmlentities($this->Format($comment['body'])).'</content:encoded>'."\n";
                                $output .= '</item>'."\n";
                                break;
                }        
        }

        //Pied du contenu XML
        switch ($format) {
                case 'rss1.0' :
                    $output .= "</rdf:Seq>\n</items>\n</channel>\n";
                        $output .= $items . "</rdf:RDF>\n";
                        break;
                case 'rss2.0' :
                        $output .= '</channel>'."\n";
                        $output .= '</rss>'."\n";
                        break;
        }

        echo $output;
}
?>