/**
* Constructor
*/
-function wfSpecialMovepage() {
+function wfSpecialMovepage( $par = null ) {
global $wgUser, $wgOut, $wgRequest, $action, $wgOnlySysopMayMove;
# check rights. We don't want newbies to move pages to prevents possible attack
return;
}
- $f = new MovePageForm();
+ $f = new MovePageForm( $par );
if ( 'success' == $action ) {
$f->showSuccess();
*/
class MovePageForm {
var $oldTitle, $newTitle, $reason; # Text input
- var $moveTalk;
+ var $moveTalk, $deleteAndMove;
- function MovePageForm() {
+ function MovePageForm( $par ) {
global $wgRequest;
- $this->oldTitle = $wgRequest->getText( 'wpOldTitle', $wgRequest->getVal( 'target' ) );
+ $target = isset($par) ? $par : $wgRequest->getVal( 'target' );
+ $this->oldTitle = $wgRequest->getText( 'wpOldTitle', $target );
$this->newTitle = $wgRequest->getText( 'wpNewTitle' );
$this->reason = $wgRequest->getText( 'wpReason' );
$this->moveTalk = $wgRequest->getBool( 'wpMovetalk', true );
+ $this->deleteAndMove = $wgRequest->getBool( 'wpDeleteAndMove' );
}
function showForm( $err ) {
# when the form is first opened.
$encNewTitle = $oldTitle;
} else {
+ if( $err == '' ) {
+ $nt = Title::newFromURL( $this->newTitle );
+ if( $nt ) {
+ # If a title was supplied, probably from the move log revert
+ # link, check for validity. We can then show some diagnostic
+ # information and save a click.
+ $newerr = $ot->isValidMoveOperation( $nt );
+ if( is_string( $newerr ) ) {
+ $err = $newerr;
+ }
+ }
+ }
$encNewTitle = htmlspecialchars( $this->newTitle );
}
$encReason = htmlspecialchars( $this->reason );
- $wgOut->addWikiText( wfMsg( 'movepagetext' ) );
+ if ( $err == 'articleexists' && $wgUser->isAllowed( 'delete' ) ) {
+ $wgOut->addWikiText( wfMsg( 'delete_and_move_text', $encNewTitle ) );
+ $movepagebtn = wfMsg( 'delete_and_move' );
+ $submitVar = 'wpDeleteAndMove';
+ $err = '';
+ } else {
+ $wgOut->addWikiText( wfMsg( 'movepagetext' ) );
+ $movepagebtn = wfMsg( 'movepagebtn' );
+ $submitVar = 'wpMove';
+ }
+
if ( !$ot->isTalkPage() ) {
$wgOut->addWikiText( wfMsg( 'movepagetalktext' ) );
}
$movearticle = wfMsg( 'movearticle' );
$newtitle = wfMsg( 'newtitle' );
- $movepagebtn = wfMsg( 'movepagebtn' );
$movetalk = wfMsg( 'movetalk' );
$movereason = wfMsg( 'movereason' );
if ( $err != '' ) {
$wgOut->setSubtitle( wfMsg( 'formerror' ) );
- $wgOut->addHTML( '<p class="error">'.$err."</p>\n" );
+ $wgOut->addHTML( '<p class="error">' . wfMsg($err) . "</p>\n" );
}
- if ( $this->moveTalk ) {
- $moveTalkChecked = " checked='checked'";
- } else {
- $moveTalkChecked = '';
- }
+ $moveTalkChecked = $this->moveTalk ? ' checked="checked"' : '';
$wgOut->addHTML( "
<form id=\"movepage\" method=\"post\" action=\"{$action}\">
<tr>
<td align='right'>{$movereason}:</td>
<td align='left'>
- <input type='text' size=40 name=\"wpReason\" value=\"{$encReason}\" />
+ <input type='text' size='40' name=\"wpReason\" value=\"{$encReason}\" />
</td>
</tr>" );
<tr>
<td> </td>
<td align='left'>
- <input type='submit' name=\"wpMove\" value=\"{$movepagebtn}\" />
+ <input type='submit' name=\"{$submitVar}\" value=\"{$movepagebtn}\" />
</td>
</tr>
</table>
# Variables beginning with 'o' for old article 'n' for new article
- # Attempt to move the article
$ot = Title::newFromText( $this->oldTitle );
$nt = Title::newFromText( $this->newTitle );
+ # Delete to make way if requested
+ if ( $wgUser->isAllowed( 'delete' ) && $this->deleteAndMove ) {
+ $article = new Article( $nt );
+ // This may output an error message and exit
+ $article->doDelete( wfMsgForContent( 'delete_and_move_reason' ) );
+ }
+
# don't allow moving to pages with # in
if ( !$nt || $nt->getFragment() != '' ) {
- $this->showForm( wfMsg( "badtitletext" ) );
+ $this->showForm( 'badtitletext' );
return;
}
$error = $ot->moveTo( $nt, true, $this->reason );
if ( $error !== true ) {
- $this->showForm( wfMsg( $error ) );
+ $this->showForm( $error );
return;
}
} else {
$talkmoved = $error;
}
+ } else {
+ # Stay silent on the subject of talk.
+ $talkmoved = '';
}
# Give back result to user.