Index: trunk/phase3/includes/Parser.php
===================================================================
--- trunk/phase3/includes/Parser.php (revision 17320)
+++ trunk/phase3/includes/Parser.php (revision 17321)
@@ -164,6 +164,7 @@
$this->setFunctionHook( 'padleft', array( 'CoreParserFunctions', 'padleft' ), SFH_NO_HASH );
$this->setFunctionHook( 'padright', array( 'CoreParserFunctions', 'padright' ), SFH_NO_HASH );
$this->setFunctionHook( 'anchorencode', array( 'CoreParserFunctions', 'anchorencode' ), SFH_NO_HASH );
+ $this->setFunctionHook( 'special', array( 'CoreParserFunctions', 'special' ) );
if ( $wgAllowDisplayTitle ) {
$this->setFunctionHook( 'displaytitle', array( 'CoreParserFunctions', 'displaytitle' ), SFH_NO_HASH );
Index: trunk/phase3/includes/CoreParserFunctions.php
===================================================================
--- trunk/phase3/includes/CoreParserFunctions.php (revision 17320)
+++ trunk/phase3/includes/CoreParserFunctions.php (revision 17321)
@@ -174,7 +174,15 @@
function anchorencode( $parser, $text ) {
return str_replace( '%', '.', str_replace('+', '_', urlencode( $text ) ) );
}
-
+
+ function special( $parser, $text ) {
+ $title = SpecialPage::getTitleForAlias( $text );
+ if ( $title ) {
+ return $title->getPrefixedText();
+ } else {
+ return wfMsgForContent( 'nosuchspecialpage' );
+ }
+ }
}
?>
Index: trunk/phase3/includes/SpecialPage.php
===================================================================
--- trunk/phase3/includes/SpecialPage.php (revision 17320)
+++ trunk/phase3/includes/SpecialPage.php (revision 17321)
@@ -475,7 +475,11 @@
*/
static function getTitleFor( $name, $subpage = false ) {
$name = self::getLocalNameFor( $name, $subpage );
- return Title::makeTitle( NS_SPECIAL, $name );
+ if ( $name ) {
+ return Title::makeTitle( NS_SPECIAL, $name );
+ } else {
+ throw new MWException( "Invalid special page name \"$name\"" );
+ }
}
/**
@@ -483,15 +487,24 @@
*/
static function getSafeTitleFor( $name, $subpage = false ) {
$name = self::getLocalNameFor( $name, $subpage );
- return Title::makeTitleSafe( NS_SPECIAL, $name );
+ if ( $name ) {
+ return Title::makeTitleSafe( NS_SPECIAL, $name );
+ } else {
+ return null;
+ }
}
/**
* Get a title for a given alias
+ * @return Title or null if there is no such alias
*/
static function getTitleForAlias( $alias ) {
$name = self::resolveAlias( $alias );
- return self::getTitleFor( $name );
+ if ( $name ) {
+ return self::getTitleFor( $name );
+ } else {
+ return null;
+ }
}
/**
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES (revision 17320)
+++ trunk/phase3/RELEASE-NOTES (revision 17321)
@@ -108,6 +108,8 @@
* Used special page subpages in a few more places, instead of query parameters.
* (bug 7758) Added wrapper span to "templates used" explanation to allow CSS
styling (class="mw-templatesUsedExplanation").
+* Added {{#special:}} parser function, to give the local default title for
+ special pages
== Languages updated ==
Index: trunk/phase3/languages/messages/MessagesEn.php
===================================================================
--- trunk/phase3/languages/messages/MessagesEn.php (revision 17320)
+++ trunk/phase3/languages/messages/MessagesEn.php (revision 17321)
@@ -318,6 +318,7 @@
'formatnum' => array( 0, 'FORMATNUM' ),
'padleft' => array( 0, 'PADLEFT' ),
'padright' => array( 0, 'PADRIGHT' ),
+ 'special' => array( 0, 'special', ),
);
/**