| Index: trunk/phase3/RELEASE-NOTES |
| — | — | @@ -108,6 +108,8 @@ |
| 109 | 109 | * Used special page subpages in a few more places, instead of query parameters. |
| 110 | 110 | * (bug 7758) Added wrapper span to "templates used" explanation to allow CSS |
| 111 | 111 | styling (class="mw-templatesUsedExplanation"). |
| | 112 | +* Added {{#special:}} parser function, to give the local default title for |
| | 113 | + special pages |
| 112 | 114 | |
| 113 | 115 | == Languages updated == |
| 114 | 116 | |
| Index: trunk/phase3/languages/messages/MessagesEn.php |
| — | — | @@ -318,6 +318,7 @@ |
| 319 | 319 | 'formatnum' => array( 0, 'FORMATNUM' ), |
| 320 | 320 | 'padleft' => array( 0, 'PADLEFT' ), |
| 321 | 321 | 'padright' => array( 0, 'PADRIGHT' ), |
| | 322 | + 'special' => array( 0, 'special', ), |
| 322 | 323 | ); |
| 323 | 324 | |
| 324 | 325 | /** |
| Index: trunk/phase3/includes/Parser.php |
| — | — | @@ -164,6 +164,7 @@ |
| 165 | 165 | $this->setFunctionHook( 'padleft', array( 'CoreParserFunctions', 'padleft' ), SFH_NO_HASH ); |
| 166 | 166 | $this->setFunctionHook( 'padright', array( 'CoreParserFunctions', 'padright' ), SFH_NO_HASH ); |
| 167 | 167 | $this->setFunctionHook( 'anchorencode', array( 'CoreParserFunctions', 'anchorencode' ), SFH_NO_HASH ); |
| | 168 | + $this->setFunctionHook( 'special', array( 'CoreParserFunctions', 'special' ) ); |
| 168 | 169 | |
| 169 | 170 | if ( $wgAllowDisplayTitle ) { |
| 170 | 171 | $this->setFunctionHook( 'displaytitle', array( 'CoreParserFunctions', 'displaytitle' ), SFH_NO_HASH ); |
| Index: trunk/phase3/includes/CoreParserFunctions.php |
| — | — | @@ -174,7 +174,15 @@ |
| 175 | 175 | function anchorencode( $parser, $text ) { |
| 176 | 176 | return str_replace( '%', '.', str_replace('+', '_', urlencode( $text ) ) ); |
| 177 | 177 | } |
| 178 | | - |
| | 178 | + |
| | 179 | + function special( $parser, $text ) { |
| | 180 | + $title = SpecialPage::getTitleForAlias( $text ); |
| | 181 | + if ( $title ) { |
| | 182 | + return $title->getPrefixedText(); |
| | 183 | + } else { |
| | 184 | + return wfMsgForContent( 'nosuchspecialpage' ); |
| | 185 | + } |
| | 186 | + } |
| 179 | 187 | } |
| 180 | 188 | |
| 181 | 189 | ?> |
| Index: trunk/phase3/includes/SpecialPage.php |
| — | — | @@ -475,7 +475,11 @@ |
| 476 | 476 | */ |
| 477 | 477 | static function getTitleFor( $name, $subpage = false ) { |
| 478 | 478 | $name = self::getLocalNameFor( $name, $subpage ); |
| 479 | | - return Title::makeTitle( NS_SPECIAL, $name ); |
| | 479 | + if ( $name ) { |
| | 480 | + return Title::makeTitle( NS_SPECIAL, $name ); |
| | 481 | + } else { |
| | 482 | + throw new MWException( "Invalid special page name \"$name\"" ); |
| | 483 | + } |
| 480 | 484 | } |
| 481 | 485 | |
| 482 | 486 | /** |
| — | — | @@ -483,15 +487,24 @@ |
| 484 | 488 | */ |
| 485 | 489 | static function getSafeTitleFor( $name, $subpage = false ) { |
| 486 | 490 | $name = self::getLocalNameFor( $name, $subpage ); |
| 487 | | - return Title::makeTitleSafe( NS_SPECIAL, $name ); |
| | 491 | + if ( $name ) { |
| | 492 | + return Title::makeTitleSafe( NS_SPECIAL, $name ); |
| | 493 | + } else { |
| | 494 | + return null; |
| | 495 | + } |
| 488 | 496 | } |
| 489 | 497 | |
| 490 | 498 | /** |
| 491 | 499 | * Get a title for a given alias |
| | 500 | + * @return Title or null if there is no such alias |
| 492 | 501 | */ |
| 493 | 502 | static function getTitleForAlias( $alias ) { |
| 494 | 503 | $name = self::resolveAlias( $alias ); |
| 495 | | - return self::getTitleFor( $name ); |
| | 504 | + if ( $name ) { |
| | 505 | + return self::getTitleFor( $name ); |
| | 506 | + } else { |
| | 507 | + return null; |
| | 508 | + } |
| 496 | 509 | } |
| 497 | 510 | |
| 498 | 511 | /** |