Subversion Repositories Applications.wikini

Rev

Rev 46 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 46 Rev 47
1
<?php
1
<?php
2
/*
2
/*
3
recentchangesrss.php
3
recentchangesrss.php
4
 
4
 
5
Copyright 2003  David DELON
5
Copyright 2003  David DELON
6
Copyright 2005-2007  Didier LOISEAU
6
Copyright 2005-2007  Didier LOISEAU
7
This program is free software; you can redistribute it and/or modify
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
10
(at your option) any later version.
11
 
11
 
12
This program is distributed in the hope that it will be useful,
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
15
GNU General Public License for more details.
16
 
16
 
17
You should have received a copy of the GNU General Public License
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
*/
20
*/
-
 
21
if (!defined("WIKINI_VERSION"))
-
 
22
{
-
 
23
    die ("acc&egrave;s direct interdit");
-
 
24
}
21
 
25
 
22
if ($this->GetMethod() != 'xml') {
26
if ($this->GetMethod() != 'xml') {
23
	echo 'Pour obtenir le fil RSS des derniers changements, utilisez l\'adresse suivante: ';
27
	echo 'Pour obtenir le fil RSS des derniers changements, utilisez l\'adresse suivante: ';
24
	echo $this->Link($this->Href('xml'));
28
	echo $this->Link($this->Href('xml'));
25
	return;
29
	return;
26
}
30
}
-
 
31
 
-
 
32
 
-
 
33
if (!function_exists("rssdiff")) {
-
 
34
 
-
 
35
    function rssdiff($tag,$idfirst,$idlast) {
-
 
36
 
-
 
37
        require_once 'includes/diff/side.class.php';
-
 
38
        require_once 'includes/diff/diff.class.php';
-
 
39
        require_once 'includes/diff/diffformatter.class.php';
-
 
40
 
-
 
41
        $output='';
-
 
42
        global $wiki;
-
 
43
        // TODO : cache ?
-
 
44
 
-
 
45
        if ($idfirst==$idlast) {
-
 
46
            $previousdiff=$wiki->LoadSingle("select id from ".$wiki->config["table_prefix"]."pages where tag = '".mysql_escape_string($tag)."' and id < $idfirst order by time desc limit 1");
-
 
47
            if ($previousdiff) {
-
 
48
                $idlast=$previousdiff['id'];
-
 
49
            }
-
 
50
            else {
-
 
51
                return;
-
 
52
            }
-
 
53
 
-
 
54
        }
-
 
55
 
-
 
56
        $pageA = $wiki->LoadPageById($idfirst);
-
 
57
        $pageB = $wiki->LoadPageById($idlast);
-
 
58
 
-
 
59
 
-
 
60
        $bodyA = explode("\n", $pageA["body"]);
-
 
61
        $bodyB = explode("\n", $pageB["body"]);
-
 
62
 
-
 
63
        $added = array_diff($bodyA, $bodyB);
-
 
64
        $deleted = array_diff($bodyB, $bodyA);
-
 
65
        if (!isset($output)) $output = '';
-
 
66
 
-
 
67
        $output .= "<br />\n";
-
 
68
        $output .= "<br />\n";
-
 
69
        $output .= "<b>Comparaison de <a href=\"".$wiki->href("", "", "time=".urlencode($pageA["time"]))."\">".$pageA["time"]."</a> &agrave; <a href=\"".$wiki->href("", "", "time=".urlencode($pageB["time"]))."\">".$pageB["time"]."</a></b><br />\n";
-
 
70
 
-
 
71
        $wiki->RegisterInclusion($tag);
-
 
72
        if ($added)
-
 
73
        {
-
 
74
            // remove blank lines
-
 
75
            $output .= "<br />\n<b>Ajouts:</b><br />\n";
-
 
76
            $output .= "<div class=\"additions\">".(implode("\n", $added))."</div>";
-
 
77
        }
-
 
78
 
-
 
79
        if ($deleted)
-
 
80
        {
-
 
81
            $output .= "<br />\n<b>Suppressions:</b><br />\n";
-
 
82
            $output .= "<div class=\"deletions\">".(implode("\n", $deleted))."</div>";
-
 
83
        }
-
 
84
        $wiki->UnregisterLastInclusion();
-
 
85
 
-
 
86
        if (!$added && !$deleted)
-
 
87
        {
-
 
88
            $output .= "<br />\nPas de diff&eacute;rences.";
-
 
89
        }
-
 
90
        return $output;
-
 
91
 
-
 
92
    }
-
 
93
}
27
 
