1 rizwank 1.1 # TWiki Collaboration Platform, http://TWiki.org/
2 #
3 # Copyright (C) 1999-2004 Peter Thoeny, peter@thoeny.com
4 #
5 # Based on parts of Ward Cunninghams original Wiki and JosWiki.
6 # Copyright (C) 1998 Markus Peter - SPiN GmbH (warpi@spin.de)
7 # Some changes by Dave Harris (drh@bhresearch.co.uk) incorporated
8 # Copyright (C) 1999-2003 Peter Thoeny, peter@thoeny.com
9 #
10 # For licensing info read license.txt file in the TWiki root.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License
13 # as published by the Free Software Foundation; either version 2
14 # of the License, or (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details, published at
20 # http://www.gnu.ai.mit.edu/copyleft/gpl.html
21
22 rizwank 1.1 package TWiki::UI::Changes;
23
24 use strict;
25
26 use TWiki;
27 use TWiki::Prefs;
28 use TWiki::Store;
29 use TWiki::UI;
30
31 # Command handler for changes command
32 sub changes {
33 my ( $webName, $topic, $query ) = @_;
34
35 return unless TWiki::UI::webExists( $webName, $topic );
36
37 my $skin = $query->param( "skin" );
38 $skin = TWiki::Prefs::getPreferencesValue( "SKIN" ) unless ( $skin );
39
40 my $text = TWiki::Store::readTemplate( "changes", $skin );
41 my $changes= TWiki::Store::readFile( "$TWiki::dataDir/$webName/.changes" );
42
43 rizwank 1.1 my @bar = ();
44 my $foo = "";
45 my %exclude = ();
46 my $summary = "";
47 my $time = "";
48 my $frev = "";
49
50 $text = &TWiki::handleCommonTags( $text, $topic );
51 $text = &TWiki::Render::getRenderedVersion( $text );
52 $text =~ s/\%META{.*?}\%//go; # remove %META{"parent"}%
53
54 my $before = "";
55 my $after = "";
56 ( $before, $text, $after) = split( /%REPEAT%/, $text );
57 &TWiki::writeHeader( $query );
58 $before =~ s/( ?) *<\/?(nop|noautolink)\/?>\n?/$1/gois; # remove <nop> and <noautolink> tags
59 print $before;
60
61 foreach( reverse split( /\n/, $changes ) ) {
62 @bar = split( /\t/ );
63 if( ( ! %exclude ) || ( ! $exclude{ $bar[0] } ) ) {
64 rizwank 1.1 next unless TWiki::Store::topicExists( $webName, $bar[0] );
65 $foo = $text;
66 $foo =~ s/%TOPICNAME%/$bar[0]/go;
67 my $wikiuser = &TWiki::userToWikiName( $bar[1] );
68 $foo =~ s/%AUTHOR%/$wikiuser/go;
69 $foo =~ s/%LOCKED%//go;
70 $time = &TWiki::formatTime( $bar[2] );
71 $frev = "";
72 if( $bar[3] ) {
73 if( $bar[3] > 1 ) {
74 $frev = "r1.$bar[3]";
75 } else {
76 $frev = "<span class=\"twikiNew\"><b>NEW</b></span>";
77 }
78 }
79 $foo =~ s/%TIME%/$time/go;
80 $foo =~ s/%REVISION%/$frev/go;
81 $foo = &TWiki::Render::getRenderedVersion( $foo );
82
83 $summary = &TWiki::Store::readFileHead( "$TWiki::dataDir\/$webName\/$bar[0].txt", 16 );
84 $summary = &TWiki::makeTopicSummary( $summary, $bar[0], $webName );
85 rizwank 1.1 $foo =~ s/%TEXTHEAD%/$summary/go;
86 $foo =~ s/( ?) *<\/?(nop|noautolink)\/?>\n?/$1/gois; # remove <nop> and <noautolink> tags
87 print $foo;
88 $exclude{ $bar[0] } = "1";
89 }
90 }
91
92 if( $TWiki::doLogTopicChanges ) {
93 # write log entry
94 &TWiki::Store::writeLog( "changes", $webName, "" );
95 }
96
97 $after =~ s/( ?) *<\/?(nop|noautolink)\/?>\n?/$1/gois; # remove <nop> and <noautolink> tags
98 print $after;
99 }
100
101 1;
|