$target = !is_null( $par ) ? $par : $request->getVal( 'target' );
// Yes, the use of getVal() and getText() is wanted, see bug 20365
- $oldTitleText = $request->getVal( 'wpOldTitle', $target );
- $newTitleText = $request->getText( 'wpNewTitle' );
+ $oldTitleText = $request->getVal( 'wpOldTitle', $target );
$this->oldTitle = Title::newFromText( $oldTitleText );
- $this->newTitle = Title::newFromText( $newTitleText );
if( is_null( $this->oldTitle ) ) {
throw new ErrorPageError( 'notargettitle', 'notargettext' );
throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
}
+ $newTitleTextMain = $request->getText( 'wpNewTitleMain' );
+ $newTitleTextNs = $request->getInt( 'wpNewTitleNs', $this->oldTitle->getNamespace() );
+ // Backwards compatibility for forms submitting here from other sources
+ // which is more common than it should be..
+ $newTitleText_bc = $request->getText( 'wpNewTitle' );
+ $this->newTitle = strlen( $newTitleText_bc ) > 0
+ ? Title::newFromText( $newTitleText_bc )
+ : Title::makeTitleSafe( $newTitleTextNs, $newTitleTextMain );
+
+
$user = $this->getUser();
# Check rights
$permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $user );
- if( !empty( $permErrors ) ) {
+ if ( count( $permErrors ) ) {
// Auto-block user's IP if the account was "hard" blocked
$user->spreadAnyEditBlock();
throw new PermissionsError( 'move', $permErrors );
&& $user->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) {
$this->doSubmit();
} else {
- $this->showForm( '' );
+ $this->showForm( array() );
}
}
/**
* Show the form
*
- * @param $err Mixed: error message. May either be a string message name or
- * array message name and parameters, like the second argument to
- * OutputPage::wrapWikiMsg().
+ * @param $err Array: error messages. Each item is an error message.
+ * It may either be a string message name or array message name and
+ * parameters, like the second argument to OutputPage::wrapWikiMsg().
*/
function showForm( $err ) {
global $wgContLang, $wgFixDoubleRedirects, $wgMaximumMovedPages;
$newTitle = $this->newTitle;
- if( !$newTitle ) {
+ if ( !$newTitle ) {
# Show the current title as a default
# when the form is first opened.
$newTitle = $this->oldTitle;
- }
- else {
- if( empty($err) ) {
- # 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 = $this->oldTitle->isValidMoveOperation( $newTitle );
- if( $newerr ) {
- $err = $newerr[0];
- }
+ } elseif ( !count( $err ) ) {
+ # 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 = $this->oldTitle->isValidMoveOperation( $newTitle );
+ if( is_array( $newerr ) ) {
+ $err = $newerr;
}
}
$user = $this->getUser();
- if ( !empty($err) && $err[0] == 'articleexists' && $user->isAllowed( 'delete' ) ) {
+ if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'articleexists'
+ && $newTitle->quickUserCan( 'delete', $user )
+ ) {
$out->addWikiMsg( 'delete_and_move_text', $newTitle->getPrefixedText() );
- $movepagebtn = wfMsg( 'delete_and_move' );
+ $movepagebtn = $this->msg( 'delete_and_move' )->text();
$submitVar = 'wpDeleteAndMove';
$confirm = "
<tr>
<td></td>
<td class='mw-input'>" .
- Xml::checkLabel( wfMsg( 'delete_and_move_confirm' ), 'wpConfirm', 'wpConfirm' ) .
+ Xml::checkLabel( $this->msg( 'delete_and_move_confirm' )->text(), 'wpConfirm', 'wpConfirm' ) .
"</td>
</tr>";
- $err = '';
+ $err = array();
} else {
if ($this->oldTitle->getNamespace() == NS_USER && !$this->oldTitle->isSubpage() ) {
$out->wrapWikiMsg( "<div class=\"error mw-moveuserpage-warning\">\n$1\n</div>", 'moveuserpage-warning' );
}
$out->addWikiMsg( $wgFixDoubleRedirects ? 'movepagetext' :
'movepagetext-noredirectfixer' );
- $movepagebtn = wfMsg( 'movepagebtn' );
+ $movepagebtn = $this->msg( 'movepagebtn' )->text();
$submitVar = 'wpMove';
$confirm = false;
}
- if ( !empty($err) && $err[0] == 'file-exists-sharedrepo' && $user->isAllowed( 'reupload-shared' ) ) {
+ if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'file-exists-sharedrepo'
+ && $user->isAllowed( 'reupload-shared' )
+ ) {
$out->addWikiMsg( 'move-over-sharedrepo', $newTitle->getPrefixedText() );
$submitVar = 'wpMoveOverSharedFile';
- $err = '';
+ $err = array();
}
$oldTalk = $this->oldTitle->getTalkPage();
# We also want to be able to move assoc. subpage talk-pages even if base page
# has no associated talk page, so || with $oldTitleTalkSubpages.
- $considerTalk = !$this->oldTitle->isTalkPage() &&
+ $considerTalk = !$this->oldTitle->isTalkPage() &&
( $oldTalk->exists()
|| ( $oldTitleTalkSubpages && $canMoveSubpage ) );
$out->addWikiMsg( 'movepagetalktext' );
}
- $token = htmlspecialchars( $user->editToken() );
+ if ( count( $err ) ) {
+ $out->addHTML( "<div class='error'>\n" );
+ $action_desc = $this->msg( 'action-move' )->plain();
+ $out->addWikiMsg( 'permissionserrorstext-withaction', count( $err ), $action_desc );
- if ( !empty($err) ) {
- $out->addSubtitle( $this->msg( 'formerror' ) );
- if( $err[0] == 'hookaborted' ) {
- $hookErr = $err[1];
- $errMsg = "<p><strong class=\"error\">$hookErr</strong></p>\n";
- $out->addHTML( $errMsg );
+ if ( count( $err ) == 1 ) {
+ $errMsg = $err[0];
+ $errMsgName = array_shift( $errMsg );
+ if ( $errMsgName == 'hookaborted' ) {
+ $out->addHTML( "<p>{$errMsg[0]}</p>\n" );
+ } else {
+ $out->addWikiMsgArray( $errMsgName, $errMsg );
+ }
} else {
- $out->wrapWikiMsg( "<p><strong class=\"error\">\n$1\n</strong></p>", $err );
+ $errStr = array();
+ foreach( $err as $errMsg ) {
+ if( $errMsg[0] == 'hookaborted' ) {
+ $errStr[] = $errMsg[1];
+ } else {
+ $errMsgName = array_shift( $errMsg );
+ $errStr[] = $this->msg( $errMsgName, $errMsg )->parse();
+ }
+ }
+
+ $out->addHTML( '<ul><li>' . implode( "</li>\n<li>", $errStr ) . "</li></ul>\n" );
}
+ $out->addHTML( "</div>\n" );
}
if ( $this->oldTitle->isProtected( 'move' ) ) {
$out->addHTML( "</div>\n" );
}
+ // Byte limit (not string length limit) for wpReason and wpNewTitleMain
+ // is enforced in the mediawiki.special.movePage module
+
+ $immovableNamespaces = array();
+
+ foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) {
+ if ( !MWNamespace::isMovable( $nsId ) ) {
+ $immovableNamespaces[] = $nsId;
+ }
+ }
+
$out->addHTML(
Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL( 'action=submit' ), 'id' => 'movepage' ) ) .
Xml::openElement( 'fieldset' ) .
- Xml::element( 'legend', null, wfMsg( 'move-page-legend' ) ) .
+ Xml::element( 'legend', null, $this->msg( 'move-page-legend' )->text() ) .
Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-movepage-table' ) ) .
"<tr>
<td class='mw-label'>" .
- wfMsgHtml( 'movearticle' ) .
+ $this->msg( 'movearticle' )->escaped() .
"</td>
<td class='mw-input'>
<strong>{$oldTitleLink}</strong>
</tr>
<tr>
<td class='mw-label'>" .
- Xml::label( wfMsg( 'newtitle' ), 'wpNewTitle' ) .
+ Xml::label( $this->msg( 'newtitle' )->text(), 'wpNewTitleMain' ) .
"</td>
<td class='mw-input'>" .
- Xml::input( 'wpNewTitle', 60, $wgContLang->recodeForEdit( $newTitle->getPrefixedText() ), array( 'type' => 'text', 'id' => 'wpNewTitle' ) ) .
+ Html::namespaceSelector(
+ array(
+ 'selected' => $newTitle->getNamespace(),
+ 'exclude' => $immovableNamespaces
+ ),
+ array( 'name' => 'wpNewTitleNs', 'id' => 'wpNewTitleNs' )
+ ) .
+ Xml::input( 'wpNewTitleMain', 60, $wgContLang->recodeForEdit( $newTitle->getText() ), array(
+ 'type' => 'text',
+ 'id' => 'wpNewTitleMain',
+ 'maxlength' => 255,
+ ) ) .
Html::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) .
"</td>
</tr>
<tr>
<td class='mw-label'>" .
- Xml::label( wfMsg( 'movereason' ), 'wpReason' ) .
+ Xml::label( $this->msg( 'movereason' )->text(), 'wpReason' ) .
"</td>
<td class='mw-input'>" .
Html::element( 'textarea', array( 'name' => 'wpReason', 'id' => 'wpReason', 'cols' => 60, 'rows' => 2,
- 'maxlength' => 200 ), $this->reason ) . // maxlength byte limit is enforce in mediawiki.special.movePage.js
+ 'maxlength' => 200 ), $this->reason ) .
"</td>
</tr>"
);
<tr>
<td></td>
<td class='mw-input'>" .
- Xml::checkLabel( wfMsg( 'movetalk' ), 'wpMovetalk', 'wpMovetalk', $this->moveTalk ) .
+ Xml::checkLabel( $this->msg( 'movetalk' )->text(), 'wpMovetalk', 'wpMovetalk', $this->moveTalk ) .
"</td>
</tr>"
);
<tr>
<td></td>
<td class='mw-input' >" .
- Xml::checkLabel( wfMsg( 'move-leave-redirect' ), 'wpLeaveRedirect',
+ Xml::checkLabel( $this->msg( 'move-leave-redirect' )->text(), 'wpLeaveRedirect',
'wpLeaveRedirect', $this->leaveRedirect ) .
"</td>
</tr>"
<tr>
<td></td>
<td class='mw-input' >" .
- Xml::checkLabel( wfMsg( 'fix-double-redirects' ), 'wpFixRedirects',
+ Xml::checkLabel( $this->msg( 'fix-double-redirects' )->text(), 'wpFixRedirects',
'wpFixRedirects', $this->fixRedirects ) .
"</td>
</tr>"
array( 'id' => 'wpMovesubpages' )
) . ' ' .
Xml::tags( 'label', array( 'for' => 'wpMovesubpages' ),
- wfMsgExt(
+ $this->msg(
( $this->oldTitle->hasSubpages()
? 'move-subpages'
- : 'move-talk-subpages' ),
- array( 'parseinline' ),
- $this->getLang()->formatNum( $wgMaximumMovedPages ),
- # $2 to allow use of PLURAL in message.
- $wgMaximumMovedPages
- )
+ : 'move-talk-subpages' )
+ )->numParams( $wgMaximumMovedPages )->params( $wgMaximumMovedPages )->parse()
) .
"</td>
</tr>"
}
$watchChecked = $user->isLoggedIn() && ($this->watch || $user->getBoolOption( 'watchmoves' )
- || $this->oldTitle->userIsWatching());
+ || $user->isWatched( $this->oldTitle ) );
# Don't allow watching if user is not logged in
if( $user->isLoggedIn() ) {
$out->addHTML( "
<tr>
<td></td>
<td class='mw-input'>" .
- Xml::checkLabel( wfMsg( 'move-watch' ), 'wpWatch', 'watch', $watchChecked ) .
+ Xml::checkLabel( $this->msg( 'move-watch' )->text(), 'wpWatch', 'watch', $watchChecked ) .
"</td>
</tr>");
}
"</td>
</tr>" .
Xml::closeElement( 'table' ) .
- Html::hidden( 'wpEditToken', $token ) .
+ Html::hidden( 'wpEditToken', $user->getEditToken() ) .
Xml::closeElement( 'fieldset' ) .
Xml::closeElement( 'form' ) .
"\n"
}
function doSubmit() {
- global $wgMaximumMovedPages, $wgFixDoubleRedirects, $wgDeleteRevisionsLimit;
+ global $wgMaximumMovedPages, $wgFixDoubleRedirects;
$user = $this->getUser();
$ot = $this->oldTitle;
$nt = $this->newTitle;
- # Delete to make way if requested
- if ( !count( $nt->getUserPermissionsErrors( 'delete', $user ) ) && $this->deleteAndMove ) {
- $page = WikiPage::factory( $nt );
+ # don't allow moving to pages with # in
+ if ( !$nt || $nt->getFragment() != '' ) {
+ $this->showForm( array( array( 'badtitletext' ) ) );
+ return;
+ }
+
+ # Show a warning if the target file exists on a shared repo
+ if ( $nt->getNamespace() == NS_FILE
+ && !( $this->moveOverShared && $user->isAllowed( 'reupload-shared' ) )
+ && !RepoGroup::singleton()->getLocalRepo()->findFile( $nt )
+ && wfFindFile( $nt ) )
+ {
+ $this->showForm( array( array( 'file-exists-sharedrepo' ) ) );
+ return;
+
+ }
- # Disallow deletions of big articles
- $bigHistory = $page->isBigDeletion();
- if( $bigHistory && count( $nt->getUserPermissionsErrors( 'bigdelete', $user ) ) ) {
- $this->showForm( array( 'delete-toobig', $this->getLang()->formatNum( $wgDeleteRevisionsLimit ) ) );
+ # Delete to make way if requested
+ if ( $this->deleteAndMove ) {
+ $permErrors = $nt->getUserPermissionsErrors( 'delete', $user );
+ if ( count( $permErrors ) ) {
+ # Only show the first error
+ $this->showForm( $permErrors );
return;
}
- $reason = wfMessage( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
+ $reason = $this->msg( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
// Delete an associated image if there is
if ( $nt->getNamespace() == NS_FILE ) {
}
$error = ''; // passed by ref
- if ( !$page->doDeleteArticle( $reason, false, 0, true, $error, $user ) ) {
- $this->showForm( array( 'cannotdelete', wfEscapeWikiText( $nt->getPrefixedText() ) ) );
+ $page = WikiPage::factory( $nt );
+ $deleteStatus = $page->doDeleteArticleReal( $reason, false, 0, true, $error, $user );
+ if ( !$deleteStatus->isGood() ) {
+ $this->showForm( $deleteStatus->getErrorsArray() );
return;
}
-
- }
-
- # don't allow moving to pages with # in
- if ( !$nt || $nt->getFragment() != '' ) {
- $this->showForm( 'badtitletext' );
- return;
- }
-
- # Show a warning if the target file exists on a shared repo
- if ( $nt->getNamespace() == NS_FILE
- && !( $this->moveOverShared && $user->isAllowed( 'reupload-shared' ) )
- && !RepoGroup::singleton()->getLocalRepo()->findFile( $nt )
- && wfFindFile( $nt ) )
- {
- $this->showForm( array('file-exists-sharedrepo') );
- return;
-
}
if ( $user->isAllowed( 'suppressredirect' ) ) {
# Do the actual move.
$error = $ot->moveTo( $nt, true, $this->reason, $createRedirect );
if ( $error !== true ) {
- # @todo FIXME: Show all the errors in a list, not just the first one
- $this->showForm( reset( $error ) );
+ $this->showForm( $error );
return;
}
wfRunHooks( 'SpecialMovepageAfterMove', array( &$this, &$ot, &$nt ) );
$out = $this->getOutput();
- $out->setPagetitle( wfMsg( 'pagemovedsub' ) );
+ $out->setPageTitle( $this->msg( 'pagemovedsub' ) );
$oldLink = Linker::link(
$ot,
array(),
array( 'redirect' => 'no' )
);
- $newLink = Linker::linkKnown( $nt );
+ $newLink = Linker::linkKnown( $nt );
$oldText = $ot->getPrefixedText();
$newText = $nt->getPrefixedText();
$msgName = $createRedirect ? 'movepage-moved-redirect' : 'movepage-moved-noredirect';
- $out->addHTML( wfMessage( 'movepage-moved' )->rawParams( $oldLink, $newLink, $oldText, $newText )->parseAsBlock() );
+ $out->addHTML( $this->msg( 'movepage-moved' )->rawParams( $oldLink,
+ $newLink )->params( $oldText, $newText )->parseAsBlock() );
$out->addWikiMsg( $msgName );
# Now we move extra pages we've been asked to move: subpages and talk
$newSubpage = Title::makeTitleSafe( $newNs, $newPageName );
if( !$newSubpage ) {
$oldLink = Linker::linkKnown( $oldSubpage );
- $extraOutput []= wfMsgHtml( 'movepage-page-unmoved', $oldLink,
- htmlspecialchars(Title::makeName( $newNs, $newPageName )));
+ $extraOutput []= $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink
+ )->params( Title::makeName( $newNs, $newPageName ) )->escaped();
continue;
}
# This was copy-pasted from Renameuser, bleh.
if ( $newSubpage->exists() && !$oldSubpage->isValidMoveTarget( $newSubpage ) ) {
$link = Linker::linkKnown( $newSubpage );
- $extraOutput []= wfMsgHtml( 'movepage-page-exists', $link );
+ $extraOutput []= $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped();
} else {
$success = $oldSubpage->moveTo( $newSubpage, true, $this->reason, $createRedirect );
if( $success === true ) {
array( 'redirect' => 'no' )
);
$newLink = Linker::linkKnown( $newSubpage );
- $extraOutput []= wfMsgHtml( 'movepage-page-moved', $oldLink, $newLink );
+ $extraOutput []= $this->msg( 'movepage-page-moved' )->rawParams( $oldLink, $newLink )->escaped();
++$count;
if( $count >= $wgMaximumMovedPages ) {
- $extraOutput []= wfMsgExt( 'movepage-max-pages', array( 'parsemag', 'escape' ), $this->getLang()->formatNum( $wgMaximumMovedPages ) );
+ $extraOutput []= $this->msg( 'movepage-max-pages' )->numParams( $wgMaximumMovedPages )->escaped();
break;
}
} else {
$oldLink = Linker::linkKnown( $oldSubpage );
$newLink = Linker::link( $newSubpage );
- $extraOutput []= wfMsgHtml( 'movepage-page-unmoved', $oldLink, $newLink );
+ $extraOutput []= $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink, $newLink )->escaped();
}
}
}
function showLogFragment( $title ) {
+ $moveLogPage = new LogPage( 'move' );
$out = $this->getOutput();
- $out->addHTML( Xml::element( 'h2', null, LogPage::logName( 'move' ) ) );
+ $out->addHTML( Xml::element( 'h2', null, $moveLogPage->getName()->text() ) );
LogEventsList::showLogExtract( $out, 'move', $title );
}
return;
}
- $out->addWikiMsg( 'movesubpagetext', $this->getLang()->formatNum( $count ) );
+ $out->addWikiMsg( 'movesubpagetext', $this->getLanguage()->formatNum( $count ) );
$out->addHTML( "<ul>\n" );
foreach( $subpages as $subpage ) {
$out->addHTML( "</ul>\n" );
}
}
-