<?php
/**
*
- * @package MediaWiki
- * @subpackage SpecialPage
+ * @addtogroup SpecialPage
*/
-/**
- *
- */
-require_once( "LinksUpdate.php" );
-
/**
* Constructor
*/
function wfSpecialMovepage( $par = null ) {
- global $wgUser, $wgOut, $wgRequest, $action, $wgOnlySysopMayMove;
+ global $wgUser, $wgOut, $wgRequest, $action;
+
+ # Check rights
+ if ( !$wgUser->isAllowed( 'move' ) ) {
+ $wgOut->showErrorPage( 'movenologin', 'movenologintext' );
+ return;
+ }
- # check rights. We don't want newbies to move pages to prevents possible attack
- if ( $wgUser->isAnon() or $wgUser->isBlocked() or ($wgOnlySysopMayMove and $wgUser->isNewbie())) {
- $wgOut->errorpage( "movenologin", "movenologintext" );
+ # Don't allow blocked users to move pages
+ if ( $wgUser->isBlocked() ) {
+ $wgOut->blockedPage();
return;
}
- # We don't move protected pages
+
+ # Check for database lock
if ( wfReadOnly() ) {
$wgOut->readOnlyPage();
return;
}
/**
- *
- * @package MediaWiki
- * @subpackage SpecialPage
+ * HTML form for Special:Movepage
+ * @addtogroup SpecialPage
*/
class MovePageForm {
var $oldTitle, $newTitle, $reason; # Text input
var $moveTalk, $deleteAndMove;
-
+
+ private $watch = false;
+
function MovePageForm( $par ) {
global $wgRequest;
$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' );
+ if ( $wgRequest->wasPosted() ) {
+ $this->moveTalk = $wgRequest->getBool( 'wpMovetalk', false );
+ } else {
+ $this->moveTalk = $wgRequest->getBool( 'wpMovetalk', true );
+ }
+ $this->deleteAndMove = $wgRequest->getBool( 'wpDeleteAndMove' ) && $wgRequest->getBool( 'wpConfirm' );
+ $this->watch = $wgRequest->getCheck( 'wpWatch' );
}
-
+
function showForm( $err ) {
- global $wgOut, $wgUser, $wgLang;
+ global $wgOut, $wgUser, $wgContLang;
+
+ $start = $wgContLang->isRTL() ? 'right' : 'left';
+ $end = $wgContLang->isRTL() ? 'left' : 'right';
$wgOut->setPagetitle( wfMsg( 'movepage' ) );
$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
$wgOut->addWikiText( wfMsg( 'delete_and_move_text', $encNewTitle ) );
$movepagebtn = wfMsgHtml( 'delete_and_move' );
$submitVar = 'wpDeleteAndMove';
+ $confirm = "
+ <tr>
+ <td></td><td>" . Xml::checkLabel( wfMsg( 'delete_and_move_confirm' ), 'wpConfirm', 'wpConfirm' ) . "</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' ) );
}
$movearticle = wfMsgHtml( 'movearticle' );
$newtitle = wfMsgHtml( 'newtitle' );
- $movetalk = wfMsgHtml( 'movetalk' );
$movereason = wfMsgHtml( 'movereason' );
- $titleObj = Title::makeTitle( NS_SPECIAL, 'Movepage' );
+ $titleObj = SpecialPage::getTitleFor( 'Movepage' );
$action = $titleObj->escapeLocalURL( 'action=submit' );
$token = htmlspecialchars( $wgUser->editToken() );
}
$moveTalkChecked = $this->moveTalk ? ' checked="checked"' : '';
-
+
$wgOut->addHTML( "
<form id=\"movepage\" method=\"post\" action=\"{$action}\">
<table border='0'>
<tr>
- <td align='right'>{$movearticle}:</td>
- <td align='left'><strong>{$oldTitle}</strong></td>
+ <td align='$end'>{$movearticle}</td>
+ <td align='$start'><strong>{$oldTitle}</strong></td>
</tr>
<tr>
- <td align='right'>{$newtitle}:</td>
- <td align='left'>
- <input type='text' size='40' name=\"wpNewTitle\" value=\"{$encNewTitle}\" />
+ <td align='$end'><label for='wpNewTitle'>{$newtitle}</label></td>
+ <td align='$start'>
+ <input type='text' size='40' name='wpNewTitle' id='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 align='$end' valign='top'><br /><label for='wpReason'>{$movereason}</label></td>
+ <td align='$start' valign='top'><br />
+ <textarea cols='60' rows='2' name='wpReason' id='wpReason'>{$encReason}</textarea>
</td>
</tr>" );
- if ( ! $ot->isTalkPage() ) {
+ if ( $considerTalk ) {
$wgOut->addHTML( "
<tr>
- <td align='right'>
- <input type='checkbox' name=\"wpMovetalk\"{$moveTalkChecked} value=\"1\" />
- </td>
- <td>{$movetalk}</td>
+ <td></td><td>" . Xml::checkLabel( wfMsg( 'movetalk' ), 'wpMovetalk', 'wpMovetalk', $moveTalkChecked ) . "</td>
</tr>" );
}
+
+ $watchChecked = $this->watch || $wgUser->getBoolOption( 'watchmoves' ) || $ot->userIsWatching();
+ $watch = '<tr>';
+ $watch .= '<td></td><td>' . Xml::checkLabel( wfMsg( 'move-watch' ), 'wpWatch', 'watch', $watchChecked ) . '</td>';
+ $watch .= '</tr>';
+ $wgOut->addHtml( $watch );
+
$wgOut->addHTML( "
+ {$confirm}
<tr>
<td> </td>
- <td align='left'>
+ <td align='$start'>
<input type='submit' name=\"{$submitVar}\" value=\"{$movepagebtn}\" />
</td>
</tr>
<input type='hidden' name='wpEditToken' value=\"{$token}\" />
</form>\n" );
+ $this->showLogFragment( $ot, $wgOut );
+
}
function doSubmit() {
- global $wgOut, $wgUser, $wgLang;
- global $wgDeferredUpdateList, $wgMessageCache;
- global $wgUseSquid, $wgRequest;
- $fname = "MovePageForm::doSubmit";
-
+ global $wgOut, $wgUser, $wgRequest;
+
if ( $wgUser->pingLimiter( 'move' ) ) {
$wgOut->rateLimited();
return;
}
-
+
# Variables beginning with 'o' for old article 'n' for new article
$ot = Title::newFromText( $this->oldTitle );
$this->showForm( $error );
return;
}
-
- # 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 ) &&
- ( ! Namespace::isTalk( $ons ) ) &&
- ( ! Namespace::isTalk( $nns ) ) ) {
-
- # get old talk page namespace
- $ons = Namespace::getTalk( $ons );
- # get new talk page namespace
- $nns = Namespace::getTalk( $nns );
-
- # make talk page title objects
- $ott = Title::makeTitle( $ons, $ot->getDBkey() );
- $ntt = Title::makeTitle( $nns, $nt->getDBkey() );
-
- # Attempt the move
- $error = $ott->moveTo( $ntt, true, $this->reason );
- if ( $error === true ) {
- $talkmoved = 1;
+
+ wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ot , &$nt ) ) ;
+
+ # Move the talk page if relevant, if it exists, and if we've been told to
+ $ott = $ot->getTalkPage();
+ if( $ott->exists() ) {
+ if( $this->moveTalk && !$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';
}
+ # Deal with watches
+ if( $this->watch ) {
+ $wgUser->addWatch( $ot );
+ $wgUser->addWatch( $nt );
+ } else {
+ $wgUser->removeWatch( $ot );
+ $wgUser->removeWatch( $nt );
+ }
+
# Give back result to user.
- $titleObj = Title::makeTitle( NS_SPECIAL, 'Movepage' );
- $success = $titleObj->getFullURL(
+ $titleObj = SpecialPage::getTitleFor( 'Movepage' );
+ $success = $titleObj->getFullURL(
'action=success&oldtitle=' . wfUrlencode( $ot->getPrefixedText() ) .
'&newtitle=' . wfUrlencode( $nt->getPrefixedText() ) .
'&talkmoved='.$talkmoved );
}
function showSuccess() {
- global $wgOut, $wgRequest, $wgRawHtml;
-
+ global $wgOut, $wgRequest, $wgUser, $wgRawHtml;
+
+ $old = Title::newFromText( $wgRequest->getVal( 'oldtitle' ) );
+ $new = Title::newFromText( $wgRequest->getVal( 'newtitle' ) );
+
+ if( is_null( $old ) || is_null( $new ) ) {
+ throw new ErrorPageError( 'badtitle', 'badtitletext' );
+ }
+
$wgOut->setPagetitle( wfMsg( 'movepage' ) );
$wgOut->setSubtitle( wfMsg( 'pagemovedsub' ) );
- $oldtitle = $wgRequest->getVal('oldtitle');
- $newtitle = $wgRequest->getVal('newtitle');
- $talkmoved = $wgRequest->getVal('talkmoved');
- $text = wfMsg( 'pagemovedtext', $oldtitle, $newtitle );
-
- # Temporarily disable raw html wikitext option out of XSS paranoia
- $marchingantofdoom = $wgRawHtml;
- $wgRawHtml = false;
- $wgOut->addWikiText( $text );
- $wgRawHtml = $marchingantofdoom;
+ $talkmoved = $wgRequest->getVal( 'talkmoved' );
+ $oldUrl = $old->getFullUrl( 'redirect=no' );
+ $newUrl = $new->getFullURl();
+ $oldText = $old->getPrefixedText();
+ $newText = $new->getPrefixedText();
+ $oldLink = "<span class='plainlinks'>[$oldUrl $oldText]</span>";
+ $newLink = "<span class='plainlinks'>[$newUrl $newText]</span>";
+
+ $s = wfMsg( 'movepage-moved', $oldLink, $newLink, $oldText, $newText );
if ( $talkmoved == 1 ) {
- $wgOut->addWikiText( wfMsg( 'talkpagemoved' ) );
+ $s .= "\n\n" . wfMsg( 'talkpagemoved' );
} elseif( 'articleexists' == $talkmoved ) {
- $wgOut->addWikiText( wfMsg( 'talkexists' ) );
+ $s .= "\n\n" . wfMsg( 'talkexists' );
} else {
- $ot = Title::newFromURL( $oldtitle );
- if ( ! $ot->isTalkPage() ) {
- $wgOut->addWikiText( wfMsg( 'talkpagenotmoved', wfMsg( $talkmoved ) ) );
+ if( !$old->isTalkPage() && $talkmoved != 'notalkpage' ) {
+ $s .= "\n\n" . wfMsg( 'talkpagenotmoved', wfMsg( $talkmoved ) );
}
}
+ $wgOut->addWikiText( $s );
+ }
+
+ 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 );
}
+
}
-?>
+