Index: trunk/phase3/includes/specials/SpecialMovepage.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | |
70 | 70 | # Check rights |
71 | 71 | $permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $user ); |
72 | | - if( !empty( $permErrors ) ) { |
| 72 | + if ( count( $permErrors ) ) { |
73 | 73 | // Auto-block user's IP if the account was "hard" blocked |
74 | 74 | $user->spreadAnyEditBlock(); |
75 | 75 | throw new PermissionsError( 'move', $permErrors ); |
— | — | @@ -89,16 +89,16 @@ |
90 | 90 | && $user->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) { |
91 | 91 | $this->doSubmit(); |
92 | 92 | } else { |
93 | | - $this->showForm( '' ); |
| 93 | + $this->showForm( array() ); |
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
98 | 98 | * Show the form |
99 | 99 | * |
100 | | - * @param $err Mixed: error message. May either be a string message name or |
101 | | - * array message name and parameters, like the second argument to |
102 | | - * OutputPage::wrapWikiMsg(). |
| 100 | + * @param $err Array: error messages. Each item is an error message. |
| 101 | + * It may either be a string message name or array message name and |
| 102 | + * parameters, like the second argument to OutputPage::wrapWikiMsg(). |
103 | 103 | */ |
104 | 104 | function showForm( $err ) { |
105 | 105 | global $wgContLang, $wgFixDoubleRedirects, $wgMaximumMovedPages; |
— | — | @@ -117,22 +117,21 @@ |
118 | 118 | # Show the current title as a default |
119 | 119 | # when the form is first opened. |
120 | 120 | $newTitle = $this->oldTitle; |
121 | | - } |
122 | | - else { |
123 | | - if( empty($err) ) { |
124 | | - # If a title was supplied, probably from the move log revert |
125 | | - # link, check for validity. We can then show some diagnostic |
126 | | - # information and save a click. |
127 | | - $newerr = $this->oldTitle->isValidMoveOperation( $newTitle ); |
128 | | - if( $newerr ) { |
129 | | - $err = $newerr[0]; |
130 | | - } |
| 121 | + } elseif ( !count( $err ) ) { |
| 122 | + # If a title was supplied, probably from the move log revert |
| 123 | + # link, check for validity. We can then show some diagnostic |
| 124 | + # information and save a click. |
| 125 | + $newerr = $this->oldTitle->isValidMoveOperation( $newTitle ); |
| 126 | + if( is_array( $newerr ) ) { |
| 127 | + $err = $newerr; |
131 | 128 | } |
132 | 129 | } |
133 | 130 | |
134 | 131 | $user = $this->getUser(); |
135 | 132 | |
136 | | - if ( !empty($err) && $err[0] == 'articleexists' && $user->isAllowed( 'delete' ) ) { |
| 133 | + if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'articleexists' |
| 134 | + && $newTitle->quickUserCan( 'delete', $user ) |
| 135 | + ) { |
137 | 136 | $out->addWikiMsg( 'delete_and_move_text', $newTitle->getPrefixedText() ); |
138 | 137 | $movepagebtn = wfMsg( 'delete_and_move' ); |
139 | 138 | $submitVar = 'wpDeleteAndMove'; |
— | — | @@ -143,7 +142,7 @@ |
144 | 143 | Xml::checkLabel( wfMsg( 'delete_and_move_confirm' ), 'wpConfirm', 'wpConfirm' ) . |
145 | 144 | "</td> |
146 | 145 | </tr>"; |
147 | | - $err = ''; |
| 146 | + $err = array(); |
148 | 147 | } else { |
149 | 148 | if ($this->oldTitle->getNamespace() == NS_USER && !$this->oldTitle->isSubpage() ) { |
150 | 149 | $out->wrapWikiMsg( "<div class=\"error mw-moveuserpage-warning\">\n$1\n</div>", 'moveuserpage-warning' ); |
— | — | @@ -155,10 +154,12 @@ |
156 | 155 | $confirm = false; |
157 | 156 | } |
158 | 157 | |
159 | | - if ( !empty($err) && $err[0] == 'file-exists-sharedrepo' && $user->isAllowed( 'reupload-shared' ) ) { |
| 158 | + if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'file-exists-sharedrepo' |
| 159 | + && $user->isAllowed( 'reupload-shared' ) |
| 160 | + ) { |
160 | 161 | $out->addWikiMsg( 'move-over-sharedrepo', $newTitle->getPrefixedText() ); |
161 | 162 | $submitVar = 'wpMoveOverSharedFile'; |
162 | | - $err = ''; |
| 163 | + $err = array(); |
163 | 164 | } |
164 | 165 | |
165 | 166 | $oldTalk = $this->oldTitle->getTalkPage(); |
— | — | @@ -189,17 +190,33 @@ |
190 | 191 | $out->addWikiMsg( 'movepagetalktext' ); |
191 | 192 | } |
192 | 193 | |
193 | | - $token = htmlspecialchars( $user->getEditToken() ); |
| 194 | + if ( count( $err ) ) { |
| 195 | + $out->addHTML( "<div class='error'>\n" ); |
| 196 | + $action_desc = $this->msg( 'action-move' )->plain(); |
| 197 | + $out->addWikiMsg( 'permissionserrorstext-withaction', count( $err ), $action_desc ); |
194 | 198 | |
195 | | - if ( !empty($err) ) { |
196 | | - $out->addSubtitle( $this->msg( 'formerror' ) ); |
197 | | - if( $err[0] == 'hookaborted' ) { |
198 | | - $hookErr = $err[1]; |
199 | | - $errMsg = "<p><strong class=\"error\">$hookErr</strong></p>\n"; |
200 | | - $out->addHTML( $errMsg ); |
| 199 | + if ( count( $err ) ) { |
| 200 | + $errMsg = $err[0]; |
| 201 | + $errMsgName = array_shift( $errMsg ); |
| 202 | + if ( $errMsgName == 'hookaborted' ) { |
| 203 | + $out->addHTML( "<p>{$errMsg[0]}</p>\n" ); |
| 204 | + } else { |
| 205 | + $out->addWikiMsgArray( $errMsg, $errMsgName ); |
| 206 | + } |
201 | 207 | } else { |
202 | | - $out->wrapWikiMsg( "<p><strong class=\"error\">\n$1\n</strong></p>", $err ); |
| 208 | + $errStr = array(); |
| 209 | + foreach( $err as $errMsg ) { |
| 210 | + if( $errMsg[0] == 'hookaborted' ) { |
| 211 | + $errStr[] = $errMsg[1]; |
| 212 | + } else { |
| 213 | + $errMsgName = array_shift( $errMsg ); |
| 214 | + $errStr[] = $this->msg( $errMsgName, $errMsg )->parse(); |
| 215 | + } |
| 216 | + } |
| 217 | + |
| 218 | + $out->addHTML( '<ul><li>' . implode( "</li>\n<li>", $errStr ) . "</li></ul>\n" ); |
203 | 219 | } |
| 220 | + $out->addHTML( "</div>\n" ); |
204 | 221 | } |
205 | 222 | |
206 | 223 | if ( $this->oldTitle->isProtected( 'move' ) ) { |
— | — | @@ -336,7 +353,7 @@ |
337 | 354 | "</td> |
338 | 355 | </tr>" . |
339 | 356 | Xml::closeElement( 'table' ) . |
340 | | - Html::hidden( 'wpEditToken', $token ) . |
| 357 | + Html::hidden( 'wpEditToken', $user->getEditToken() ) . |
341 | 358 | Xml::closeElement( 'fieldset' ) . |
342 | 359 | Xml::closeElement( 'form' ) . |
343 | 360 | "\n" |
— | — | @@ -359,12 +376,29 @@ |
360 | 377 | $ot = $this->oldTitle; |
361 | 378 | $nt = $this->newTitle; |
362 | 379 | |
| 380 | + # don't allow moving to pages with # in |
| 381 | + if ( !$nt || $nt->getFragment() != '' ) { |
| 382 | + $this->showForm( array( array( 'badtitletext' ) ) ); |
| 383 | + return; |
| 384 | + } |
| 385 | + |
| 386 | + # Show a warning if the target file exists on a shared repo |
| 387 | + if ( $nt->getNamespace() == NS_FILE |
| 388 | + && !( $this->moveOverShared && $user->isAllowed( 'reupload-shared' ) ) |
| 389 | + && !RepoGroup::singleton()->getLocalRepo()->findFile( $nt ) |
| 390 | + && wfFindFile( $nt ) ) |
| 391 | + { |
| 392 | + $this->showForm( array( array( 'file-exists-sharedrepo' ) ) ); |
| 393 | + return; |
| 394 | + |
| 395 | + } |
| 396 | + |
363 | 397 | # Delete to make way if requested |
364 | 398 | if ( $this->deleteAndMove ) { |
365 | 399 | $permErrors = $nt->getUserPermissionsErrors( 'delete', $user ); |
366 | 400 | if ( count( $permErrors ) ) { |
367 | 401 | # Only show the first error |
368 | | - $this->showForm( $permErrors[0] ); |
| 402 | + $this->showForm( $permErrors ); |
369 | 403 | return; |
370 | 404 | } |
371 | 405 | |
— | — | @@ -381,29 +415,11 @@ |
382 | 416 | $error = ''; // passed by ref |
383 | 417 | $page = WikiPage::factory( $nt ); |
384 | 418 | if ( !$page->doDeleteArticle( $reason, false, 0, true, $error, $user ) ) { |
385 | | - $this->showForm( array( 'cannotdelete', wfEscapeWikiText( $nt->getPrefixedText() ) ) ); |
| 419 | + $this->showForm( array( array( 'cannotdelete', wfEscapeWikiText( $nt->getPrefixedText() ) ) ) ); |
386 | 420 | return; |
387 | 421 | } |
388 | | - |
389 | 422 | } |
390 | 423 | |
391 | | - # don't allow moving to pages with # in |
392 | | - if ( !$nt || $nt->getFragment() != '' ) { |
393 | | - $this->showForm( 'badtitletext' ); |
394 | | - return; |
395 | | - } |
396 | | - |
397 | | - # Show a warning if the target file exists on a shared repo |
398 | | - if ( $nt->getNamespace() == NS_FILE |
399 | | - && !( $this->moveOverShared && $user->isAllowed( 'reupload-shared' ) ) |
400 | | - && !RepoGroup::singleton()->getLocalRepo()->findFile( $nt ) |
401 | | - && wfFindFile( $nt ) ) |
402 | | - { |
403 | | - $this->showForm( array('file-exists-sharedrepo') ); |
404 | | - return; |
405 | | - |
406 | | - } |
407 | | - |
408 | 424 | if ( $user->isAllowed( 'suppressredirect' ) ) { |
409 | 425 | $createRedirect = $this->leaveRedirect; |
410 | 426 | } else { |
— | — | @@ -413,8 +429,7 @@ |
414 | 430 | # Do the actual move. |
415 | 431 | $error = $ot->moveTo( $nt, true, $this->reason, $createRedirect ); |
416 | 432 | if ( $error !== true ) { |
417 | | - # @todo FIXME: Show all the errors in a list, not just the first one |
418 | | - $this->showForm( reset( $error ) ); |
| 433 | + $this->showForm( $error ); |
419 | 434 | return; |
420 | 435 | } |
421 | 436 | |