<?php
/**
*
- * @package MediaWiki
- * @subpackage SpecialPage
+ * @addtogroup SpecialPage
*/
/**
* Constructor
*/
function wfSpecialMovepage( $par = null ) {
- global $wgUser, $wgOut, $wgRequest, $action, $wgOnlySysopMayMove;
+ global $wgUser, $wgOut, $wgRequest, $action;
# Check rights
- if ( !$wgUser->isAllowed( 'move' ) || ( $wgOnlySysopMayMove && $wgUser->isNewbie() ) ) {
- $wgOut->showErrorPage( 'movenologin', 'movenologintext' );
+ if ( !$wgUser->isAllowed( 'move' ) ) {
+ $wgOut->showPermissionsErrorPage( array( $wgUser->isAnon() ? 'movenologintext' : 'movenotallowed' ) );
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;
$this->oldTitle = $wgRequest->getText( 'wpOldTitle', $target );
$this->newTitle = $wgRequest->getText( 'wpNewTitle' );
$this->reason = $wgRequest->getText( 'wpReason' );
- $this->moveTalk = $wgRequest->getBool( 'wpMovetalk', true );
+ 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;
+ global $wgOut, $wgUser, $wgContLang;
+
+ $start = $wgContLang->isRTL() ? 'right' : 'left';
+ $end = $wgContLang->isRTL() ? 'left' : 'right';
$wgOut->setPagetitle( wfMsg( 'movepage' ) );
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>
+ <td></td><td>" . Xml::checkLabel( wfMsg( 'delete_and_move_confirm' ), 'wpConfirm', 'wpConfirm' ) . "</td>
</tr>";
$err = '';
} else {
$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() );
<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'><label for='wpNewTitle'>{$newtitle}:</label></td>
- <td align='left'>
+ <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' valign='top'><br /><label for='wpReason'>{$movereason}:</label></td>
- <td align='left' valign='top'><br />
+ <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 ( $considerTalk ) {
$wgOut->addHTML( "
<tr>
- <td align='right'>
- <input type='checkbox' id=\"wpMovetalk\" name=\"wpMovetalk\"{$moveTalkChecked} value=\"1\" />
- </td>
- <td><label for=\"wpMovetalk\">{$movetalk}</label></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>
function doSubmit() {
global $wgOut, $wgUser, $wgRequest;
- $fname = "MovePageForm::doSubmit";
if ( $wgUser->pingLimiter( 'move' ) ) {
$wgOut->rateLimited();
# 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() ) {
+ if( $this->moveTalk && !$ot->isTalkPage() && !$nt->isTalkPage() ) {
$ntt = $nt->getTalkPage();
# Attempt the move
} else {
$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' );
+ $titleObj = SpecialPage::getTitleFor( 'Movepage' );
$success = $titleObj->getFullURL(
'action=success&oldtitle=' . wfUrlencode( $ot->getPrefixedText() ) .
'&newtitle=' . wfUrlencode( $nt->getPrefixedText() ) .
}
function showSuccess() {
- global $wgOut, $wgRequest, $wgRawHtml;
+ global $wgOut, $wgRequest, $wgUser;
+
+ $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' ) );
- $oldText = wfEscapeWikiText( $wgRequest->getVal('oldtitle') );
- $newText = wfEscapeWikiText( $wgRequest->getVal('newtitle') );
- $talkmoved = $wgRequest->getVal('talkmoved');
+ $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>";
- $text = wfMsg( 'pagemovedtext', $oldText, $newText );
-
- $allowHTML = $wgRawHtml;
- $wgRawHtml = false;
- $wgOut->addWikiText( $text );
- $wgRawHtml = $allowHTML;
+ $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 {
- $oldTitle = Title::newFromText( $oldText );
- if ( isset( $oldTitle ) && !$oldTitle->isTalkPage() && $talkmoved != 'notalkpage' ) {
- $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 ) {
}
}
-?>
+