From 76fe43ba65090c1a5083bb05777d5f51f05b831d Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 3 Apr 2005 14:45:42 +0000 Subject: [PATCH] Allow the user to specify a reason for page moves --- includes/SpecialMovepage.php | 35 ++++++++++++++++++++++------------- includes/Title.php | 21 ++++++++++++++------- languages/Language.php | 1 + 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/includes/SpecialMovepage.php b/includes/SpecialMovepage.php index a8e2e76fba..0f9e5ec922 100644 --- a/includes/SpecialMovepage.php +++ b/includes/SpecialMovepage.php @@ -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 {
- - + + - + + + + + " ); if ( ! $ot->isTalkPage() ) { @@ -121,7 +130,7 @@ class MovePageForm {
{$ma}:{$ott}{$movearticle}:{$oldTitle}
{$newt}:{$newtitle}:
{$movereason}: + +
  - +
@@ -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 +?> diff --git a/includes/Title.php b/includes/Title.php index 6807e428cb..be452a5f75 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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 ); diff --git a/languages/Language.php b/languages/Language.php index 0a57e2734f..9135ad2ffd 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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 -- 2.20.1