Revision [8804]

This is an old revision of RecentChangesAction made by NilsLindenberg on 2005-06-03 17:58:13.

 

Development page for the Recentchanges action




The action which is (with wikka 1.1.6.0) named "recentchanges" is infact the "recently changed" action (as stated on ImprovedRecentChanges by JavaWoman)

To make a real recentchanges action, I have just copied the code from the "recently changed" action and made the necessary (small) modification. Since all pages are loaded into "a sort of cache", this action definitely needs improvement!

The code

don't forget to rename the old recentchanges.php into recentlychanged.php!

actions/recentchanges.php
  1. <?php
  2. if ($pages = $this->LoadRecentChanges())
  3. {
  4.     $curday = "";
  5.     print('<p><link rel="alternate" type="application/rss+xml" title="RSS" href="'.$this->href("recentchanges.xml", $this->page["tag"]).'" ><img src="images/xml.png" width="36" height="14" alt="XML" /></link></p>\n');
  6.     //<a href=\"".$this->href("recentchanges.xml", $this->page["tag"])."\">
  7.  
  8.     if ($user = $this->GetUser()) {
  9.         $max = $user["changescount"];
  10.     } else {
  11.         $max = 50;
  12.     }
  13.  
  14.     foreach ($pages as $i => $page)
  15.     {
  16.         if (($i < $max) || !$max)
  17.         {
  18.             // day header
  19.             list($day, $time) = explode(" ", $page["time"]);
  20.             if ($day != $curday)
  21.             {
  22.                 $dateformatted = date("D, d M Y", strtotime($day));
  23.  
  24.                 if ($curday) print("</span><br />\n");
  25.                 print("<strong>$dateformatted:</strong><br />\n<span class=\"recentchanges\">");
  26.                 $curday = $day;
  27.             }
  28.  
  29.             $timeformatted = date("H:i T", strtotime($page["time"]));
  30.             $page_edited_by = $page["user"];   
  31.             if (!$this->LoadUser($page_edited_by)) $page_edited_by .= " (unregistered user)";
  32.  
  33.             // print entry
  34.             if ($page["note"]) $note=" <span class=\"pagenote\">[".$page["note"]."]</span>"; else $note ="";
  35.             $pagetag = $page["tag"];
  36.             if ($this->HasAccess("read", $pagetag)) {
  37.                     print("&nbsp;&nbsp;&nbsp;&nbsp;(".$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)."] - &nbsp;".$this->Link($pagetag, "", "", 0)." &rArr; $page_edited_by ".$note."<br />");
  38.             } else {
  39.                     print("&nbsp;&nbsp;&nbsp;&nbsp;($timeformatted) [history] - &nbsp;".$page["tag"]." &rArr; $page_edited_by ".$note."<br />");
  40.             }
  41.         }
  42.     }
  43.     print "</span>\n";
  44.  
  45.     $wikipingserver = $this->config["wikiping_server"];
  46.     if ($wikipingserver) {
  47.         $wikipingserver_url_parsed = parse_url($wikipingserver);
  48.         $wikipingserver_host = $wikipingserver_url_parsed["host"];
  49.         echo "<br /><br />[WikiPing enabled: Changes on this wiki are broadcast to <a href=\"http://$wikipingserver_host\">http://$wikipingserver_host</a>]";
  50.     }
  51. }
  52. ?>


addition to wikka.php (right behind LoadRecentlyChanged)

    function LoadRecentChanges()
    {
        if ($pages = $this->LoadAll("select * from ".$this->config["table_prefix"]."pages order by time desc"))
        {
            foreach ($pages as $page)
            {
                $this->CachePage($page);
            }
            return $pages;
        }
    }



CategoryDevelopmentActions CategoryDevelopmentCore
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki