* @subpackage SpecialPage
*/
-/**
- *
- */
-require_once( "LinksUpdate.php" );
-
/**
* Constructor
*/
function wfSpecialMovepage( $par = null ) {
global $wgUser, $wgOut, $wgRequest, $action, $wgOnlySysopMayMove;
- # check rights. We don't want newbies to move pages to prevents possible attack
- if ( !$wgUser->isAllowed( 'move' ) or $wgUser->isBlocked() or ($wgOnlySysopMayMove and $wgUser->isNewbie())) {
- $wgOut->errorpage( "movenologin", "movenologintext" );
+ # Check rights
+ if ( !$wgUser->isAllowed( 'move' ) ) {
+ $wgOut->showErrorPage( 'movenologin', 'movenologintext' );
return;
}
- # We don't move protected pages
+
+ # Don't allow blocked users to move pages
+ if ( $wgUser->isBlocked() ) {
+ $wgOut->blockedPage();
+ return;
+ }
+
+ # Check for database lock
if ( wfReadOnly() ) {
$wgOut->readOnlyPage();
return;
class MovePageForm {
var $oldTitle, $newTitle, $reason; # Text input
var $moveTalk, $deleteAndMove;
-
+
function MovePageForm( $par ) {
global $wgRequest;
$target = isset($par) ? $par : $wgRequest->getVal( 'target' );
$this->newTitle = $wgRequest->getText( 'wpNewTitle' );
$this->reason = $wgRequest->getText( 'wpReason' );
$this->moveTalk = $wgRequest->getBool( 'wpMovetalk', true );
- $this->deleteAndMove = $wgRequest->getBool( 'wpDeleteAndMove' );
+ $this->deleteAndMove = $wgRequest->getBool( 'wpDeleteAndMove' ) && $wgRequest->getBool( 'wpConfirm' );
}
-
+
function showForm( $err ) {
global $wgOut, $wgUser;
$ot = Title::newFromURL( $this->oldTitle );
if( is_null( $ot ) ) {
- $wgOut->errorpage( 'notargettitle', 'notargettext' );
+ $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
return;
}
$oldTitle = $ot->getPrefixedText();
-
+
$encOldTitle = htmlspecialchars( $oldTitle );
if( $this->newTitle == '' ) {
# Show the current title as a default
if ( $err == 'articleexists' && $wgUser->isAllowed( 'delete' ) ) {
$wgOut->addWikiText( wfMsg( 'delete_and_move_text', $encNewTitle ) );
$movepagebtn = wfMsgHtml( 'delete_and_move' );
+ $confirmText = wfMsgHtml( 'delete_and_move_confirm' );
$submitVar = 'wpDeleteAndMove';
+ $confirm = "
+ <tr>
+ <td align='right'>
+ <input type='checkbox' name='wpConfirm' id='wpConfirm' value=\"true\" />
+ </td>
+ <td align='left'><label for='wpConfirm'>{$confirmText}</label></td>
+ </tr>";
$err = '';
} else {
$wgOut->addWikiText( wfMsg( 'movepagetext' ) );
$movepagebtn = wfMsgHtml( 'movepagebtn' );
$submitVar = 'wpMove';
+ $confirm = false;
}
- if ( !$ot->isTalkPage() ) {
+ $oldTalk = $ot->getTalkPage();
+ $considerTalk = ( !$ot->isTalkPage() && $oldTalk->exists() );
+
+ if ( $considerTalk ) {
$wgOut->addWikiText( wfMsg( 'movepagetalktext' ) );
}
}
$moveTalkChecked = $this->moveTalk ? ' checked="checked"' : '';
-
+
$wgOut->addHTML( "
<form id=\"movepage\" method=\"post\" action=\"{$action}\">
<table border='0'>
</td>
</tr>" );
- if ( ! $ot->isTalkPage() ) {
+ if ( $considerTalk ) {
$wgOut->addHTML( "
<tr>
<td align='right'>
</tr>" );
}
$wgOut->addHTML( "
+ {$confirm}
<tr>
<td> </td>
<td align='left'>
<input type='hidden' name='wpEditToken' value=\"{$token}\" />
</form>\n" );
+ $this->showLogFragment( $ot, $wgOut );
+
}
function doSubmit() {
global $wgOut, $wgUser, $wgRequest;
$fname = "MovePageForm::doSubmit";
-
+
if ( $wgUser->pingLimiter( 'move' ) ) {
$wgOut->rateLimited();
return;
}
-
+
# Variables beginning with 'o' for old article 'n' for new article
$ot = Title::newFromText( $this->oldTitle );
}
wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ot , &$nt ) ) ;
-
- # Move talk page if
- # (1) the checkbox says to,
- # (2) the namespaces are not themselves talk namespaces, and of course
- # (3) it exists.
- if ( ( $wgRequest->getVal('wpMovetalk') == 1 ) &&
- !$ot->isTalkPage() &&
- !$nt->isTalkPage() ) {
-
- $ott = $ot->getTalkPage();
- $ntt = $nt->getTalkPage();
-
- # Attempt the move
- $error = $ott->moveTo( $ntt, true, $this->reason );
- if ( $error === true ) {
- $talkmoved = 1;
- wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ott , &$ntt ) ) ;
+
+ # Move the talk page if relevant, if it exists, and if we've been told to
+ $ott = $ot->getTalkPage();
+ if( $ott->exists() ) {
+ if( $wgRequest->getVal( 'wpMovetalk' ) == 1 && !$ot->isTalkPage() && !$nt->isTalkPage() ) {
+ $ntt = $nt->getTalkPage();
+
+ # Attempt the move
+ $error = $ott->moveTo( $ntt, true, $this->reason );
+ if ( $error === true ) {
+ $talkmoved = 1;
+ wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ott , &$ntt ) ) ;
+ } else {
+ $talkmoved = $error;
+ }
} else {
- $talkmoved = $error;
+ # Stay silent on the subject of talk.
+ $talkmoved = '';
}
} else {
- # Stay silent on the subject of talk.
- $talkmoved = '';
+ $talkmoved = 'notalkpage';
}
-
+
# Give back result to user.
$titleObj = Title::makeTitle( NS_SPECIAL, 'Movepage' );
- $success = $titleObj->getFullURL(
+ $success = $titleObj->getFullURL(
'action=success&oldtitle=' . wfUrlencode( $ot->getPrefixedText() ) .
'&newtitle=' . wfUrlencode( $nt->getPrefixedText() ) .
'&talkmoved='.$talkmoved );
function showSuccess() {
global $wgOut, $wgRequest, $wgRawHtml;
-
+
$wgOut->setPagetitle( wfMsg( 'movepage' ) );
$wgOut->setSubtitle( wfMsg( 'pagemovedsub' ) );
- $oldtitle = $wgRequest->getVal('oldtitle');
- $newtitle = $wgRequest->getVal('newtitle');
+
+ $oldText = wfEscapeWikiText( $wgRequest->getVal('oldtitle') );
+ $newText = wfEscapeWikiText( $wgRequest->getVal('newtitle') );
$talkmoved = $wgRequest->getVal('talkmoved');
- $text = wfMsg( 'pagemovedtext', $oldtitle, $newtitle );
+ $text = wfMsg( 'pagemovedtext', $oldText, $newText );
- # Temporarily disable raw html wikitext option out of XSS paranoia
- $marchingantofdoom = $wgRawHtml;
+ $allowHTML = $wgRawHtml;
$wgRawHtml = false;
$wgOut->addWikiText( $text );
- $wgRawHtml = $marchingantofdoom;
+ $wgRawHtml = $allowHTML;
if ( $talkmoved == 1 ) {
$wgOut->addWikiText( wfMsg( 'talkpagemoved' ) );
} elseif( 'articleexists' == $talkmoved ) {
$wgOut->addWikiText( wfMsg( 'talkexists' ) );
} else {
- $ot = Title::newFromURL( $oldtitle );
- if ( ! $ot->isTalkPage() ) {
+ $oldTitle = Title::newFromText( $oldText );
+ if ( isset( $oldTitle ) && !$oldTitle->isTalkPage() && $talkmoved != 'notalkpage' ) {
$wgOut->addWikiText( wfMsg( 'talkpagenotmoved', wfMsg( $talkmoved ) ) );
}
}
}
+
+ function showLogFragment( $title, &$out ) {
+ $out->addHtml( wfElement( 'h2', NULL, LogPage::logName( 'move' ) ) );
+ $request = new FauxRequest( array( 'page' => $title->getPrefixedText(), 'type' => 'move' ) );
+ $viewer = new LogViewer( new LogReader( $request ) );
+ $viewer->showList( $out );
+ }
+
}
?>