From: umherirrender Date: Thu, 5 Apr 2012 17:22:34 +0000 (+0200) Subject: (bug 23006) create #speciale parser function X-Git-Tag: 1.31.0-rc.0~24009^2 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=bf2a9989b2eab090afed07603dc38f9bd65d20cc;p=lhc%2Fweb%2Fwiklou.git (bug 23006) create #speciale parser function Also add explicit Title::getPrefixedText() in CoreParserFunctions::special, so that method does not rely on Title::toString. Change-Id: I1d041b11386bff15811e19de47a662e5ed7a2b07 --- diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index 9c0534903d..9af725443c 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -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. diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index e578f273d4..35d03c4c28 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -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 diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index ab3182d3a1..7eaf6630d7 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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' ), diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 04f7b50a63..7a67a8d3f4 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -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 ###