[Home]WikiPatches/RenameSubpages

UseModWiki | WikiPatches | RecentChanges | Preferences

Apply WikiPatches/GetSubpages first. (see latest updated version if you previously applied it) --BrianHunter

Allows the following syntax to rename a page AND all of its subpages:

 =OldPageName/*=NewPageName?

4369a4370
>         "<tt>=OldPageName/*=NewPageName</tt> -- renames all subpages too<BR>",

4403,4405c4404,4421
<     } elsif (/^\=(?:\[\[)?([^]=]+)(?:\]\])?\=(?:\[\[)?([^]=]+)(?:\]\])?/) {
<       &RenamePage($1, $2, $doRC, $doText);
<     } elsif (/^\|(?:\[\[)?([^]|]+)(?:\]\])?\|(?:\[\[)?([^]|]+)(?:\]\])?/) {
---
>     } 
>     elsif (/^\=(?:\[\[)?([^]=]+)(?:\]\])?\=(?:\[\[)?([^]=]+)(?:\]\])?/) {
>       my $GivenPage = $1 ;
>       my $GivenNewName = $2;
>       if( $GivenPage =~ s[\/\*][] ) {
>         print "Renaming subpages of $GivenPage too...<br>";
>         foreach( &AllSubPagesList( $GivenPage ) ) {
>           my $NewSubName = $_;
>           $NewSubName =~ s[$GivenPage][$GivenNewName]i;
>           print "renaming " . $_ . " to " . $NewSubName  ."<BR>";
>           &RenamePage($_, $NewSubName, $doRC, $doText)
>         }
>       }
>       # rename the page itself
>       print "renaming " . $GivenPage . " to " . $GivenNewName  ."<BR>";
>       &RenamePage($GivenPage, $GivenNewName, $doRC, $doText);
>     } 
>     elsif (/^\|(?:\[\[)?([^]|]+)(?:\]\])?\|(?:\[\[)?([^]|]+)(?:\]\])?/) {


Here we are some context to this patch:

First line (4369a4370) comes under subroutine DoEditLinks? between these two lines:

        "to NewPageName and updates links to OldPageName.<br>\n",
        "<tt>=OldPageName/*=NewPageName</tt> -- renames all subpages too<BR>",
        "<tt>|OldPageName|NewPageName</tt> -- Changes links to OldPageName ",

Second block (4403,4405c4404,4421) replaces this line in the subroutine UpdateLinksList:

    } elsif (/^\=(?:\[\[)?([^]=]+)(?:\]\])?\=(?:\[\[)?([^]=]+)(?:\]\])?/) {
      &RenamePage($1, $2, $doRC, $doText);
    } elsif (/^\|(?:\[\[)?([^]|]+)(?:\]\])?\|(?:\[\[)?([^]|]+)(?:\]\])?/) {

with these lines:

    } elsif (/^\=(?:\[\[)?([^]=]+)(?:\]\])?\=(?:\[\[)?([^]=]+)(?:\]\])?/) {
      my $GivenPage = $1;
      my $GivenNewName = $2;
      if ($GivenPage =~ s[\/\*][]) {
        print "Renaming subpages of $GivenPage too...<br>";
        foreach (&AllSubPagesList($GivenPage)) {
          my $NewSubName = $_;
          $NewSubName =~ s[$GivenPage][$GivenNewName]i;
          print "renaming " . $_ . " to " . $NewSubName  ."<BR>";
          &RenamePage($_, $NewSubName, $doRC, $doText);
        }
      }
      # rename the page itself
      print "renaming " . $GivenPage . " to " . $GivenNewName  ."<BR>";
      &RenamePage($GivenPage, $GivenNewName, $doRC, $doText);
    } elsif (/^\|(?:\[\[)?([^]|]+)(?:\]\])?\|(?:\[\[)?([^]|]+)(?:\]\])?/) {

-- FerdinandPrantl


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited October 22, 2007 8:44 pm by JuanmaMP (diff)
Search: