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