* @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 ) {
}
$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' );
<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() ) {
<tr>
<td> </td>
<td align='left'>
- <input type='submit' name=\"wpMove\" value=\"{$mpb}\" />
+ <input type='submit' name=\"wpMove\" value=\"{$movepagebtn}\" />
</td>
</tr>
</table>
return;
}
- $error = $ot->moveTo( $nt );
+ $error = $ot->moveTo( $nt, true, $this->reason );
if ( $error !== true ) {
$this->showForm( wfMsg( $error ) );
return;
$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 {
}
}
}
-?>
\ No newline at end of file
+?>
* @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';
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
* 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();
# 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
* @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();
# 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 );