[Home]WikiPatches/Contributors

UseModWiki | WikiPatches | RecentChanges | Preferences

Implementing in Usemod a patch for contributors per each page.

Other perl wikis with this feature or related: http://www.oddmuse.org/cgi-bin/wiki/Contrib_Action.

Patch

Sub DoOtherRequest {
...
      &DoTrimUsers();
+    } elsif ($action eq "contrib") {
+      &DoContrib($id);

sub GetFooterText {
...
    $result .= &GetPageLinkText($id, T('View current revision'));
  }
+ $result .= ' | ';
+ $result .= &ScriptLink("action=contrib&id=$id", T('View Contributors'));

+  sub DoContrib {
+  my ($id) = @_;
+  my ($status, $fileData, $oldFileData);
+  my ($firstTs, @firstTs, @firstUs, @firstT, @firstU);
+  my (@full, @fullrc, @fullnewrc);
+  my $action;
+  my ($i, @i);
+  my ($c, @unsorted, $dupla, $date, $auth, %v, %t, @sorted, @auth);
+
+  print  &GetHeader('', Ts('ContribsOn %s', $id),'');
+  ($status, $fileData) = &ReadFile($RcFile);
+  if ($status) {@fullnewrc = split(/\n/, $fileData);}
+  ($status, $oldFileData) = &ReadFile($RcOldFile);
+  if ($status) {@fullrc = split(/\n/, $oldFileData);}
+  @full = (@fullrc, @fullnewrc);
+  if (@full > 0) {  # Only false if no lines in file
+	for ($i=0; $i<=$#full; $i++) {
+      $c++;  
+      @firstTs = split(/$FS3/, $full[$i]);
+      if ($id eq $firstTs[1]) {
+        @firstUs = split(/$FS2/, $full[$i]);
+        $v{$c} = $firstTs[0];
+        if ($firstUs[$#i-2] eq $firstUs[3] && $firstUs[3] ne '') { 
+          $t{$c} = $firstUs[3];
+        } else { $t{$c} = 0;}
+        $dupla = "$v{$c}|$t{$c}";
+        push(@unsorted, $dupla);
+      }
+    }
+  }
+
+  @sorted = sort { $b <=> $a } @unsorted; 
+  print '<ol>';
+  foreach $c (@sorted) {
+    ($date,$auth) = split(/\|/,$c); # $dupla = "$v{$c}|$t{$c}";
+    if ($auth) {
+      print '<li>' . '(' . &TimeToText($date) . ') ';
+      print &GetPageOrEditLink($auth, $auth)
+      . ' ' . &GetPageOrEditLink($auth.'/Talk', "Talk")
+      . ' ' . &ScriptLink("action=contribs&userName=$auth", 
+      T("Contribs"));
+    } else { 
+      print '<li>' . '(' . &TimeToText($date) . ') '
+      . '...';
+    }
+  }
+  print &GetCommonFooter();
+ }
+}

Snapshot

(This snapshot contains more information (i.e UserID) than the patch's features)

Todo

  1. To list without repeated users and without timestamp (if LoginRework is applied) would be useful for meta datas on own pages.
  2. To distinguish according to ID Number (if LoginRework is NOT applied)

--JuanmaMP


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited February 17, 2010 1:06 am by s235-79.resnet.ucla.edu (diff)
Search: