Merge "Fix border-radii on FilterTagMultiselectWidget"
[lhc/web/wiklou.git] / includes / specials / SpecialContributions.php
1 <?php
2 /**
3 * Implements Special:Contributions
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 use MediaWiki\Widget\DateInputWidget;
25
26 /**
27 * Special:Contributions, show user contributions in a paged list
28 *
29 * @ingroup SpecialPage
30 */
31 class SpecialContributions extends IncludableSpecialPage {
32 protected $opts;
33
34 public function __construct() {
35 parent::__construct( 'Contributions' );
36 }
37
38 public function execute( $par ) {
39 $this->setHeaders();
40 $this->outputHeader();
41 $out = $this->getOutput();
42 $out->addModuleStyles( [
43 'mediawiki.special',
44 'mediawiki.special.changeslist',
45 'mediawiki.widgets.DateInputWidget.styles',
46 ] );
47 $out->addModules( 'mediawiki.special.contributions' );
48 $this->addHelpLink( 'Help:User contributions' );
49 $out->enableOOUI();
50
51 $this->opts = [];
52 $request = $this->getRequest();
53
54 if ( $par !== null ) {
55 $target = $par;
56 } else {
57 $target = $request->getVal( 'target' );
58 }
59
60 if ( $request->getVal( 'contribs' ) == 'newbie' || $par === 'newbies' ) {
61 $target = 'newbies';
62 $this->opts['contribs'] = 'newbie';
63 } else {
64 $this->opts['contribs'] = 'user';
65 }
66
67 $this->opts['deletedOnly'] = $request->getBool( 'deletedOnly' );
68
69 if ( !strlen( $target ) ) {
70 if ( !$this->including() ) {
71 $out->addHTML( $this->getForm() );
72 }
73
74 return;
75 }
76
77 $user = $this->getUser();
78
79 $this->opts['limit'] = $request->getInt( 'limit', $user->getOption( 'rclimit' ) );
80 $this->opts['target'] = $target;
81 $this->opts['topOnly'] = $request->getBool( 'topOnly' );
82 $this->opts['newOnly'] = $request->getBool( 'newOnly' );
83 $this->opts['hideMinor'] = $request->getBool( 'hideMinor' );
84
85 $nt = Title::makeTitleSafe( NS_USER, $target );
86 if ( !$nt ) {
87 $out->addHTML( $this->getForm() );
88
89 return;
90 }
91 $userObj = User::newFromName( $nt->getText(), false );
92 if ( !$userObj ) {
93 $out->addHTML( $this->getForm() );
94
95 return;
96 }
97 $id = $userObj->getId();
98
99 if ( $this->opts['contribs'] != 'newbie' ) {
100 $target = $nt->getText();
101 $out->addSubtitle( $this->contributionsSub( $userObj ) );
102 $out->setHTMLTitle( $this->msg(
103 'pagetitle',
104 $this->msg( 'contributions-title', $target )->plain()
105 )->inContentLanguage() );
106 $this->getSkin()->setRelevantUser( $userObj );
107 } else {
108 $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
109 $out->setHTMLTitle( $this->msg(
110 'pagetitle',
111 $this->msg( 'sp-contributions-newbies-title' )->plain()
112 )->inContentLanguage() );
113 }
114
115 $ns = $request->getVal( 'namespace', null );
116 if ( $ns !== null && $ns !== '' ) {
117 $this->opts['namespace'] = intval( $ns );
118 } else {
119 $this->opts['namespace'] = '';
120 }
121
122 $this->opts['associated'] = $request->getBool( 'associated' );
123 $this->opts['nsInvert'] = (bool)$request->getVal( 'nsInvert' );
124 $this->opts['tagfilter'] = (string)$request->getVal( 'tagfilter' );
125
126 // Allows reverts to have the bot flag in recent changes. It is just here to
127 // be passed in the form at the top of the page
128 if ( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) {
129 $this->opts['bot'] = '1';
130 }
131
132 $skip = $request->getText( 'offset' ) || $request->getText( 'dir' ) == 'prev';
133 # Offset overrides year/month selection
134 if ( $skip ) {
135 $this->opts['year'] = '';
136 $this->opts['month'] = '';
137 } else {
138 $this->opts['year'] = $request->getVal( 'year' );
139 $this->opts['month'] = $request->getVal( 'month' );
140
141 $this->opts['start'] = $request->getVal( 'start' );
142 $this->opts['end'] = $request->getVal( 'end' );
143 $this->opts = ContribsPager::processDateFilter( $this->opts );
144 }
145
146 $feedType = $request->getVal( 'feed' );
147
148 $feedParams = [
149 'action' => 'feedcontributions',
150 'user' => $target,
151 ];
152 if ( $this->opts['topOnly'] ) {
153 $feedParams['toponly'] = true;
154 }
155 if ( $this->opts['newOnly'] ) {
156 $feedParams['newonly'] = true;
157 }
158 if ( $this->opts['hideMinor'] ) {
159 $feedParams['hideminor'] = true;
160 }
161 if ( $this->opts['deletedOnly'] ) {
162 $feedParams['deletedonly'] = true;
163 }
164 if ( $this->opts['tagfilter'] !== '' ) {
165 $feedParams['tagfilter'] = $this->opts['tagfilter'];
166 }
167 if ( $this->opts['namespace'] !== '' ) {
168 $feedParams['namespace'] = $this->opts['namespace'];
169 }
170 // Don't use year and month for the feed URL, but pass them on if
171 // we redirect to API (if $feedType is specified)
172 if ( $feedType && $this->opts['year'] !== null ) {
173 $feedParams['year'] = $this->opts['year'];
174 }
175 if ( $feedType && $this->opts['month'] !== null ) {
176 $feedParams['month'] = $this->opts['month'];
177 }
178
179 if ( $feedType ) {
180 // Maintain some level of backwards compatibility
181 // If people request feeds using the old parameters, redirect to API
182 $feedParams['feedformat'] = $feedType;
183 $url = wfAppendQuery( wfScript( 'api' ), $feedParams );
184
185 $out->redirect( $url, '301' );
186
187 return;
188 }
189
190 // Add RSS/atom links
191 $this->addFeedLinks( $feedParams );
192
193 if ( Hooks::run( 'SpecialContributionsBeforeMainOutput', [ $id, $userObj, $this ] ) ) {
194 if ( !$this->including() ) {
195 $out->addHTML( $this->getForm() );
196 }
197 $pager = new ContribsPager( $this->getContext(), [
198 'target' => $target,
199 'contribs' => $this->opts['contribs'],
200 'namespace' => $this->opts['namespace'],
201 'tagfilter' => $this->opts['tagfilter'],
202 'start' => $this->opts['start'],
203 'end' => $this->opts['end'],
204 'deletedOnly' => $this->opts['deletedOnly'],
205 'topOnly' => $this->opts['topOnly'],
206 'newOnly' => $this->opts['newOnly'],
207 'hideMinor' => $this->opts['hideMinor'],
208 'nsInvert' => $this->opts['nsInvert'],
209 'associated' => $this->opts['associated'],
210 ] );
211
212 if ( !$pager->getNumRows() ) {
213 $out->addWikiMsg( 'nocontribs', $target );
214 } else {
215 # Show a message about replica DB lag, if applicable
216 $lag = wfGetLB()->safeGetLag( $pager->getDatabase() );
217 if ( $lag > 0 ) {
218 $out->showLagWarning( $lag );
219 }
220
221 $output = $pager->getBody();
222 if ( !$this->including() ) {
223 $output = '<p>' . $pager->getNavigationBar() . '</p>' .
224 $output .
225 '<p>' . $pager->getNavigationBar() . '</p>';
226 }
227 $out->addHTML( $output );
228 }
229 $out->preventClickjacking( $pager->getPreventClickjacking() );
230
231 # Show the appropriate "footer" message - WHOIS tools, etc.
232 if ( $this->opts['contribs'] == 'newbie' ) {
233 $message = 'sp-contributions-footer-newbies';
234 } elseif ( IP::isIPAddress( $target ) ) {
235 $message = 'sp-contributions-footer-anon';
236 } elseif ( $userObj->isAnon() ) {
237 // No message for non-existing users
238 $message = '';
239 } else {
240 $message = 'sp-contributions-footer';
241 }
242
243 if ( $message ) {
244 if ( !$this->including() ) {
245 if ( !$this->msg( $message, $target )->isDisabled() ) {
246 $out->wrapWikiMsg(
247 "<div class='mw-contributions-footer'>\n$1\n</div>",
248 [ $message, $target ] );
249 }
250 }
251 }
252 }
253 }
254
255 /**
256 * Generates the subheading with links
257 * @param User $userObj User object for the target
258 * @return string Appropriately-escaped HTML to be output literally
259 * @todo FIXME: Almost the same as getSubTitle in SpecialDeletedContributions.php.
260 * Could be combined.
261 */
262 protected function contributionsSub( $userObj ) {
263 if ( $userObj->isAnon() ) {
264 // Show a warning message that the user being searched for doesn't exists
265 if ( !User::isIP( $userObj->getName() ) ) {
266 $this->getOutput()->wrapWikiMsg(
267 "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
268 [
269 'contributions-userdoesnotexist',
270 wfEscapeWikiText( $userObj->getName() ),
271 ]
272 );
273 if ( !$this->including() ) {
274 $this->getOutput()->setStatusCode( 404 );
275 }
276 }
277 $user = htmlspecialchars( $userObj->getName() );
278 } else {
279 $user = $this->getLinkRenderer()->makeLink( $userObj->getUserPage(), $userObj->getName() );
280 }
281 $nt = $userObj->getUserPage();
282 $talk = $userObj->getTalkPage();
283 $links = '';
284 if ( $talk ) {
285 $tools = self::getUserLinks( $this, $userObj );
286 $links = $this->getLanguage()->pipeList( $tools );
287
288 // Show a note if the user is blocked and display the last block log entry.
289 // Do not expose the autoblocks, since that may lead to a leak of accounts' IPs,
290 // and also this will display a totally irrelevant log entry as a current block.
291 if ( !$this->including() ) {
292 $block = Block::newFromTarget( $userObj, $userObj );
293 if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
294 if ( $block->getType() == Block::TYPE_RANGE ) {
295 $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
296 }
297
298 $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
299 LogEventsList::showLogExtract(
300 $out,
301 'block',
302 $nt,
303 '',
304 [
305 'lim' => 1,
306 'showIfEmpty' => false,
307 'msgKey' => [
308 $userObj->isAnon() ?
309 'sp-contributions-blocked-notice-anon' :
310 'sp-contributions-blocked-notice',
311 $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
312 ],
313 'offset' => '' # don't use WebRequest parameter offset
314 ]
315 );
316 }
317 }
318 }
319
320 return $this->msg( 'contribsub2' )->rawParams( $user, $links )->params( $userObj->getName() );
321 }
322
323 /**
324 * Links to different places.
325 *
326 * @note This function is also called in DeletedContributionsPage
327 * @param SpecialPage $sp SpecialPage instance, for context
328 * @param User $target Target user object
329 * @return array
330 */
331 public static function getUserLinks( SpecialPage $sp, User $target ) {
332
333 $id = $target->getId();
334 $username = $target->getName();
335 $userpage = $target->getUserPage();
336 $talkpage = $target->getTalkPage();
337
338 $linkRenderer = $sp->getLinkRenderer();
339 $tools['user-talk'] = $linkRenderer->makeLink(
340 $talkpage,
341 $sp->msg( 'sp-contributions-talk' )->text()
342 );
343
344 if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
345 if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
346 if ( $target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO ) {
347 $tools['block'] = $linkRenderer->makeKnownLink( # Change block link
348 SpecialPage::getTitleFor( 'Block', $username ),
349 $sp->msg( 'change-blocklink' )->text()
350 );
351 $tools['unblock'] = $linkRenderer->makeKnownLink( # Unblock link
352 SpecialPage::getTitleFor( 'Unblock', $username ),
353 $sp->msg( 'unblocklink' )->text()
354 );
355 } else { # User is not blocked
356 $tools['block'] = $linkRenderer->makeKnownLink( # Block link
357 SpecialPage::getTitleFor( 'Block', $username ),
358 $sp->msg( 'blocklink' )->text()
359 );
360 }
361 }
362
363 # Block log link
364 $tools['log-block'] = $linkRenderer->makeKnownLink(
365 SpecialPage::getTitleFor( 'Log', 'block' ),
366 $sp->msg( 'sp-contributions-blocklog' )->text(),
367 [],
368 [ 'page' => $userpage->getPrefixedText() ]
369 );
370
371 # Suppression log link (T61120)
372 if ( $sp->getUser()->isAllowed( 'suppressionlog' ) ) {
373 $tools['log-suppression'] = $linkRenderer->makeKnownLink(
374 SpecialPage::getTitleFor( 'Log', 'suppress' ),
375 $sp->msg( 'sp-contributions-suppresslog', $username )->text(),
376 [],
377 [ 'offender' => $username ]
378 );
379 }
380 }
381 # Uploads
382 $tools['uploads'] = $linkRenderer->makeKnownLink(
383 SpecialPage::getTitleFor( 'Listfiles', $username ),
384 $sp->msg( 'sp-contributions-uploads' )->text()
385 );
386
387 # Other logs link
388 $tools['logs'] = $linkRenderer->makeKnownLink(
389 SpecialPage::getTitleFor( 'Log', $username ),
390 $sp->msg( 'sp-contributions-logs' )->text()
391 );
392
393 # Add link to deleted user contributions for priviledged users
394 if ( $sp->getUser()->isAllowed( 'deletedhistory' ) ) {
395 $tools['deletedcontribs'] = $linkRenderer->makeKnownLink(
396 SpecialPage::getTitleFor( 'DeletedContributions', $username ),
397 $sp->msg( 'sp-contributions-deleted', $username )->text()
398 );
399 }
400
401 # Add a link to change user rights for privileged users
402 $userrightsPage = new UserrightsPage();
403 $userrightsPage->setContext( $sp->getContext() );
404 if ( $userrightsPage->userCanChangeRights( $target ) ) {
405 $tools['userrights'] = $linkRenderer->makeKnownLink(
406 SpecialPage::getTitleFor( 'Userrights', $username ),
407 $sp->msg( 'sp-contributions-userrights', $username )->text()
408 );
409 }
410
411 Hooks::run( 'ContributionsToolLinks', [ $id, $userpage, &$tools, $sp ] );
412
413 return $tools;
414 }
415
416 /**
417 * Generates the namespace selector form with hidden attributes.
418 * @return string HTML fragment
419 */
420 protected function getForm() {
421 $this->opts['title'] = $this->getPageTitle()->getPrefixedText();
422 if ( !isset( $this->opts['target'] ) ) {
423 $this->opts['target'] = '';
424 } else {
425 $this->opts['target'] = str_replace( '_', ' ', $this->opts['target'] );
426 }
427
428 if ( !isset( $this->opts['namespace'] ) ) {
429 $this->opts['namespace'] = '';
430 }
431
432 if ( !isset( $this->opts['nsInvert'] ) ) {
433 $this->opts['nsInvert'] = '';
434 }
435
436 if ( !isset( $this->opts['associated'] ) ) {
437 $this->opts['associated'] = false;
438 }
439
440 if ( !isset( $this->opts['contribs'] ) ) {
441 $this->opts['contribs'] = 'user';
442 }
443
444 if ( !isset( $this->opts['start'] ) ) {
445 $this->opts['start'] = '';
446 }
447
448 if ( !isset( $this->opts['end'] ) ) {
449 $this->opts['end'] = '';
450 }
451
452 if ( $this->opts['contribs'] == 'newbie' ) {
453 $this->opts['target'] = '';
454 }
455
456 if ( !isset( $this->opts['tagfilter'] ) ) {
457 $this->opts['tagfilter'] = '';
458 }
459
460 if ( !isset( $this->opts['topOnly'] ) ) {
461 $this->opts['topOnly'] = false;
462 }
463
464 if ( !isset( $this->opts['newOnly'] ) ) {
465 $this->opts['newOnly'] = false;
466 }
467
468 if ( !isset( $this->opts['hideMinor'] ) ) {
469 $this->opts['hideMinor'] = false;
470 }
471
472 $form = Html::openElement(
473 'form',
474 [
475 'method' => 'get',
476 'action' => wfScript(),
477 'class' => 'mw-contributions-form'
478 ]
479 );
480
481 # Add hidden params for tracking except for parameters in $skipParameters
482 $skipParameters = [
483 'namespace',
484 'nsInvert',
485 'deletedOnly',
486 'target',
487 'contribs',
488 'year',
489 'month',
490 'start',
491 'end',
492 'topOnly',
493 'newOnly',
494 'hideMinor',
495 'associated',
496 'tagfilter'
497 ];
498
499 foreach ( $this->opts as $name => $value ) {
500 if ( in_array( $name, $skipParameters ) ) {
501 continue;
502 }
503 $form .= "\t" . Html::hidden( $name, $value ) . "\n";
504 }
505
506 $tagFilter = ChangeTags::buildTagFilterSelector(
507 $this->opts['tagfilter'], false, $this->getContext() );
508
509 if ( $tagFilter ) {
510 $filterSelection = Html::rawElement(
511 'div',
512 [],
513 implode( '&#160;', $tagFilter )
514 );
515 } else {
516 $filterSelection = Html::rawElement( 'div', [], '' );
517 }
518
519 $this->getOutput()->addModules( 'mediawiki.userSuggest' );
520
521 $labelNewbies = Xml::radioLabel(
522 $this->msg( 'sp-contributions-newbies' )->text(),
523 'contribs',
524 'newbie',
525 'newbie',
526 $this->opts['contribs'] == 'newbie',
527 [ 'class' => 'mw-input' ]
528 );
529 $labelUsername = Xml::radioLabel(
530 $this->msg( 'sp-contributions-username' )->text(),
531 'contribs',
532 'user',
533 'user',
534 $this->opts['contribs'] == 'user',
535 [ 'class' => 'mw-input' ]
536 );
537 $input = Html::input(
538 'target',
539 $this->opts['target'],
540 'text',
541 [
542 'size' => '40',
543 'class' => [
544 'mw-input',
545 'mw-ui-input-inline',
546 'mw-autocomplete-user', // used by mediawiki.userSuggest
547 ],
548 ] + (
549 // Only autofocus if target hasn't been specified or in non-newbies mode
550 ( $this->opts['contribs'] === 'newbie' || $this->opts['target'] )
551 ? [] : [ 'autofocus' => true ]
552 )
553 );
554
555 $targetSelection = Html::rawElement(
556 'div',
557 [],
558 $labelNewbies . '<br>' . $labelUsername . ' ' . $input . ' '
559 );
560
561 $namespaceSelection = Xml::tags(
562 'div',
563 [],
564 Xml::label(
565 $this->msg( 'namespace' )->text(),
566 'namespace',
567 ''
568 ) . '&#160;' .
569 Html::namespaceSelector(
570 [ 'selected' => $this->opts['namespace'], 'all' => '' ],
571 [
572 'name' => 'namespace',
573 'id' => 'namespace',
574 'class' => 'namespaceselector',
575 ]
576 ) . '&#160;' .
577 Html::rawElement(
578 'span',
579 [ 'class' => 'mw-input-with-label' ],
580 Xml::checkLabel(
581 $this->msg( 'invert' )->text(),
582 'nsInvert',
583 'nsInvert',
584 $this->opts['nsInvert'],
585 [
586 'title' => $this->msg( 'tooltip-invert' )->text(),
587 'class' => 'mw-input'
588 ]
589 ) . '&#160;'
590 ) .
591 Html::rawElement( 'span', [ 'class' => 'mw-input-with-label' ],
592 Xml::checkLabel(
593 $this->msg( 'namespace_association' )->text(),
594 'associated',
595 'associated',
596 $this->opts['associated'],
597 [
598 'title' => $this->msg( 'tooltip-namespace_association' )->text(),
599 'class' => 'mw-input'
600 ]
601 ) . '&#160;'
602 )
603 );
604
605 $filters = [];
606
607 if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
608 $filters[] = Html::rawElement(
609 'span',
610 [ 'class' => 'mw-input-with-label' ],
611 Xml::checkLabel(
612 $this->msg( 'history-show-deleted' )->text(),
613 'deletedOnly',
614 'mw-show-deleted-only',
615 $this->opts['deletedOnly'],
616 [ 'class' => 'mw-input' ]
617 )
618 );
619 }
620
621 $filters[] = Html::rawElement(
622 'span',
623 [ 'class' => 'mw-input-with-label' ],
624 Xml::checkLabel(
625 $this->msg( 'sp-contributions-toponly' )->text(),
626 'topOnly',
627 'mw-show-top-only',
628 $this->opts['topOnly'],
629 [ 'class' => 'mw-input' ]
630 )
631 );
632 $filters[] = Html::rawElement(
633 'span',
634 [ 'class' => 'mw-input-with-label' ],
635 Xml::checkLabel(
636 $this->msg( 'sp-contributions-newonly' )->text(),
637 'newOnly',
638 'mw-show-new-only',
639 $this->opts['newOnly'],
640 [ 'class' => 'mw-input' ]
641 )
642 );
643 $filters[] = Html::rawElement(
644 'span',
645 [ 'class' => 'mw-input-with-label' ],
646 Xml::checkLabel(
647 $this->msg( 'sp-contributions-hideminor' )->text(),
648 'hideMinor',
649 'mw-hide-minor-edits',
650 $this->opts['hideMinor'],
651 [ 'class' => 'mw-input' ]
652 )
653 );
654
655 Hooks::run(
656 'SpecialContributions::getForm::filters',
657 [ $this, &$filters ]
658 );
659
660 $extraOptions = Html::rawElement(
661 'div',
662 [],
663 implode( '', $filters )
664 );
665
666 $dateRangeSelection = Html::rawElement(
667 'div',
668 [],
669 Xml::label( wfMessage( 'date-range-from' )->text(), 'mw-date-start' ) . ' ' .
670 new DateInputWidget( [
671 'infusable' => true,
672 'id' => 'mw-date-start',
673 'name' => 'start',
674 'value' => $this->opts['start'],
675 'longDisplayFormat' => true,
676 ] ) . '<br>' .
677 Xml::label( wfMessage( 'date-range-to' )->text(), 'mw-date-end' ) . ' ' .
678 new DateInputWidget( [
679 'infusable' => true,
680 'id' => 'mw-date-end',
681 'name' => 'end',
682 'value' => $this->opts['end'],
683 'longDisplayFormat' => true,
684 ] )
685 );
686
687 $submit = Xml::tags( 'div', [],
688 Html::submitButton(
689 $this->msg( 'sp-contributions-submit' )->text(),
690 [ 'class' => 'mw-submit' ], [ 'mw-ui-progressive' ]
691 )
692 );
693
694 $form .= Xml::fieldset(
695 $this->msg( 'sp-contributions-search' )->text(),
696 $targetSelection .
697 $namespaceSelection .
698 $filterSelection .
699 $extraOptions .
700 $dateRangeSelection .
701 $submit,
702 [ 'class' => 'mw-contributions-table' ]
703 );
704
705 $explain = $this->msg( 'sp-contributions-explain' );
706 if ( !$explain->isBlank() ) {
707 $form .= "<p id='mw-sp-contributions-explain'>{$explain->parse()}</p>";
708 }
709
710 $form .= Xml::closeElement( 'form' );
711
712 return $form;
713 }
714
715 /**
716 * Return an array of subpages beginning with $search that this special page will accept.
717 *
718 * @param string $search Prefix to search for
719 * @param int $limit Maximum number of results to return (usually 10)
720 * @param int $offset Number of results to skip (usually 0)
721 * @return string[] Matching subpages
722 */
723 public function prefixSearchSubpages( $search, $limit, $offset ) {
724 $user = User::newFromName( $search );
725 if ( !$user ) {
726 // No prefix suggestion for invalid user
727 return [];
728 }
729 // Autocomplete subpage as user list - public to allow caching
730 return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
731 }
732
733 protected function getGroupName() {
734 return 'users';
735 }
736 }