# Configuration/constant variables: use vars qw( ... $HalfLinkPattern ... sub InitLinkPatterns { - my ($UpperLetter, $LowerLetter, $AnyLetter, $LpA, $LpB, $QDelim); + my ($UpperLetter, $LowerLetter, $AnyLetter, $LpA, $LpB, $QDelim); ... -if ($UseSubpage) { # Loose pattern: If subpage is used, subpage may be simple name # $LinkPattern = "((?:(?:$LpA)?\\/$LpB)|$LpA)"; # Strict pattern: both sides must be the main LinkPattern # $LinkPattern = "((?:(?:$LpA)?\\/)?$LpA)"; # $LinkPattern = "(((?:(?:$LpA)?\\/)+$LpA)|$LpA)"; ## Dromer $LinkPattern = "(((?:(?:$LpA)?\\/)+$LpB)|$LpA)"; ## Camel # end subpage - } else { - $LinkPattern = "($LpA)"; - } ... + sub CreateSubDir { ## Cwick + my ($path, $dir) = @_; + &CreateDir($path); + if ($dir =~ m|([^/]+)/|) { + $path .= "/" . $1; + $dir =~ s/([^\/]+)\///; + &CreateSubDir($path,$dir); + } + } sub CreatePageDir { my ($dir, $id) = @_; my $subdir; &CreateDir($dir); # Make sure main page exists $subdir = $dir . "/" . &GetPageDirectory($id); &CreateSubDir($subdir,$id); - if ($id =~ m|([^/]+)/|) { - $subdir = $subdir . "/" . $1; - &CreateDir($subdir); - } } + sub GenerateSubDirDBList { + my ($dirName) = @_; + my (@pages, @dirs, $pageID, $dir, @pageFiles, @subpageFiles, $subId); + @pages = (); + if ($FastGlob) { + # The following was inspired by the FastGlob code by Marc W. Mengel. + # Thanks to Bob Showalter for pointing out the improvement. + opendir(PAGELIST,$dirName); + @pages = readdir(PAGELIST); + closedir(PAGELIST); + foreach $pageID (@pages) { + next if (($pageID eq '.') || ($pageID eq '..')); + if( $pageID =~ /\.db$/ ) { + push(@pageFiles, substr($pageID, 0, -3)); + } elsif( $pageID =~ /\.lck$/ ) { + } else { + @subpageFiles = &GenerateSubDirDBList("$dirName/$pageID"); + foreach $subId (@subpageFiles) { + push(@pageFiles, "$pageID/$subId" ); + } + } + } + } + return @pageFiles; + } + sub GenerateParentDirDBList { ## Cwick changes Usemod GenerateAllPagesList + my ($dirName) = @_; + my (@pages, @dirs, $id, $dir, @pageFiles, @subpageFiles, $subId); + @pageFiles = (); + if ($FastGlob) { + opendir(PAGELIST, $dirName); + @dirs = readdir(PAGELIST); + closedir(PAGELIST); + @dirs = sort(@dirs); + foreach $dir (@dirs) { + next if (($dir eq '.') || ($dir eq '..')); + push( @pageFiles, &GenerateSubDirDBList("$dirName/$dir") ); + } + } + return sort( @pageFiles ); + } sub AllPagesList { my ($rawIndex, $refresh, $status); if (!$UseIndex) { - return &GenerateAllPagesList(); + return &GenerateParentDirDBList($PageDir)); } ... @IndexList = (); %IndexHash = (); - @IndexList = &GenerateAllPagesList(); + @IndexList = &GenerateParentDirDBList($PageDir); ...In ValidId comments 4 lines:
sub ValidId { ... if ($id =~ m| |) { return Ts('Page name may not contain space characters: %s', $id); } # REMOVED FOR MULTILEVEL SUPPORT # if ($id =~ m|.*/.*/|) { # return Ts('Too many / characters in page %s', $id); # } if ($id =~ /^\//) {