2014-06-22 00:21:46 +02:00
|
|
|
# Copyright (C) 2006-2014 Alex Schroeder <alex@gnu.org>
|
2016-12-02 14:34:44 +01:00
|
|
|
# Copyright (C) 2016 Ingo Belka
|
2006-03-21 00:18:43 +00:00
|
|
|
#
|
2014-06-22 00:21:46 +02: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 the Free Software
|
|
|
|
|
# Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
|
# version.
|
2006-03-21 00:18:43 +00:00
|
|
|
#
|
2014-06-22 00:21:46 +02:00
|
|
|
# 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.
|
2006-03-21 00:18:43 +00:00
|
|
|
#
|
2014-06-22 00:21:46 +02:00
|
|
|
# You should have received a copy of the GNU General Public License along with
|
|
|
|
|
# this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-03-21 00:18:43 +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
|
|
|
|
2015-04-10 13:31:28 +03:00
|
|
|
our (%Page, %IndexHash, %AdminPages, $HomePage, $RCName, @MyInitVariables, $LinkPattern, $FreeLinkPattern, $FullUrlPattern, $InterLinkPattern, $UserGotoBar, @UserGotoBarPages);
|
2015-03-27 03:01:01 +02:00
|
|
|
|
2014-08-21 22:23:23 +02:00
|
|
|
AddModuleDescription('gotobar.pl', 'Gotobar Extension');
|
2006-03-21 00:18:43 +00:00
|
|
|
|
2015-04-10 13:31:28 +03:00
|
|
|
our ($GotobarName);
|
2006-03-21 00:18:43 +00:00
|
|
|
|
|
|
|
|
# Include this page on every page:
|
|
|
|
|
|
|
|
|
|
$GotobarName = 'GotoBar';
|
|
|
|
|
|
2016-12-02 14:34:44 +01:00
|
|
|
our ($GotobarSetHome, $GotobarSetRC);
|
2017-01-09 22:37:08 +01:00
|
|
|
# 0 does set home-link and/or rc-link automatically, 1 doesn't
|
2016-12-02 14:34:44 +01:00
|
|
|
|
2006-03-21 00:18:43 +00:00
|
|
|
# do this later so that the user can customize $GotobarName
|
|
|
|
|
push(@MyInitVariables, \&GotobarInit);
|
|
|
|
|
|
|
|
|
|
sub GotobarInit {
|
|
|
|
|
$GotobarName = FreeToNormal($GotobarName); # spaces to underscores
|
2006-07-15 23:12:35 +00:00
|
|
|
$AdminPages{$GotobarName} = 1;
|
2006-03-21 00:18:43 +00:00
|
|
|
if ($IndexHash{$GotobarName}) {
|
|
|
|
|
OpenPage($GotobarName);
|
2014-07-11 10:23:46 +02:00
|
|
|
return if PageMarkedForDeletion();
|
2006-04-17 14:36:08 +00:00
|
|
|
# Don't use @UserGotoBarPages because this messes up the order of
|
|
|
|
|
# links for unsuspecting users.
|
2006-03-21 00:18:43 +00:00
|
|
|
@UserGotoBarPages = ();
|
2006-04-07 07:30:24 +00:00
|
|
|
$UserGotoBar = '';
|
2006-04-17 14:36:08 +00:00
|
|
|
my $count = 0;
|
2015-08-23 21:22:12 +03:00
|
|
|
while ($Page{text} =~ m/($LinkPattern|\[\[$FreeLinkPattern\]\]|\[\[$FreeLinkPattern\|([^\]]+)\]\]|\[$InterLinkPattern\s+([^\]]+?)\]|\[$FullUrlPattern[|[:space:]]([^\]]+?)\])/g) {
|
2014-06-22 00:21:46 +02:00
|
|
|
my $page = $2||$3||$4||$6||$8;
|
|
|
|
|
my $text = $5||$7||$9;
|
2006-04-17 14:36:08 +00:00
|
|
|
$UserGotoBar .= ' ' if $UserGotoBar;
|
|
|
|
|
if ($6) {
|
|
|
|
|
$UserGotoBar .= GetInterLink($page, $text);
|
2014-06-22 00:21:46 +02:00
|
|
|
} elsif ($8) {
|
|
|
|
|
$UserGotoBar .= GetUrl($page, $text);
|
2006-04-17 14:36:08 +00:00
|
|
|
} else {
|
|
|
|
|
$UserGotoBar .= GetPageLink($page, $text);
|
|
|
|
|
# The first local page is the homepage, the second local page
|
|
|
|
|
# is the list of recent changes.
|
|
|
|
|
$count++;
|
|
|
|
|
if ($count == 1) {
|
2016-12-02 14:34:44 +01:00
|
|
|
unless ($GotobarSetHome) {$HomePage = FreeToNormal($page)};
|
|
|
|
|
} elsif ($count == 2) {
|
|
|
|
|
unless ($GotobarSetRC) {$RCName = FreeToNormal($page);}
|
|
|
|
|
}
|
2006-04-07 07:30:24 +00:00
|
|
|
}
|
2006-03-21 00:18:43 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|