#!/usr/bin/perl # TmNetWiki version 0.4 (September 11, 2002) # Copyright (C) 2002 Adam Brate # # Based on the GPLed UseModWiki 0.92 # Copyright (C) 2000-2001 Clifford A. Adams # or # Based on the GPLed AtisWiki 0.3 (C) 1998 Markus Denker # # ...which was based on # the LGPLed CVWiki CVS-patches (C) 1997 Peter Merel # and The Original WikiWikiWeb (C) Ward Cunningham # (code reused with permission) # Email and ThinLine options by Jim Mahoney # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the # Free Software Foundation, Inc. # 59 Temple Place, Suite 330 # Boston, MA 02111-1307 USA package Wiki::history; use strict; # needs subs Wiki::template: GetHeader, GetCommonFooter, GetPageLinkText, # GetEditLink, GetOldPageLink, GetAuthorLink, # ScriptLinkDiffRevision # Wiki::user: UserCanEdit, # Wiki::page: OpenPage # Wiki::text: OpenDefaultText # Wiki::keep: OpenKeptRevisions, # Wiki::translate: T, Ts # Wiki::utility: QuoteHtml # Wiki::calc: TimeToText # needs consts $KeepDays, $UseDiff # needs vars %Page, %KeptRevisions use base 'Exporter'; use Wiki::consts; use Wiki::template; use Wiki::user; use Wiki::page; use Wiki::text; use Wiki::keep; use Wiki::translate; use Wiki::utility; use Wiki::calc; #if ($^V and $^V gt v5.6.0) { # our @EXPORT; #else { use vars qw(@EXPORT); #} @EXPORT = qw( DoHistory ); sub GetHistoryLine; sub DoHistory { # my $W = shift; my ($id) = @_; my ($html, $canEdit); print &GetHeader("",&QuoteHtml(Ts('History of %s', $id)), "") . "
"; &OpenPage($id); &OpenDefaultText(); $canEdit = &UserCanEdit($id); $canEdit = 0; # Turn off direct "Edit" links $html = &GetHistoryLine($id, $Page{'text_default'}, $canEdit, 1); &OpenKeptRevisions('text_default'); foreach (reverse sort {$a <=> $b} keys %KeptRevisions) { next if ($_ eq ""); # (needed?) $html .= &GetHistoryLine($id, $KeptRevisions{$_}, $canEdit, 0); } print $html; print &GetCommonFooter(); } sub GetHistoryLine { my ($id, $section, $canEdit, $isCurrent) = @_; my ($html, $expirets, $rev, $summary, $host, $user, $uid, $ts, $minor); my (%sect, %revtext); %sect = split(/$Consts->{FS2}/, $section, -1); %revtext = split(/$Consts->{FS3}/, $sect{'data'}); $rev = $sect{'revision'}; $summary = $revtext{'summary'}; if ((defined($sect{'host'})) && ($sect{'host'} ne '')) { $host = $sect{'host'}; } else { $host = $sect{'ip'}; $host =~ s/\d+$/xxx/; # Be somewhat anonymous (if no host) } $user = $sect{'username'}; $uid = $sect{'id'}; $ts = $sect{'ts'}; $minor = ''; $minor = '' . T('(edit)') . ' ' if ($revtext{'minor'}); $expirets = $Now - ($KeepDays * 24 * 60 * 60); $html = Ts('Revision %s', $rev) . ": "; if ($isCurrent) { $html .= &GetPageLinkText($id, T('View')) . ' '; if ($canEdit) { $html .= &GetEditLink($id, T('Edit')) . ' '; } if ($UseDiff) { $html .= T('Diff') . ' '; } } else { $html .= &GetOldPageLink('browse', $id, $rev, T('View')) . ' '; if ($canEdit) { $html .= &GetOldPageLink('edit', $id, $rev, T('Edit')) . ' '; } if ($UseDiff) { $html .= &ScriptLinkDiffRevision(1, $id, $rev, T('Diff')) . ' '; } } $html .= ". . " . $minor . &TimeToText($ts) . " "; $html .= T('by') . ' ' . &GetAuthorLink($host, $user, $uid) . " "; if (defined($summary) && ($summary ne "") && ($summary ne "*")) { $summary = &QuoteHtml($summary); # Thanks Sunir! :-) $html .= "[$summary] "; } $html .= "
\n"; return $html; }