2012-10-27 13:28:13 +02:00
|
|
|
# Copyright (C) 2012 Alex Schroeder <alex@gnu.org>
|
|
|
|
|
#
|
|
|
|
|
# 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
2015-03-27 03:01:01 +02:00
|
|
|
use strict;
|
|
|
|
|
|
2014-08-21 22:23:23 +02:00
|
|
|
AddModuleDescription('fix-encoding.pl', 'Fix Encoding');
|
2012-10-27 13:28:13 +02:00
|
|
|
|
2015-04-10 13:31:28 +03:00
|
|
|
our (%Action, %Page, @MyAdminCode);
|
2015-03-27 03:01:01 +02:00
|
|
|
|
2012-10-27 13:28:13 +02:00
|
|
|
$Action{'fix-encoding'} = \&FixEncoding;
|
|
|
|
|
|
|
|
|
|
sub FixEncoding {
|
|
|
|
|
my $id = shift;
|
|
|
|
|
ValidIdOrDie($id);
|
|
|
|
|
RequestLockOrError();
|
|
|
|
|
OpenPage($id);
|
|
|
|
|
my $text = $Page{text};
|
|
|
|
|
utf8::decode($text);
|
2013-10-20 20:00:30 +02:00
|
|
|
Save($id, $text, T('Fix character encoding'), 1) if $text ne $Page{text};
|
|
|
|
|
ReleaseLock();
|
|
|
|
|
ReBrowsePage($id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$Action{'fix-escaping'} = \&FixEscaping;
|
|
|
|
|
|
|
|
|
|
sub FixEscaping {
|
|
|
|
|
my $id = shift;
|
|
|
|
|
ValidIdOrDie($id);
|
|
|
|
|
RequestLockOrError();
|
|
|
|
|
OpenPage($id);
|
|
|
|
|
my $text = UnquoteHtml($Page{text});
|
|
|
|
|
Save($id, $text, T('Fix HTML escapes'), 1) if $text ne $Page{text};
|
2012-10-27 13:28:13 +02:00
|
|
|
ReleaseLock();
|
|
|
|
|
ReBrowsePage($id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
push(@MyAdminCode, \&FixEncodingMenu);
|
|
|
|
|
|
|
|
|
|
sub FixEncodingMenu {
|
|
|
|
|
my ($id, $menuref, $restref) = @_;
|
2013-11-21 14:31:24 +01:00
|
|
|
if ($id && GetParam('username')) {
|
2012-10-27 13:28:13 +02:00
|
|
|
push(@$menuref,
|
2013-10-20 20:00:30 +02:00
|
|
|
ScriptLink('action=fix-encoding;id=' . UrlEncode($id),
|
|
|
|
|
T('Fix character encoding')));
|
|
|
|
|
push(@$menuref,
|
|
|
|
|
ScriptLink('action=fix-escaping;id=' . UrlEncode($id),
|
|
|
|
|
T('Fix HTML escapes')));
|
2012-10-27 13:28:13 +02:00
|
|
|
}
|
|
|
|
|
}
|