}
public function execute( $par ) {
- # Check for database lock
- if ( wfReadOnly() ) {
- throw new ReadOnlyError;
- }
+ $this->checkReadOnly();
$this->setHeaders();
$this->outputHeader();
$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' );
$submitVar = 'wpDeleteAndMove';
Xml::checkLabel( wfMsg( 'delete_and_move_confirm' ), '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' );
$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
+
$out->addHTML(
Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL( 'action=submit' ), 'id' => 'movepage' ) ) .
Xml::openElement( 'fieldset' ) .
</tr>
<tr>
<td class='mw-label'>" .
- Xml::label( wfMsg( 'newtitle' ), 'wpNewTitle' ) .
+ Xml::label( wfMsg( 'newtitle' ), 'wpNewTitleMain' ) .
"</td>
<td class='mw-input'>" .
- Xml::input( 'wpNewTitle', 40, $wgContLang->recodeForEdit( $newTitle->getPrefixedText() ), array( 'type' => 'text', 'id' => 'wpNewTitle' ) ) .
+ Html::namespaceSelector(
+ array( 'selected' => $newTitle->getNamespace() ),
+ 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>
"</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>"
);
? 'move-subpages'
: 'move-talk-subpages' ),
array( 'parseinline' ),
- $this->getLang()->formatNum( $wgMaximumMovedPages ),
+ $this->getLanguage()->formatNum( $wgMaximumMovedPages ),
# $2 to allow use of PLURAL in message.
$wgMaximumMovedPages
)
"</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 );
-
- # Disallow deletions of big articles
- $bigHistory = $page->isBigDeletion();
- if( $bigHistory && count( $nt->getUserPermissionsErrors( 'bigdelete', $user ) ) ) {
- $this->showForm( array( 'delete-toobig', $this->getLang()->formatNum( $wgDeleteRevisionsLimit ) ) );
- return;
- }
-
- $reason = wfMessage( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
-
- // Delete an associated image if there is
- $file = wfLocalFile( $nt );
- if( $file->exists() ) {
- $file->delete( $reason, false );
- }
-
- $error = ''; // passed by ref
- if ( !$page->doDeleteArticle( $reason, false, 0, true, $error, $user ) ) {
- $this->showForm( array( 'cannotdelete', wfEscapeWikiText( $nt->getPrefixedText() ) ) );
- return;
- }
-
- }
-
# don't allow moving to pages with # in
if ( !$nt || $nt->getFragment() != '' ) {
- $this->showForm( 'badtitletext' );
+ $this->showForm( array( array( 'badtitletext' ) ) );
return;
}
&& !RepoGroup::singleton()->getLocalRepo()->findFile( $nt )
&& wfFindFile( $nt ) )
{
- $this->showForm( array('file-exists-sharedrepo') );
+ $this->showForm( array( array( 'file-exists-sharedrepo' ) ) );
return;
}
+ # 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();
+
+ // Delete an associated image if there is
+ if ( $nt->getNamespace() == NS_FILE ) {
+ $file = wfLocalFile( $nt );
+ if ( $file->exists() ) {
+ $file->delete( $reason, false );
+ }
+ }
+
+ $error = ''; // passed by ref
+ $page = WikiPage::factory( $nt );
+ if ( !$page->doDeleteArticle( $reason, false, 0, true, $error, $user ) ) {
+ $this->showForm( array( array( 'cannotdelete', wfEscapeWikiText( $nt->getPrefixedText() ) ) ) );
+ return;
+ }
+ }
+
if ( $user->isAllowed( 'suppressredirect' ) ) {
$createRedirect = $this->leaveRedirect;
} else {
# 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( wfMessage( '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
$extraOutput []= wfMsgHtml( 'movepage-page-moved', $oldLink, $newLink );
++$count;
if( $count >= $wgMaximumMovedPages ) {
- $extraOutput []= wfMsgExt( 'movepage-max-pages', array( 'parsemag', 'escape' ), $this->getLang()->formatNum( $wgMaximumMovedPages ) );
+ $extraOutput []= wfMsgExt( 'movepage-max-pages', array( 'parsemag', 'escape' ), $this->getLanguage()->formatNum( $wgMaximumMovedPages ) );
break;
}
} else {
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" );
}
}
-