Merge "Documentation improvements in includes/actions"
[lhc/web/wiklou.git] / includes / specials / SpecialMovepage.php
1 <?php
2 /**
3 * Implements Special:Movepage
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 /**
25 * A special page that allows users to change page titles
26 *
27 * @ingroup SpecialPage
28 */
29 class MovePageForm extends UnlistedSpecialPage {
30
31 /**
32 * @var Title
33 */
34 var $oldTitle, $newTitle; # Objects
35 var $reason; # Text input
36 var $moveTalk, $deleteAndMove, $moveSubpages, $fixRedirects, $leaveRedirect, $moveOverShared; # Checks
37
38 private $watch = false;
39
40 public function __construct() {
41 parent::__construct( 'Movepage' );
42 }
43
44 public function execute( $par ) {
45 $this->checkReadOnly();
46
47 $this->setHeaders();
48 $this->outputHeader();
49
50 $request = $this->getRequest();
51 $target = !is_null( $par ) ? $par : $request->getVal( 'target' );
52
53 // Yes, the use of getVal() and getText() is wanted, see bug 20365
54
55 $oldTitleText = $request->getVal( 'wpOldTitle', $target );
56 $this->oldTitle = Title::newFromText( $oldTitleText );
57
58 if( is_null( $this->oldTitle ) ) {
59 throw new ErrorPageError( 'notargettitle', 'notargettext' );
60 }
61 if( !$this->oldTitle->exists() ) {
62 throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
63 }
64
65 $newTitleTextMain = $request->getText( 'wpNewTitleMain' );
66 $newTitleTextNs = $request->getInt( 'wpNewTitleNs', $this->oldTitle->getNamespace() );
67 // Backwards compatibility for forms submitting here from other sources
68 // which is more common than it should be..
69 $newTitleText_bc = $request->getText( 'wpNewTitle' );
70 $this->newTitle = strlen( $newTitleText_bc ) > 0
71 ? Title::newFromText( $newTitleText_bc )
72 : Title::makeTitleSafe( $newTitleTextNs, $newTitleTextMain );
73
74 $user = $this->getUser();
75
76 # Check rights
77 $permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $user );
78 if ( count( $permErrors ) ) {
79 // Auto-block user's IP if the account was "hard" blocked
80 $user->spreadAnyEditBlock();
81 throw new PermissionsError( 'move', $permErrors );
82 }
83
84 $def = !$request->wasPosted();
85
86 $this->reason = $request->getText( 'wpReason' );
87 $this->moveTalk = $request->getBool( 'wpMovetalk', $def );
88 $this->fixRedirects = $request->getBool( 'wpFixRedirects', $def );
89 $this->leaveRedirect = $request->getBool( 'wpLeaveRedirect', $def );
90 $this->moveSubpages = $request->getBool( 'wpMovesubpages', false );
91 $this->deleteAndMove = $request->getBool( 'wpDeleteAndMove' ) && $request->getBool( 'wpConfirm' );
92 $this->moveOverShared = $request->getBool( 'wpMoveOverSharedFile', false );
93 $this->watch = $request->getCheck( 'wpWatch' ) && $user->isLoggedIn();
94
95 if ( 'submit' == $request->getVal( 'action' ) && $request->wasPosted()
96 && $user->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) {
97 $this->doSubmit();
98 } else {
99 $this->showForm( array() );
100 }
101 }
102
103 /**
104 * Show the form
105 *
106 * @param array $err error messages. Each item is an error message.
107 * It may either be a string message name or array message name and
108 * parameters, like the second argument to OutputPage::wrapWikiMsg().
109 */
110 function showForm( $err ) {
111 global $wgContLang, $wgFixDoubleRedirects, $wgMaximumMovedPages;
112
113 $this->getSkin()->setRelevantTitle( $this->oldTitle );
114
115 $oldTitleLink = Linker::link( $this->oldTitle );
116
117 $out = $this->getOutput();
118 $out->setPageTitle( $this->msg( 'move-page', $this->oldTitle->getPrefixedText() ) );
119 $out->addModules( 'mediawiki.special.movePage' );
120
121 $newTitle = $this->newTitle;
122
123 if ( !$newTitle ) {
124 # Show the current title as a default
125 # when the form is first opened.
126 $newTitle = $this->oldTitle;
127 } elseif ( !count( $err ) ) {
128 # If a title was supplied, probably from the move log revert
129 # link, check for validity. We can then show some diagnostic
130 # information and save a click.
131 $newerr = $this->oldTitle->isValidMoveOperation( $newTitle );
132 if( is_array( $newerr ) ) {
133 $err = $newerr;
134 }
135 }
136
137 $user = $this->getUser();
138
139 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'articleexists'
140 && $newTitle->quickUserCan( 'delete', $user )
141 ) {
142 $out->addWikiMsg( 'delete_and_move_text', $newTitle->getPrefixedText() );
143 $movepagebtn = $this->msg( 'delete_and_move' )->text();
144 $submitVar = 'wpDeleteAndMove';
145 $confirm = "
146 <tr>
147 <td></td>
148 <td class='mw-input'>" .
149 Xml::checkLabel( $this->msg( 'delete_and_move_confirm' )->text(), 'wpConfirm', 'wpConfirm' ) .
150 "</td>
151 </tr>";
152 $err = array();
153 } else {
154 if ( $this->oldTitle->getNamespace() == NS_USER && !$this->oldTitle->isSubpage() ) {
155 $out->wrapWikiMsg( "<div class=\"error mw-moveuserpage-warning\">\n$1\n</div>", 'moveuserpage-warning' );
156 }
157 $out->addWikiMsg( $wgFixDoubleRedirects ? 'movepagetext' :
158 'movepagetext-noredirectfixer' );
159 $movepagebtn = $this->msg( 'movepagebtn' )->text();
160 $submitVar = 'wpMove';
161 $confirm = false;
162 }
163
164 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'file-exists-sharedrepo'
165 && $user->isAllowed( 'reupload-shared' )
166 ) {
167 $out->addWikiMsg( 'move-over-sharedrepo', $newTitle->getPrefixedText() );
168 $submitVar = 'wpMoveOverSharedFile';
169 $err = array();
170 }
171
172 $oldTalk = $this->oldTitle->getTalkPage();
173 $oldTitleSubpages = $this->oldTitle->hasSubpages();
174 $oldTitleTalkSubpages = $this->oldTitle->getTalkPage()->hasSubpages();
175
176 $canMoveSubpage = ( $oldTitleSubpages || $oldTitleTalkSubpages ) &&
177 !count( $this->oldTitle->getUserPermissionsErrors( 'move-subpages', $user ) );
178
179 # We also want to be able to move assoc. subpage talk-pages even if base page
180 # has no associated talk page, so || with $oldTitleTalkSubpages.
181 $considerTalk = !$this->oldTitle->isTalkPage() &&
182 ( $oldTalk->exists()
183 || ( $oldTitleTalkSubpages && $canMoveSubpage ) );
184
185 $dbr = wfGetDB( DB_SLAVE );
186 if ( $wgFixDoubleRedirects ) {
187 $hasRedirects = $dbr->selectField( 'redirect', '1',
188 array(
189 'rd_namespace' => $this->oldTitle->getNamespace(),
190 'rd_title' => $this->oldTitle->getDBkey(),
191 ), __METHOD__ );
192 } else {
193 $hasRedirects = false;
194 }
195
196 if ( $considerTalk ) {
197 $out->addWikiMsg( 'movepagetalktext' );
198 }
199
200 if ( count( $err ) ) {
201 $out->addHTML( "<div class='error'>\n" );
202 $action_desc = $this->msg( 'action-move' )->plain();
203 $out->addWikiMsg( 'permissionserrorstext-withaction', count( $err ), $action_desc );
204
205 if ( count( $err ) == 1 ) {
206 $errMsg = $err[0];
207 $errMsgName = array_shift( $errMsg );
208 if ( $errMsgName == 'hookaborted' ) {
209 $out->addHTML( "<p>{$errMsg[0]}</p>\n" );
210 } else {
211 $out->addWikiMsgArray( $errMsgName, $errMsg );
212 }
213 } else {
214 $errStr = array();
215 foreach( $err as $errMsg ) {
216 if( $errMsg[0] == 'hookaborted' ) {
217 $errStr[] = $errMsg[1];
218 } else {
219 $errMsgName = array_shift( $errMsg );
220 $errStr[] = $this->msg( $errMsgName, $errMsg )->parse();
221 }
222 }
223
224 $out->addHTML( '<ul><li>' . implode( "</li>\n<li>", $errStr ) . "</li></ul>\n" );
225 }
226 $out->addHTML( "</div>\n" );
227 }
228
229 if ( $this->oldTitle->isProtected( 'move' ) ) {
230 # Is the title semi-protected?
231 if ( $this->oldTitle->isSemiProtected( 'move' ) ) {
232 $noticeMsg = 'semiprotectedpagemovewarning';
233 $classes[] = 'mw-textarea-sprotected';
234 } else {
235 # Then it must be protected based on static groups (regular)
236 $noticeMsg = 'protectedpagemovewarning';
237 $classes[] = 'mw-textarea-protected';
238 }
239 $out->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
240 $out->addWikiMsg( $noticeMsg );
241 LogEventsList::showLogExtract( $out, 'protect', $this->oldTitle, '', array( 'lim' => 1 ) );
242 $out->addHTML( "</div>\n" );
243 }
244
245 // Byte limit (not string length limit) for wpReason and wpNewTitleMain
246 // is enforced in the mediawiki.special.movePage module
247
248 $immovableNamespaces = array();
249
250 foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) {
251 if ( !MWNamespace::isMovable( $nsId ) ) {
252 $immovableNamespaces[] = $nsId;
253 }
254 }
255
256 $handler = ContentHandler::getForTitle( $this->oldTitle );
257
258 $out->addHTML(
259 Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL( 'action=submit' ), 'id' => 'movepage' ) ) .
260 Xml::openElement( 'fieldset' ) .
261 Xml::element( 'legend', null, $this->msg( 'move-page-legend' )->text() ) .
262 Xml::openElement( 'table', array( 'id' => 'mw-movepage-table' ) ) .
263 "<tr>
264 <td class='mw-label'>" .
265 $this->msg( 'movearticle' )->escaped() .
266 "</td>
267 <td class='mw-input'>
268 <strong>{$oldTitleLink}</strong>
269 </td>
270 </tr>
271 <tr>
272 <td class='mw-label'>" .
273 Xml::label( $this->msg( 'newtitle' )->text(), 'wpNewTitleMain' ) .
274 "</td>
275 <td class='mw-input'>" .
276 Html::namespaceSelector(
277 array(
278 'selected' => $newTitle->getNamespace(),
279 'exclude' => $immovableNamespaces
280 ),
281 array( 'name' => 'wpNewTitleNs', 'id' => 'wpNewTitleNs' )
282 ) .
283 Xml::input( 'wpNewTitleMain', 60, $wgContLang->recodeForEdit( $newTitle->getText() ), array(
284 'type' => 'text',
285 'id' => 'wpNewTitleMain',
286 'maxlength' => 255,
287 ) ) .
288 Html::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) .
289 "</td>
290 </tr>
291 <tr>
292 <td class='mw-label'>" .
293 Xml::label( $this->msg( 'movereason' )->text(), 'wpReason' ) .
294 "</td>
295 <td class='mw-input'>" .
296 Html::element( 'textarea', array( 'name' => 'wpReason', 'id' => 'wpReason', 'cols' => 60, 'rows' => 2,
297 'maxlength' => 200 ), $this->reason ) .
298 "</td>
299 </tr>"
300 );
301
302 if( $considerTalk ) {
303 $out->addHTML( "
304 <tr>
305 <td></td>
306 <td class='mw-input'>" .
307 Xml::checkLabel( $this->msg( 'movetalk' )->text(), 'wpMovetalk', 'wpMovetalk', $this->moveTalk ) .
308 "</td>
309 </tr>"
310 );
311 }
312
313 if ( $user->isAllowed( 'suppressredirect' ) && $handler->supportsRedirects() ) {
314 $out->addHTML( "
315 <tr>
316 <td></td>
317 <td class='mw-input' >" .
318 Xml::checkLabel( $this->msg( 'move-leave-redirect' )->text(), 'wpLeaveRedirect',
319 'wpLeaveRedirect', $this->leaveRedirect ) .
320 "</td>
321 </tr>"
322 );
323 }
324
325 if ( $hasRedirects ) {
326 $out->addHTML( "
327 <tr>
328 <td></td>
329 <td class='mw-input' >" .
330 Xml::checkLabel( $this->msg( 'fix-double-redirects' )->text(), 'wpFixRedirects',
331 'wpFixRedirects', $this->fixRedirects ) .
332 "</td>
333 </tr>"
334 );
335 }
336
337 if( $canMoveSubpage ) {
338 $out->addHTML( "
339 <tr>
340 <td></td>
341 <td class=\"mw-input\">" .
342 Xml::check(
343 'wpMovesubpages',
344 # Don't check the box if we only have talk subpages to
345 # move and we aren't moving the talk page.
346 $this->moveSubpages && ( $this->oldTitle->hasSubpages() || $this->moveTalk ),
347 array( 'id' => 'wpMovesubpages' )
348 ) . '&#160;' .
349 Xml::tags( 'label', array( 'for' => 'wpMovesubpages' ),
350 $this->msg(
351 ( $this->oldTitle->hasSubpages()
352 ? 'move-subpages'
353 : 'move-talk-subpages' )
354 )->numParams( $wgMaximumMovedPages )->params( $wgMaximumMovedPages )->parse()
355 ) .
356 "</td>
357 </tr>"
358 );
359 }
360
361 $watchChecked = $user->isLoggedIn() && ( $this->watch || $user->getBoolOption( 'watchmoves' )
362 || $user->isWatched( $this->oldTitle ) );
363 # Don't allow watching if user is not logged in
364 if( $user->isLoggedIn() ) {
365 $out->addHTML( "
366 <tr>
367 <td></td>
368 <td class='mw-input'>" .
369 Xml::checkLabel( $this->msg( 'move-watch' )->text(), 'wpWatch', 'watch', $watchChecked ) .
370 "</td>
371 </tr>");
372 }
373
374 $out->addHTML( "
375 {$confirm}
376 <tr>
377 <td>&#160;</td>
378 <td class='mw-submit'>" .
379 Xml::submitButton( $movepagebtn, array( 'name' => $submitVar ) ) .
380 "</td>
381 </tr>" .
382 Xml::closeElement( 'table' ) .
383 Html::hidden( 'wpEditToken', $user->getEditToken() ) .
384 Xml::closeElement( 'fieldset' ) .
385 Xml::closeElement( 'form' ) .
386 "\n"
387 );
388
389 $this->showLogFragment( $this->oldTitle );
390 $this->showSubpages( $this->oldTitle );
391
392 }
393
394 function doSubmit() {
395 global $wgMaximumMovedPages, $wgFixDoubleRedirects;
396
397 $user = $this->getUser();
398
399 if ( $user->pingLimiter( 'move' ) ) {
400 throw new ThrottledError;
401 }
402
403 $ot = $this->oldTitle;
404 $nt = $this->newTitle;
405
406 # don't allow moving to pages with # in
407 if ( !$nt || $nt->getFragment() != '' ) {
408 $this->showForm( array( array( 'badtitletext' ) ) );
409 return;
410 }
411
412 # Show a warning if the target file exists on a shared repo
413 if ( $nt->getNamespace() == NS_FILE
414 && !( $this->moveOverShared && $user->isAllowed( 'reupload-shared' ) )
415 && !RepoGroup::singleton()->getLocalRepo()->findFile( $nt )
416 && wfFindFile( $nt ) )
417 {
418 $this->showForm( array( array( 'file-exists-sharedrepo' ) ) );
419 return;
420
421 }
422
423 # Delete to make way if requested
424 if ( $this->deleteAndMove ) {
425 $permErrors = $nt->getUserPermissionsErrors( 'delete', $user );
426 if ( count( $permErrors ) ) {
427 # Only show the first error
428 $this->showForm( $permErrors );
429 return;
430 }
431
432 $reason = $this->msg( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
433
434 // Delete an associated image if there is
435 if ( $nt->getNamespace() == NS_FILE ) {
436 $file = wfLocalFile( $nt );
437 if ( $file->exists() ) {
438 $file->delete( $reason, false );
439 }
440 }
441
442 $error = ''; // passed by ref
443 $page = WikiPage::factory( $nt );
444 $deleteStatus = $page->doDeleteArticleReal( $reason, false, 0, true, $error, $user );
445 if ( !$deleteStatus->isGood() ) {
446 $this->showForm( $deleteStatus->getErrorsArray() );
447 return;
448 }
449 }
450
451 $handler = ContentHandler::getForTitle( $ot );
452
453 if ( !$handler->supportsRedirects() ) {
454 $createRedirect = false;
455 } elseif ( $user->isAllowed( 'suppressredirect' ) ) {
456 $createRedirect = $this->leaveRedirect;
457 } else {
458 $createRedirect = true;
459 }
460
461 # Do the actual move.
462 $error = $ot->moveTo( $nt, true, $this->reason, $createRedirect );
463 if ( $error !== true ) {
464 $this->showForm( $error );
465 return;
466 }
467
468 if ( $wgFixDoubleRedirects && $this->fixRedirects ) {
469 DoubleRedirectJob::fixRedirects( 'move', $ot, $nt );
470 }
471
472 $out = $this->getOutput();
473 $out->setPageTitle( $this->msg( 'pagemovedsub' ) );
474
475 $oldLink = Linker::link(
476 $ot,
477 null,
478 array(),
479 array( 'redirect' => 'no' )
480 );
481 $newLink = Linker::linkKnown( $nt );
482 $oldText = $ot->getPrefixedText();
483 $newText = $nt->getPrefixedText();
484
485 if ( $ot->exists() ) {
486 //NOTE: we assume that if the old title exists, it's because it was re-created as
487 // a redirect to the new title. This is not safe, but what we did before was
488 // even worse: we just determined whether a redirect should have been created,
489 // and reported that it was created if it should have, without any checks.
490 // Also note that isRedirect() is unreliable because of bug 37209.
491 $msgName = 'movepage-moved-redirect';
492 } else {
493 $msgName = 'movepage-moved-noredirect';
494 }
495
496 $out->addHTML( $this->msg( 'movepage-moved' )->rawParams( $oldLink,
497 $newLink )->params( $oldText, $newText )->parseAsBlock() );
498 $out->addWikiMsg( $msgName );
499
500 wfRunHooks( 'SpecialMovepageAfterMove', array( &$this, &$ot, &$nt ) );
501
502 # Now we move extra pages we've been asked to move: subpages and talk
503 # pages. First, if the old page or the new page is a talk page, we
504 # can't move any talk pages: cancel that.
505 if( $ot->isTalkPage() || $nt->isTalkPage() ) {
506 $this->moveTalk = false;
507 }
508
509 if ( count( $ot->getUserPermissionsErrors( 'move-subpages', $user ) ) ) {
510 $this->moveSubpages = false;
511 }
512
513 # Next make a list of id's. This might be marginally less efficient
514 # than a more direct method, but this is not a highly performance-cri-
515 # tical code path and readable code is more important here.
516 #
517 # Note: this query works nicely on MySQL 5, but the optimizer in MySQL
518 # 4 might get confused. If so, consider rewriting as a UNION.
519 #
520 # If the target namespace doesn't allow subpages, moving with subpages
521 # would mean that you couldn't move them back in one operation, which
522 # is bad.
523 # @todo FIXME: A specific error message should be given in this case.
524
525 // @todo FIXME: Use Title::moveSubpages() here
526 $dbr = wfGetDB( DB_MASTER );
527 if( $this->moveSubpages && (
528 MWNamespace::hasSubpages( $nt->getNamespace() ) || (
529 $this->moveTalk &&
530 MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
531 )
532 ) ) {
533 $conds = array(
534 'page_title' . $dbr->buildLike( $ot->getDBkey() . '/', $dbr->anyString() )
535 .' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() )
536 );
537 $conds['page_namespace'] = array();
538 if( MWNamespace::hasSubpages( $nt->getNamespace() ) ) {
539 $conds['page_namespace'][] = $ot->getNamespace();
540 }
541 if( $this->moveTalk && MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() ) ) {
542 $conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
543 }
544 } elseif( $this->moveTalk ) {
545 $conds = array(
546 'page_namespace' => $ot->getTalkPage()->getNamespace(),
547 'page_title' => $ot->getDBkey()
548 );
549 } else {
550 # Skip the query
551 $conds = null;
552 }
553
554 $extraPages = array();
555 if( !is_null( $conds ) ) {
556 $extraPages = TitleArray::newFromResult(
557 $dbr->select( 'page',
558 array( 'page_id', 'page_namespace', 'page_title' ),
559 $conds,
560 __METHOD__
561 )
562 );
563 }
564
565 $extraOutput = array();
566 $count = 1;
567 foreach( $extraPages as $oldSubpage ) {
568 if( $ot->equals( $oldSubpage ) ) {
569 # Already did this one.
570 continue;
571 }
572
573 $newPageName = preg_replace(
574 '#^'.preg_quote( $ot->getDBkey(), '#' ).'#',
575 StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # bug 21234
576 $oldSubpage->getDBkey()
577 );
578 if( $oldSubpage->isTalkPage() ) {
579 $newNs = $nt->getTalkPage()->getNamespace();
580 } else {
581 $newNs = $nt->getSubjectPage()->getNamespace();
582 }
583 # Bug 14385: we need makeTitleSafe because the new page names may
584 # be longer than 255 characters.
585 $newSubpage = Title::makeTitleSafe( $newNs, $newPageName );
586 if( !$newSubpage ) {
587 $oldLink = Linker::linkKnown( $oldSubpage );
588 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink
589 )->params( Title::makeName( $newNs, $newPageName ) )->escaped();
590 continue;
591 }
592
593 # This was copy-pasted from Renameuser, bleh.
594 if ( $newSubpage->exists() && !$oldSubpage->isValidMoveTarget( $newSubpage ) ) {
595 $link = Linker::linkKnown( $newSubpage );
596 $extraOutput[] = $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped();
597 } else {
598 $success = $oldSubpage->moveTo( $newSubpage, true, $this->reason, $createRedirect );
599 if( $success === true ) {
600 if ( $this->fixRedirects ) {
601 DoubleRedirectJob::fixRedirects( 'move', $oldSubpage, $newSubpage );
602 }
603 $oldLink = Linker::link(
604 $oldSubpage,
605 null,
606 array(),
607 array( 'redirect' => 'no' )
608 );
609 $newLink = Linker::linkKnown( $newSubpage );
610 $extraOutput[] = $this->msg( 'movepage-page-moved' )->rawParams( $oldLink, $newLink )->escaped();
611 ++$count;
612 if( $count >= $wgMaximumMovedPages ) {
613 $extraOutput[] = $this->msg( 'movepage-max-pages' )->numParams( $wgMaximumMovedPages )->escaped();
614 break;
615 }
616 } else {
617 $oldLink = Linker::linkKnown( $oldSubpage );
618 $newLink = Linker::link( $newSubpage );
619 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink, $newLink )->escaped();
620 }
621 }
622
623 }
624
625 if( $extraOutput !== array() ) {
626 $out->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $extraOutput ) . "</li>\n</ul>" );
627 }
628
629 # Deal with watches (we don't watch subpages)
630 if( $this->watch && $user->isLoggedIn() ) {
631 $user->addWatch( $ot );
632 $user->addWatch( $nt );
633 } else {
634 $user->removeWatch( $ot );
635 $user->removeWatch( $nt );
636 }
637
638 # Re-clear the file redirect cache, which may have been polluted by
639 # parsing in messages above. See CR r56745.
640 # @todo FIXME: Needs a more robust solution inside FileRepo.
641 if( $ot->getNamespace() == NS_FILE ) {
642 RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $ot );
643 }
644 }
645
646 function showLogFragment( $title ) {
647 $moveLogPage = new LogPage( 'move' );
648 $out = $this->getOutput();
649 $out->addHTML( Xml::element( 'h2', null, $moveLogPage->getName()->text() ) );
650 LogEventsList::showLogExtract( $out, 'move', $title );
651 }
652
653 function showSubpages( $title ) {
654 if( !MWNamespace::hasSubpages( $title->getNamespace() ) )
655 return;
656
657 $subpages = $title->getSubpages();
658 $count = $subpages instanceof TitleArray ? $subpages->count() : 0;
659
660 $out = $this->getOutput();
661 $out->wrapWikiMsg( '== $1 ==', array( 'movesubpage', $count ) );
662
663 # No subpages.
664 if ( $count == 0 ) {
665 $out->addWikiMsg( 'movenosubpage' );
666 return;
667 }
668
669 $out->addWikiMsg( 'movesubpagetext', $this->getLanguage()->formatNum( $count ) );
670 $out->addHTML( "<ul>\n" );
671
672 foreach( $subpages as $subpage ) {
673 $link = Linker::link( $subpage );
674 $out->addHTML( "<li>$link</li>\n" );
675 }
676 $out->addHTML( "</ul>\n" );
677 }
678
679 protected function getGroupName() {
680 return 'pagetools';
681 }
682 }