Subversion Repositories Applications.wikini

Compare Revisions

Ignore whitespace Rev 46 → Rev 47

/trunk/tools/actions/actions/recentchangesrss.php
18,6 → 18,10
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
if (!defined("WIKINI_VERSION"))
{
die ("accès direct interdit");
}
 
if ($this->GetMethod() != 'xml') {
echo 'Pour obtenir le fil RSS des derniers changements, utilisez l\'adresse suivante: ';
25,6 → 29,69
return;
}
 
 
if (!function_exists("rssdiff")) {
 
function rssdiff($tag,$idfirst,$idlast) {
 
require_once 'includes/diff/side.class.php';
require_once 'includes/diff/diff.class.php';
require_once 'includes/diff/diffformatter.class.php';
 
$output='';
global $wiki;
// TODO : cache ?
 
if ($idfirst==$idlast) {
$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");
if ($previousdiff) {
$idlast=$previousdiff['id'];
}
else {
return;
}
 
}
 
$pageA = $wiki->LoadPageById($idfirst);
$pageB = $wiki->LoadPageById($idlast);
 
 
$bodyA = explode("\n", $pageA["body"]);
$bodyB = explode("\n", $pageB["body"]);
 
$added = array_diff($bodyA, $bodyB);
$deleted = array_diff($bodyB, $bodyA);
if (!isset($output)) $output = '';
 
$output .= "<br />\n";
$output .= "<br />\n";
$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";
 
$wiki->RegisterInclusion($tag);
if ($added)
{
// remove blank lines
$output .= "<br />\n<b>Ajouts:</b><br />\n";
$output .= "<div class=\"additions\">".(implode("\n", $added))."</div>";
}
 
if ($deleted)
{
$output .= "<br />\n<b>Suppressions:</b><br />\n";
$output .= "<div class=\"deletions\">".(implode("\n", $deleted))."</div>";
}
$wiki->UnregisterLastInclusion();
 
if (!$added && !$deleted)
{
$output .= "<br />\nPas de diff&eacute;rences.";
}
return $output;
 
}
}
 
if (isset($_GET['max']) && is_numeric($_GET['max'])) {
$max = ($_GET['max'] < 1000) ? $_GET['max'] : 1000;
} else if ($user = $this->GetUser()) {
32,67 → 99,66
} else {
$max = 50;
}
$pages = $this->LoadRecentlyChanged($max);
$pages = $this->LoadAll("SELECT id, tag, time, user, owner FROM ".$this->config["table_prefix"]."pages WHERE comment_on = '' ORDER BY time DESC LIMIT $max");
$last_users = $this->LoadAll('SELECT name, signuptime, motto FROM '.$this->GetConfigValue('table_prefix').'users ORDER BY signuptime DESC LIMIT '.$max);
if ($pages || $last_users)
{
if ($pages || $last_users) {
 
if (!($link = $this->GetParameter("link"))) $link=$this->GetConfigValue("root_page");
$output = '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n";
$output = '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">' . "\n";
$output .= "<channel>\n";
$output .= "<title> Derniers changements sur ". $this->GetConfigValue("wakka_name") . "</title>\n";
$output .= "<atom:link href=\"".$this->Href("xml")."\" rel=\"self\" type=\"application/rss+xml\" />\n";
$output .= "<title> ". htmlspecialchars($this->GetConfigValue("wakka_name"), ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET) . "</title>\n";
$output .= "<link>" . $this->Href(false, $link) . "</link>\n";
$output .= "<description> $max derniers changements sur " . htmlspecialchars($this->GetConfigValue("wakka_name")) . " </description>\n";
$output .= "<description>$max derniers changements sur " . htmlspecialchars($this->GetConfigValue("wakka_name"), ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET) . "</description>\n";
$output .= "<language>fr</language>\n";
$output .= '<generator>WikiNi ' . WIKINI_VERSION . "</generator>\n";
 
$items = array();
if ($pages)
{
foreach ($pages as $page)
{
if ($pages) {
foreach ($pages as $page) {
$page['diff'] = rssdiff($page["tag"], $page["id"], $page["id"]);
 
$items[strtotime($page['time'])] = array('type' => 'page', 'content' => $page);
}
}
if ($last_users)
{
 
if ($last_users) {
foreach ($last_users as $user) {
$items[strtotime($user['signuptime'])] = array('type' => 'user', 'content' => $user);
}
}
krsort($items);
 
foreach ($items as $item) {
$type = $item['type'];
if ($type == 'page')
{
if ($type == 'page') {
$page = $item['content'];
 
$output .= "<item>\n";
$output .= "<title>" . htmlspecialchars($page["tag"]) . "</title>\n";
$output .= '<dc:creator>' . htmlspecialchars($page["user"]) . "</dc:creator>\n";
$output .= "<title>" . htmlspecialchars($page["tag"], ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET) . "</title>\n";
$output .= '<dc:creator>' . htmlspecialchars($page["user"], ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET) . "</dc:creator>\n";
$output .= '<pubDate>' . gmdate('D, d M Y H:i:s \G\M\T', strtotime($page['time'])) . "</pubDate>\n";
$output .= "<description>" . htmlspecialchars(
'Modification de ' . $this->ComposeLinkToPage($page["tag"])
. ' (' . $this->ComposeLinkToPage($page["tag"], 'revisions', 'historique') . ')'
. " --- par " .$page["user"])
. "</description>\n";
$itemurl = $this->href(false, $page["tag"], "time=" . htmlspecialchars(rawurlencode($page["time"])));
'Modification de ' . $this->ComposeLinkToPage($page["tag"]).
' (' . $this->ComposeLinkToPage($page["tag"], 'revisions', 'historique') . ')'.
' --- par ' . $page["user"].
$page['diff']).
"</description>\n";
$output .= "<dc:format>text/html</dc:format>";
 
$itemurl = $this->href(false, $page["tag"], "time=" . htmlspecialchars(rawurlencode($page["time"]), ENT_COMPAT, TEMPLATES_DEFAULT_CHARSET));
$output .= '<guid>' . $itemurl . "</guid>\n";
$output .= "</item>\n";
}
else if ($type == 'user')
{
} else if ($type == 'user') {
$user = $item['content'];
$itemurl = $this->Href('', $user['name']);
 
$output .= '<item>'."\n";
$output .= '<title>'.'Utilisateur '.htmlspecialchars($user['name']).' - inscription le '.$user['signuptime'].'</title>'."\n";
$output .= '<link>'.$itemurl.'</link>'."\n";
$output .= '<pubDate>' . gmdate('D, d M Y H:i:s \G\M\T', strtotime($user['signuptime'])) . "</pubDate>\n";
$output .= '<description>'.'L\'utilisateur '.htmlspecialchars($user['name']).' s\'est inscrit le '.$user['signuptime'];
if (!empty($user['motto']))
{
if (!empty($user['motto'])) {
$output .= ' avec pour devise "'.htmlspecialchars($user['motto']).'"';
}
$output .= '</description>'."\n";
102,6 → 168,6
}
$output .= "</channel>\n";
$output .= "</rss>\n";
echo $output ;
echo $output;
}
?>
?>