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