The following code is a backport. Korean comments and code related to features only found in UseModKr were removed. Currently I'm somewhat confused with the code. Any help is apreciated.
The subroutine PrintPageList? is replaced by a new one.
--TilmannHolst, 2004-06-05
On http://www.oddmuse.org/cgi-bin/oddmuse-en/Index_Extension there is a similar aproach. Much cleaner I think. --TilmannHolst, 2004-09-23
sub PrintPageList { my ($pagename); my $count = 0; my $titleIsPrinted = 0; # my @han = qw(°¡ ³ª ŽÙ ¶ó ž¶ ¹Ù »ç ŸÆ ÀÚ Â÷ Ä« Åž ÆÄ ÇÏ); my @indexTitle = (0, "A".."Z","Ä","Ö","Ü"); #push (@indexTitle, @han, "±âÅž"); my @indexSearch=("A".."Z","Ä","Ö","Ü"); #push (@indexSearch, @han, "ËÐ"); print "<a name=\"top\">"; print "<h2>", Ts('%s pages found:', ($#_ + 1)), "</h2>\n"; my $count2 = 0; #print("\n|"); while ( $count2 <= $#indexTitle ) { #if ($count2 == 27) { # print("<br>\n|"); #} if ($count2 == 0) { # nothing } else { print("|"); } print("<a href=\"#H_$indexTitle[$count2]\"><b>"); print(" $indexTitle[$count2] "); print("</b></a>"); $count2++; } print "<br><br>"; $count2 = 0; foreach $pagename(@_) { until ( $pagename lt @indexSearch[$count] && ($count == 0 || $pagename gt @indexSearch[$count-1]) ) { $count++; $titleIsPrinted = 0; last if $count > 40; # what is that? } if (!$titleIsPrinted) { while ( $count2 <= ($count - 1) ) { print "\n<a name=\"H_$indexTitle[$count2]\">"; print "</a>"; $count2++; } print "\n<a name=\"H_$indexTitle[$count]\"></a>"; print $q->h3($indexTitle[$count] . " <a href=\"#top\">" . T('Top') . "</a>"); print "\n"; $count2 = $count + 1; $titleIsPrinted=1; } print ".... " if ($pagename =~ m|/|); print &GetPageLink($pagename); if (&UserIsAdmin()) { if (-f &GetLockedPageFile($pagename)) { print " " . T('(locked)'); } print " (" . &ScriptLink("action=pagelock&set=1&id=" . $pagename, T('lock')); print " | " . &ScriptLink("action=pagelock&set=0&id=" . $pagename, T('unlock')); print " | " . &ScriptLink("action=delete&confirm=0&id=" . $pagename, T('delete')); print ")"; } print $q->br; print "\n"; } }
--- wiki.pl 2004-06-15 17:14:14.000000000 +0200 +++ larpwiki-index.pl 2004-06-15 17:14:12.000000000 +0200 @@ -26,6 +26,8 @@ # 59 Temple Place, Suite 330 # Boston, MA 02111-1307 USA +# applied patch: better PrintPageList + package UseModWiki; use strict; local $| = 1; # Do not buffer output (localized for mod_perl) @@ -3736,15 +3738,75 @@ print &GetCommonFooter(); } +# changed by patch: nicer PrintPageList sub PrintPageList { - my $pagename; - - print "<h2>", Ts('%s pages found:', ($#_ + 1)), "</h2>\n"; - foreach $pagename (@_) { - print ".... " if ($pagename =~ m|/|); - print &GetPageLink($pagename), "<br>\n"; - } + my ($pagename); + my $count = 0; + my $titleIsPrinted = 0; + # my @han = qw(°¡ ³ª ŽÙ ¶ó ž¶ ¹Ù »ç ŸÆ ÀÚ Â÷ Ä« Åž ÆÄ ÇÏ); + my @indexTitle = (0, "A".."Z","Ä","Ö","Ü"); + #push (@indexTitle, @han, "±âÅž"); + my @indexSearch=("A".."Z","Ä","Ö","Ü"); + #push (@indexSearch, @han, "ËÐ"); + print "<a name=\"top\">"; + print "<h2>", Ts('%s pages found:', ($#_ + 1)), "</h2>\n"; + + my $count2 = 0; + #print("\n|"); + while ( $count2 <= $#indexTitle ) { + my $mathead = 0; # BH047 + #if ($count2 == 27) { + # print("<br>\n|"); + #} + if ($count2 == 0) { + foreach $pagename (@_) { # BH047 + $mathead = 1 if !($pagename =~ m/^[A-ZÄÖÜ]/); # BH047 + } # BH047 + # previously nothing + } else { + foreach $pagename (@_) { # BH047 + $mathead = 1 if ($pagename =~ m/^$indexTitle[$count2]/); # BH047 + } # BH047 + print("|"); + } + if ($mathead) { # BH047 + print("<a href=\"#H_$indexTitle[$count2]\"><b>"); + print(" $indexTitle[$count2] "); + print("</b></a>"); + } else { # BH047 + print(" $indexTitle[$count2] "); # BH047 + } # BH047 + $count2++; + } + print "<br><br>"; + $count2 = 0; + foreach $pagename(@_) { + until ( + $pagename lt @indexSearch[$count] + && ($count == 0 || $pagename gt @indexSearch[$count-1]) + ) { + $count++; + $titleIsPrinted = 0; + last if $count > 40; # what is that? + } + if (!$titleIsPrinted) { + while ( $count2 <= ($count - 1) ) { + print "\n<a name=\"H_$indexTitle[$count2]\">"; + print "</a>"; + $count2++; + } + print "\n<a name=\"H_$indexTitle[$count]\"></a>"; + print $q->h3($indexTitle[$count] + . " <a href=\"#top\">" . T('Top') . "</a>"); + print "\n"; + $count2 = $count + 1; + $titleIsPrinted=1; + } + print ".... " if ($pagename =~ m|/|); + print &GetPageLink($pagename); + if (&UserIsAdmin()) { + if (-f &GetLockedPageFile($pagename)) { + print " " . T('(locked)'); + } + print " (" . &ScriptLink("action=pagelock&set=1&id=" . $pagename, T('lock')); + print " | " . &ScriptLink("action=pagelock&set=0&id=" . $pagename, T('unlock')); + print " | " . &ScriptLink("action=delete&confirm=0&id=" . $pagename, T('delete')); + print ")"; + } + print $q->br; + print "\n"; + } + print "<br>"; # BH047 } +# /changed by patch: nicer PrintPageList sub DoLinks { print &GetHeader('', &QuoteHtml(T('Full Link List')), '');
last if $count > 40; # what is that?is a check to see if we have printed the last header and prevents us looping forever. The 40 just needs to be bigger than the number of title entries. This was high in the original version which allowed for Korean characters. It still works even with the reduced set of titles. Better code would check if we have reached the end of the titles array. I have used...
if ($pagename gt @indexSearch[-1]) { # Is the pagename higher than the last title? # BH047 $count = 1+$#indexSearch; # if so, set the count to one beyond the title search # BH047 last; # and finish # BH047 } # BH047Also in the section starting ...
if (!$titleIsPrinted) {The lines
while ( $count2 <= ($count - 1) ) { print "\n<a name=\"H_$indexTitle[$count2]\">"; print "</a>"; $count2++; }and the line
$count2 = $count + 1;are not required
I'm sure the code could be improved further... --Brian Hunter