Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -1581,10 +1581,8 @@ |
1582 | 1582 | 'talkexists', |
1583 | 1583 | 'movedto', |
1584 | 1584 | 'movetalk', |
1585 | | - 'move-subpages', |
1586 | | - 'movepage-page-exists', |
1587 | | - 'movepage-page-unmoved', |
1588 | | - 'movepage-page-moved', |
| 1585 | + 'talkpagemoved', |
| 1586 | + 'talkpagenotmoved', |
1589 | 1587 | '1movedto2', |
1590 | 1588 | '1movedto2_redir', |
1591 | 1589 | 'movelogpage', |
Index: trunk/phase3/includes/SpecialMovepage.php |
— | — | @@ -30,7 +30,9 @@ |
31 | 31 | |
32 | 32 | $f = new MovePageForm( $par ); |
33 | 33 | |
34 | | - if ( 'submit' == $action && $wgRequest->wasPosted() |
| 34 | + if ( 'success' == $action ) { |
| 35 | + $f->showSuccess(); |
| 36 | + } else if ( 'submit' == $action && $wgRequest->wasPosted() |
35 | 37 | && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
36 | 38 | $f->doSubmit(); |
37 | 39 | } else { |
— | — | @@ -44,7 +46,7 @@ |
45 | 47 | */ |
46 | 48 | class MovePageForm { |
47 | 49 | var $oldTitle, $newTitle, $reason; # Text input |
48 | | - var $moveTalk, $deleteAndMove, $moveSubpages; |
| 50 | + var $moveTalk, $deleteAndMove; |
49 | 51 | |
50 | 52 | private $watch = false; |
51 | 53 | |
— | — | @@ -59,13 +61,12 @@ |
60 | 62 | } else { |
61 | 63 | $this->moveTalk = $wgRequest->getBool( 'wpMovetalk', true ); |
62 | 64 | } |
63 | | - $this->moveSubpages = $wgRequest->getBool( 'wpMovesubpages', false ); |
64 | 65 | $this->deleteAndMove = $wgRequest->getBool( 'wpDeleteAndMove' ) && $wgRequest->getBool( 'wpConfirm' ); |
65 | 66 | $this->watch = $wgRequest->getCheck( 'wpWatch' ); |
66 | 67 | } |
67 | 68 | |
68 | 69 | function showForm( $err, $hookErr = '' ) { |
69 | | - global $wgOut, $wgUser, $wgNamespacesWithSubpages; |
| 70 | + global $wgOut, $wgUser; |
70 | 71 | |
71 | 72 | $ot = Title::newFromURL( $this->oldTitle ); |
72 | 73 | if( is_null( $ot ) ) { |
— | — | @@ -143,6 +144,8 @@ |
144 | 145 | $wgOut->addHTML( $errMsg ); |
145 | 146 | } |
146 | 147 | |
| 148 | + $moveTalkChecked = $this->moveTalk ? ' checked="checked"' : ''; |
| 149 | + |
147 | 150 | $wgOut->addHTML( |
148 | 151 | Xml::openElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalURL( 'action=submit' ), 'id' => 'movepage' ) ) . |
149 | 152 | Xml::openElement( 'fieldset' ) . |
— | — | @@ -175,31 +178,17 @@ |
176 | 179 | </tr>" |
177 | 180 | ); |
178 | 181 | |
179 | | - if( $considerTalk ) { |
| 182 | + if ( $considerTalk ) { |
180 | 183 | $wgOut->addHTML( " |
181 | 184 | <tr> |
182 | 185 | <td></td> |
183 | 186 | <td class='mw-input'>" . |
184 | | - Xml::checkLabel( wfMsg( 'movetalk' ), 'wpMovetalk', |
185 | | - 'wpMovetalk', $this->moveTalk ? ' checked="checked"' : ''). |
| 187 | + Xml::checkLabel( wfMsg( 'movetalk' ), 'wpMovetalk', 'wpMovetalk', $moveTalkChecked ) . |
186 | 188 | "</td> |
187 | 189 | </tr>" |
188 | 190 | ); |
189 | 191 | } |
190 | 192 | |
191 | | - if( isset( $wgNamespacesWithSubpages[$ot->getNamespace()] ) ) { |
192 | | - $wgOut->addHTML( " |
193 | | - <tr> |
194 | | - <td></td> |
195 | | - <td class=\"mw-input\">" . |
196 | | - Xml::checkLabel( wfMsgHtml( 'move-subpages' ), |
197 | | - 'wpMovesubpages', 'wpMovesubpages', |
198 | | - $this->moveSubpages ? ' checked="checked"' : '' ) . |
199 | | - "</td> |
200 | | - </tr>" |
201 | | - ); |
202 | | - } |
203 | | - |
204 | 193 | $watchChecked = $this->watch || $wgUser->getBoolOption( 'watchmoves' ) || $ot->userIsWatching(); |
205 | 194 | $wgOut->addHTML( " |
206 | 195 | <tr> |
— | — | @@ -275,100 +264,28 @@ |
276 | 265 | |
277 | 266 | wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ot , &$nt ) ) ; |
278 | 267 | |
279 | | - $wgOut->setPagetitle( wfMsg( 'pagemovedsub' ) ); |
| 268 | + # Move the talk page if relevant, if it exists, and if we've been told to |
| 269 | + $ott = $ot->getTalkPage(); |
| 270 | + if( $ott->exists() ) { |
| 271 | + if( $this->moveTalk && !$ot->isTalkPage() && !$nt->isTalkPage() ) { |
| 272 | + $ntt = $nt->getTalkPage(); |
280 | 273 | |
281 | | - $oldUrl = $ot->getFullUrl( 'redirect=no' ); |
282 | | - $newUrl = $nt->getFullUrl(); |
283 | | - $oldText = $ot->getPrefixedText(); |
284 | | - $newText = $nt->getPrefixedText(); |
285 | | - $oldLink = "<span class='plainlinks'>[$oldUrl $oldText]</span>"; |
286 | | - $newLink = "<span class='plainlinks'>[$newUrl $newText]</span>"; |
287 | | - |
288 | | - $wgOut->addWikiMsg( 'movepage-moved', $oldLink, $newLink, $oldText, $newText ); |
289 | | - |
290 | | - # Now we move extra pages we've been asked to move: subpages and talk |
291 | | - # pages. First, if the old page or the new page is a talk page, we |
292 | | - # can't move any talk pages: cancel that. |
293 | | - if( $ot->isTalkPage() || $nt->isTalkPage() ) { |
294 | | - $this->moveTalk = false; |
295 | | - } |
296 | | - |
297 | | - # Next make a list of id's. This might be marginally less efficient |
298 | | - # than a more direct method, but this is not a highly performance-cri- |
299 | | - # tical code path and readable code is more important here. |
300 | | - # |
301 | | - # Note: this query works nicely on MySQL 5, but the optimizer in MySQL |
302 | | - # 4 might get confused. If so, consider rewriting as a UNION. |
303 | | - $dbr = wfGetDB( DB_SLAVE ); |
304 | | - if( $this->moveSubpages ) { |
305 | | - $conds = array( |
306 | | - 'page_title LIKE '.$dbr->addQuotes( $dbr->escapeLike( $ot->getDBkey() ) . '/%' ) |
307 | | - .' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() ) |
308 | | - ); |
309 | | - if( $this->moveTalk ) { |
310 | | - $conds['page_namespace'] = array( $ot->getNamespace(), |
311 | | - MWNamespace::getTalk($ot->getNamespace()) ); |
| 274 | + # Attempt the move |
| 275 | + $error = $ott->moveTo( $ntt, true, $this->reason ); |
| 276 | + if ( $error === true ) { |
| 277 | + $talkmoved = 1; |
| 278 | + wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ott , &$ntt ) ); |
| 279 | + } else { |
| 280 | + $talkmoved = $error; |
| 281 | + } |
312 | 282 | } else { |
313 | | - $conds['page_namespace'] = $ot->getNamespace(); |
| 283 | + # Stay silent on the subject of talk. |
| 284 | + $talkmoved = ''; |
314 | 285 | } |
315 | 286 | } else { |
316 | | - if( $this->moveTalk ) { |
317 | | - $conds = array( |
318 | | - 'page_namespace' => MWNamespace::getTalk($ot->getNamespace()), |
319 | | - 'page_title' => $ot->getDBKey() |
320 | | - ); |
321 | | - } else { |
322 | | - $conds = '0 = 1'; |
323 | | - } |
| 287 | + $talkmoved = 'notalkpage'; |
324 | 288 | } |
325 | 289 | |
326 | | - $extrapages = $dbr->select( |
327 | | - 'page', |
328 | | - array( 'page_id', 'page_namespace', 'page_title' ), |
329 | | - $conds, |
330 | | - __METHOD__ |
331 | | - ); |
332 | | - |
333 | | - $extraOutput = ''; |
334 | | - $skin =& $wgUser->getSkin(); |
335 | | - foreach( $extrapages as $row ) { |
336 | | - if( $row->page_id == $ot->getArticleId() ) { |
337 | | - # Already did this one. |
338 | | - continue; |
339 | | - } |
340 | | - |
341 | | - $oldPage = Title::newFromRow( $row ); |
342 | | - $newPageName = preg_replace( |
343 | | - '#^'.preg_quote( $ot->getDBKey(), '#' ).'#', |
344 | | - $nt->getDBKey(), |
345 | | - $oldPage->getDBKey() |
346 | | - ); |
347 | | - # The following line is an atrocious hack. Kill it. |
348 | | - $newNs = $nt->getNamespace() + ($oldPage->getNamespace() & 1); |
349 | | - $newPage = Title::makeTitle( $newNs, $newPageName ); |
350 | | - |
351 | | - # This was copy-pasted from Renameuser, bleh. |
352 | | - if ( $newPage->exists() && !$oldPage->isValidMoveTarget( $newPage ) ) { |
353 | | - $link = $skin->makeKnownLinkObj( $newPage ); |
354 | | - $extraOutput .= '<li>' . wfMsgHtml( 'movepage-page-exists', $link ) . '</li>'; |
355 | | - } else { |
356 | | - $success = $oldPage->moveTo( $newPage, true, $this->reason ); |
357 | | - if( $success === true ) { |
358 | | - $oldLink = $skin->makeKnownLinkObj( $oldPage, '', 'redirect=no' ); |
359 | | - $newLink = $skin->makeKnownLinkObj( $newPage ); |
360 | | - $extraOutput .= '<li>' . wfMsgHtml( 'movepage-page-moved', $oldLink, $newLink ) . '</li>'; |
361 | | - } else { |
362 | | - $oldLink = $skin->makeKnownLinkObj( $oldPage ); |
363 | | - $newLink = $skin->makeLinkObj( $newPage ); |
364 | | - $extraOutput .= '<li>' . wfMsgHtml( 'movepage-page-unmoved', $oldLink, $newLink ) . '</li>'; |
365 | | - } |
366 | | - } |
367 | | - } |
368 | | - |
369 | | - if( $extraOutput !== '' ) { |
370 | | - $wgOut->addHTML( "<ul>$extraOutput</ul>" ); |
371 | | - } |
372 | | - |
373 | 290 | # Deal with watches |
374 | 291 | if( $this->watch ) { |
375 | 292 | $wgUser->addWatch( $ot ); |
— | — | @@ -377,8 +294,51 @@ |
378 | 295 | $wgUser->removeWatch( $ot ); |
379 | 296 | $wgUser->removeWatch( $nt ); |
380 | 297 | } |
| 298 | + |
| 299 | + # Give back result to user. |
| 300 | + $titleObj = SpecialPage::getTitleFor( 'Movepage' ); |
| 301 | + $success = $titleObj->getFullURL( |
| 302 | + 'action=success&oldtitle=' . wfUrlencode( $ot->getPrefixedText() ) . |
| 303 | + '&newtitle=' . wfUrlencode( $nt->getPrefixedText() ) . |
| 304 | + '&talkmoved='.$talkmoved ); |
| 305 | + |
| 306 | + $wgOut->redirect( $success ); |
381 | 307 | } |
382 | 308 | |
| 309 | + function showSuccess() { |
| 310 | + global $wgOut, $wgRequest, $wgUser; |
| 311 | + |
| 312 | + $old = Title::newFromText( $wgRequest->getVal( 'oldtitle' ) ); |
| 313 | + $new = Title::newFromText( $wgRequest->getVal( 'newtitle' ) ); |
| 314 | + |
| 315 | + if( is_null( $old ) || is_null( $new ) ) { |
| 316 | + throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
| 317 | + } |
| 318 | + |
| 319 | + $wgOut->setPagetitle( wfMsg( 'pagemovedsub' ) ); |
| 320 | + |
| 321 | + $talkmoved = $wgRequest->getVal( 'talkmoved' ); |
| 322 | + $oldUrl = $old->getFullUrl( 'redirect=no' ); |
| 323 | + $newUrl = $new->getFullUrl(); |
| 324 | + $oldText = $old->getPrefixedText(); |
| 325 | + $newText = $new->getPrefixedText(); |
| 326 | + $oldLink = "<span class='plainlinks'>[$oldUrl $oldText]</span>"; |
| 327 | + $newLink = "<span class='plainlinks'>[$newUrl $newText]</span>"; |
| 328 | + |
| 329 | + $s = wfMsgNoTrans( 'movepage-moved', $oldLink, $newLink, $oldText, $newText ); |
| 330 | + |
| 331 | + if ( $talkmoved == 1 ) { |
| 332 | + $s .= "\n\n" . wfMsgNoTrans( 'talkpagemoved' ); |
| 333 | + } elseif( 'articleexists' == $talkmoved ) { |
| 334 | + $s .= "\n\n" . wfMsgNoTrans( 'talkexists' ); |
| 335 | + } else { |
| 336 | + if( !$old->isTalkPage() && $talkmoved != 'notalkpage' ) { |
| 337 | + $s .= "\n\n" . wfMsgNoTrans( 'talkpagenotmoved', wfMsgNoTrans( $talkmoved ) ); |
| 338 | + } |
| 339 | + } |
| 340 | + $wgOut->addWikiText( $s ); |
| 341 | + } |
| 342 | + |
383 | 343 | function showLogFragment( $title, &$out ) { |
384 | 344 | $out->addHTML( Xml::element( 'h2', NULL, LogPage::logName( 'move' ) ) ); |
385 | 345 | LogEventsList::showLogExtract( $out, 'move', $title->getPrefixedText() ); |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2345,10 +2345,8 @@ |
2346 | 2346 | Please merge them manually.'''", |
2347 | 2347 | 'movedto' => 'moved to', |
2348 | 2348 | 'movetalk' => 'Move associated talk page', |
2349 | | -'move-subpages' => 'Move all subpages, if applicable', |
2350 | | -'movepage-page-exists' => 'The page $1 already exists and cannot be automatically overwritten.', |
2351 | | -'movepage-page-moved' => 'The page $1 has been moved to $2.', |
2352 | | -'movepage-page-unmoved' => 'The page $1 could not be moved to $2.', |
| 2349 | +'talkpagemoved' => 'The corresponding talk page was also moved.', |
| 2350 | +'talkpagenotmoved' => 'The corresponding talk page was <strong>not</strong> moved.', |
2353 | 2351 | '1movedto2' => '[[$1]] moved to [[$2]]', |
2354 | 2352 | '1movedto2_redir' => '[[$1]] moved to [[$2]] over redirect', |
2355 | 2353 | 'movelogpage' => 'Move log', |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -87,7 +87,6 @@ |
88 | 88 | text from Special:UserLogin title (new message 'nav-login-createaccount') |
89 | 89 | * Say "log in / create account" if an anonymous user can create an account, |
90 | 90 | otherwise just "log in", consistently across skins |
91 | | -* Users moving a page can now have all subpages automatically moved as well |
92 | 91 | |
93 | 92 | === Bug fixes in 1.13 === |
94 | 93 | |