Subversion Repositories Applications.wikini

Rev

Rev 46 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 46 Rev 47
Line 16... Line 16...
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
*/
-
 
21
if (!defined("WIKINI_VERSION"))
-
 
22
{
-
 
23
    die ("accès direct interdit");
Line 20... Line 24...
20
*/
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'));
Line -... Line 29...
-
 
29
	return;
-
 
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
 
25
	return;
92
    }
26
}
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
 
-
 
106
	if (!($link = $this->GetParameter("link"))) $link=$this->GetConfigValue("root_page");
39
	if (!($link = $this->GetParameter("link"))) $link=$this->GetConfigValue("root_page");
107
	$output = '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">' . "\n";
40
	$output = '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n";
108
	$output .= "<channel>\n";
41
	$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
	
-
 
48
	$items = array();
115
 
-
 
116
	$items = array();
49
	if ($pages)
117
	if ($pages) {
50
	{
118
		foreach ($pages as $page) {
51
		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
	}
-
 
56
	
123
	}
57
	if ($last_users)
124
 
58
	{
125
	if ($last_users) {
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) {
-
 
66
		$type = $item['type'];
132
	foreach ($items as $item) {
67
		if ($type == 'page')
133
		$type = $item['type'];
68
		{
134
		if ($type == 'page') {
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(
-
 
142
				'Modification de ' . $this->ComposeLinkToPage($page["tag"]).
76
					'Modification de ' . $this->ComposeLinkToPage($page["tag"])
143
				' (' . $this->ComposeLinkToPage($page["tag"], 'revisions', 'historique') . ')'.
-
 
144
				' --- par ' . $page["user"].
-
 
145
				$page['diff']).
77
					. ' (' . $this->ComposeLinkToPage($page["tag"], 'revisions', 'historique') . ')'
146
				"</description>\n";
78
					. " --- par " .$page["user"])
147
			$output .= "<dc:format>text/html</dc:format>";
79
					. "</description>\n";
148
 
80
			$itemurl = $this->href(false, $page["tag"], "time=" . htmlspecialchars(rawurlencode($page["time"])));
-
 
81
			$output .= '<guid>' . $itemurl . "</guid>\n";
149
			$itemurl = $this->href(false, $page["tag"], "time=" . htmlspecialchars(rawurlencode($page["time"]), ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET));
82
			$output .= "</item>\n";
-
 
83
		}
150
			$output .= '<guid>' . $itemurl . "</guid>\n";
84
		else if ($type == 'user')
151
			$output .= "</item>\n";
85
		{
152
		} else if ($type == 'user') {
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";
-
 
93
			$output .= '<description>'.'L\'utilisateur '.htmlspecialchars($user['name']).' s\'est inscrit le '.$user['signuptime'];
159
			$output .= '<pubDate>' . gmdate('D, d M Y H:i:s \G\M\T', strtotime($user['signuptime'])) . "</pubDate>\n";
94
			if (!empty($user['motto']))
160
			$output .= '<description>'.'L\'utilisateur '.htmlspecialchars($user['name']).' s\'est inscrit le '.$user['signuptime'];
95
			{
161
			if (!empty($user['motto'])) {
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;