* 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 ==
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' );
+ }
+ }
}
?>
$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 );
*/
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\"" );
+ }
}
/**
*/
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;
+ }
}
/**
'formatnum' => array( 0, 'FORMATNUM' ),
'padleft' => array( 0, 'PADLEFT' ),
'padright' => array( 0, 'PADRIGHT' ),
+ 'special' => array( 0, 'special', ),
);
/**