94
 
28
if (isset($_GET['max']) && is_numeric($_GET['max'])) {
95
if (isset($_GET['max']) && is_numeric($_GET['max'])) {
29
	$max = ($_GET['max'] < 1000) ? $_GET['max'] : 1000;
96
	$max = ($_GET['max'] < 1000) ? $_GET['max'] : 1000;
30
} else if ($user = $this->GetUser()) {
97
} else if ($user = $this->GetUser()) {
31
	$max = $user["changescount"];
98
	$max = $user["changescount"];
32
} else {
99
} else {
33
	$max = 50;
100
	$max = 50;
34
}
101
}
35
$pages = $this->LoadRecentlyChanged($max);
102
$pages = $this->LoadAll("SELECT id, tag, time, user, owner FROM ".$this->config["table_prefix"]."pages WHERE comment_on = '' ORDER BY time DESC LIMIT $max");
36
$last_users = $this->LoadAll('SELECT name, signuptime, motto FROM '.$this->GetConfigValue('table_prefix').'users ORDER BY signuptime DESC LIMIT '.$max);
103
$last_users = $this->LoadAll('SELECT name, signuptime, motto FROM '.$this->GetConfigValue('table_prefix').'users ORDER BY signuptime DESC LIMIT '.$max);
37
if ($pages || $last_users)
104
if ($pages || $last_users) {
38
{
105
 
39
	if (!($link = $this->GetParameter("link"))) $link=$this->GetConfigValue("root_page");
106
	if (!($link = $this->GetParameter("link"))) $link=$this->GetConfigValue("root_page");
40
	$output = '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n";
107
	$output = '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">' . "\n";
41
	$output .= "<channel>\n";
108
	$output .= "<channel>\n";
-
 
109
	$output .= "<atom:link href=\"".$this->Href("xml")."\" rel=\"self\" type=\"application/rss+xml\" />\n";
42
	$output .= "<title> Derniers changements sur ". $this->GetConfigValue("wakka_name")  . "</title>\n";
110
	$output .= "<title> ". htmlspecialchars($this->GetConfigValue("wakka_name"), ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET) . "</title>\n";
43
	$output .= "<link>" . $this->Href(false, $link) . "</link>\n";
111
	$output .= "<link>" . $this->Href(false, $link) . "</link>\n";
44
	$output .= "<description> $max derniers changements sur " . htmlspecialchars($this->GetConfigValue("wakka_name")) . " </description>\n";
112
	$output .= "<description>$max derniers changements sur " . htmlspecialchars($this->GetConfigValue("wakka_name"), ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET) . "</description>\n";
45
	$output .= "<language>fr</language>\n";
113
	$output .= "<language>fr</language>\n";
46
	$output .= '<generator>WikiNi ' . WIKINI_VERSION . "</generator>\n";
114
	$output .= '<generator>WikiNi ' . WIKINI_VERSION . "</generator>\n";
47
	
115
 
48
	$items = array();
116
	$items = array();
49
	if ($pages)
117
	if ($pages) {
50
	{
-
 
51
		foreach ($pages as $page)
118
		foreach ($pages as $page) {
-
 
119
			$page['diff'] = rssdiff($page["tag"], $page["id"], $page["id"]);
52
		{
120
 
53
			$items[strtotime($page['time'])] = array('type' => 'page', 'content' => $page);
121
			$items[strtotime($page['time'])] = array('type' => 'page', 'content' => $page);
54
		}
122
		}
55
	}
123
	}
56
	
124
 
57
	if ($last_users)
125
	if ($last_users) {
58
	{
-
 
59
		foreach ($last_users as $user) {
126
		foreach ($last_users as $user) {
60
			$items[strtotime($user['signuptime'])] = array('type' => 'user', 'content' => $user);
127
			$items[strtotime($user['signuptime'])] = array('type' => 'user', 'content' => $user);
61
		}
128
		}
62
	}
129
	}
63
	krsort($items);
130
	krsort($items);
64
	
131
 
65
	foreach ($items as $item) {
132
	foreach ($items as $item) {
66
		$type = $item['type'];
133
		$type = $item['type'];
67
		if ($type == 'page')
134
		if ($type == 'page') {
68
		{
-
 
69
			$page = $item['content'];
135
			$page = $item['content'];
70
			
136
 
71
			$output .= "<item>\n";
137
			$output .= "<item>\n";
72
			$output .= "<title>" . htmlspecialchars($page["tag"]) . "</title>\n";
138
			$output .= "<title>" . htmlspecialchars($page["tag"], ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET) . "</title>\n";
73
			$output .= '<dc:creator>' . htmlspecialchars($page["user"]) . "</dc:creator>\n";
139
			$output .= '<dc:creator>' . htmlspecialchars($page["user"], ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET) . "</dc:creator>\n";
74
			$output .= '<pubDate>' . gmdate('D, d M Y H:i:s \G\M\T', strtotime($page['time'])) . "</pubDate>\n";
140
			$output .= '<pubDate>' . gmdate('D, d M Y H:i:s \G\M\T', strtotime($page['time'])) . "</pubDate>\n";
75
			$output .= "<description>" . htmlspecialchars(
141
			$output .= "<description>" . htmlspecialchars(
76
					'Modification de ' . $this->ComposeLinkToPage($page["tag"])
142
				'Modification de ' . $this->ComposeLinkToPage($page["tag"]).
77
					. ' (' . $this->ComposeLinkToPage($page["tag"], 'revisions', 'historique') . ')'
143
				' (' . $this->ComposeLinkToPage($page["tag"], 'revisions', 'historique') . ')'.
78
					. " --- par " .$page["user"])
144
				' --- par ' . $page["user"].
-
 
145
				$page['diff']).
79
					. "</description>\n";
146
				"</description>\n";
-
 
147
			$output .= "<dc:format>text/html</dc:format>";
-
 
148
 
80
			$itemurl = $this->href(false, $page["tag"], "time=" . htmlspecialchars(rawurlencode($page["time"])));
149
			$itemurl = $this->href(false, $page["tag"], "time=" . htmlspecialchars(rawurlencode($page["time"]), ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET));
81
			$output .= '<guid>' . $itemurl . "</guid>\n";
150
			$output .= '<guid>' . $itemurl . "</guid>\n";
82
			$output .= "</item>\n";
151
			$output .= "</item>\n";
83
		}
-
 
84
		else if ($type == 'user')
152
		} else if ($type == 'user') {
85
		{
-
 
86
			$user = $item['content'];
153
			$user = $item['content'];
87
			$itemurl = $this->Href('', $user['name']);
154
			$itemurl = $this->Href('', $user['name']);
88
			
155
 
89
			$output .= '<item>'."\n";
156
			$output .= '<item>'."\n";
90
			$output .= '<title>'.'Utilisateur '.htmlspecialchars($user['name']).' - inscription le '.$user['signuptime'].'</title>'."\n";
157
			$output .= '<title>'.'Utilisateur '.htmlspecialchars($user['name']).' - inscription le '.$user['signuptime'].'</title>'."\n";
91
			$output .= '<link>'.$itemurl.'</link>'."\n";
158
			$output .= '<link>'.$itemurl.'</link>'."\n";
92
			$output .= '<pubDate>' . gmdate('D, d M Y H:i:s \G\M\T', strtotime($user['signuptime'])) . "</pubDate>\n";
159
			$output .= '<pubDate>' . gmdate('D, d M Y H:i:s \G\M\T', strtotime($user['signuptime'])) . "</pubDate>\n";
93
			$output .= '<description>'.'L\'utilisateur '.htmlspecialchars($user['name']).' s\'est inscrit le '.$user['signuptime'];
160
			$output .= '<description>'.'L\'utilisateur '.htmlspecialchars($user['name']).' s\'est inscrit le '.$user['signuptime'];
94
			if (!empty($user['motto']))
161
			if (!empty($user['motto'])) {
95
			{
-
 
96
				$output .= ' avec pour devise  "'.htmlspecialchars($user['motto']).'"';
162
				$output .= ' avec pour devise  "'.htmlspecialchars($user['motto']).'"';
97
			}
163
			}
98
			$output .= '</description>'."\n";
164
			$output .= '</description>'."\n";
99
			$output .= '<guid>'.$itemurl.'</guid>'."\n";
165
			$output .= '<guid>'.$itemurl.'</guid>'."\n";
100
			$output .= '</item>'."\n";
166
			$output .= '</item>'."\n";
101
		}
167
		}
102
	}
168
	}
103
	$output .= "</channel>\n";
169
	$output .= "</channel>\n";
104
	$output .= "</rss>\n";
170
	$output .= "</rss>\n";
105
	echo $output ;
171
	echo $output;
106
}
172
}
107
?>
173
?>
108
174