Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -1581,8 +1581,10 @@ |
1582 | 1582 | 'talkexists', |
1583 | 1583 | 'movedto', |
1584 | 1584 | 'movetalk', |
1585 | | - 'talkpagemoved', |
1586 | | - 'talkpagenotmoved', |
| 1585 | + 'move-subpages', |
| 1586 | + 'movepage-page-exists', |
| 1587 | + 'movepage-page-unmoved', |
| 1588 | + 'movepage-page-moved', |
1587 | 1589 | '1movedto2', |
1588 | 1590 | '1movedto2_redir', |
1589 | 1591 | 'movelogpage', |
Index: trunk/phase3/includes/SpecialMovepage.php |
— | — | @@ -30,9 +30,7 @@ |
31 | 31 | |
32 | 32 | $f = new MovePageForm( $par ); |
33 | 33 | |
34 | | - if ( 'success' == $action ) { |
35 | | - $f->showSuccess(); |
36 | | - } else if ( 'submit' == $action && $wgRequest->wasPosted() |
| 34 | + if ( 'submit' == $action && $wgRequest->wasPosted() |
37 | 35 | && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
38 | 36 | $f->doSubmit(); |
39 | 37 | } else { |
— | — | @@ -46,7 +44,7 @@ |
47 | 45 | */ |
48 | 46 | class MovePageForm { |
49 | 47 | var $oldTitle, $newTitle, $reason; # Text input |
50 | | - var $moveTalk, $deleteAndMove; |
| 48 | + var $moveTalk, $deleteAndMove, $moveSubpages; |
51 | 49 | |
52 | 50 | private $watch = false; |
53 | 51 | |
— | — | @@ -61,12 +59,13 @@ |
62 | 60 | } else { |
63 | 61 | $this->moveTalk = $wgRequest->getBool( 'wpMovetalk', true ); |
64 | 62 | } |
| 63 | + $this->moveSubpages = $wgRequest->getBool( 'wpMovesubpages', false ); |
65 | 64 | $this->deleteAndMove = $wgRequest->getBool( 'wpDeleteAndMove' ) && $wgRequest->getBool( 'wpConfirm' ); |
66 | 65 | $this->watch = $wgRequest->getCheck( 'wpWatch' ); |
67 | 66 | } |
68 | 67 | |
69 | 68 | function showForm( $err, $hookErr = '' ) { |
70 | | - global $wgOut, $wgUser; |
| 69 | + global $wgOut, $wgUser, $wgNamespacesWithSubpages; |
71 | 70 | |
72 | 71 | $ot = Title::newFromURL( $this->oldTitle ); |
73 | 72 | if( is_null( $ot ) ) { |
— | — | @@ -144,8 +143,6 @@ |
145 | 144 | $wgOut->addHTML( $errMsg ); |
146 | 145 | } |
147 | 146 | |
148 | | - $moveTalkChecked = $this->moveTalk ? ' checked="checked"' : ''; |
149 | | - |
150 | 147 | $wgOut->addHTML( |
151 | 148 | Xml::openElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalURL( 'action=submit' ), 'id' => 'movepage' ) ) . |
152 | 149 | Xml::openElement( 'fieldset' ) . |
— | — | @@ -178,17 +175,31 @@ |
179 | 176 | </tr>" |
180 | 177 | ); |
181 | 178 | |
182 | | - if ( $considerTalk ) { |
| 179 | + if( $considerTalk ) { |
183 | 180 | $wgOut->addHTML( " |
184 | 181 | <tr> |
185 | 182 | <td></td> |
186 | 183 | <td class='mw-input'>" . |
187 | | - Xml::checkLabel( wfMsg( 'movetalk' ), 'wpMovetalk', 'wpMovetalk', $moveTalkChecked ) . |
| 184 | + Xml::checkLabel( wfMsg( 'movetalk' ), 'wpMovetalk', |
| 185 | + 'wpMovetalk', $this->moveTalk ? ' checked="checked"' : ''). |
188 | 186 | "</td> |
189 | 187 | </tr>" |
190 | 188 | ); |
191 | 189 | } |
192 | 190 | |
| 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 | + |
193 | 204 | $watchChecked = $this->watch || $wgUser->getBoolOption( 'watchmoves' ) || $ot->userIsWatching(); |
194 | 205 | $wgOut->addHTML( " |
195 | 206 | <tr> |
— | — | @@ -264,28 +275,100 @@ |
265 | 276 | |
266 | 277 | wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ot , &$nt ) ) ; |
267 | 278 | |
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(); |
| 279 | + $wgOut->setPagetitle( wfMsg( 'pagemovedsub' ) ); |
273 | 280 | |
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 | | - } |
| 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()) ); |
282 | 312 | } else { |
283 | | - # Stay silent on the subject of talk. |
284 | | - $talkmoved = ''; |
| 313 | + $conds['page_namespace'] = $ot->getNamespace(); |
285 | 314 | } |
286 | 315 | } else { |
287 | | - $talkmoved = 'notalkpage'; |
| 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 | + } |
288 | 324 | } |
289 | 325 | |
| 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 | + |
290 | 373 | # Deal with watches |
291 | 374 | if( $this->watch ) { |
292 | 375 | $wgUser->addWatch( $ot ); |
— | — | @@ -294,51 +377,8 @@ |
295 | 378 | $wgUser->removeWatch( $ot ); |
296 | 379 | $wgUser->removeWatch( $nt ); |
297 | 380 | } |
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 ); |
307 | 381 | } |
308 | 382 | |
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 | | - |
343 | 383 | function showLogFragment( $title, &$out ) { |
344 | 384 | $out->addHTML( Xml::element( 'h2', NULL, LogPage::logName( 'move' ) ) ); |
345 | 385 | LogEventsList::showLogExtract( $out, 'move', $title->getPrefixedText() ); |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2345,8 +2345,10 @@ |
2346 | 2346 | Please merge them manually.'''", |
2347 | 2347 | 'movedto' => 'moved to', |
2348 | 2348 | 'movetalk' => 'Move associated talk page', |
2349 | | -'talkpagemoved' => 'The corresponding talk page was also moved.', |
2350 | | -'talkpagenotmoved' => 'The corresponding talk page was <strong>not</strong> moved.', |
| 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.', |
2351 | 2353 | '1movedto2' => '[[$1]] moved to [[$2]]', |
2352 | 2354 | '1movedto2_redir' => '[[$1]] moved to [[$2]] over redirect', |
2353 | 2355 | 'movelogpage' => 'Move log', |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -87,6 +87,7 @@ |
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 |
91 | 92 | |
92 | 93 | === Bug fixes in 1.13 === |
93 | 94 | |