From c49f2edda62df6d87c257ea9a1935ffa37804efe Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Fri, 21 Oct 2005 22:54:33 +0000 Subject: [PATCH] (LocalNamesInit, LocalNamesNewNearInit): Merged LocalNamesNewNearInit with LocalNamesInit. --- modules/localnames.pl | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/modules/localnames.pl b/modules/localnames.pl index 1cb93984..ba3cec8a 100644 --- a/modules/localnames.pl +++ b/modules/localnames.pl @@ -16,43 +16,41 @@ # 59 Temple Place, Suite 330 # Boston, MA 02111-1307 USA -$ModulesDescription .= '

$Id: localnames.pl,v 1.4 2005/01/07 01:18:02 as Exp $

'; +$ModulesDescription .= '

$Id: localnames.pl,v 1.5 2005/10/21 22:54:33 as Exp $

'; -use vars qw($LocalNamesPage); +use vars qw($LocalNamesPage $LocalNamesInit %LocalNames); $LocalNamesPage = 'LocalNames'; # do this later so that the user can customize $LocalNamesPage push(@MyInitVariables, \&LocalNamesInit); -sub LocalNamesInit { - $LocalNamesPage = FreeToNormal($LocalNamesPage); # spaces to underscores - push(@AdminPages, $LocalNamesPage) unless grep(/$LocalNamesPage/, @AdminPages); # mod_perl! -} - -my %LocalNames = (); - # Just hook into NearLink stuff -- whenever near links are # initialized, we initialize as well. Add our stuff first, because # local names have priority over near links. -*LocalNamesOldNearInit = *NearInit; -*NearInit = *LocalNamesNewNearInit; - -sub LocalNamesNewNearInit { +sub LocalNamesInit { + return if $LocalNamesInit; # just once, mod_perl! + $LocalNamesInit = 1; + %LocalNames = (); + $LocalNamesPage = FreeToNormal($LocalNamesPage); # spaces to underscores + push(@AdminPages, $LocalNamesPage); my $data = GetPageContent($LocalNamesPage); while ($data =~ m/\[$FullUrlPattern\s+([^\]]+?)\]/go) { my ($id, $url) = ($2, $1); my $page = FreeToNormal($id); - # Make sure we're listed in action=index;near=1 + # The entries in %NearSource will make sure that ResolveId will + # call GetInterSiteUrl for our pages. $LocalNames{$page} = $url; - push(@{$NearSource{$page}}, $LocalNamesPage); + # Add at the front to override near links. + unshift(@{$NearSource{$page}}, $LocalNamesPage); # %NearSite is for fetching the list of pages -- we don't need that. + # %NearSearch is for searching remote sites -- we don't need that. } - LocalNamesOldNearInit(); } -# Now make sure we resolve correctly: +# Allow interlinks: We cannot just use %InterSite, because that would +# result in the same ULR for $LocalNamesPage all the time. *OldLocalNamesGetInterSiteUrl = *GetInterSiteUrl; *GetInterSiteUrl = *NewLocalNamesGetInterSiteUrl;