Subversion Repositories Sites.tela-botanica.org

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
393 jpm 1
<?php
2
/*
3
recentchangesrss.php
4
 
5
Copyright 2003,2007  David DELON, Jean-Pascal MILCENT
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
*/
20
 
21
if ($user = $this->GetUser()) {
22
	$max = $user['changescount'];
23
} else {
24
	$max = 50;
25
}
26
 
27
if ($comments = $this->LoadRecentComments($max)) {
28
	if (!($link = $this->GetParameter('link'))) $link = $this->GetConfigValue('root_page');
29
	if (!($format = $this->GetParameter('format'))) $format = 'rss1.0';
30
 
31
	// Création de la sortie pour le contenu xml
32
	$output = '<?xml version="1.0" encoding="iso-8859-1" ?>'."\n";
33
 
34
	// En-tête du contenu xml
35
	switch ($format) {
36
		case 'rss1.0' :
37
 
38
			$output .= '<!-- RSS v1.0 generated by Wikini -->'."\n";
39
			$output .= '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n";
40
		    $output .= 'xmlns="http://purl.org/rss/1.0/">';
41
 
42
			$output .= '<channel rdf:about="'.$this->Href('', $link).'">'."\n";
43
			$output .= '<title>Derniers commentaires sur '.$this->GetConfigValue('wakka_name').'</title>'."\n";
44
			$output .= '<link>'.$this->Href('', $link).'</link>'."\n";
45
			$output .= '<description>Derniers commentaires sur '.$this->GetConfigValue('wakka_name').'</description>'."\n";
46
 
47
    		$output .= "<items>\n<rdf:Seq>\n";
48
			break;
49
		case 'rss2.0' :
50
			$output .= '<!-- RSS v2.0 generated by Wikini -->'."\n";
51
			$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";
52
			$output .= '<channel>'."\n";
53
			$output .= '<title>Derniers commentaires sur '.$this->GetConfigValue('wakka_name').'</title>'."\n";
54
			$output .= '<link>'.$this->Href('', $link).'</link>'."\n";
55
			$output .= '<description>Derniers commentaires sur '.$this->GetConfigValue('wakka_name').'</description>'."\n";
56
			break;
57
	}
58
 
59
	// Corps du contenu XML
60
    $items = '';
61
	foreach ($comments as $i => $comment) {
62
		list($day, $time) = explode(' ', $comment['time']);
63
		$day = preg_replace('/-/', ' ', $day);
64
		list($hh,$mm,$ss) = explode(':', $time);
65
        $itemurl = $this->Href('', $comment['comment_on'], 'show_comments=1#'.$comment['tag']);
66
		switch ($format) {
67
			case 'rss1.0' :
68
		        $output .= '<rdf:li rdf:resource="' . $itemurl . '" />';
69
 
70
				$items .= '<item rdf:about="'.$itemurl.'">'."\n";
71
				$items .= '<title>Commentaire '.$comment['tag'].' - page '.$comment['comment_on'].' --- par '.$comment['user'].' le '.$day.' - '.$hh.':'.$mm.'</title>'."\n";
72
				$items .= '<description>'.'Modification du commentaire '.$comment['tag'].' sur la page '.$comment['comment_on'].' --- par '.$comment['user'].' le '.$day.' - '.$hh.':'.$mm.'</description>'."\n";
73
				$items .= '<link>'.$itemurl.'</link>'."\n";
74
				$items .= '</item>'."\n";
75
				break;
76
			case 'rss2.0' :
77
				$output .= '<item>'."\n";
78
				$output .= '<title>Commentaire '.$comment['tag'].' - page '.$comment['comment_on'].' --- par '.$comment['user'].' le '.$day.' - '.$hh.':'.$mm.'</title>'."\n";
79
				$output .= '<link>'.$itemurl.'</link>'."\n";
80
				$output .= '<guid>'.$itemurl.'</guid>'."\n";
81
				$output .= '<description>'.htmlentities($this->Format($comment['body'])).'</description>'."\n";
82
				$output .= '<content:encoded>'.htmlentities($this->Format($comment['body'])).'</content:encoded>'."\n";
83
				$output .= '</item>'."\n";
84
				break;
85
		}
86
	}
87
 
88
	//Pied du contenu XML
89
	switch ($format) {
90
		case 'rss1.0' :
91
		    $output .= "</rdf:Seq>\n</items>\n</channel>\n";
92
			$output .= $items . "</rdf:RDF>\n";
93
			break;
94
		case 'rss2.0' :
95
			$output .= '</channel>'."\n";
96
			$output .= '</rss>'."\n";
97
			break;
98
	}
99
 
100
	echo $output;
101
}
102
?>