[Home]WikiPatches/SubSubPagesAndSoOn

UseModWiki | WikiPatches | RecentChanges | Preferences

It allows multi-level page hierarchy (sub pages can have more sub pages, and so on) a la CWICK. In fact, I have brought those snippets in order to make that code compatible here. Always It can be as an option in Config file (not implemented). Here's is by default, not as an option.

# 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 =~ /^\//) {

Dromercase case, with multinivel alway connects with Toppage (most higher Subpage), instead with next higher Subpage (if URL without brackets). --JuanmaMP
Dromercase can be eliminated: comment ## Camel and uncomment ## Dromer
Even so, still it shows a different behavior to the script of which comes (CWICK). --JuanmaMP (2009.11.29)

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited November 29, 2009 12:40 pm by JuanmaMP (diff)
Search: