Allow appending text to redirects from moved pages
authorJackmcbarn <jackmcbarn@gmail.com>
Thu, 3 Oct 2013 15:09:08 +0000 (11:09 -0400)
committerJackmcbarn <jackmcbarn@gmail.com>
Fri, 4 Oct 2013 14:40:47 +0000 (10:40 -0400)
Add message move-redirect-text, which is appended to redirects created by
page moves (empty by default). This could be used on enwiki to automatically
add {{R from move}} while still allowing non-admins to revert the move, for
example.

Change-Id: Ic2158897ce46177b695a7fb90c8ed3349df18bde

includes/Title.php
includes/content/ContentHandler.php
includes/content/WikitextContentHandler.php
languages/messages/MessagesEn.php
maintenance/language/messageTypes.inc
maintenance/language/messages.inc

index cdbebf1..487dd87 100644 (file)
@@ -3840,7 +3840,8 @@ class Title {
 
                if ( $createRedirect ) {
                        $contentHandler = ContentHandler::getForTitle( $this );
-                       $redirectContent = $contentHandler->makeRedirectContent( $nt );
+                       $redirectContent = $contentHandler->makeRedirectContent( $nt,
+                               wfMessage( 'move-redirect-text' )->inContentLanguage()->plain() );
 
                        // NOTE: If this page's content model does not support redirects, $redirectContent will be null.
                } else {
index 2de8408..a8fa9ed 100644 (file)
@@ -449,10 +449,11 @@ abstract class ContentHandler {
         * @since 1.21
         *
         * @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 = '' ) {
                return null;
        }
 
index 8be85bc..b1b461f 100644 (file)
@@ -55,10 +55,11 @@ 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 ) {
@@ -72,6 +73,9 @@ class WikitextContentHandler extends TextContentHandler {
 
                $mwRedir = MagicWord::get( 'redirect' );
                $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $optionalColon . $destination->getFullText() . ']]';
+               if ( $text != '' ) {
+                       $redirectText .= "\n" . $text;
+               }
 
                return new WikitextContent( $redirectText );
        }
index 87f729f..d6f1f6a 100644 (file)
@@ -3499,6 +3499,7 @@ Please merge them manually.'''",
 'movesubpagetext'              => 'This page has $1 {{PLURAL:$1|subpage|subpages}} shown below.',
 'movenosubpage'                => 'This page has no subpages.',
 'movereason'                   => 'Reason:',
+'move-redirect-text'           => '', # do not translate or duplicate this message to other languages
 'revertmove'                   => 'revert',
 'delete_and_move'              => 'Delete and move',
 'delete_and_move_text'         => '== Deletion required ==
index c153fa7..d47138d 100644 (file)
@@ -261,6 +261,7 @@ $wgIgnoredMessages = array(
        'redirect-text',
        'edithelppage',
        'autocomment-prefix',
+       'move-redirect-text',
 );
 
 /** Optional messages, which may be translated only if changed in the target language. */
index 65933f3..e21b3c7 100644 (file)
@@ -2448,6 +2448,7 @@ $wgMessageStructure = array(
                'movesubpagetext',
                'movenosubpage',
                'movereason',
+               'move-redirect-text',
                'revertmove',
                'delete_and_move',
                'delete_and_move_text',