| 1 | package Labyrinth::Plugin::Wiki; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | $VERSION = '1.06'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | Labyrinth::Plugin::Wiki - Wiki handler for the Labyrinth framework. | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Contains all the wiki handling functionality for Labyrinth. | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =cut | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # ------------------------------------- | ||||||||||||||||||||||||||||
| 20 | # Library Modules | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 5 | ▶ | use Algorithm::Diff; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 5 | ▶ | use VCS::Lite; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 5 | ▶ | use base qw(Labyrinth::Plugin::Base); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 5 | ▶ | use Labyrinth::Audit; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 5 | ▶ | use Labyrinth::DBUtils; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 5 | ▶ | use Labyrinth::DTUtils; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 5 | ▶ | use Labyrinth::MLUtils; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 5 | ▶ | use Labyrinth::Support; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 5 | ▶ | use Labyrinth::Variables; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 5 | ▶ | use Labyrinth::Plugin::Wiki::Text; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | # ------------------------------------- | ||||||||||||||||||||||||||||
| 37 | # Variables | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # type: 0 = optional, 1 = mandatory | ||||||||||||||||||||||||||||
| 40 | # html: 0 = none, 1 = text, 2 = textarea | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 5 | my %fields = ( | |||||||||||||||||||||||||||
| 43 | pagename => { type => 1, html => 1 }, | ||||||||||||||||||||||||||||
| 44 | comment => { type => 0, html => 1 }, | ||||||||||||||||||||||||||||
| 45 | content => { type => 1, html => 2 }, | ||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 5 | my (@mandatory,@allfields); | |||||||||||||||||||||||||||
| 49 | 5 | for(keys %fields) { | |||||||||||||||||||||||||||
| 50 | 15 | ▶ | push @mandatory, $_ if($fields{$_}->{type}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 15 | push @allfields, $_; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 5 | my $LEVEL = ADMIN; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 5 | my $wikitext = Labyrinth::Plugin::Wiki::Text->new(); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 5 | my %valid_limits = map {$_ => 1} qw(10 20 50 100 200 500); | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | # ------------------------------------- | ||||||||||||||||||||||||||||
| 61 | # Public Methods | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head1 PUBLIC INTERFACE METHODS | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =over 4 | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =item Page | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | Checks for alternative page references and redirects if necessary. | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =item Edit | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | Provides the edit page for the given page. | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =item View | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | Provides the view page for the given page. | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =item Save | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | Saves the given page. | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =item History | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | Provides the history of edits for the given page. | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =item Diff | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | Provides the differences between to versions of the given page. | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =item Search | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | Searches through the current set of pages for the given text string. | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =item Recent | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | Lists the most recent changes. | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =back | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =cut | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub Page { | ||||||||||||||||||||||||||
|
Subroutine
Page: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 104 | 0 | ▶ | $cgiparams{pagename} ||= 'HomePage'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Wiki::cgiparams{"pagename"} ||= "HomePage"
MC/DC0%0/1
$Labyrinth::Plugin::Wiki::cgiparams{"pagename"} ||= "HomePage"
$Labyrinth::Plugin::Wiki::cgiparams{"pagename"}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Wiki::cgiparams{"pagename"}
| |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | # check for special pages first | ||||||||||||||||||||||||||||
| 107 | return _redirect($cgiparams{pagename}) | ||||||||||||||||||||||||||||
| 108 | if(defined $cgiparams{pagename} && | ||||||||||||||||||||||||||||
| 109 | 0 | ▶ | $cgiparams{pagename} =~ /^People|Login|Search|RecentChanges$/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Labyrinth::Plugin::Wiki::cgiparams{"pagename"} and $Labyrinth::Plugin::Wiki::cgiparams{"pagename"} =~ /^People|Login|Search|RecentChanges$/
MC/DC0%0/2
defined $Labyrinth::Plugin::Wiki::cgiparams{"pagename"} and $Labyrinth::Plugin::Wiki::cgiparams{"pagename"} =~ /^People|Login|Search|RecentChanges$/
defined $Labyrinth::Plugin::Wiki::cgiparams{"pagename"}
$Labyrinth::Plugin::Wiki::cgiparams{"pagename"} =~ /^People|Login|Search|RecentChanges$/
Truth table0%0/3
A and B
A= defined $Labyrinth::Plugin::Wiki::cgiparams{"pagename"}B= $Labyrinth::Plugin::Wiki::cgiparams{"pagename"} =~ /^People|Login|Search|RecentChanges$/
| |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | # now deal with the page | ||||||||||||||||||||||||||||
| 112 | 0 | ▶ | return unless CheckPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if($tvars{wikihash}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | #REDIRECT [[PAGE]] | ||||||||||||||||||||||||||||
| 115 | return _redirect($1) | ||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if($tvars{wikihash}->{content} =~ /^\#REDIRECT\s+\[\[\s*(.*)\s*\]\]/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | ($tvars{wikihash}{title},$tvars{wikihash}{html}) = $wikitext->Render($tvars{wikihash}); | |||||||||||||||||||||||||||
| 119 | 0 | $tvars{wikihash}{showmode} = 1; | |||||||||||||||||||||||||||
| 120 | } else { | ||||||||||||||||||||||||||||
| 121 | 0 | SetCommand('wiki-edit'); | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub Edit { | ||||||||||||||||||||||||||
|
Subroutine
Edit: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | return unless AccessUser(USER); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 0 | ▶ | return if RestrictedPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 0 | ▶ | return unless CheckPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 0 | ▶ | return if LockedPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if(!$tvars{wikihash}{version}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | 0 | $tvars{wikihash}{pagename} = $cgiparams{pagename}; | |||||||||||||||||||||||||||
| 133 | 0 | $tvars{wikihash}{title} = $cgiparams{pagename}; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 0 | $tvars{wikihash}{editmode} = 1; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 0 | ▶ | sub View { | ||||||||||||||||||||||||||
|
Subroutine
View: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 140 | 0 | ▶ | return unless AccessUser(USER); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | return if RestrictedPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 0 | ▶ | return unless CheckPage(1); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | 0 | ▶ | return if LockedPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 0 | for(keys %fields) { | |||||||||||||||||||||||||||
| 146 | 0 | ▶ | if($fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) } | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 147 | 0 | elsif($fields{$_}->{html} == 2) { $cgiparams{$_} = CleanTags($cgiparams{$_}) } | |||||||||||||||||||||||||||
| 148 | 0 | elsif($fields{$_}->{html} == 3) { $cgiparams{$_} = CleanLink($cgiparams{$_}) } | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | $tvars{wikihash}->{$_} = $cgiparams{$_}; | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 0 | ($tvars{wikihash}{title},$tvars{wikihash}{html}) = $wikitext->Render($tvars{wikihash}); | |||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 0 | $tvars{wikihash}{editmode} = 1; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 0 | ▶ | sub Save { | ||||||||||||||||||||||||||
|
Subroutine
Save: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||
| 159 | 0 | ▶ | return unless AccessUser(USER); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 0 | ▶ | return if RestrictedPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | 0 | ▶ | return unless CheckPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | ▶ | return if LockedPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 0 | for(keys %fields) { | |||||||||||||||||||||||||||
| 165 | 0 | ▶ | if($fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) } | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 166 | 0 | elsif($fields{$_}->{html} == 2) { $cgiparams{$_} = CleanTags($cgiparams{$_}) } | |||||||||||||||||||||||||||
| 167 | 0 | elsif($fields{$_}->{html} == 3) { $cgiparams{$_} = CleanLink($cgiparams{$_}) } | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | $tvars{wikihash}->{$_} = $cgiparams{$_}; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 0 | ▶ | return if FieldCheck(\@allfields,\@mandatory); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 0 | $tvars{wikihash}->{'version'}++; | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | # normalise line endings | ||||||||||||||||||||||||||||
| 177 | 0 | $tvars{wikihash}->{'content'} =~ s/\r\n/\n/g; # Win32 | |||||||||||||||||||||||||||
| 178 | 0 | $tvars{wikihash}->{'content'} =~ s/\r/\n/g; # Mac | |||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | $dbi->DoQuery('SaveWikiPage', | ||||||||||||||||||||||||||||
| 181 | $tvars{wikihash}->{'pagename'}, | ||||||||||||||||||||||||||||
| 182 | $tvars{wikihash}->{'version'}, | ||||||||||||||||||||||||||||
| 183 | $tvars{user}->{'userid'}, | ||||||||||||||||||||||||||||
| 184 | $tvars{wikihash}->{'comment'}, | ||||||||||||||||||||||||||||
| 185 | 0 | $tvars{wikihash}->{'content'}, | |||||||||||||||||||||||||||
| 186 | formatDate(0) | ||||||||||||||||||||||||||||
| 187 | ); | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 0 | my @rows = $dbi->GetQuery('hash','GetWikiIndex',$tvars{wikihash}->{'pagename'}); | |||||||||||||||||||||||||||
| 190 | 0 | ▶ | if(@rows) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | 0 | $dbi->DoQuery('UpdateWikiIndex',$tvars{wikihash}->{'version'},$tvars{wikihash}->{'pagename'}); | |||||||||||||||||||||||||||
| 192 | } else { | ||||||||||||||||||||||||||||
| 193 | 0 | $dbi->DoQuery('InsertWikiIndex',$tvars{wikihash}->{'version'},$tvars{wikihash}->{'pagename'}); | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub History { | ||||||||||||||||||||||||||
|
Subroutine
History: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 198 | 0 | ▶ | return if RestrictedPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | 0 | ▶ | return unless CheckPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 0 | ▶ | return if LockedPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 0 | my @rows = $dbi->GetQuery('hash','GetWikiHistory',$cgiparams{'pagename'}); | |||||||||||||||||||||||||||
| 203 | 0 | for (@rows) { | |||||||||||||||||||||||||||
| 204 | 0 | $_->{postdate} = formatDate(20,$_->{createdate}); | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | 0 | $tvars{wikihash}{history} = \@rows; | |||||||||||||||||||||||||||
| 207 | 0 | $tvars{wikihash}{histmode} = 1; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 0 | ▶ | sub Diff { | ||||||||||||||||||||||||||
|
Subroutine
Diff: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 211 | 0 | ▶ | return if RestrictedPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | 0 | ▶ | return unless CheckPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if(!$cgiparams{diff1} || !$cgiparams{diff2}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Labyrinth::Plugin::Wiki::cgiparams{"diff1"} and $Labyrinth::Plugin::Wiki::cgiparams{"diff2"}
MC/DC0%0/2
$Labyrinth::Plugin::Wiki::cgiparams{"diff1"} and $Labyrinth::Plugin::Wiki::cgiparams{"diff2"}
$Labyrinth::Plugin::Wiki::cgiparams{"diff1"}
$Labyrinth::Plugin::Wiki::cgiparams{"diff2"}
Truth table0%0/3
A and B
A= $Labyrinth::Plugin::Wiki::cgiparams{"diff1"}B= $Labyrinth::Plugin::Wiki::cgiparams{"diff2"}
| |||||||||||||||||||||||||||||
| 215 | # $tvars{errcode} = 'MESSAGE'; | ||||||||||||||||||||||||||||
| 216 | 0 | $tvars{errmess} = 'Need to supply two valid versions to check the differences!'; | |||||||||||||||||||||||||||
| 217 | 0 | return; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | my $diff1 = GetPage($cgiparams{pagename},$cgiparams{diff1}); | |||||||||||||||||||||||||||
| 221 | 0 | my $diff2 = GetPage($cgiparams{pagename},$cgiparams{diff2}); | |||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if(!$diff1 || !$diff2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$diff1 and $diff2
MC/DC0%0/2
$diff1 and $diff2
$diff1
$diff2
Truth table0%0/3
A and B
A= $diff1B= $diff2
| |||||||||||||||||||||||||||||
| 224 | # $tvars{errcode} = 'MESSAGE'; | ||||||||||||||||||||||||||||
| 225 | 0 | $tvars{errmess} = 'Need to supply two valid versions to check the differences!'; | |||||||||||||||||||||||||||
| 226 | 0 | return; | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 0 | $tvars{wikihash}{diff1} = $diff1; | |||||||||||||||||||||||||||
| 230 | 0 | $tvars{wikihash}{diff2} = $diff2; | |||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 0 | $tvars{wikihash}{diff0} = _differences($diff1,$diff2); | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 0 | ▶ | sub Search { | ||||||||||||||||||||||||||
|
Subroutine
Search: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if(!$cgiparams{data}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | # $tvars{errcode} = 'MESSAGE'; | ||||||||||||||||||||||||||||
| 238 | 0 | $tvars{errmess} = 'Need to supply a search term!'; | |||||||||||||||||||||||||||
| 239 | 0 | return; | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | 0 | $tvars{wikihash}{key} = $cgiparams{data}; | |||||||||||||||||||||||||||
| 243 | 0 | $tvars{wikihash}{checked} = $cgiparams{allversions}; | |||||||||||||||||||||||||||
| 244 | 0 | ▶ | my $key = $cgiparams{allversions} ? 'WikiSearchFull' : 'WikiSearch'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 245 | 0 | my @rows = $dbi->GetQuery('hash',$key,'%'.$cgiparams{data}.'%'); | |||||||||||||||||||||||||||
| 246 | 0 | for (@rows) { | |||||||||||||||||||||||||||
| 247 | 0 | $_->{postdate} = formatDate(20,$_->{createdate}); | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | 0 | ▶ | $tvars{wikihash}{results} = \@rows if(@rows); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | ▶ | sub Recent { | ||||||||||||||||||||||||||
|
Subroutine
Recent: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 253 | 0 | ▶ | my $limit = $cgiparams{entries} || 10; | ||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Wiki::cgiparams{'entries'} || 10
MC/DC0%0/1
$Labyrinth::Plugin::Wiki::cgiparams{'entries'} || 10
$Labyrinth::Plugin::Wiki::cgiparams{'entries'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Wiki::cgiparams{'entries'}
| |||||||||||||||||||||||||||||
| 254 | 0 | ▶ | $limit = 10 unless($valid_limits{$limit}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | 0 | my @rows = $dbi->GetQuery('hash','WikiRecentChanges',{limit => "LIMIT $limit"}); | |||||||||||||||||||||||||||
| 256 | 0 | for (@rows) { | |||||||||||||||||||||||||||
| 257 | 0 | $_->{postdate} = formatDate(20,$_->{createdate}); | |||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | 0 | $tvars{wikihash}{recent} = \@rows; | |||||||||||||||||||||||||||
| 260 | 0 | $tvars{wikihash}{entries} = $limit; | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | # ------------------------------------- | ||||||||||||||||||||||||||||
| 264 | # Private Methods | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 0 | ▶ | sub _redirect { | ||||||||||||||||||||||||||
|
Subroutine
_redirect: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 267 | 0 | my $page = shift; | |||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if($page eq 'People') { $tvars{command} = 'user-list'; } | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 270 | 0 | elsif($page eq 'Login') { $tvars{command} = 'user-login'; } | |||||||||||||||||||||||||||
| 271 | 0 | elsif($page eq 'Search') { $tvars{command} = 'wiki-search'; } | |||||||||||||||||||||||||||
| 272 | 0 | elsif($page eq 'RecentChanges') { $tvars{command} = 'wiki-recent'; } | |||||||||||||||||||||||||||
| 273 | 0 | else { $tvars{command} = 'wiki-page'; $cgiparams{pagename} = $page; } | |||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 0 | $tvars{errcode} = 'NEXT'; | |||||||||||||||||||||||||||
| 276 | 0 | return; | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | # Subroutine code based on CGI::Wiki::Plugin::Diff by Ivor Williams. | ||||||||||||||||||||||||||||
| 280 | 0 | ▶ | sub _differences { | ||||||||||||||||||||||||||
|
Subroutine
_differences: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||
| 281 | 0 | my ($d1,$d2) = @_; | |||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 0 | my $el1 = VCS::Lite->new($d1->{version},undef,_content_escape($d1->{content})); | |||||||||||||||||||||||||||
| 284 | 0 | my $el2 = VCS::Lite->new($d2->{version},undef,_content_escape($d2->{content})); | |||||||||||||||||||||||||||
| 285 | 0 | ▶ | my $dlt = $el2->delta($el1) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 0 | my @out; | |||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 0 | for ($dlt->hunks) { | |||||||||||||||||||||||||||
| 290 | 0 | my ($lin1,$lin2,$lin3,$lin4,$out1,$out2); | |||||||||||||||||||||||||||
| 291 | 0 | for (@$_) { | |||||||||||||||||||||||||||
| 292 | 0 | my ($ind,$line,$text) = @$_; | |||||||||||||||||||||||||||
| 293 | # LogDebug("hunk:[$ind][$line][$text]"); | ||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if ($ind =~ /^\+/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 295 | 0 | ▶ | if($lin1) { $lin3 = $line } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 296 | 0 | else { $lin1 = $line } | |||||||||||||||||||||||||||
| 297 | 0 | $out1 .= $text; | |||||||||||||||||||||||||||
| 298 | 0 | ▶ | $out1 .= ' <br />' if($text =~ /^$/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | 0 | ▶ | if ($ind =~ /^\-/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if($lin2) { $lin4 = $line } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 302 | 0 | else { $lin2 = $line } | |||||||||||||||||||||||||||
| 303 | 0 | $out2 .= $text; | |||||||||||||||||||||||||||
| 304 | 0 | ▶ | $out2 .= ' <br />' if($text =~ /^$/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | 0 | ▶ | my $left = $lin3 ? "== Line $lin1-$lin3 ==" : $lin1 ? "== Line $lin1 ==" : "== END OF FILE =="; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 309 | 0 | ▶ | my $right = $lin4 ? "== Line $lin2-$lin4 ==" : $lin2 ? "== Line $lin2 ==" : "== END OF FILE =="; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | # push @out,{ left => $left, right => $right }; | ||||||||||||||||||||||||||||
| 312 | 0 | my ($text1,$text2) = _intradiff($out1,$out2); | |||||||||||||||||||||||||||
| 313 | 0 | push @out,{left => "$left<br />$text1", right => "$right<br />$text2"}; | |||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | 0 | return \@out; | |||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | 0 | ▶ | sub _content_escape { | ||||||||||||||||||||||||||
|
Subroutine
_content_escape: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 320 | 0 | my $txt = shift; | |||||||||||||||||||||||||||
| 321 | 0 | my @txt = split(/\n/,$txt); | |||||||||||||||||||||||||||
| 322 | 0 | return \@txt; | |||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | 0 | ▶ | sub _intradiff { | ||||||||||||||||||||||||||
|
Subroutine
_intradiff: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||
| 326 | 0 | my ($str1,$str2) = @_; | |||||||||||||||||||||||||||
| 327 | # LogDebug("diff:[$str1][$str2]"); | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 0 | ▶ | return (qq{<span class="diff1">$str1</span>},'') unless $str2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 330 | 0 | ▶ | return ('',qq{<span class="diff2">$str2</span>}) unless $str1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 0 | my $re_wordmatcher = qr( | |||||||||||||||||||||||||||
| 333 | &.+?; #HTML special characters e.g. < | ||||||||||||||||||||||||||||
| 334 | |<br\s*/> #Line breaks | ||||||||||||||||||||||||||||
| 335 | |\w+\s* #Word with trailing spaces | ||||||||||||||||||||||||||||
| 336 | |. #Any other single character | ||||||||||||||||||||||||||||
| 337 | )xsi; | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | my @diffs = Algorithm::Diff::sdiff( | ||||||||||||||||||||||||||||
| 340 | [$str1 =~ /$re_wordmatcher/sg], | ||||||||||||||||||||||||||||
| 341 | 0 | ▶ | [$str2 =~ /$re_wordmatcher/sg], sub {_get_token(@_)}); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 342 | 0 | my $out1 = ''; | |||||||||||||||||||||||||||
| 343 | 0 | my $out2 = ''; | |||||||||||||||||||||||||||
| 344 | 0 | my ($mode1,$mode2); | |||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | 0 | for (@diffs) { | |||||||||||||||||||||||||||
| 347 | 0 | my ($ind,$c1,$c2) = @$_; | |||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | 0 | my $newmode1 = $ind =~ /[c\-]/; | |||||||||||||||||||||||||||
| 350 | 0 | my $newmode2 = $ind =~ /[c+]/; | |||||||||||||||||||||||||||
| 351 | 0 | ▶ | $out1 .= '<span class="diff1">' if $newmode1 && !$mode1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$newmode1 and not $mode1
MC/DC0%0/2
$newmode1 and not $mode1
$newmode1
not $mode1
Truth table0%0/3
A and not(B)
A= $newmode1B= not $mode1
| |||||||||||||||||||||||||||||
| 352 | 0 | ▶ | $out2 .= '<span class="diff2">' if $newmode2 && !$mode2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$newmode2 and not $mode2
MC/DC0%0/2
$newmode2 and not $mode2
$newmode2
not $mode2
Truth table0%0/3
A and not(B)
A= $newmode2B= not $mode2
| |||||||||||||||||||||||||||||
| 353 | 0 | ▶ | $out1 .= '</span>' if !$newmode1 && $mode1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $newmode1 and $mode1
MC/DC0%0/2
not $newmode1 and $mode1
not $newmode1
$mode1
Truth table0%0/3
not(A) and B
A= not $newmode1B= $mode1
| |||||||||||||||||||||||||||||
| 354 | 0 | ▶ | $out2 .= '</span>' if !$newmode2 && $mode2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $newmode2 and $mode2
MC/DC0%0/2
not $newmode2 and $mode2
not $newmode2
$mode2
Truth table0%0/3
not(A) and B
A= not $newmode2B= $mode2
| |||||||||||||||||||||||||||||
| 355 | 0 | ($mode1,$mode2) = ($newmode1,$newmode2); | |||||||||||||||||||||||||||
| 356 | 0 | $out1 .= $c1; | |||||||||||||||||||||||||||
| 357 | 0 | $out2 .= $c2; | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | 0 | ▶ | $out1 .= '</span>' if $mode1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 360 | 0 | ▶ | $out2 .= '</span>' if $mode2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 0 | ($out1,$out2); | |||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub _get_token { | ||||||||||||||||||||||||||
|
Subroutine
_get_token: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 366 | 0 | my $str = shift; | |||||||||||||||||||||||||||
| 367 | 0 | $str =~ /^(\S*)\s*$/; # Match all but trailing whitespace | |||||||||||||||||||||||||||
| 368 | 0 | ▶ | $1 || $str; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | # ------------------------------------- | ||||||||||||||||||||||||||||
| 372 | # Admin Methods | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | =head1 ADMIN INTERFACE METHODS | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | =over 4 | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | =item Admin | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | Checks whether user has admin priviledges. | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | =item Rollback | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | Rollbacks the given page by one version. | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | =item Delete | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | Deletes the given page. | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | =item Locks | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | Locks or unlocks the given page. | ||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | =back | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | =cut | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | 0 | ▶ | sub Admin { | ||||||||||||||||||||||||||
|
Subroutine
Admin: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 399 | 0 | ▶ | return unless AccessUser(ADMIN); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | 0 | ▶ | sub Rollback { | ||||||||||||||||||||||||||
|
Subroutine
Rollback: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 403 | 0 | ▶ | return unless AccessUser(ADMIN); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 404 | 0 | LogDebug("Rollback: 1.version=$tvars{wikihash}{version}"); | |||||||||||||||||||||||||||
| 405 | 0 | ▶ | return unless CheckPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 406 | 0 | LogDebug("Rollback: 2.version=$tvars{wikihash}{version}"); | |||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | 0 | my $version = $tvars{wikihash}{version} - 1; | |||||||||||||||||||||||||||
| 409 | 0 | $dbi->DoQuery('DeleteWikiPage' ,$version,$tvars{wikihash}->{'pagename'}); | |||||||||||||||||||||||||||
| 410 | 0 | $dbi->DoQuery('UpdateWikiIndex',$version,$tvars{wikihash}->{'pagename'}); | |||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 0 | ▶ | sub Delete { | ||||||||||||||||||||||||||
|
Subroutine
Delete: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 414 | 0 | ▶ | return unless AccessUser(ADMIN); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 415 | 0 | ▶ | return unless CheckPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | 0 | my $version = $tvars{wikihash}{version} - 1; | |||||||||||||||||||||||||||
| 418 | 0 | $dbi->DoQuery('DeleteWikiPages',$tvars{wikihash}->{'pagename'}); | |||||||||||||||||||||||||||
| 419 | 0 | $dbi->DoQuery('DeleteWikiIndex',$tvars{wikihash}->{'pagename'}); | |||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | 0 | ▶ | sub Locks { | ||||||||||||||||||||||||||
|
Subroutine
Locks: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 423 | 0 | ▶ | return unless AccessUser(ADMIN); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 424 | 0 | ▶ | return unless CheckPage(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | 0 | ▶ | my $lock = $tvars{wikihash}{locked} ? 0 : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 427 | 0 | $dbi->DoQuery('SetWikiLock',$lock,$tvars{wikihash}->{'pagename'}); | |||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | =head1 INTERNAL METHODS | ||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | =over 4 | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | =item CheckPage | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | Checks the page exists. | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | =item GetPage | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | Retrieves the page content for a given version or current page. | ||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | =item RestrictedPage | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | Checks whether the page is restricted. | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | =item LockedPage | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | Checks whether the page is locked. | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | =back | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | =cut | ||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||
| 454 | 0 | ▶ | sub CheckPage { | ||||||||||||||||||||||||||
|
Subroutine
CheckPage: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 455 | 0 | ▶ | my $passthru = shift || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | 0 | ▶ | if($cgiparams{'pagename'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 458 | 0 | ▶ | return 1 if($passthru); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | # retrieve the last known version | ||||||||||||||||||||||||||||
| 461 | 0 | $tvars{wikihash} = GetPage($cgiparams{'pagename'},$cgiparams{'version'}); | |||||||||||||||||||||||||||
| 462 | 0 | return 1; | |||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | 0 | $tvars{errcode} = 'ERROR'; | |||||||||||||||||||||||||||
| 466 | 0 | return 0; | |||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | 0 | ▶ | sub GetPage { | ||||||||||||||||||||||||||
|
Subroutine
GetPage: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 470 | 0 | my ($p,$v) = @_; | |||||||||||||||||||||||||||
| 471 | 0 | ▶ | return unless($p); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | 0 | my @rows; | |||||||||||||||||||||||||||
| 474 | 0 | ▶ | if($v) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 475 | 0 | @rows = $dbi->GetQuery('hash','GetWikiPageVersion',$p,$v); | |||||||||||||||||||||||||||
| 476 | } else { | ||||||||||||||||||||||||||||
| 477 | 0 | @rows = $dbi->GetQuery('hash','GetWikiPage',$p); | |||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | 0 | ▶ | return $rows[0] if(@rows); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 481 | 0 | return; | |||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | 0 | ▶ | sub RestrictedPage { | ||||||||||||||||||||||||||
|
Subroutine
RestrictedPage: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 485 | 0 | ▶ | if($cgiparams{pagename} =~ /^People|Login|Search|RecentChanges$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 486 | 0 | $tvars{errcode} = 'MESSAGE'; | |||||||||||||||||||||||||||
| 487 | 0 | $tvars{errmess} = 'This page is restricted.'; | |||||||||||||||||||||||||||
| 488 | 0 | return 1; | |||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | 0 | return 0; | |||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | 0 | ▶ | sub LockedPage { | ||||||||||||||||||||||||||
|
Subroutine
LockedPage: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 495 | 0 | ▶ | if( $tvars{wikihash}->{locked} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 496 | 0 | $tvars{errcode} = 'MESSAGE'; | |||||||||||||||||||||||||||
| 497 | 0 | $tvars{errmess} = 'This page is locked.'; | |||||||||||||||||||||||||||
| 498 | 0 | return 1; | |||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | 0 | return 0; | |||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | 5 | 1; | |||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||
| 506 | __END__ | ||||||||||||||||||||||||||||