MediaWiki REL1_33
SpecialContributions.php
Go to the documentation of this file.
1<?php
25
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 // Modules required for viewing the list of contributions (also when included on other pages)
43 $out->addModuleStyles( [
44 'mediawiki.interface.helpers.styles',
45 'mediawiki.special',
46 'mediawiki.special.changeslist',
47 ] );
48 $out->addModules( 'mediawiki.special.recentchanges' );
49 $this->addHelpLink( 'Help:User contributions' );
50
51 $this->opts = [];
52 $request = $this->getRequest();
53
54 $target = $par ?? $request->getVal( 'target' );
55
56 if ( $request->getVal( 'contribs' ) == 'newbie' || $par === 'newbies' ) {
57 $target = 'newbies';
58 $this->opts['contribs'] = 'newbie';
59 } else {
60 $this->opts['contribs'] = 'user';
61 }
62
63 $this->opts['deletedOnly'] = $request->getBool( 'deletedOnly' );
64
65 if ( !strlen( $target ) ) {
66 if ( !$this->including() ) {
67 $out->addHTML( $this->getForm() );
68 }
69
70 return;
71 }
72
73 $user = $this->getUser();
74
75 $this->opts['limit'] = $request->getInt( 'limit', $user->getOption( 'rclimit' ) );
76 $this->opts['target'] = $target;
77 $this->opts['topOnly'] = $request->getBool( 'topOnly' );
78 $this->opts['newOnly'] = $request->getBool( 'newOnly' );
79 $this->opts['hideMinor'] = $request->getBool( 'hideMinor' );
80
81 $id = 0;
82 if ( $this->opts['contribs'] === 'newbie' ) {
83 $userObj = User::newFromName( $target ); // hysterical raisins
84 $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
85 $out->setHTMLTitle( $this->msg(
86 'pagetitle',
87 $this->msg( 'sp-contributions-newbies-title' )->plain()
88 )->inContentLanguage() );
89 } elseif ( ExternalUserNames::isExternal( $target ) ) {
90 $userObj = User::newFromName( $target, false );
91 if ( !$userObj ) {
92 $out->addHTML( $this->getForm() );
93 return;
94 }
95
96 $out->addSubtitle( $this->contributionsSub( $userObj ) );
97 $out->setHTMLTitle( $this->msg(
98 'pagetitle',
99 $this->msg( 'contributions-title', $target )->plain()
100 )->inContentLanguage() );
101 } else {
102 $nt = Title::makeTitleSafe( NS_USER, $target );
103 if ( !$nt ) {
104 $out->addHTML( $this->getForm() );
105 return;
106 }
107 $userObj = User::newFromName( $nt->getText(), false );
108 if ( !$userObj ) {
109 $out->addHTML( $this->getForm() );
110 return;
111 }
112 $id = $userObj->getId();
113
114 $target = $nt->getText();
115 $out->addSubtitle( $this->contributionsSub( $userObj ) );
116 $out->setHTMLTitle( $this->msg(
117 'pagetitle',
118 $this->msg( 'contributions-title', $target )->plain()
119 )->inContentLanguage() );
120
121 # For IP ranges, we want the contributionsSub, but not the skin-dependent
122 # links under 'Tools', which may include irrelevant links like 'Logs'.
123 if ( !IP::isValidRange( $target ) ) {
124 $this->getSkin()->setRelevantUser( $userObj );
125 }
126 }
127
128 $ns = $request->getVal( 'namespace', null );
129 if ( $ns !== null && $ns !== '' ) {
130 $this->opts['namespace'] = intval( $ns );
131 } else {
132 $this->opts['namespace'] = '';
133 }
134
135 $this->opts['associated'] = $request->getBool( 'associated' );
136 $this->opts['nsInvert'] = (bool)$request->getVal( 'nsInvert' );
137 $this->opts['tagfilter'] = (string)$request->getVal( 'tagfilter' );
138
139 // Allows reverts to have the bot flag in recent changes. It is just here to
140 // be passed in the form at the top of the page
141 if ( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) {
142 $this->opts['bot'] = '1';
143 }
144
145 $skip = $request->getText( 'offset' ) || $request->getText( 'dir' ) == 'prev';
146 # Offset overrides year/month selection
147 if ( !$skip ) {
148 $this->opts['year'] = $request->getVal( 'year' );
149 $this->opts['month'] = $request->getVal( 'month' );
150
151 $this->opts['start'] = $request->getVal( 'start' );
152 $this->opts['end'] = $request->getVal( 'end' );
153 }
154 $this->opts = ContribsPager::processDateFilter( $this->opts );
155
156 if ( $this->opts['namespace'] < NS_MAIN ) {
157 $this->getOutput()->wrapWikiMsg(
158 "<div class=\"mw-negative-namespace-not-supported error\">\n\$1\n</div>",
159 [ 'negative-namespace-not-supported' ]
160 );
161 $out->addHTML( $this->getForm() );
162 return;
163 }
164
165 $feedType = $request->getVal( 'feed' );
166
167 $feedParams = [
168 'action' => 'feedcontributions',
169 'user' => $target,
170 ];
171 if ( $this->opts['topOnly'] ) {
172 $feedParams['toponly'] = true;
173 }
174 if ( $this->opts['newOnly'] ) {
175 $feedParams['newonly'] = true;
176 }
177 if ( $this->opts['hideMinor'] ) {
178 $feedParams['hideminor'] = true;
179 }
180 if ( $this->opts['deletedOnly'] ) {
181 $feedParams['deletedonly'] = true;
182 }
183 if ( $this->opts['tagfilter'] !== '' ) {
184 $feedParams['tagfilter'] = $this->opts['tagfilter'];
185 }
186 if ( $this->opts['namespace'] !== '' ) {
187 $feedParams['namespace'] = $this->opts['namespace'];
188 }
189 // Don't use year and month for the feed URL, but pass them on if
190 // we redirect to API (if $feedType is specified)
191 if ( $feedType && $this->opts['year'] !== null ) {
192 $feedParams['year'] = $this->opts['year'];
193 }
194 if ( $feedType && $this->opts['month'] !== null ) {
195 $feedParams['month'] = $this->opts['month'];
196 }
197
198 if ( $feedType ) {
199 // Maintain some level of backwards compatibility
200 // If people request feeds using the old parameters, redirect to API
201 $feedParams['feedformat'] = $feedType;
202 $url = wfAppendQuery( wfScript( 'api' ), $feedParams );
203
204 $out->redirect( $url, '301' );
205
206 return;
207 }
208
209 // Add RSS/atom links
210 $this->addFeedLinks( $feedParams );
211
212 if ( Hooks::run( 'SpecialContributionsBeforeMainOutput', [ $id, $userObj, $this ] ) ) {
213 if ( !$this->including() ) {
214 $out->addHTML( $this->getForm() );
215 }
216 $pager = new ContribsPager( $this->getContext(), [
217 'target' => $target,
218 'contribs' => $this->opts['contribs'],
219 'namespace' => $this->opts['namespace'],
220 'tagfilter' => $this->opts['tagfilter'],
221 'start' => $this->opts['start'],
222 'end' => $this->opts['end'],
223 'deletedOnly' => $this->opts['deletedOnly'],
224 'topOnly' => $this->opts['topOnly'],
225 'newOnly' => $this->opts['newOnly'],
226 'hideMinor' => $this->opts['hideMinor'],
227 'nsInvert' => $this->opts['nsInvert'],
228 'associated' => $this->opts['associated'],
229 ] );
230
231 if ( IP::isValidRange( $target ) && !$pager->isQueryableRange( $target ) ) {
232 // Valid range, but outside CIDR limit.
233 $limits = $this->getConfig()->get( 'RangeContributionsCIDRLimit' );
234 $limit = $limits[ IP::isIPv4( $target ) ? 'IPv4' : 'IPv6' ];
235 $out->addWikiMsg( 'sp-contributions-outofrange', $limit );
236 } elseif ( !$pager->getNumRows() ) {
237 $out->addWikiMsg( 'nocontribs', $target );
238 } else {
239 // @todo We just want a wiki ID here, not a "DB domain", but
240 // current status of MediaWiki conflates the two. See T235955.
241 $poolKey = WikiMap::getCurrentWikiDbDomain() . ':SpecialContributions:';
242 if ( $this->getUser()->isAnon() ) {
243 $poolKey .= 'a:' . $this->getUser()->getName();
244 } else {
245 $poolKey .= 'u:' . $this->getUser()->getId();
246 }
247 $work = new PoolCounterWorkViaCallback( 'SpecialContributions', $poolKey, [
248 'doWork' => function () use ( $pager, $out ) {
249 # Show a message about replica DB lag, if applicable
250 $lag = $pager->getDatabase()->getSessionLagStatus()['lag'];
251 if ( $lag > 0 ) {
252 $out->showLagWarning( $lag );
253 }
254
255 $output = $pager->getBody();
256 if ( !$this->including() ) {
257 $output = $pager->getNavigationBar() .
258 $output .
259 $pager->getNavigationBar();
260 }
261 $out->addHTML( $output );
262 },
263 'error' => function () use ( $out ) {
264 $msg = $this->getUser()->isAnon()
265 ? 'sp-contributions-concurrency-ip'
266 : 'sp-contributions-concurrency-user';
267 $out->wrapWikiMsg( "<div class='errorbox'>\n$1\n</div>", $msg );
268 }
269 ] );
270 $work->execute();
271 }
272
273 $out->preventClickjacking( $pager->getPreventClickjacking() );
274
275 # Show the appropriate "footer" message - WHOIS tools, etc.
276 if ( $this->opts['contribs'] == 'newbie' ) {
277 $message = 'sp-contributions-footer-newbies';
278 } elseif ( IP::isValidRange( $target ) ) {
279 $message = 'sp-contributions-footer-anon-range';
280 } elseif ( IP::isIPAddress( $target ) ) {
281 $message = 'sp-contributions-footer-anon';
282 } elseif ( $userObj->isAnon() ) {
283 // No message for non-existing users
284 $message = '';
285 } else {
286 $message = 'sp-contributions-footer';
287 }
288
289 if ( $message && !$this->including() && !$this->msg( $message, $target )->isDisabled() ) {
290 $out->wrapWikiMsg(
291 "<div class='mw-contributions-footer'>\n$1\n</div>",
292 [ $message, $target ] );
293 }
294 }
295 }
296
304 protected function contributionsSub( $userObj ) {
305 if ( $userObj->isAnon() ) {
306 // Show a warning message that the user being searched for doesn't exists.
307 // User::isIP returns true for IP address and usemod IPs like '123.123.123.xxx',
308 // but returns false for IP ranges. We don't want to suggest either of these are
309 // valid usernames which we would with the 'contributions-userdoesnotexist' message.
310 if ( !User::isIP( $userObj->getName() ) && !$userObj->isIPRange() ) {
311 $this->getOutput()->wrapWikiMsg(
312 "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
313 [
314 'contributions-userdoesnotexist',
315 wfEscapeWikiText( $userObj->getName() ),
316 ]
317 );
318 if ( !$this->including() ) {
319 $this->getOutput()->setStatusCode( 404 );
320 }
321 }
322 $user = htmlspecialchars( $userObj->getName() );
323 } else {
324 $user = $this->getLinkRenderer()->makeLink( $userObj->getUserPage(), $userObj->getName() );
325 }
326 $nt = $userObj->getUserPage();
327 $talk = $userObj->getTalkPage();
328 $links = '';
329 if ( $talk ) {
330 $tools = self::getUserLinks( $this, $userObj );
331 $links = Html::openElement( 'span', [ 'class' => 'mw-changeslist-links' ] );
332 foreach ( $tools as $tool ) {
333 $links .= Html::rawElement( 'span', [], $tool ) . ' ';
334 }
335 $links = trim( $links ) . Html::closeElement( 'span' );
336
337 // Show a note if the user is blocked and display the last block log entry.
338 // Do not expose the autoblocks, since that may lead to a leak of accounts' IPs,
339 // and also this will display a totally irrelevant log entry as a current block.
340 if ( !$this->including() ) {
341 // For IP ranges you must give Block::newFromTarget the CIDR string and not a user object.
342 if ( $userObj->isIPRange() ) {
343 $block = Block::newFromTarget( $userObj->getName(), $userObj->getName() );
344 } else {
345 $block = Block::newFromTarget( $userObj, $userObj );
346 }
347
348 if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
349 if ( $block->getType() == Block::TYPE_RANGE ) {
350 $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
351 }
352
353 $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
355 $out,
356 'block',
357 $nt,
358 '',
359 [
360 'lim' => 1,
361 'showIfEmpty' => false,
362 'msgKey' => [
363 $userObj->isAnon() ?
364 'sp-contributions-blocked-notice-anon' :
365 'sp-contributions-blocked-notice',
366 $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
367 ],
368 'offset' => '' # don't use WebRequest parameter offset
369 ]
370 );
371 }
372 }
373 }
374
375 return Html::rawElement( 'div', [ 'class' => 'mw-contributions-user-tools' ],
376 $this->msg( 'contributions-subtitle' )->rawParams( $user )->params( $userObj->getName() )
377 . ' ' . $links
378 );
379 }
380
389 public static function getUserLinks( SpecialPage $sp, User $target ) {
390 $id = $target->getId();
391 $username = $target->getName();
392 $userpage = $target->getUserPage();
393 $talkpage = $target->getTalkPage();
394
395 $linkRenderer = $sp->getLinkRenderer();
396
397 # No talk pages for IP ranges.
398 if ( !IP::isValidRange( $username ) ) {
399 $tools['user-talk'] = $linkRenderer->makeLink(
400 $talkpage,
401 $sp->msg( 'sp-contributions-talk' )->text()
402 );
403 }
404
405 if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
406 if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
407 if ( $target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO ) {
408 $tools['block'] = $linkRenderer->makeKnownLink( # Change block link
409 SpecialPage::getTitleFor( 'Block', $username ),
410 $sp->msg( 'change-blocklink' )->text()
411 );
412 $tools['unblock'] = $linkRenderer->makeKnownLink( # Unblock link
413 SpecialPage::getTitleFor( 'Unblock', $username ),
414 $sp->msg( 'unblocklink' )->text()
415 );
416 } else { # User is not blocked
417 $tools['block'] = $linkRenderer->makeKnownLink( # Block link
418 SpecialPage::getTitleFor( 'Block', $username ),
419 $sp->msg( 'blocklink' )->text()
420 );
421 }
422 }
423
424 # Block log link
425 $tools['log-block'] = $linkRenderer->makeKnownLink(
426 SpecialPage::getTitleFor( 'Log', 'block' ),
427 $sp->msg( 'sp-contributions-blocklog' )->text(),
428 [],
429 [ 'page' => $userpage->getPrefixedText() ]
430 );
431
432 # Suppression log link (T61120)
433 if ( $sp->getUser()->isAllowed( 'suppressionlog' ) ) {
434 $tools['log-suppression'] = $linkRenderer->makeKnownLink(
435 SpecialPage::getTitleFor( 'Log', 'suppress' ),
436 $sp->msg( 'sp-contributions-suppresslog', $username )->text(),
437 [],
438 [ 'offender' => $username ]
439 );
440 }
441 }
442
443 # Don't show some links for IP ranges
444 if ( !IP::isValidRange( $username ) ) {
445 # Uploads
446 $tools['uploads'] = $linkRenderer->makeKnownLink(
447 SpecialPage::getTitleFor( 'Listfiles', $username ),
448 $sp->msg( 'sp-contributions-uploads' )->text()
449 );
450
451 # Other logs link
452 $tools['logs'] = $linkRenderer->makeKnownLink(
454 $sp->msg( 'sp-contributions-logs' )->text()
455 );
456
457 # Add link to deleted user contributions for priviledged users
458 if ( $sp->getUser()->isAllowed( 'deletedhistory' ) ) {
459 $tools['deletedcontribs'] = $linkRenderer->makeKnownLink(
460 SpecialPage::getTitleFor( 'DeletedContributions', $username ),
461 $sp->msg( 'sp-contributions-deleted', $username )->text()
462 );
463 }
464 }
465
466 # Add a link to change user rights for privileged users
467 $userrightsPage = new UserrightsPage();
468 $userrightsPage->setContext( $sp->getContext() );
469 if ( $userrightsPage->userCanChangeRights( $target ) ) {
470 $tools['userrights'] = $linkRenderer->makeKnownLink(
471 SpecialPage::getTitleFor( 'Userrights', $username ),
472 $sp->msg( 'sp-contributions-userrights', $username )->text()
473 );
474 }
475
476 Hooks::run( 'ContributionsToolLinks', [ $id, $userpage, &$tools, $sp ] );
477
478 return $tools;
479 }
480
485 protected function getForm() {
486 $this->opts['title'] = $this->getPageTitle()->getPrefixedText();
487 if ( !isset( $this->opts['target'] ) ) {
488 $this->opts['target'] = '';
489 } else {
490 $this->opts['target'] = str_replace( '_', ' ', $this->opts['target'] );
491 }
492
493 if ( !isset( $this->opts['namespace'] ) ) {
494 $this->opts['namespace'] = '';
495 }
496
497 if ( !isset( $this->opts['nsInvert'] ) ) {
498 $this->opts['nsInvert'] = '';
499 }
500
501 if ( !isset( $this->opts['associated'] ) ) {
502 $this->opts['associated'] = false;
503 }
504
505 if ( !isset( $this->opts['contribs'] ) ) {
506 $this->opts['contribs'] = 'user';
507 }
508
509 if ( !isset( $this->opts['start'] ) ) {
510 $this->opts['start'] = '';
511 }
512
513 if ( !isset( $this->opts['end'] ) ) {
514 $this->opts['end'] = '';
515 }
516
517 if ( $this->opts['contribs'] == 'newbie' ) {
518 $this->opts['target'] = '';
519 }
520
521 if ( !isset( $this->opts['tagfilter'] ) ) {
522 $this->opts['tagfilter'] = '';
523 }
524
525 if ( !isset( $this->opts['topOnly'] ) ) {
526 $this->opts['topOnly'] = false;
527 }
528
529 if ( !isset( $this->opts['newOnly'] ) ) {
530 $this->opts['newOnly'] = false;
531 }
532
533 if ( !isset( $this->opts['hideMinor'] ) ) {
534 $this->opts['hideMinor'] = false;
535 }
536
537 // Modules required only for the form
538 $this->getOutput()->addModules( [
539 'mediawiki.userSuggest',
540 'mediawiki.special.contributions',
541 ] );
542 $this->getOutput()->addModuleStyles( 'mediawiki.widgets.DateInputWidget.styles' );
543 $this->getOutput()->enableOOUI();
544
545 $form = Html::openElement(
546 'form',
547 [
548 'method' => 'get',
549 'action' => wfScript(),
550 'class' => 'mw-contributions-form'
551 ]
552 );
553
554 # Add hidden params for tracking except for parameters in $skipParameters
555 $skipParameters = [
556 'namespace',
557 'nsInvert',
558 'deletedOnly',
559 'target',
560 'contribs',
561 'year',
562 'month',
563 'start',
564 'end',
565 'topOnly',
566 'newOnly',
567 'hideMinor',
568 'associated',
569 'tagfilter'
570 ];
571
572 foreach ( $this->opts as $name => $value ) {
573 if ( in_array( $name, $skipParameters ) ) {
574 continue;
575 }
576 $form .= "\t" . Html::hidden( $name, $value ) . "\n";
577 }
578
580 $this->opts['tagfilter'], false, $this->getContext() );
581
582 if ( $tagFilter ) {
583 $filterSelection = Html::rawElement(
584 'div',
585 [],
586 implode( "\u{00A0}", $tagFilter )
587 );
588 } else {
589 $filterSelection = Html::rawElement( 'div', [], '' );
590 }
591
592 $labelNewbies = Xml::radioLabel(
593 $this->msg( 'sp-contributions-newbies' )->text(),
594 'contribs',
595 'newbie',
596 'newbie',
597 $this->opts['contribs'] == 'newbie',
598 [ 'class' => 'mw-input' ]
599 );
600 $labelUsername = Xml::radioLabel(
601 $this->msg( 'sp-contributions-username' )->text(),
602 'contribs',
603 'user',
604 'user',
605 $this->opts['contribs'] == 'user',
606 [ 'class' => 'mw-input' ]
607 );
608 $input = Html::input(
609 'target',
610 $this->opts['target'],
611 'text',
612 [
613 'id' => 'mw-target-user-or-ip',
614 'size' => '40',
615 'class' => [
616 'mw-input',
617 'mw-ui-input-inline',
618 'mw-autocomplete-user', // used by mediawiki.userSuggest
619 ],
620 ] + (
621 // Only autofocus if target hasn't been specified or in non-newbies mode
622 ( $this->opts['contribs'] === 'newbie' || $this->opts['target'] )
623 ? [] : [ 'autofocus' => true ]
624 )
625 );
626
627 $targetSelection = Html::rawElement(
628 'div',
629 [],
630 $labelNewbies . '<br>' . $labelUsername . ' ' . $input . ' '
631 );
632
633 $hidden = $this->opts['namespace'] === '' ? ' mw-input-hidden' : '';
634 $namespaceSelection = Xml::tags(
635 'div',
636 [],
637 Xml::label(
638 $this->msg( 'namespace' )->text(),
639 'namespace',
640 ''
641 ) . "\u{00A0}" .
642 Html::namespaceSelector(
643 [ 'selected' => $this->opts['namespace'], 'all' => '', 'in-user-lang' => true ],
644 [
645 'name' => 'namespace',
646 'id' => 'namespace',
647 'class' => 'namespaceselector',
648 ]
649 ) . "\u{00A0}" .
650 Html::rawElement(
651 'span',
652 [ 'class' => 'mw-input-with-label' . $hidden ],
653 Xml::checkLabel(
654 $this->msg( 'invert' )->text(),
655 'nsInvert',
656 'nsinvert',
657 $this->opts['nsInvert'],
658 [
659 'title' => $this->msg( 'tooltip-invert' )->text(),
660 'class' => 'mw-input'
661 ]
662 ) . "\u{00A0}"
663 ) .
664 Html::rawElement( 'span', [ 'class' => 'mw-input-with-label' . $hidden ],
665 Xml::checkLabel(
666 $this->msg( 'namespace_association' )->text(),
667 'associated',
668 'nsassociated',
669 $this->opts['associated'],
670 [
671 'title' => $this->msg( 'tooltip-namespace_association' )->text(),
672 'class' => 'mw-input'
673 ]
674 ) . "\u{00A0}"
675 )
676 );
677
678 $filters = [];
679
680 if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
681 $filters[] = Html::rawElement(
682 'span',
683 [ 'class' => 'mw-input-with-label' ],
684 Xml::checkLabel(
685 $this->msg( 'history-show-deleted' )->text(),
686 'deletedOnly',
687 'mw-show-deleted-only',
688 $this->opts['deletedOnly'],
689 [ 'class' => 'mw-input' ]
690 )
691 );
692 }
693
694 $filters[] = Html::rawElement(
695 'span',
696 [ 'class' => 'mw-input-with-label' ],
697 Xml::checkLabel(
698 $this->msg( 'sp-contributions-toponly' )->text(),
699 'topOnly',
700 'mw-show-top-only',
701 $this->opts['topOnly'],
702 [ 'class' => 'mw-input' ]
703 )
704 );
705 $filters[] = Html::rawElement(
706 'span',
707 [ 'class' => 'mw-input-with-label' ],
708 Xml::checkLabel(
709 $this->msg( 'sp-contributions-newonly' )->text(),
710 'newOnly',
711 'mw-show-new-only',
712 $this->opts['newOnly'],
713 [ 'class' => 'mw-input' ]
714 )
715 );
716 $filters[] = Html::rawElement(
717 'span',
718 [ 'class' => 'mw-input-with-label' ],
719 Xml::checkLabel(
720 $this->msg( 'sp-contributions-hideminor' )->text(),
721 'hideMinor',
722 'mw-hide-minor-edits',
723 $this->opts['hideMinor'],
724 [ 'class' => 'mw-input' ]
725 )
726 );
727
728 Hooks::run(
729 'SpecialContributions::getForm::filters',
730 [ $this, &$filters ]
731 );
732
733 $extraOptions = Html::rawElement(
734 'div',
735 [],
736 implode( '', $filters )
737 );
738
739 $dateRangeSelection = Html::rawElement(
740 'div',
741 [],
742 Xml::label( $this->msg( 'date-range-from' )->text(), 'mw-date-start' ) . ' ' .
743 new DateInputWidget( [
744 'infusable' => true,
745 'id' => 'mw-date-start',
746 'name' => 'start',
747 'value' => $this->opts['start'],
748 'longDisplayFormat' => true,
749 ] ) . '<br>' .
750 Xml::label( $this->msg( 'date-range-to' )->text(), 'mw-date-end' ) . ' ' .
751 new DateInputWidget( [
752 'infusable' => true,
753 'id' => 'mw-date-end',
754 'name' => 'end',
755 'value' => $this->opts['end'],
756 'longDisplayFormat' => true,
757 ] )
758 );
759
760 $submit = Xml::tags( 'div', [],
761 Html::submitButton(
762 $this->msg( 'sp-contributions-submit' )->text(),
763 [ 'class' => 'mw-submit' ], [ 'mw-ui-progressive' ]
764 )
765 );
766
767 $form .= Xml::fieldset(
768 $this->msg( 'sp-contributions-search' )->text(),
769 $targetSelection .
770 $namespaceSelection .
771 $filterSelection .
772 $extraOptions .
773 $dateRangeSelection .
774 $submit,
775 [ 'class' => 'mw-contributions-table' ]
776 );
777
778 $explain = $this->msg( 'sp-contributions-explain' );
779 if ( !$explain->isBlank() ) {
780 $form .= Html::rawElement(
781 'p', [ 'id' => 'mw-sp-contributions-explain' ], $explain->parse()
782 );
783 }
784
785 $form .= Xml::closeElement( 'form' );
786
787 return $form;
788 }
789
798 public function prefixSearchSubpages( $search, $limit, $offset ) {
799 $user = User::newFromName( $search );
800 if ( !$user ) {
801 // No prefix suggestion for invalid user
802 return [];
803 }
804 // Autocomplete subpage as user list - public to allow caching
805 return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
806 }
807
808 protected function getGroupName() {
809 return 'users';
810 }
811}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
target page
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
const TYPE_RANGE
Definition Block.php:98
const TYPE_AUTO
Definition Block.php:99
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
Definition Block.php:1403
static buildTagFilterSelector( $selected='', $ooui=false, IContextSource $context=null)
Build a text box to select a change tag.
static processDateFilter(array $opts)
Set up date filter options, given request data.
static isExternal( $username)
Tells whether the username is external or not.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition Hooks.php:200
A collection of public static functions to play with IP address and IP ranges.
Definition IP.php:67
Shortcut to construct an includable special page.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Convenience class for dealing with PoolCounters using callbacks.
execute( $skipcache=false)
Get the result of the work (whatever it is), or the result of the error() function.
Special:Contributions, show user contributions in a paged list.
static getUserLinks(SpecialPage $sp, User $target)
Links to different places.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
getForm()
Generates the namespace selector form with hidden attributes.
execute( $par)
Default execute method Checks user permissions.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
contributionsSub( $userObj)
Generates the subheading with links.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
getSkin()
Shortcut to get the skin being used for this instance.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
addFeedLinks( $params)
Adds RSS/atom links.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
including( $x=null)
Whether the special page is being evaluated via transclusion.
MediaWiki Linker LinkRenderer null $linkRenderer
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition User.php:585
static isIP( $name)
Does the string match an anonymous IP address?
Definition User.php:967
Special page to allow managing user group membership.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could change
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Wikitext formatted, in the key only.
const NS_USER
Definition Defines.php:75
const NS_MAIN
Definition Defines.php:73
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Definition hooks.txt:2843
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition hooks.txt:855
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Definition hooks.txt:181
either a plain
Definition hooks.txt:2054
null for the local wiki Added in
Definition hooks.txt:1588
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition hooks.txt:2004
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:271
this hook is for auditing only or null if authentication failed before getting that far $username
Definition hooks.txt:782
returning false will NOT prevent logging a wrapping ErrorException block
Definition hooks.txt:2188
return true to allow those checks to and false if checking is done & $user
Definition hooks.txt:1510
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
Definition hooks.txt:2272
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
if(is_array($mode)) switch( $mode) $input
This document describes the XML format used to represent information about external sites known to a MediaWiki installation This information about external sites is used to allow inter wiki links
in the order they appear.
Definition sitelist.txt:3