diff options
Diffstat (limited to 'includes/content/WikitextContentHandler.php')
-rw-r--r-- | includes/content/WikitextContentHandler.php | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/includes/content/WikitextContentHandler.php b/includes/content/WikitextContentHandler.php index e1dcc668..b1b461fb 100644 --- a/includes/content/WikitextContentHandler.php +++ b/includes/content/WikitextContentHandler.php @@ -55,12 +55,27 @@ class WikitextContentHandler extends TextContentHandler { * @see ContentHandler::makeRedirectContent * * @param Title $destination the page to redirect to. + * @param string $text text to include in the redirect, if possible. * * @return Content */ - public function makeRedirectContent( Title $destination ) { + public function makeRedirectContent( Title $destination, $text = '' ) { + $optionalColon = ''; + + if ( $destination->getNamespace() == NS_CATEGORY ) { + $optionalColon = ':'; + } else { + $iw = $destination->getInterwiki(); + if ( $iw && Language::fetchLanguageName( $iw, null, 'mw' ) ) { + $optionalColon = ':'; + } + } + $mwRedir = MagicWord::get( 'redirect' ); - $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $destination->getPrefixedText() . ']]'; + $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $optionalColon . $destination->getFullText() . ']]'; + if ( $text != '' ) { + $redirectText .= "\n" . $text; + } return new WikitextContent( $redirectText ); } |