[Home]WikiPatches/DeletedPages

UseModWiki | WikiPatches | RecentChanges | Preferences

The function below is the core for providing an "deleted" action that lists pages that were deleted at some point.

[KinoWiki] has [RecentDeleted] for instance.

The Patch

sub DoOtherRequest {
  ...
  + } elsif ($action eq "deleted") { 
  +   &DoDeleted; 
  ...

sub DoDeleted {
  + my ($status, $fileData, $oldFileData);
  + my (@firstTs, @firstAuthor);
  + my (@full, @fullrc, @fullnewrc);
  + my ($i, @i);
  + my ($elem, @first);
  + my @unique = ();
  + my %seen = ();
     
  + print &GetHeader('', T('Deleted Pages'), '');
  + ($status, $fileData) = &ReadFile($RcFile);
  + if ($status) {
  +   @fullnewrc = split(/\n/, $fileData);
  + }
  + ($status, $oldFileData) = &ReadFile($RcOldFile);
  + if ($status) {
  +   @fullrc = split(/\n/, $oldFileData);
  + }
  + @full = (@fullrc, @fullnewrc);
  + ($i, $j) =0;
  + if ($#full > 0) { # Only false if no lines in file
  +   for ($i=0; $i<=$#full; $i++) {
  +     @firstTs = split(/$FS3/, $full[$i]);
  +     @firstAuthor = split(/$FS2/, $full[$i]);
  +     if ($firstAuthor[$#i-2] eq $firstAuthor[3]) { # line pattern ok
  +       if (!-f &GetPageFile($firstTs[1]) && $firstTs[1] ne '') { # page ok
  +         push(@first, $firstTs[1]);
  +       }
  +     }
  +   }
  + }
  + # http://perldoc.perl.org
  + # /perlfaq4.html#How-can-I-remove-duplicate-elements-from-a-list-or-array%3f;
  + foreach $elem (@first) {
  +   next if $seen{ $elem }++;
  +   push (@unique, $elem);
  + }  
  + print '<ol>';
  + foreach $elem (sort @unique) {
  +   print '<li>' . &ScriptLinkClass("action=edit&id=$elem", $elem, 'wikipageedit');
  + }
  + print '</ol>';  
  + print &GetMinimumFooter();
  + }
--JuanmaMP

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited December 10, 2009 7:08 pm by JuanmaMP (diff)
Search: