2009-02-13 10:29:21 +00:00
|
|
|
# Copyright (C) 2004, 2005, 2006, 2009 Alex Schroeder <alex@gnu.org>
|
2004-01-30 21:35:44 +00:00
|
|
|
#
|
|
|
|
|
# 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
|
2009-02-13 10:29:21 +00:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2004-01-30 21:35:44 +00:00
|
|
|
# (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
|
2009-02-13 10:29:21 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-01-30 21:35:44 +00:00
|
|
|
|
2015-03-27 03:01:01 +02:00
|
|
|
use strict;
|
2015-08-18 10:48:03 +02:00
|
|
|
use v5.10;
|
2015-03-27 03:01:01 +02:00
|
|
|
|
2014-08-21 22:23:23 +02:00
|
|
|
AddModuleDescription('portrait-support.pl', 'Portraits Support Extension');
|
2004-01-30 11:53:18 +00:00
|
|
|
|
2015-04-10 13:31:28 +03:00
|
|
|
our ($q, $bol, $Now, @MyMacros, @MyRules, $FreeLinkPattern, $UrlPattern, $FS);
|
2015-03-27 03:01:01 +02:00
|
|
|
|
2004-02-05 18:05:58 +00:00
|
|
|
push(@MyMacros, sub{ s/\[new::\]/"[new:" . GetParam('username', T('Anonymous'))
|
2015-08-23 21:22:12 +03:00
|
|
|
. ':' . TimeToText($Now) . "]"/eg });
|
|
|
|
|
push(@MyMacros, sub{ s/\[new:$FreeLinkPattern\]/"[new:$1:" . TimeToText($Now) . "]"/eg });
|
2004-01-30 11:53:18 +00:00
|
|
|
|
|
|
|
|
push(@MyRules, \&PortraitSupportRule);
|
|
|
|
|
|
2015-04-10 13:31:28 +03:00
|
|
|
our ($PortraitSupportColorDiv, $PortraitSupportColor);
|
2004-11-27 21:12:20 +00:00
|
|
|
|
2004-12-03 08:41:19 +00:00
|
|
|
$PortraitSupportColor = 0;
|
2004-11-27 21:16:02 +00:00
|
|
|
$PortraitSupportColorDiv = 0;
|
2004-11-27 21:12:20 +00:00
|
|
|
|
2015-03-27 03:01:01 +02:00
|
|
|
my %Portrait = ();
|
2004-01-30 11:53:18 +00:00
|
|
|
|
|
|
|
|
sub PortraitSupportRule {
|
2004-10-10 17:03:09 +00:00
|
|
|
if ($bol) {
|
|
|
|
|
if (m/\G(\s*\n)*----+[ \t]*\n?/cg) {
|
2004-12-03 08:41:19 +00:00
|
|
|
$PortraitSupportColor = 0;
|
2004-12-05 03:58:44 +00:00
|
|
|
my $html = CloseHtmlEnvironments() . ($PortraitSupportColorDiv ? '</div>' : '')
|
|
|
|
|
. $q->hr() . AddHtmlEnvironment('p');
|
2004-11-27 21:16:02 +00:00
|
|
|
$PortraitSupportColorDiv = 0;
|
2004-12-03 08:41:19 +00:00
|
|
|
return $html;
|
2015-08-23 21:22:12 +03:00
|
|
|
} elsif ($bol && m/\Gportrait:$UrlPattern/cg) {
|
2004-10-10 17:03:09 +00:00
|
|
|
return $q->img({-src=>$1, -alt=>T("Portrait"), -class=>'portrait'});
|
2015-08-23 21:22:12 +03:00
|
|
|
} elsif ($bol && m/\G(:*)\[new(.*)\]/cg) {
|
2004-10-10 17:03:09 +00:00
|
|
|
my $portrait = '';
|
2006-03-18 19:51:58 +00:00
|
|
|
my $depth = length($1);
|
|
|
|
|
my ($ignore, $name, $time) = split(/:/, $2, 3);
|
2004-10-10 17:03:09 +00:00
|
|
|
if ($name) {
|
|
|
|
|
if (not $Portrait{$name}) {
|
|
|
|
|
my $oldpos = pos;
|
|
|
|
|
if (GetPageContent($name) =~ m/portrait:$UrlPattern/) {
|
|
|
|
|
$Portrait{$name} =
|
2006-03-18 19:51:58 +00:00
|
|
|
$q->div({-class=>"portrait"},
|
2004-12-05 03:58:44 +00:00
|
|
|
$q->p(ScriptLink($name, $q->img({-src=>$1, -alt=>'new: ' . $time,
|
|
|
|
|
-class=>'portrait'}),
|
|
|
|
|
'newauthor', '', $FS),
|
|
|
|
|
$q->br(),
|
|
|
|
|
GetPageLink($name)));
|
2004-10-10 17:03:09 +00:00
|
|
|
}
|
2004-01-30 11:53:18 +00:00
|
|
|
}
|
2004-10-10 17:03:09 +00:00
|
|
|
$portrait = $Portrait{$name};
|
|
|
|
|
$portrait =~ s/$FS/$time/;
|
2004-01-30 11:53:18 +00:00
|
|
|
}
|
2004-12-03 08:42:19 +00:00
|
|
|
my $html = CloseHtmlEnvironments()
|
|
|
|
|
. ($PortraitSupportColorDiv ? '</div>' : '');
|
2004-12-03 08:41:19 +00:00
|
|
|
$PortraitSupportColor = !$PortraitSupportColor;
|
2004-12-03 08:42:19 +00:00
|
|
|
$html .= '<div class="color '
|
|
|
|
|
. ($PortraitSupportColor ? 'one' : 'two')
|
2006-03-18 19:51:58 +00:00
|
|
|
. ' level' . $depth
|
2004-12-05 03:58:44 +00:00
|
|
|
. '">' . $portrait . AddHtmlEnvironment('p');
|
2004-11-27 21:16:02 +00:00
|
|
|
$PortraitSupportColorDiv = 1;
|
2004-10-10 17:03:09 +00:00
|
|
|
return $html;
|
2004-01-30 11:53:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-02-27 12:10:18 +02:00
|
|
|
return;
|
2004-01-30 11:53:18 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-11 23:41:33 +03:00
|
|
|
*OldPortraitSupportApplyRules = \&ApplyRules;
|
|
|
|
|
*ApplyRules = \&NewPortraitSupportApplyRules;
|
2004-01-30 11:53:18 +00:00
|
|
|
|
2004-10-10 17:26:28 +00:00
|
|
|
sub NewPortraitSupportApplyRules {
|
|
|
|
|
my ($blocks, $flags) = OldPortraitSupportApplyRules(@_);
|
2004-11-27 21:16:02 +00:00
|
|
|
if ($PortraitSupportColorDiv) {
|
2004-10-10 17:26:28 +00:00
|
|
|
print '</div>';
|
|
|
|
|
$blocks .= $FS . '</div>';
|
|
|
|
|
$flags .= $FS . 0;
|
2004-11-27 21:16:02 +00:00
|
|
|
$PortraitSupportColorDiv = 0;
|
2004-01-30 11:53:18 +00:00
|
|
|
}
|
2004-10-10 17:26:28 +00:00
|
|
|
return ($blocks, $flags);
|
|
|
|
|
}
|