Introducing a new variable {{ROOTPAGENAME}}
authorblotmandroid <pragun06@gmail.com>
Sun, 21 Apr 2013 14:09:49 +0000 (19:39 +0530)
committerblotmandroid <pragun06@gmail.com>
Tue, 23 Apr 2013 20:43:25 +0000 (02:13 +0530)
Introduced a new variable ROOTPAGENAME which has similar
content like BASEPAGENAME.
ROOTPAGENAME only contains the name of the topmost page without namespace, e.g.
for "User:Name/Article/Subarticle" it should be "Name".
BASEPAGENAME would be "Name/Article" here.

Update : fixed indentation in maintenance/fuzz-tester.php

Added to RELEASE-NOTES-1.2.2

Bug: 6747
Change-Id: I71ef0a15c95c9145462f3aa7fdb3ed11dac79265

RELEASE-NOTES-1.22
includes/MagicWord.php
includes/parser/CoreParserFunctions.php
includes/parser/Parser.php
languages/messages/MessagesEn.php
maintenance/fuzz-tester.php
tests/parser/parserTests.txt

index d3ea77e..138b20e 100644 (file)
@@ -39,6 +39,8 @@ production.
   an accesskey in it already). As such it now rountrips. Creating a link with a
   message as tooltip, grabbing the title attribute and using it to create
   another portlet will work as expected.
+* (bug 6747) {{ROOTPAGENAME}} introduced, contains the name of the topmost
+  page without namespace.
 
 === Bug fixes in 1.22 ===
 * Disable Special:PasswordReset when $wgEnableEmail. Previously one could still
index 18b79c4..f9457c3 100644 (file)
@@ -138,6 +138,8 @@ class MagicWord {
                'numberofactiveusers',
                'numberofpages',
                'currentversion',
+               'rootpagename',
+               'rootpagenamee',
                'basepagename',
                'basepagenamee',
                'currenttimestamp',
index 5b02e19..7db6fab 100644 (file)
@@ -88,6 +88,8 @@ class CoreParserFunctions {
                $parser->setFunctionHook( 'pagenamee',        array( __CLASS__, 'pagenamee'        ), SFH_NO_HASH );
                $parser->setFunctionHook( 'fullpagename',     array( __CLASS__, 'fullpagename'     ), SFH_NO_HASH );
                $parser->setFunctionHook( 'fullpagenamee',    array( __CLASS__, 'fullpagenamee'    ), SFH_NO_HASH );
+               $parser->setFunctionHook( 'rootpagename',     array( __CLASS__, 'rootpagename'     ), SFH_NO_HASH );
+               $parser->setFunctionHook( 'rootpagenamee',    array( __CLASS__, 'rootpagenamee'    ), SFH_NO_HASH );
                $parser->setFunctionHook( 'basepagename',     array( __CLASS__, 'basepagename'     ), SFH_NO_HASH );
                $parser->setFunctionHook( 'basepagenamee',    array( __CLASS__, 'basepagenamee'    ), SFH_NO_HASH );
                $parser->setFunctionHook( 'subpagename',      array( __CLASS__, 'subpagename'      ), SFH_NO_HASH );
@@ -546,6 +548,20 @@ class CoreParserFunctions {
                }
                return wfEscapeWikiText( $t->getSubpageUrlForm() );
        }
+       static function rootpagename( $parser, $title = null ) {
+               $t = Title::newFromText( $title );
+               if ( is_null( $t ) ) {
+                       return '';
+               }
+               return wfEscapeWikiText( $t->getRootText() );
+       }
+       static function rootpagenamee( $parser, $title = null ) {
+               $t = Title::newFromText( $title );
+               if ( is_null( $t ) ) {
+                       return '';
+               }
+               return wfEscapeWikiText( wfUrlEncode( str_replace( ' ', '_', $t->getRootText() ) ) );
+       }
        static function basepagename( $parser, $title = null ) {
                $t = Title::newFromText( $title );
                if ( is_null( $t ) ) {
index b51ef38..ab69256 100644 (file)
@@ -2762,6 +2762,12 @@ class Parser {
                        case 'subpagenamee':
                                $value = wfEscapeWikiText( $this->mTitle->getSubpageUrlForm() );
                                break;
+                       case 'rootpagename':
+                               $value = wfEscapeWikiText( $this->mTitle->getRootText() );
+                               break;
+                       case 'rootpagenamee':
+                               $value = wfEscapeWikiText( wfUrlEncode( str_replace( ' ', '_', $this->mTitle->getRootText() ) ) );
+                               break;
                        case 'basepagename':
                                $value = wfEscapeWikiText( $this->mTitle->getBaseText() );
                                break;
index 80dd417..9d09fe8 100644 (file)
@@ -253,6 +253,8 @@ $magicWords = array(
        'fullpagenamee'           => array( 1,    'FULLPAGENAMEE' ),
        'subpagename'             => array( 1,    'SUBPAGENAME' ),
        'subpagenamee'            => array( 1,    'SUBPAGENAMEE' ),
+       'rootpagename'            => array( 1,    'ROOTPAGENAME' ),
+       'rootpagenamee'           => array( 1,    'ROOTPAGENAMEE' ),
        'basepagename'            => array( 1,    'BASEPAGENAME' ),
        'basepagenamee'           => array( 1,    'BASEPAGENAMEE' ),
        'talkpagename'            => array( 1,    'TALKPAGENAME' ),
index 4c03980..b3d8174 100644 (file)
@@ -657,6 +657,7 @@ class wikiFuzz {
                        "}}",
                        "{{INT:googlesearch|",
                        "}}",
+                        "{{ROOTPAGENAME}}",
                        "{{BASEPAGENAME}}",
                        "{{CONTENTLANGUAGE}}",
                        "{{PAGESINNAMESPACE:}}",
index 540b6f4..b34c957 100644 (file)
@@ -10955,6 +10955,8 @@ Say the magic word
 * {{BASEPAGENAME}}
 * {{SUBPAGENAME}}
 * {{SUBPAGENAMEE}}
+* {{ROOTPAGENAME}}
+* {{ROOTPAGENAMEE}}
 * {{BASEPAGENAME}}
 * {{BASEPAGENAMEE}}
 * {{TALKPAGENAME}}
@@ -10975,6 +10977,8 @@ Say the magic word
 </li><li> Parser_test
 </li><li> Parser test
 </li><li> Parser_test
+</li><li> Parser test
+</li><li> Parser_test
 </li><li> Talk:Parser test
 </li><li> Talk:Parser_test
 </li><li> Parser test