Allow the user to specify a reason for page moves
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 3 Apr 2005 14:45:42 +0000 (14:45 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 3 Apr 2005 14:45:42 +0000 (14:45 +0000)
includes/SpecialMovepage.php
includes/Title.php
languages/Language.php

index a8e2e76..0f9e5ec 100644 (file)
@@ -45,12 +45,13 @@ function wfSpecialMovepage() {
  * @subpackage SpecialPage
  */
 class MovePageForm {
-       var $oldTitle, $newTitle; # Text input
+       var $oldTitle, $newTitle, $reason; # Text input
                
        function MovePageForm() {
                global $wgRequest;
                $this->oldTitle = $wgRequest->getText( 'wpOldTitle', $wgRequest->getVal( 'target' ) );
                $this->newTitle = $wgRequest->getText( 'wpNewTitle' );
+               $this->reason = $wgRequest->getText( 'wpReason' );
        }
        
        function showForm( $err ) {
@@ -64,26 +65,28 @@ class MovePageForm {
                }
 
                $ot = Title::newFromURL( $this->oldTitle );
-               $ott = $ot->getPrefixedText();
+               $oldTitle = $ot->getPrefixedText();
                
                $encOldTitle = htmlspecialchars( $this->oldTitle );
                if( $this->newTitle == '' ) {
                        # Show the current title as a default
                        # when the form is first opened.
-                       $encNewTitle = $ott;
+                       $encNewTitle = $oldTitle;
                } else {
                        $encNewTitle = htmlspecialchars( $this->newTitle );
                }
+               $encReason = htmlspecialchars( $this->reason );
 
                $wgOut->addWikiText( wfMsg( 'movepagetext' ) );
                if ( !$ot->isTalkPage() ) {
                        $wgOut->addWikiText( wfMsg( 'movepagetalktext' ) );
                }
 
-               $ma = wfMsg( 'movearticle' );
-               $newt = wfMsg( 'newtitle' );
-               $mpb = wfMsg( 'movepagebtn' );
+               $movearticle = wfMsg( 'movearticle' );
+               $newtitle = wfMsg( 'newtitle' );
+               $movepagebtn = wfMsg( 'movepagebtn' );
                $movetalk = wfMsg( 'movetalk' );
+               $movereason = wfMsg( 'movereason' );
 
                $titleObj = Title::makeTitle( NS_SPECIAL, 'Movepage' );
                $action = $titleObj->escapeLocalURL( 'action=submit' );
@@ -97,15 +100,21 @@ class MovePageForm {
 <form id=\"movepage\" method=\"post\" action=\"{$action}\">
        <table border='0'>
                <tr>
-                       <td align='right'>{$ma}:</td>
-                       <td align='left'><strong>{$ott}</strong></td>
+                       <td align='right'>{$movearticle}:</td>
+                       <td align='left'><strong>{$oldTitle}</strong></td>
                </tr>
                <tr>
-                       <td align='right'>{$newt}:</td>
+                       <td align='right'>{$newtitle}:</td>
                        <td align='left'>
                                <input type='text' size='40' name=\"wpNewTitle\" value=\"{$encNewTitle}\" />
                                <input type='hidden' name=\"wpOldTitle\" value=\"{$encOldTitle}\" />
                        </td>
+               </tr>
+               <tr>
+                       <td align='right'>{$movereason}:</td>
+                       <td align='left'>
+                               <input type='text' size=40 name=\"wpReason\" value=\"{$encReason}\" />
+                       </td>
                </tr>" );
 
                if ( ! $ot->isTalkPage() ) {
@@ -121,7 +130,7 @@ class MovePageForm {
                <tr>
                        <td>&nbsp;</td>
                        <td align='left'>
-                               <input type='submit' name=\"wpMove\" value=\"{$mpb}\" />
+                               <input type='submit' name=\"wpMove\" value=\"{$movepagebtn}\" />
                        </td>
                </tr>
        </table>
@@ -148,7 +157,7 @@ class MovePageForm {
                        return;
                }
 
-               $error = $ot->moveTo( $nt );
+               $error = $ot->moveTo( $nt, true, $this->reason );
                if ( $error !== true ) {
                        $this->showForm( wfMsg( $error ) );
                        return;
@@ -192,7 +201,7 @@ class MovePageForm {
                        $ntt = Title::makeTitle( $nns, $nt->getDBkey() );
 
                        # Attempt the move
-                       $error = $ott->moveTo( $ntt );
+                       $error = $ott->moveTo( $ntt, true, $this->reason );
                        if ( $error === true ) {
                                $talkmoved = 1;
                        } else {
@@ -239,4 +248,4 @@ class MovePageForm {
                }
        }
 }
-?>
\ No newline at end of file
+?>
index 6807e42..be452a5 100644 (file)
@@ -1404,7 +1404,7 @@ class Title {
         * @return mixed true on success, message name on failure
         * @access public
         */
-       function moveTo( &$nt, $auth = true ) {
+       function moveTo( &$nt, $auth = true, $reason = '' ) {
                global $wgUser;
                if( !$this or !$nt ) {
                        return 'badtitletext';
@@ -1441,9 +1441,9 @@ class Title {
                        if ( ! $this->isValidMoveTarget( $nt ) ) {
                                return 'articleexists';
                        }
-                       $this->moveOverExistingRedirect( $nt );
+                       $this->moveOverExistingRedirect( $nt, $reason );
                } else { # Target didn't exist, do normal move.
-                       $this->moveToNewTitle( $nt, $newid );
+                       $this->moveToNewTitle( $nt, $newid, $reason );
                }
 
                # Fixing category links (those without piped 'alternate' names) to be sorted under the new title
@@ -1484,10 +1484,14 @@ class Title {
         *      be a redirect
         * @access private
         */
-       /* private */ function moveOverExistingRedirect( &$nt ) {
+       /* private */ function moveOverExistingRedirect( &$nt, $reason = '' ) {
                global $wgUser, $wgLinkCache, $wgUseSquid, $wgMwRedir;
                $fname = 'Title::moveOverExistingRedirect';
                $comment = wfMsgForContent( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
+
+               if ( $reason ) {
+                       $comment .= ": $reason";
+               }
                
                $now = wfTimestampNow();
                $rand = wfRandom();
@@ -1535,7 +1539,7 @@ class Title {
 
                # Log the move
                $log = new LogPage( 'move' );
-               $log->addEntry( 'move_redir', $this, '', array( 1 => $nt->getPrefixedText() ) );
+               $log->addEntry( 'move_redir', $this, $reason, array( 1 => $nt->getPrefixedText() ) );
                
                # Swap links
                
@@ -1600,11 +1604,14 @@ class Title {
         * @param int &$newid set to be the new article ID
         * @access private
         */
-       /* private */ function moveToNewTitle( &$nt, &$newid ) {
+       /* private */ function moveToNewTitle( &$nt, &$newid, $reason = '' ) {
                global $wgUser, $wgLinkCache, $wgUseSquid;
                global $wgMwRedir;
                $fname = 'MovePageForm::moveToNewTitle';
                $comment = wfMsgForContent( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
+               if ( $reason ) {
+                       $comment .= ": $reason";
+               }
 
                $newid = $nt->getArticleID();
                $oldid = $this->getArticleID();
@@ -1647,7 +1654,7 @@ class Title {
 
                # Log the move
                $log = new LogPage( 'move' );
-               $log->addEntry( 'move', $this, '', array( 1 => $nt->getPrefixedText()) );
+               $log->addEntry( 'move', $this, $reason, array( 1 => $nt->getPrefixedText()) );
 
                # Purge squid and linkscc as per article creation
                Article::onArticleCreate( $nt );
index 0a57e27..9135ad2 100644 (file)
@@ -1586,6 +1586,7 @@ title. Please merge them manually.',
 '1movedto2_redir' => '[[$1]] moved to [[$2]] over redirect',
 'movelogpage' => 'Move log',
 'movelogpagetext' => 'Below is a list of page moved.',
+'movereason'   => 'Reason',
 
 # Export