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