(bug 23006) create #speciale parser function
authorumherirrender <umherirrender_de.wp@web.de>
Thu, 5 Apr 2012 17:22:34 +0000 (19:22 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Fri, 6 Apr 2012 07:14:47 +0000 (09:14 +0200)
Also add explicit Title::getPrefixedText() in
CoreParserFunctions::special, so that method does not rely on
Title::toString.

Change-Id: I1d041b11386bff15811e19de47a662e5ed7a2b07

RELEASE-NOTES-1.20
includes/parser/CoreParserFunctions.php
languages/messages/MessagesEn.php
tests/parser/parserTests.txt

index 9c05349..9af7254 100644 (file)
@@ -35,6 +35,7 @@ production.
 * (bug 35649) Special:Version now shows hashes of extensions checked out from git.
 * (bug 35728) Git revisions are now linked on Special:Version.
 * "Show Changes" on default messages shows now diff against default message text
+* (bug 23006) create #speciale parser function.
 
 === Bug fixes in 1.20 ===
 * (bug 30245) Use the correct way to construct a log page title.
index e578f27..35d03c4 100644 (file)
@@ -55,6 +55,7 @@ class CoreParserFunctions {
                $parser->setFunctionHook( 'padright',         array( __CLASS__, 'padright'         ), SFH_NO_HASH );
                $parser->setFunctionHook( 'anchorencode',     array( __CLASS__, 'anchorencode'     ), SFH_NO_HASH );
                $parser->setFunctionHook( 'special',          array( __CLASS__, 'special'          ) );
+               $parser->setFunctionHook( 'speciale',         array( __CLASS__, 'speciale'         ) );
                $parser->setFunctionHook( 'defaultsort',      array( __CLASS__, 'defaultsort'      ), SFH_NO_HASH );
                $parser->setFunctionHook( 'filepath',         array( __CLASS__, 'filepath'         ), SFH_NO_HASH );
                $parser->setFunctionHook( 'pagesincategory',  array( __CLASS__, 'pagesincategory'  ), SFH_NO_HASH );
@@ -692,12 +693,16 @@ class CoreParserFunctions {
                list( $page, $subpage ) = SpecialPageFactory::resolveAlias( $text );
                if ( $page ) {
                        $title = SpecialPage::getTitleFor( $page, $subpage );
-                       return $title;
+                       return $title->getPrefixedText();
                } else {
                        return wfMsgForContent( 'nosuchspecialpage' );
                }
        }
 
+       static function speciale( $parser, $text ) {
+               return wfUrlencode( str_replace( ' ', '_', self::special( $parser, $text ) ) );
+       }
+
        /**
         * @param $parser Parser
         * @param $text String The sortkey to use
index ab3182d..7eaf663 100644 (file)
@@ -336,6 +336,7 @@ $magicWords = array(
        'padleft'                => array( 0,    'PADLEFT'                ),
        'padright'               => array( 0,    'PADRIGHT'               ),
        'special'                => array( 0,    'special',               ),
+       'speciale'               => array( 0,    'speciale',              ),
        'defaultsort'            => array( 1,    'DEFAULTSORT:', 'DEFAULTSORTKEY:', 'DEFAULTCATEGORYSORT:' ),
        'filepath'               => array( 0,    'FILEPATH:'              ),
        'tag'                    => array( 0,    'tag'                    ),
index 04f7b50..7a67a8d 100644 (file)
@@ -3677,6 +3677,36 @@ msg
 No such special page
 !! end
 
+!! test
+{{#speciale:}} page name, known
+!! options
+msg
+!! input
+{{#speciale:Recentchanges}}
+!! result
+Special:RecentChanges
+!! end
+
+!! test
+{{#speciale:}} page name with subpage, known
+!! options
+msg
+!! input
+{{#speciale:Recentchanges/param}}
+!! result
+Special:RecentChanges/param
+!! end
+
+!! test
+{{#speciale:}} page name, unknown
+!! options
+msg
+!! input
+{{#speciale:foobarnonexistent}}
+!! result
+No_such_special_page
+!! end
+
 ###
 ### Images
 ###