Wiki source for RecentChangesPlus


Show raw source

=====Additional Options for ""RecentChanges"" action=====

This code adds a little extra functionality to the ""RecentChanges"" action. It allows to override the "max" (maximum) amount of changes shown, as well as turning on or off the RSS icon.

I think it would be useful for inclusion on a ""HomePage"", for instance, when you just want to show the last 10 pages changed.

====Parameters====

{{table columns="4" cells="Parameter;Values;Default;Description;max;integer;User's profile or 50 for anonymous user;Maximum amount of recent changes to show;showrss;true|false;true;Show the rss icon"}}

====Useage examples====

**""{{RecentChanges}}""**
Will produce the exact same results as the original action
**""{{RecentChanges max="10" showrss="false"}}""**
Show last 10 pages changed, and do not show the RSS icon

Replace recentchanges.php with:
%%(php)
<?php
if ($pages = $this->LoadRecentlyChanged())
{
$max = is_numeric($vars['max']) ? $vars['max'] : false;
$showrss = $vars['showrss'] ? strtolower($vars['showrss']) : "true";

$curday = "";
if ($showrss == "true") {
print("<p><a href=\"".$this->href("recentchanges.xml", $this->page["tag"])."\"><img src=\"images/xml.png\" width=\"36\" height=\"14\" alt=\"XML\" /></a></p>\n");
}
if (! $max) {
if ($user = $this->GetUser()) {
$max = $user["changescount"];
} else {
$max = 50;
}
}

foreach ($pages as $i => $page)
{
if (($i < $max) || !$max)
{
// day header
list($day, $time) = explode(" ", $page["time"]);
if ($day != $curday)
{
$dateformatted = date("D, d M Y", strtotime($day));

if ($curday) print("</span><br />\n");
print("<strong>$dateformatted:</strong><br />\n<span class=\"recentchanges\">");
$curday = $day;
}

$timeformatted = date("H:i T", strtotime($page["time"]));
$page_edited_by = $page["user"];
if (!$this->LoadUser($page_edited_by)) $page_edited_by .= " (unregistered user)";

// print entry
if ($page["note"]) $note=" <span class=\"pagenote\">[".$page["note"]."]</span>"; else $note ="";
$pagetag = $page["tag"];
if ($this->HasAccess("read", $pagetag)) {
print("    (".$this->Link($pagetag, "revisions", $timeformatted, 0, 1, "View recent revisions list for ".$pagetag).") [".$this->Link($pagetag, "history", "history", 0, 1, "View edit history of ".$pagetag)."] -  ".$this->Link($pagetag, "", "", 0)." ⇒ $page_edited_by ".$note."<br />");
} else {
print("    ($timeformatted) [history] -  ".$page["tag"]." ⇒ $page_edited_by ".$note."<br />");
}
}
}
print "</span>\n";

$wikipingserver = $this->config["wikiping_server"];
if ($wikipingserver) {
$wikipingserver_url_parsed = parse_url($wikipingserver);
$wikipingserver_host = $wikipingserver_url_parsed["host"];
echo "<br /><br />[WikiPing enabled: Changes on this wiki are broadcast to <a href=\"http://$wikipingserver_host\">http://$wikipingserver_host</a>]";
}
}
?>
%%

----
CategoryDevelopmentActions
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki