forked from github/kensanata.oddmuse
Merge remote-tracking branch 'origin/return-objects'
This commit is contained in:
@@ -36,8 +36,7 @@ sub WrapperGetHeader {
|
||||
*PrintFooter = \&WrapperPrintFooter;
|
||||
|
||||
sub WrapperPrintFooter {
|
||||
my ($id, $rev, $comment) = @_;
|
||||
print $q->start_div({-class=>'wrapper close'});
|
||||
print $q->end_div(), $q->end_div();
|
||||
OldPrintFooter($id, $rev, $comment);
|
||||
OldPrintFooter(@_);
|
||||
}
|
||||
|
||||
@@ -126,8 +126,8 @@ sub DoAggregate {
|
||||
}
|
||||
}
|
||||
foreach my $id (@pages) {
|
||||
my %data = ParseData(ReadFileOrDie(GetPageFile(FreeToNormal($id))));
|
||||
my $page = $data{text};
|
||||
my $data = ParseData(ReadFileOrDie(GetPageFile(FreeToNormal($id))));
|
||||
my $page = $data->{text};
|
||||
my $size = length($page);
|
||||
my $i = index($page, "\n=");
|
||||
my $j = index($page, "\n----");
|
||||
@@ -136,13 +136,13 @@ sub DoAggregate {
|
||||
$page =~ s/^=.*\n//; # if it starts with a header
|
||||
my $name = $id;
|
||||
$name =~ s/_/ /g;
|
||||
my $date = TimeToRFC822($data{ts});
|
||||
my $host = $data{host};
|
||||
my $username = $data{username};
|
||||
my $date = TimeToRFC822($data->{ts});
|
||||
my $host = $data->{host};
|
||||
my $username = $data->{username};
|
||||
$username = QuoteHtml($username);
|
||||
$username = $host unless $username;
|
||||
my $minor = $data{minor};
|
||||
my $revision = $data{revision};
|
||||
my $minor = $data->{minor};
|
||||
my $revision = $data->{revision};
|
||||
my $cluster = GetCluster($page);
|
||||
my $description = ToString(sub { ApplyRules(QuoteHtml($page), 1, 0, undef, 'p') });
|
||||
$description .= $q->p(GetPageLink($id, T('Learn more...')))
|
||||
|
||||
@@ -124,7 +124,7 @@ sub NewBanContributorsWriteRcLog {
|
||||
and $OpenPageName eq $id and UserIsAdmin()) {
|
||||
# we currently have the clean page loaded, so we need to reload
|
||||
# the spammed revision (there is a possible race condition here)
|
||||
my ($old) = GetTextRevision($Page{revision}-1, 1);
|
||||
my $old = GetTextRevision($Page{revision} - 1, 1)->{text};
|
||||
my %urls = map {$_ => 1 } $old =~ /$UrlPattern/g;
|
||||
# we open the file again to force a load of the despammed page
|
||||
foreach my $url ($Page{text} =~ /$UrlPattern/g) {
|
||||
|
||||
@@ -133,14 +133,14 @@ sub DespamPage {
|
||||
# from DoHistory()
|
||||
my @revisions = sort {$b <=> $a} map { m|/([0-9]+).kp$|; $1; } GetKeepFiles($OpenPageName);
|
||||
foreach my $revision (@revisions) {
|
||||
my ($text, $rev) = GetTextRevision($revision, 1); # quiet
|
||||
my ($revisionPage, $rev) = GetTextRevision($revision, 1); # quiet
|
||||
if (not $rev) {
|
||||
print ': ' . Ts('Cannot find revision %s.', $revision);
|
||||
return;
|
||||
} elsif (not DespamBannedContent($text)) {
|
||||
} elsif (not DespamBannedContent($revisionPage->{text})) {
|
||||
my $summary = Tss('Revert to revision %1: %2', $revision, $rule);
|
||||
print ': ' . $summary;
|
||||
Save($OpenPageName, $text, $summary) unless GetParam('debug', 0);
|
||||
Save($OpenPageName, $revisionPage->{text}, $summary) unless GetParam('debug', 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,10 +48,10 @@ sub DoDraft {
|
||||
SetParam('msg', T('Draft saved')); # invalidate cache
|
||||
print GetHttpHeader('', T('Draft saved'), '204 NO CONTENT');
|
||||
} elsif (-f $draft) {
|
||||
my %data = ParseData(ReadFileOrDie($draft));
|
||||
my $data = ParseData(ReadFileOrDie($draft));
|
||||
unlink ($draft);
|
||||
$Message .= $q->p(T('Draft recovered'));
|
||||
DoEdit($data{id}, $data{text}, 1);
|
||||
DoEdit($data->{id}, $data->{text}, 1);
|
||||
} else {
|
||||
ReportError(T('No draft available to recover'), '404 NOT FOUND');
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ sub NewEnclosureRssItem {
|
||||
my $id = shift;
|
||||
my $rss = OldEnclosureRssItem($id, @_);
|
||||
require MIME::Base64;
|
||||
my %data = ParseData(ReadFileOrDie(GetPageFile($id)));
|
||||
my @enclosures = split(' ', $data{enclosures});
|
||||
my $data = ParseData(ReadFileOrDie(GetPageFile($id)));
|
||||
my @enclosures = split(' ', $data->{enclosures});
|
||||
my $enclosures = '';
|
||||
foreach my $enclosure (@enclosures) {
|
||||
# Don't add the enclosure if the page has been deleted in the mean
|
||||
|
||||
@@ -240,9 +240,9 @@ sub GdSecurityImageCheck {
|
||||
if ($answer ne '' && GdSecurityImageIsValidId($id)) {
|
||||
my ($status, $data) = ReadFile(GdSecurityImageGetTicketFile($id));
|
||||
if ($status) {
|
||||
my %page = ParseData($data);
|
||||
if ($page{generation_time} + $GdSecurityImageDuration > $Now) {
|
||||
if ($answer eq $page{string}) {
|
||||
my $page = ParseData($data);
|
||||
if ($page->{generation_time} + $GdSecurityImageDuration > $Now) {
|
||||
if ($answer eq $page->{string}) {
|
||||
$GdSecurityImageId = '';
|
||||
if (!$GdSecurityImageRememberAnswer) {
|
||||
SetParam('gd_security_image_id', '');
|
||||
|
||||
@@ -174,18 +174,17 @@ sub JoinerCreateAccount {
|
||||
}
|
||||
|
||||
my ($email_status, $email_data) = ReadFile(JoinerGetEmailFile($email));
|
||||
my %email_page = ();
|
||||
if ($email_status) {
|
||||
%email_page = ParseData($email_data);
|
||||
if ($email_page{confirmed}) {
|
||||
my $email_page = ParseData($email_data);
|
||||
if ($email_page->{confirmed}) {
|
||||
return Ts('The email address %s has already been used.', $email);
|
||||
}
|
||||
if ($email_page{registration_time} + $JoinerWait > $Now) {
|
||||
my $min = 1 + int(($email_page{registration_time} + $JoinerWait - $Now) / 60);
|
||||
if ($email_page->{registration_time} + $JoinerWait > $Now) {
|
||||
my $min = 1 + int(($email_page->{registration_time} + $JoinerWait - $Now) / 60);
|
||||
return Ts('Wait %s minutes before try again.', $min);
|
||||
}
|
||||
}
|
||||
%email_page = ();
|
||||
my %email_page = ();
|
||||
$email_page{username} = $username;
|
||||
$email_page{email} = $email;
|
||||
$email_page{confirmed} = 0;
|
||||
@@ -468,37 +467,37 @@ sub JoinerDoConfirmRegistration {
|
||||
JoinerShowRegistrationConfirmationFailed();
|
||||
return;
|
||||
}
|
||||
my %page = ParseData($data);
|
||||
my $page = ParseData($data);
|
||||
|
||||
if ($key ne $page{key}) {
|
||||
if ($key ne $page->{key}) {
|
||||
$JoinerMessage = T('Invalid key.');
|
||||
JoinerShowRegistrationConfirmationFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($page{registration_time} + $JoinerWait < $Now) {
|
||||
if ($page->{registration_time} + $JoinerWait < $Now) {
|
||||
$JoinerMessage = T('The key expired.');
|
||||
JoinerShowRegistrationConfirmationFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
$page{key} = '';
|
||||
$page{confirmed} = 1;
|
||||
$page->{key} = '';
|
||||
$page->{confirmed} = 1;
|
||||
JoinerRequestLockOrError('joiner');
|
||||
CreateDir($JoinerDir);
|
||||
WriteStringToFile(JoinerGetAccountFile($username), EncodePage(%page));
|
||||
WriteStringToFile(JoinerGetAccountFile($username), EncodePage(%$page));
|
||||
ReleaseLockDir('joiner');
|
||||
|
||||
my $email = $page{email};
|
||||
my $email = $page->{email};
|
||||
JoinerRequestLockOrError('joiner');
|
||||
my ($email_status, $email_data) = ReadFile(JoinerGetEmailFile($email));
|
||||
ReleaseLockDir('joiner');
|
||||
if ($email_status) {
|
||||
my %email_page = ParseData($email_data);
|
||||
$email_page{confirmed} = 1;
|
||||
my $email_page = ParseData($email_data);
|
||||
$email_page->{confirmed} = 1;
|
||||
JoinerRequestLockOrError('joiner');
|
||||
CreateDir($JoinerEmailDir);
|
||||
WriteStringToFile(JoinerGetEmailFile($email), EncodePage(%email_page));
|
||||
WriteStringToFile(JoinerGetEmailFile($email), EncodePage(%$email_page));
|
||||
ReleaseLockDir('joiner');
|
||||
}
|
||||
|
||||
@@ -570,41 +569,41 @@ sub JoinerDoProcessLogin {
|
||||
JoinerDoLogin();
|
||||
return;
|
||||
}
|
||||
my %page = ParseData($data);
|
||||
my $page = ParseData($data);
|
||||
my $hash = JoinerGetPasswordHash($password);
|
||||
if ($hash eq $page{password}) {
|
||||
$page{recover} = 0;
|
||||
if ($hash eq $page->{password}) {
|
||||
$page->{recover} = 0;
|
||||
SetParam('joiner_recover', 0);
|
||||
} elsif ($key ne '' && $key eq $page{recover_key}) {
|
||||
if ($page{recover_time} + $JoinerWait < $Now) {
|
||||
} elsif ($key ne '' && $key eq $page->{recover_key}) {
|
||||
if ($page->{recover_time} + $JoinerWait < $Now) {
|
||||
$JoinerMessage = T('The key expired.');
|
||||
JoinerDoLogin();
|
||||
return;
|
||||
}
|
||||
$page{recover} = 1;
|
||||
$page->{recover} = 1;
|
||||
SetParam('joiner_recover', 1);
|
||||
} else {
|
||||
$JoinerMessage = T('Login failed.');
|
||||
JoinerDoLogin();
|
||||
return;
|
||||
}
|
||||
if ($page{banned}) {
|
||||
if ($page->{banned}) {
|
||||
$JoinerMessage = T('You are banned.');
|
||||
JoinerDoLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$page{confirmed}) {
|
||||
if (!$page->{confirmed}) {
|
||||
$JoinerMessage = T('You must confirm email address.');
|
||||
JoinerDoLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
my $session = Digest::MD5::md5_hex(rand());
|
||||
$page{session} = $session;
|
||||
$page->{session} = $session;
|
||||
JoinerRequestLockOrError('joiner');
|
||||
CreateDir($JoinerDir);
|
||||
WriteStringToFile(JoinerGetAccountFile($username), EncodePage(%page));
|
||||
WriteStringToFile(JoinerGetAccountFile($username), EncodePage(%$page));
|
||||
ReleaseLockDir('joiner');
|
||||
|
||||
SetParam('username', $username);
|
||||
@@ -617,7 +616,7 @@ sub JoinerDoProcessLogin {
|
||||
print Ts('%s has logged in.', $username);
|
||||
print $q->end_p();
|
||||
|
||||
if ($page{recover}) {
|
||||
if ($page->{recover}) {
|
||||
print $q->start_p();
|
||||
print T('You should set new password immediately.');
|
||||
print $q->end_p();
|
||||
@@ -735,9 +734,9 @@ sub JoinerDoProcessChangePassword {
|
||||
JoinerDoChangePassword();
|
||||
return;
|
||||
}
|
||||
my %page = ParseData($data);
|
||||
my $page = ParseData($data);
|
||||
my $hash = JoinerGetPasswordHash($current_password);
|
||||
if (!$page{recover} && $hash ne $page{password}) {
|
||||
if (!$page->{recover} && $hash ne $page->{password}) {
|
||||
$JoinerMessage = T('Current Password:') . ' ' . T('Password is wrong.');
|
||||
JoinerDoChangePassword();
|
||||
return;
|
||||
@@ -754,12 +753,12 @@ sub JoinerDoProcessChangePassword {
|
||||
return;
|
||||
}
|
||||
|
||||
$page{password} = JoinerGetPasswordHash($new_password);
|
||||
$page{key} = '';
|
||||
$page{recover} = '';
|
||||
$page->{password} = JoinerGetPasswordHash($new_password);
|
||||
$page->{key} = '';
|
||||
$page->{recover} = '';
|
||||
JoinerRequestLockOrError('joiner');
|
||||
CreateDir($JoinerDir);
|
||||
WriteStringToFile(JoinerGetAccountFile($username), EncodePage(%page));
|
||||
WriteStringToFile(JoinerGetAccountFile($username), EncodePage(%$page));
|
||||
ReleaseLockDir('joiner');
|
||||
|
||||
SetParam('joiner_recover', 0);
|
||||
@@ -823,9 +822,9 @@ sub JoinerDoProcessForgotPassword {
|
||||
JoinerDoForgotPassword();
|
||||
return;
|
||||
}
|
||||
my %email_page = ParseData($email_data);
|
||||
my $email_page = ParseData($email_data);
|
||||
|
||||
my $username = $email_page{username};
|
||||
my $username = $email_page->{username};
|
||||
JoinerRequestLockOrError('joiner');
|
||||
my ($status, $data) = ReadFile(JoinerGetAccountFile($username));
|
||||
ReleaseLockDir('joiner');
|
||||
@@ -834,27 +833,27 @@ sub JoinerDoProcessForgotPassword {
|
||||
JoinerDoForgotPassword();
|
||||
return;
|
||||
}
|
||||
my %page = ParseData($data);
|
||||
my $page = ParseData($data);
|
||||
|
||||
if ($email ne $page{email}) {
|
||||
if ($email ne $page->{email}) {
|
||||
$JoinerMessage = T('The mail address is not valid anymore.');
|
||||
JoinerDoForgotPassword();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($page{recover_time} + $JoinerWait > $Now) {
|
||||
my $min = 1 + int(($page{recover_time} + $JoinerWait - $Now) / 60);
|
||||
if ($page->{recover_time} + $JoinerWait > $Now) {
|
||||
my $min = 1 + int(($page->{recover_time} + $JoinerWait - $Now) / 60);
|
||||
$JoinerMessage = Ts('Wait %s minutes before try again.', $min);
|
||||
JoinerDoForgotPassword();
|
||||
return;
|
||||
}
|
||||
|
||||
my $key = Digest::MD5::md5_hex($JoinerGeneratorSalt . rand());
|
||||
$page{recover_time} = $Now;
|
||||
$page{recover_key} = $key;
|
||||
$page->{recover_time} = $Now;
|
||||
$page->{recover_key} = $key;
|
||||
JoinerRequestLockOrError('joiner');
|
||||
CreateDir($JoinerDir);
|
||||
WriteStringToFile(JoinerGetAccountFile($username), EncodePage(%page));
|
||||
WriteStringToFile(JoinerGetAccountFile($username), EncodePage(%$page));
|
||||
ReleaseLockDir('joiner');
|
||||
|
||||
JoinerSendRecoverAccountEmail($email, $username, $key);
|
||||
@@ -922,8 +921,8 @@ sub JoinerDoProcessChangeEmail {
|
||||
my ($email_status, $email_data) = ReadFile(JoinerGetEmailFile($email));
|
||||
ReleaseLockDir('joiner');
|
||||
if ($email_status) {
|
||||
my %email_page = ParseData($email_data);
|
||||
if ($email_page{confirmed} && $email_page{username} ne $username) {
|
||||
my $email_page = ParseData($email_data);
|
||||
if ($email_page->{confirmed} && $email_page->{username} ne $username) {
|
||||
$JoinerMessage = T('Email:') . ' ' .
|
||||
Ts('The email address %s has already been used.', $email);
|
||||
JoinerDoChangeEmail();
|
||||
@@ -939,29 +938,29 @@ sub JoinerDoProcessChangeEmail {
|
||||
JoinerDoChangeEmail();
|
||||
return;
|
||||
}
|
||||
my %page = ParseData($data);
|
||||
my $page = ParseData($data);
|
||||
|
||||
if ($page{change_email_time} + $JoinerWait > $Now) {
|
||||
my $min = 1 + int(($page{change_email_time} + $JoinerWait - $Now) / 60);
|
||||
if ($page->{change_email_time} + $JoinerWait > $Now) {
|
||||
my $min = 1 + int(($page->{change_email_time} + $JoinerWait - $Now) / 60);
|
||||
$JoinerMessage = Ts('Wait %s minutes before try again.', $min);
|
||||
JoinerDoChangeEmail();
|
||||
return;
|
||||
}
|
||||
|
||||
my $hash = JoinerGetPasswordHash($password);
|
||||
if ($hash ne $page{password}) {
|
||||
if ($hash ne $page->{password}) {
|
||||
$JoinerMessage = T('Password:') . ' ' . T('Password is wrong.');
|
||||
JoinerDoChangeEmail();
|
||||
return;
|
||||
}
|
||||
|
||||
my $key = Digest::MD5::md5_hex(rand());
|
||||
$page{change_email} = $email;
|
||||
$page{change_email_key} = $key;
|
||||
$page{change_email_time} = $Now;
|
||||
$page->{change_email} = $email;
|
||||
$page->{change_email_key} = $key;
|
||||
$page->{change_email_time} = $Now;
|
||||
JoinerRequestLockOrError('joiner');
|
||||
CreateDir($JoinerDir);
|
||||
WriteStringToFile(JoinerGetAccountFile($username), EncodePage(%page));
|
||||
WriteStringToFile(JoinerGetAccountFile($username), EncodePage(%$page));
|
||||
ReleaseLockDir('joiner');
|
||||
|
||||
JoinerSendChangeEmailEmail($email, $username, $key);
|
||||
@@ -1012,22 +1011,22 @@ sub JoinerDoConfirmEmail {
|
||||
JoinerShowConfirmEmailFailed();
|
||||
return;
|
||||
}
|
||||
my %page = ParseData($data);
|
||||
my $page = ParseData($data);
|
||||
|
||||
if ($key ne $page{change_email_key}) {
|
||||
if ($key ne $page->{change_email_key}) {
|
||||
$JoinerMessage = T('Invalid key.');
|
||||
JoinerShowConfirmEmailFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
my $new_email = $page{change_email};
|
||||
$page{email} = $new_email;
|
||||
$page{change_email} = '';
|
||||
$page{change_email_key} = '';
|
||||
$page{change_email_time} = '';
|
||||
my $new_email = $page->{change_email};
|
||||
$page->{email} = $new_email;
|
||||
$page->{change_email} = '';
|
||||
$page->{change_email_key} = '';
|
||||
$page->{change_email_time} = '';
|
||||
JoinerRequestLockOrError('joiner');
|
||||
CreateDir($JoinerDir);
|
||||
WriteStringToFile(JoinerGetAccountFile($username), EncodePage(%page));
|
||||
WriteStringToFile(JoinerGetAccountFile($username), EncodePage(%$page));
|
||||
ReleaseLockDir('joiner');
|
||||
|
||||
my %email_page = ();
|
||||
@@ -1128,30 +1127,30 @@ sub JoinerDoProcessBan {
|
||||
JoinerDoBan();
|
||||
return;
|
||||
}
|
||||
my %page = ParseData($data);
|
||||
my $page = ParseData($data);
|
||||
|
||||
if ($ban) {
|
||||
if ($page{banned}) {
|
||||
if ($page->{banned}) {
|
||||
$JoinerMessage = Ts('%s is already banned.', $username);
|
||||
JoinerDoBan();
|
||||
return;
|
||||
}
|
||||
$page{banned} = 1;
|
||||
$page{session} = '';
|
||||
$page->{banned} = 1;
|
||||
$page->{session} = '';
|
||||
$JoinerMessage = Ts('%s has been banned.', $username);
|
||||
} else {
|
||||
if (!$page{banned}) {
|
||||
if (!$page->{banned}) {
|
||||
$JoinerMessage = Ts('%s is not banned.', $username);
|
||||
JoinerDoBan();
|
||||
return;
|
||||
}
|
||||
$page{banned} = 0;
|
||||
$page->{banned} = 0;
|
||||
$JoinerMessage = Ts('%s has been unbanned.', $username);
|
||||
}
|
||||
|
||||
JoinerRequestLockOrError('joiner');
|
||||
CreateDir($JoinerDir);
|
||||
WriteStringToFile(JoinerGetAccountFile($username), EncodePage(%page));
|
||||
WriteStringToFile(JoinerGetAccountFile($username), EncodePage(%$page));
|
||||
ReleaseLockDir('joiner');
|
||||
|
||||
JoinerDoBan();
|
||||
@@ -1178,16 +1177,16 @@ sub JoinerIsLoggedIn {
|
||||
$JoinerLoggedIn = 0;
|
||||
return $JoinerLoggedIn;
|
||||
}
|
||||
my %page = ParseData($data);
|
||||
if (!$page{confirmed}) {
|
||||
my $page = ParseData($data);
|
||||
if (!$page->{confirmed}) {
|
||||
$JoinerLoggedIn = 0;
|
||||
return $JoinerLoggedIn;
|
||||
}
|
||||
if ($session ne $page{session}) {
|
||||
if ($session ne $page->{session}) {
|
||||
$JoinerLoggedIn = 0;
|
||||
return $JoinerLoggedIn;
|
||||
}
|
||||
if ($page{banned}) {
|
||||
if ($page->{banned}) {
|
||||
$JoinerLoggedIn = 0;
|
||||
return $JoinerLoggedIn;
|
||||
}
|
||||
|
||||
@@ -35,12 +35,12 @@ sub LiveTemplateRule {
|
||||
Dirty($str);
|
||||
my $oldpos = pos;
|
||||
my $old_ = $_;
|
||||
my %hash = ParseData($2);
|
||||
my $hash = ParseData($2);
|
||||
my $text = GetPageContent($template);
|
||||
return $q->p($q->strong(Ts('The template %s is either empty or does not exist.',
|
||||
$template))) . AddHtmlEnvironment('p') unless $text;
|
||||
foreach my $key (keys %hash) {
|
||||
$text =~ s/\$$key\$/$hash{$key}/g;
|
||||
foreach my $key (keys %$hash) {
|
||||
$text =~ s/\$$key\$/$hash->{$key}/g;
|
||||
}
|
||||
print "<div class=\"template $template\">";
|
||||
ApplyRules(QuoteHtml($text), 1, 1, undef, 'p');
|
||||
|
||||
@@ -381,7 +381,8 @@ sub NewNamespaceBrowsePage {
|
||||
#REDIRECT into different namespaces
|
||||
my ($id, $raw, $comment, $status) = @_;
|
||||
OpenPage($id);
|
||||
my ($text, $revision) = GetTextRevision(GetParam('revision', ''), 1);
|
||||
my ($revisionPage, $revision) = GetTextRevision(GetParam('revision', ''), 1);
|
||||
my $text = $revisionPage->{text};
|
||||
my $oldId = GetParam('oldid', '');
|
||||
if (not $oldId and not $revision and (substr($text, 0, 10) eq '#REDIRECT ')
|
||||
and (($WikiLinks and $text =~ /^\#REDIRECT\s+(($InterSitePattern:)?$InterLinkPattern)/)
|
||||
|
||||
@@ -271,11 +271,11 @@ sub SearchNearPages {
|
||||
my @entries = split(/\n\n+/, $data);
|
||||
shift @entries; # skip head
|
||||
foreach my $entry (@entries) {
|
||||
my %entry = ParseData($entry); # need to pass reference
|
||||
my $name = $entry{title};
|
||||
my $entryPage = ParseData($entry); # need to pass reference
|
||||
my $name = $entryPage->{title};
|
||||
next if $found{$name}; # do not duplicate local pages
|
||||
$found{$name} = 1;
|
||||
PrintSearchResultEntry(\%entry, $regex); # with context and full search!
|
||||
PrintSearchResultEntry($entryPage, $regex); # with context and full search!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ sub LocalMapWorkHorse {
|
||||
|
||||
my $retval_children = '';
|
||||
if ($depth > 0) {
|
||||
my %data = ParseData(ReadFileOrDie(GetPageFile($id)));
|
||||
my @flags = split(/$FS/, $data{'flags'});
|
||||
my @blocks = split(/$FS/, $data{'blocks'});
|
||||
my $data = ParseData(ReadFileOrDie(GetPageFile($id)));
|
||||
my @flags = split(/$FS/, $data->{'flags'});
|
||||
my @blocks = split(/$FS/, $data->{'blocks'});
|
||||
my @subpages;
|
||||
|
||||
# Iterate over blocks, operate only on "dirty" ones
|
||||
|
||||
@@ -69,8 +69,8 @@ sub NewPrivatePagesUserCanEdit {
|
||||
my $result = OldPrivatePagesUserCanEdit($id, $editing, @rest);
|
||||
# bypass OpenPage and GetPageContent (these are redefined below)
|
||||
if ($result > 0 and $editing and $IndexHash{$id}) {
|
||||
my %data = ParseData(ReadFileOrDie(GetPageFile($id)));
|
||||
if (PrivatePageLocked($data{text})) {
|
||||
my $data = ParseData(ReadFileOrDie(GetPageFile($id)));
|
||||
if (PrivatePageLocked($data->{text})) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -128,11 +128,11 @@ sub NewPrivatePagesGetPageContent {
|
||||
*GetTextRevision = \&NewPrivatePagesGetTextRevision;
|
||||
|
||||
sub NewPrivatePagesGetTextRevision {
|
||||
my ($text, $revision) = OldPrivatePagesGetTextRevision(@_);
|
||||
if (PrivatePageLocked($text)) {
|
||||
return (NewPrivatePageNewText(), $revision);
|
||||
my ($page, $revision) = OldPrivatePagesGetTextRevision(@_);
|
||||
if (PrivatePageLocked($page->{text})) {
|
||||
return ({text => NewPrivatePageNewText()}, $revision); # XXX faking a page object like this is not good
|
||||
}
|
||||
return ($text, $revision);
|
||||
return wantarray ? ($page, $revision) : $page;
|
||||
}
|
||||
|
||||
# hide #PASSWORD
|
||||
|
||||
@@ -117,9 +117,9 @@ sub StaticFileName {
|
||||
my ($status, $data) = ReadFile(GetPageFile(UrlDecode($id)));
|
||||
# If the link points to a wanted page, we cannot make this static.
|
||||
return $id unless $status;
|
||||
my %hash = ParseData($data);
|
||||
my $hash = ParseData($data);
|
||||
my $ext = '.html';
|
||||
if ($hash{text} =~ /^\#FILE ([^ \n]+ ?[^ \n]*)\n(.*)/s) {
|
||||
if ($hash->{text} =~ /^\#FILE ([^ \n]+ ?[^ \n]*)\n(.*)/s) {
|
||||
%StaticMimeTypes = StaticMimeTypes() unless %StaticMimeTypes;
|
||||
$ext = $StaticMimeTypes{"$1"};
|
||||
$ext = '.' . $ext if $ext;
|
||||
|
||||
@@ -113,9 +113,9 @@ sub StaticFileName {
|
||||
return $StaticFiles{$id} if $StaticFiles{$id}; # cache filenames
|
||||
my ($status, $data) = ReadFile(GetPageFile(StaticUrlDecode($id)));
|
||||
print "cannot read " . GetPageFile(StaticUrlDecode($id)) . $q->br() unless $status;
|
||||
my %hash = ParseData($data);
|
||||
my $hash = ParseData($data);
|
||||
my $ext = '.html';
|
||||
if ($hash{text} =~ /^\#FILE ([^ \n]+)\n(.*)/s) {
|
||||
if ($hash->{text} =~ /^\#FILE ([^ \n]+)\n(.*)/s) {
|
||||
$ext = $StaticMimeTypes{$1};
|
||||
$ext = '.' . $ext if $ext;
|
||||
}
|
||||
@@ -445,15 +445,15 @@ sub StaticNewDespamPage {
|
||||
# from DoHistory()
|
||||
my @revisions = sort {$b <=> $a} map { m|/([0-9]+).kp$|; $1; } GetKeepFiles($OpenPageName);
|
||||
foreach my $revision (@revisions) {
|
||||
my ($text, $rev) = GetTextRevision($revision, 1); # quiet
|
||||
my ($revisionPage, $rev) = GetTextRevision($revision, 1); # quiet
|
||||
if (not $rev) {
|
||||
print ': ' . Ts('Cannot find revision %s.', $revision);
|
||||
return;
|
||||
} elsif (not DespamBannedContent($text)) {
|
||||
} elsif (not DespamBannedContent($revisionPage->{text})) {
|
||||
my $summary = Tss('Revert to revision %1: %2', $revision, $rule);
|
||||
print ': ' . $summary;
|
||||
Save($OpenPageName, $text, $summary) unless GetParam('debug', 0);
|
||||
StaticDeleteFile($OpenPageName);
|
||||
Save($OpenPageName, $revisionPage->{text}, $summary) unless GetParam('debug', 0);
|
||||
StaticDeleteFile($OpenPageName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -461,7 +461,7 @@ sub StaticNewDespamPage {
|
||||
my $summary = Ts($rule). ' ' . Ts('Marked as %s.', $DeletedPage);
|
||||
print ': ' . $summary;
|
||||
Save($OpenPageName, $DeletedPage, $summary) unless GetParam('debug', 0);
|
||||
StaticDeleteFile($OpenPageName);
|
||||
StaticDeleteFile($OpenPageName);
|
||||
} else {
|
||||
print ': ' . T('Cannot find unspammed revision.');
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ sub NewSvgGetDownloadLink {
|
||||
local (%Page, $OpenPageName);
|
||||
OpenPage($name);
|
||||
if ($revision) {
|
||||
($data) = GetTextRevision($revision); # ignore revision reset
|
||||
$data = GetTextRevision($revision)->{text}; # ignore revision reset
|
||||
} else {
|
||||
$data = $Page{text};
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ sub GenerateThumbNail {
|
||||
# Check MIME type supported
|
||||
# Check is a file
|
||||
|
||||
my ($text, $revision) = GetTextRevision(GetParam('revision', '')); # maybe revision reset!
|
||||
my $text = GetTextRevision(GetParam('revision', ''))->{text}; # maybe revision reset!
|
||||
my ($type) = TextIsFile($text); # MIME type if an uploaded file
|
||||
my $data = substr($text, index($text, "\n") + 1);
|
||||
|
||||
|
||||
@@ -37,8 +37,7 @@ sub TranslationRule {
|
||||
|
||||
sub GetCurrentPageRevision {
|
||||
my $id = shift;
|
||||
my %page = ParseData(ReadFileOrDie(GetPageFile($id)));
|
||||
return $page{revision};
|
||||
return ParseData(ReadFileOrDie(GetPageFile($id)))->{revision};
|
||||
}
|
||||
|
||||
sub GetTranslationLink {
|
||||
|
||||
Reference in New Issue
Block a user