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