MediaWiki  1.32.0
SpecialContributions.php
Go to the documentation of this file.
1 <?php
26 
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.special',
46  'mediawiki.special.changeslist',
47  ] );
48  $this->addHelpLink( 'Help:User contributions' );
49 
50  $this->opts = [];
51  $request = $this->getRequest();
52 
53  $target = $par ?? $request->getVal( 'target' );
54 
55  if ( $request->getVal( 'contribs' ) == 'newbie' || $par === 'newbies' ) {
56  $target = 'newbies';
57  $this->opts['contribs'] = 'newbie';
58  } else {
59  $this->opts['contribs'] = 'user';
60  }
61 
62  $this->opts['deletedOnly'] = $request->getBool( 'deletedOnly' );
63 
64  if ( !strlen( $target ) ) {
65  if ( !$this->including() ) {
66  $out->addHTML( $this->getForm() );
67  }
68 
69  return;
70  }
71 
72  $user = $this->getUser();
73 
74  $this->opts['limit'] = $request->getInt( 'limit', $user->getOption( 'rclimit' ) );
75  $this->opts['target'] = $target;
76  $this->opts['topOnly'] = $request->getBool( 'topOnly' );
77  $this->opts['newOnly'] = $request->getBool( 'newOnly' );
78  $this->opts['hideMinor'] = $request->getBool( 'hideMinor' );
79 
80  $id = 0;
81  if ( $this->opts['contribs'] === 'newbie' ) {
82  $userObj = User::newFromName( $target ); // hysterical raisins
83  $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
84  $out->setHTMLTitle( $this->msg(
85  'pagetitle',
86  $this->msg( 'sp-contributions-newbies-title' )->plain()
87  )->inContentLanguage() );
88  } elseif ( ExternalUserNames::isExternal( $target ) ) {
89  $userObj = User::newFromName( $target, false );
90  if ( !$userObj ) {
91  $out->addHTML( $this->getForm() );
92  return;
93  }
94 
95  $out->addSubtitle( $this->contributionsSub( $userObj ) );
96  $out->setHTMLTitle( $this->msg(
97  'pagetitle',
98  $this->msg( 'contributions-title', $target )->plain()
99  )->inContentLanguage() );
100  } else {
101  $nt = Title::makeTitleSafe( NS_USER, $target );
102  if ( !$nt ) {
103  $out->addHTML( $this->getForm() );
104  return;
105  }
106  $userObj = User::newFromName( $nt->getText(), false );
107  if ( !$userObj ) {
108  $out->addHTML( $this->getForm() );
109  return;
110  }
111  $id = $userObj->getId();
112 
113  $target = $nt->getText();
114  $out->addSubtitle( $this->contributionsSub( $userObj ) );
115  $out->setHTMLTitle( $this->msg(
116  'pagetitle',
117  $this->msg( 'contributions-title', $target )->plain()
118  )->inContentLanguage() );
119 
120  # For IP ranges, we want the contributionsSub, but not the skin-dependent
121  # links under 'Tools', which may include irrelevant links like 'Logs'.
122  if ( !IP::isValidRange( $target ) ) {
123  $this->getSkin()->setRelevantUser( $userObj );
124  }
125  }
126 
127  $ns = $request->getVal( 'namespace', null );
128  if ( $ns !== null && $ns !== '' ) {
129  $this->opts['namespace'] = intval( $ns );
130  } else {
131  $this->opts['namespace'] = '';
132  }
133 
134  $this->opts['associated'] = $request->getBool( 'associated' );
135  $this->opts['nsInvert'] = (bool)$request->getVal( 'nsInvert' );
136  $this->opts['tagfilter'] = (string)$request->getVal( 'tagfilter' );
137 
138  // Allows reverts to have the bot flag in recent changes. It is just here to
139  // be passed in the form at the top of the page
140  if ( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) {
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  $feedType = $request->getVal( 'feed' );
156 
157  $feedParams = [
158  'action' => 'feedcontributions',
159  'user' => $target,
160  ];
161  if ( $this->opts['topOnly'] ) {
162  $feedParams['toponly'] = true;
163  }
164  if ( $this->opts['newOnly'] ) {
165  $feedParams['newonly'] = true;
166  }
167  if ( $this->opts['hideMinor'] ) {
168  $feedParams['hideminor'] = true;
169  }
170  if ( $this->opts['deletedOnly'] ) {
171  $feedParams['deletedonly'] = true;
172  }
173  if ( $this->opts['tagfilter'] !== '' ) {
174  $feedParams['tagfilter'] = $this->opts['tagfilter'];
175  }
176  if ( $this->opts['namespace'] !== '' ) {
177  $feedParams['namespace'] = $this->opts['namespace'];
178  }
179  // Don't use year and month for the feed URL, but pass them on if
180  // we redirect to API (if $feedType is specified)
181  if ( $feedType && $this->opts['year'] !== null ) {
182  $feedParams['year'] = $this->opts['year'];
183  }
184  if ( $feedType && $this->opts['month'] !== null ) {
185  $feedParams['month'] = $this->opts['month'];
186  }
187 
188  if ( $feedType ) {
189  // Maintain some level of backwards compatibility
190  // If people request feeds using the old parameters, redirect to API
191  $feedParams['feedformat'] = $feedType;
192  $url = wfAppendQuery( wfScript( 'api' ), $feedParams );
193 
194  $out->redirect( $url, '301' );
195 
196  return;
197  }
198 
199  // Add RSS/atom links
200  $this->addFeedLinks( $feedParams );
201 
202  if ( Hooks::run( 'SpecialContributionsBeforeMainOutput', [ $id, $userObj, $this ] ) ) {
203  if ( !$this->including() ) {
204  $out->addHTML( $this->getForm() );
205  }
206  $pager = new ContribsPager( $this->getContext(), [
207  'target' => $target,
208  'contribs' => $this->opts['contribs'],
209  'namespace' => $this->opts['namespace'],
210  'tagfilter' => $this->opts['tagfilter'],
211  'start' => $this->opts['start'],
212  'end' => $this->opts['end'],
213  'deletedOnly' => $this->opts['deletedOnly'],
214  'topOnly' => $this->opts['topOnly'],
215  'newOnly' => $this->opts['newOnly'],
216  'hideMinor' => $this->opts['hideMinor'],
217  'nsInvert' => $this->opts['nsInvert'],
218  'associated' => $this->opts['associated'],
219  ] );
220 
221  if ( IP::isValidRange( $target ) && !$pager->isQueryableRange( $target ) ) {
222  // Valid range, but outside CIDR limit.
223  $limits = $this->getConfig()->get( 'RangeContributionsCIDRLimit' );
224  $limit = $limits[ IP::isIPv4( $target ) ? 'IPv4' : 'IPv6' ];
225  $out->addWikiMsg( 'sp-contributions-outofrange', $limit );
226  } elseif ( !$pager->getNumRows() ) {
227  $out->addWikiMsg( 'nocontribs', $target );
228  } else {
229  # Show a message about replica DB lag, if applicable
230  $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
231  $lag = $lb->safeGetLag( $pager->getDatabase() );
232  if ( $lag > 0 ) {
233  $out->showLagWarning( $lag );
234  }
235 
236  $output = $pager->getBody();
237  if ( !$this->including() ) {
238  $output = '<p>' . $pager->getNavigationBar() . '</p>' .
239  $output .
240  '<p>' . $pager->getNavigationBar() . '</p>';
241  }
242  $out->addHTML( $output );
243  }
244 
245  $out->preventClickjacking( $pager->getPreventClickjacking() );
246 
247  # Show the appropriate "footer" message - WHOIS tools, etc.
248  if ( $this->opts['contribs'] == 'newbie' ) {
249  $message = 'sp-contributions-footer-newbies';
250  } elseif ( IP::isValidRange( $target ) ) {
251  $message = 'sp-contributions-footer-anon-range';
252  } elseif ( IP::isIPAddress( $target ) ) {
253  $message = 'sp-contributions-footer-anon';
254  } elseif ( $userObj->isAnon() ) {
255  // No message for non-existing users
256  $message = '';
257  } else {
258  $message = 'sp-contributions-footer';
259  }
260 
261  if ( $message ) {
262  if ( !$this->including() ) {
263  if ( !$this->msg( $message, $target )->isDisabled() ) {
264  $out->wrapWikiMsg(
265  "<div class='mw-contributions-footer'>\n$1\n</div>",
266  [ $message, $target ] );
267  }
268  }
269  }
270  }
271  }
272 
280  protected function contributionsSub( $userObj ) {
281  if ( $userObj->isAnon() ) {
282  // Show a warning message that the user being searched for doesn't exists.
283  // User::isIP returns true for IP address and usemod IPs like '123.123.123.xxx',
284  // but returns false for IP ranges. We don't want to suggest either of these are
285  // valid usernames which we would with the 'contributions-userdoesnotexist' message.
286  if ( !User::isIP( $userObj->getName() ) && !$userObj->isIPRange() ) {
287  $this->getOutput()->wrapWikiMsg(
288  "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
289  [
290  'contributions-userdoesnotexist',
291  wfEscapeWikiText( $userObj->getName() ),
292  ]
293  );
294  if ( !$this->including() ) {
295  $this->getOutput()->setStatusCode( 404 );
296  }
297  }
298  $user = htmlspecialchars( $userObj->getName() );
299  } else {
300  $user = $this->getLinkRenderer()->makeLink( $userObj->getUserPage(), $userObj->getName() );
301  }
302  $nt = $userObj->getUserPage();
303  $talk = $userObj->getTalkPage();
304  $links = '';
305  if ( $talk ) {
306  $tools = self::getUserLinks( $this, $userObj );
307  $links = $this->getLanguage()->pipeList( $tools );
308 
309  // Show a note if the user is blocked and display the last block log entry.
310  // Do not expose the autoblocks, since that may lead to a leak of accounts' IPs,
311  // and also this will display a totally irrelevant log entry as a current block.
312  if ( !$this->including() ) {
313  // For IP ranges you must give Block::newFromTarget the CIDR string and not a user object.
314  if ( $userObj->isIPRange() ) {
315  $block = Block::newFromTarget( $userObj->getName(), $userObj->getName() );
316  } else {
317  $block = Block::newFromTarget( $userObj, $userObj );
318  }
319 
320  if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
321  if ( $block->getType() == Block::TYPE_RANGE ) {
322  $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
323  }
324 
325  $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
327  $out,
328  'block',
329  $nt,
330  '',
331  [
332  'lim' => 1,
333  'showIfEmpty' => false,
334  'msgKey' => [
335  $userObj->isAnon() ?
336  'sp-contributions-blocked-notice-anon' :
337  'sp-contributions-blocked-notice',
338  $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
339  ],
340  'offset' => '' # don't use WebRequest parameter offset
341  ]
342  );
343  }
344  }
345  }
346 
347  return $this->msg( 'contribsub2' )->rawParams( $user, $links )->params( $userObj->getName() );
348  }
349 
358  public static function getUserLinks( SpecialPage $sp, User $target ) {
359  $id = $target->getId();
360  $username = $target->getName();
361  $userpage = $target->getUserPage();
362  $talkpage = $target->getTalkPage();
363 
364  $linkRenderer = $sp->getLinkRenderer();
365 
366  # No talk pages for IP ranges.
367  if ( !IP::isValidRange( $username ) ) {
368  $tools['user-talk'] = $linkRenderer->makeLink(
369  $talkpage,
370  $sp->msg( 'sp-contributions-talk' )->text()
371  );
372  }
373 
374  if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
375  if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
376  if ( $target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO ) {
377  $tools['block'] = $linkRenderer->makeKnownLink( # Change block link
378  SpecialPage::getTitleFor( 'Block', $username ),
379  $sp->msg( 'change-blocklink' )->text()
380  );
381  $tools['unblock'] = $linkRenderer->makeKnownLink( # Unblock link
382  SpecialPage::getTitleFor( 'Unblock', $username ),
383  $sp->msg( 'unblocklink' )->text()
384  );
385  } else { # User is not blocked
386  $tools['block'] = $linkRenderer->makeKnownLink( # Block link
387  SpecialPage::getTitleFor( 'Block', $username ),
388  $sp->msg( 'blocklink' )->text()
389  );
390  }
391  }
392 
393  # Block log link
394  $tools['log-block'] = $linkRenderer->makeKnownLink(
395  SpecialPage::getTitleFor( 'Log', 'block' ),
396  $sp->msg( 'sp-contributions-blocklog' )->text(),
397  [],
398  [ 'page' => $userpage->getPrefixedText() ]
399  );
400 
401  # Suppression log link (T61120)
402  if ( $sp->getUser()->isAllowed( 'suppressionlog' ) ) {
403  $tools['log-suppression'] = $linkRenderer->makeKnownLink(
404  SpecialPage::getTitleFor( 'Log', 'suppress' ),
405  $sp->msg( 'sp-contributions-suppresslog', $username )->text(),
406  [],
407  [ 'offender' => $username ]
408  );
409  }
410  }
411 
412  # Don't show some links for IP ranges
413  if ( !IP::isValidRange( $username ) ) {
414  # Uploads
415  $tools['uploads'] = $linkRenderer->makeKnownLink(
416  SpecialPage::getTitleFor( 'Listfiles', $username ),
417  $sp->msg( 'sp-contributions-uploads' )->text()
418  );
419 
420  # Other logs link
421  $tools['logs'] = $linkRenderer->makeKnownLink(
423  $sp->msg( 'sp-contributions-logs' )->text()
424  );
425 
426  # Add link to deleted user contributions for priviledged users
427  if ( $sp->getUser()->isAllowed( 'deletedhistory' ) ) {
428  $tools['deletedcontribs'] = $linkRenderer->makeKnownLink(
429  SpecialPage::getTitleFor( 'DeletedContributions', $username ),
430  $sp->msg( 'sp-contributions-deleted', $username )->text()
431  );
432  }
433  }
434 
435  # Add a link to change user rights for privileged users
436  $userrightsPage = new UserrightsPage();
437  $userrightsPage->setContext( $sp->getContext() );
438  if ( $userrightsPage->userCanChangeRights( $target ) ) {
439  $tools['userrights'] = $linkRenderer->makeKnownLink(
440  SpecialPage::getTitleFor( 'Userrights', $username ),
441  $sp->msg( 'sp-contributions-userrights', $username )->text()
442  );
443  }
444 
445  Hooks::run( 'ContributionsToolLinks', [ $id, $userpage, &$tools, $sp ] );
446 
447  return $tools;
448  }
449 
454  protected function getForm() {
455  $this->opts['title'] = $this->getPageTitle()->getPrefixedText();
456  if ( !isset( $this->opts['target'] ) ) {
457  $this->opts['target'] = '';
458  } else {
459  $this->opts['target'] = str_replace( '_', ' ', $this->opts['target'] );
460  }
461 
462  if ( !isset( $this->opts['namespace'] ) ) {
463  $this->opts['namespace'] = '';
464  }
465 
466  if ( !isset( $this->opts['nsInvert'] ) ) {
467  $this->opts['nsInvert'] = '';
468  }
469 
470  if ( !isset( $this->opts['associated'] ) ) {
471  $this->opts['associated'] = false;
472  }
473 
474  if ( !isset( $this->opts['contribs'] ) ) {
475  $this->opts['contribs'] = 'user';
476  }
477 
478  if ( !isset( $this->opts['start'] ) ) {
479  $this->opts['start'] = '';
480  }
481 
482  if ( !isset( $this->opts['end'] ) ) {
483  $this->opts['end'] = '';
484  }
485 
486  if ( $this->opts['contribs'] == 'newbie' ) {
487  $this->opts['target'] = '';
488  }
489 
490  if ( !isset( $this->opts['tagfilter'] ) ) {
491  $this->opts['tagfilter'] = '';
492  }
493 
494  if ( !isset( $this->opts['topOnly'] ) ) {
495  $this->opts['topOnly'] = false;
496  }
497 
498  if ( !isset( $this->opts['newOnly'] ) ) {
499  $this->opts['newOnly'] = false;
500  }
501 
502  if ( !isset( $this->opts['hideMinor'] ) ) {
503  $this->opts['hideMinor'] = false;
504  }
505 
506  // Modules required only for the form
507  $this->getOutput()->addModules( [
508  'mediawiki.userSuggest',
509  'mediawiki.special.contributions',
510  ] );
511  $this->getOutput()->addModuleStyles( 'mediawiki.widgets.DateInputWidget.styles' );
512  $this->getOutput()->enableOOUI();
513 
514  $form = Html::openElement(
515  'form',
516  [
517  'method' => 'get',
518  'action' => wfScript(),
519  'class' => 'mw-contributions-form'
520  ]
521  );
522 
523  # Add hidden params for tracking except for parameters in $skipParameters
524  $skipParameters = [
525  'namespace',
526  'nsInvert',
527  'deletedOnly',
528  'target',
529  'contribs',
530  'year',
531  'month',
532  'start',
533  'end',
534  'topOnly',
535  'newOnly',
536  'hideMinor',
537  'associated',
538  'tagfilter'
539  ];
540 
541  foreach ( $this->opts as $name => $value ) {
542  if ( in_array( $name, $skipParameters ) ) {
543  continue;
544  }
545  $form .= "\t" . Html::hidden( $name, $value ) . "\n";
546  }
547 
549  $this->opts['tagfilter'], false, $this->getContext() );
550 
551  if ( $tagFilter ) {
552  $filterSelection = Html::rawElement(
553  'div',
554  [],
555  implode( "\u{00A0}", $tagFilter )
556  );
557  } else {
558  $filterSelection = Html::rawElement( 'div', [], '' );
559  }
560 
561  $labelNewbies = Xml::radioLabel(
562  $this->msg( 'sp-contributions-newbies' )->text(),
563  'contribs',
564  'newbie',
565  'newbie',
566  $this->opts['contribs'] == 'newbie',
567  [ 'class' => 'mw-input' ]
568  );
569  $labelUsername = Xml::radioLabel(
570  $this->msg( 'sp-contributions-username' )->text(),
571  'contribs',
572  'user',
573  'user',
574  $this->opts['contribs'] == 'user',
575  [ 'class' => 'mw-input' ]
576  );
578  'target',
579  $this->opts['target'],
580  'text',
581  [
582  'size' => '40',
583  'class' => [
584  'mw-input',
585  'mw-ui-input-inline',
586  'mw-autocomplete-user', // used by mediawiki.userSuggest
587  ],
588  ] + (
589  // Only autofocus if target hasn't been specified or in non-newbies mode
590  ( $this->opts['contribs'] === 'newbie' || $this->opts['target'] )
591  ? [] : [ 'autofocus' => true ]
592  )
593  );
594 
595  $targetSelection = Html::rawElement(
596  'div',
597  [],
598  $labelNewbies . '<br>' . $labelUsername . ' ' . $input . ' '
599  );
600 
601  $namespaceSelection = Xml::tags(
602  'div',
603  [],
604  Xml::label(
605  $this->msg( 'namespace' )->text(),
606  'namespace',
607  ''
608  ) . "\u{00A0}" .
610  [ 'selected' => $this->opts['namespace'], 'all' => '' ],
611  [
612  'name' => 'namespace',
613  'id' => 'namespace',
614  'class' => 'namespaceselector',
615  ]
616  ) . "\u{00A0}" .
618  'span',
619  [ 'class' => 'mw-input-with-label' ],
621  $this->msg( 'invert' )->text(),
622  'nsInvert',
623  'nsInvert',
624  $this->opts['nsInvert'],
625  [
626  'title' => $this->msg( 'tooltip-invert' )->text(),
627  'class' => 'mw-input'
628  ]
629  ) . "\u{00A0}"
630  ) .
631  Html::rawElement( 'span', [ 'class' => 'mw-input-with-label' ],
633  $this->msg( 'namespace_association' )->text(),
634  'associated',
635  'associated',
636  $this->opts['associated'],
637  [
638  'title' => $this->msg( 'tooltip-namespace_association' )->text(),
639  'class' => 'mw-input'
640  ]
641  ) . "\u{00A0}"
642  )
643  );
644 
645  $filters = [];
646 
647  if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
648  $filters[] = Html::rawElement(
649  'span',
650  [ 'class' => 'mw-input-with-label' ],
652  $this->msg( 'history-show-deleted' )->text(),
653  'deletedOnly',
654  'mw-show-deleted-only',
655  $this->opts['deletedOnly'],
656  [ 'class' => 'mw-input' ]
657  )
658  );
659  }
660 
661  $filters[] = Html::rawElement(
662  'span',
663  [ 'class' => 'mw-input-with-label' ],
665  $this->msg( 'sp-contributions-toponly' )->text(),
666  'topOnly',
667  'mw-show-top-only',
668  $this->opts['topOnly'],
669  [ 'class' => 'mw-input' ]
670  )
671  );
672  $filters[] = Html::rawElement(
673  'span',
674  [ 'class' => 'mw-input-with-label' ],
676  $this->msg( 'sp-contributions-newonly' )->text(),
677  'newOnly',
678  'mw-show-new-only',
679  $this->opts['newOnly'],
680  [ 'class' => 'mw-input' ]
681  )
682  );
683  $filters[] = Html::rawElement(
684  'span',
685  [ 'class' => 'mw-input-with-label' ],
687  $this->msg( 'sp-contributions-hideminor' )->text(),
688  'hideMinor',
689  'mw-hide-minor-edits',
690  $this->opts['hideMinor'],
691  [ 'class' => 'mw-input' ]
692  )
693  );
694 
695  Hooks::run(
696  'SpecialContributions::getForm::filters',
697  [ $this, &$filters ]
698  );
699 
700  $extraOptions = Html::rawElement(
701  'div',
702  [],
703  implode( '', $filters )
704  );
705 
706  $dateRangeSelection = Html::rawElement(
707  'div',
708  [],
709  Xml::label( $this->msg( 'date-range-from' )->text(), 'mw-date-start' ) . ' ' .
710  new DateInputWidget( [
711  'infusable' => true,
712  'id' => 'mw-date-start',
713  'name' => 'start',
714  'value' => $this->opts['start'],
715  'longDisplayFormat' => true,
716  ] ) . '<br>' .
717  Xml::label( $this->msg( 'date-range-to' )->text(), 'mw-date-end' ) . ' ' .
718  new DateInputWidget( [
719  'infusable' => true,
720  'id' => 'mw-date-end',
721  'name' => 'end',
722  'value' => $this->opts['end'],
723  'longDisplayFormat' => true,
724  ] )
725  );
726 
727  $submit = Xml::tags( 'div', [],
729  $this->msg( 'sp-contributions-submit' )->text(),
730  [ 'class' => 'mw-submit' ], [ 'mw-ui-progressive' ]
731  )
732  );
733 
734  $form .= Xml::fieldset(
735  $this->msg( 'sp-contributions-search' )->text(),
736  $targetSelection .
737  $namespaceSelection .
738  $filterSelection .
739  $extraOptions .
740  $dateRangeSelection .
741  $submit,
742  [ 'class' => 'mw-contributions-table' ]
743  );
744 
745  $explain = $this->msg( 'sp-contributions-explain' );
746  if ( !$explain->isBlank() ) {
747  $form .= "<p id='mw-sp-contributions-explain'>{$explain->parse()}</p>";
748  }
749 
750  $form .= Xml::closeElement( 'form' );
751 
752  return $form;
753  }
754 
763  public function prefixSearchSubpages( $search, $limit, $offset ) {
764  $user = User::newFromName( $search );
765  if ( !$user ) {
766  // No prefix suggestion for invalid user
767  return [];
768  }
769  // Autocomplete subpage as user list - public to allow caching
770  return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
771  }
772 
773  protected function getGroupName() {
774  return 'users';
775  }
776 }
SpecialContributions\prefixSearchSubpages
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
Definition: SpecialContributions.php:763
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:678
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:244
SpecialPage\msg
msg( $key)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:796
SpecialContributions\getUserLinks
static getUserLinks(SpecialPage $sp, User $target)
Links to different places.
Definition: SpecialContributions.php:358
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:725
SpecialContributions\getForm
getForm()
Generates the namespace selector form with hidden attributes.
Definition: SpecialContributions.php:454
Xml\label
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:360
Block\TYPE_RANGE
const TYPE_RANGE
Definition: Block.php:85
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 change
Definition: distributors.txt:9
UserNamePrefixSearch\search
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
Definition: UserNamePrefixSearch.php:39
IP
A collection of public static functions to play with IP address and IP ranges.
Definition: IP.php:67
Block\newFromTarget
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:1174
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:592
SpecialPage\getTitleFor
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,...
Definition: SpecialPage.php:82
page
target page
Definition: All_system_messages.txt:1267
SpecialPage\getSkin
getSkin()
Shortcut to get the skin being used for this instance.
Definition: SpecialPage.php:745
IncludableSpecialPage
Shortcut to construct an includable special page.
Definition: IncludableSpecialPage.php:29
ChangeTags\buildTagFilterSelector
static buildTagFilterSelector( $selected='', $ooui=false, IContextSource $context=null)
Build a text box to select a change tag.
Definition: ChangeTags.php:867
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:755
block
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging a wrapping ErrorException instead of letting the login form give the generic error message that the account does not exist For when the account has been renamed or deleted or an array to pass a message key and parameters block
Definition: hooks.txt:2213
php
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:35
ContribsPager\processDateFilter
static processDateFilter(array $opts)
Set up date filter options, given request data.
Definition: ContribsPager.php:655
Html\input
static input( $name, $value='', $type='text', array $attribs=[])
Convenience function to produce an "<input>" element.
Definition: Html.php:666
Xml\fieldset
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition: Xml.php:611
wfAppendQuery
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Definition: GlobalFunctions.php:460
SpecialContributions\execute
execute( $par)
Default execute method Checks user permissions.
Definition: SpecialContributions.php:39
UserrightsPage
Special page to allow managing user group membership.
Definition: SpecialUserrights.php:29
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:832
IP\isValidRange
static isValidRange( $ipRange)
Validate an IP range (valid address with a valid CIDR prefix).
Definition: IP.php:138
MediaWiki\Widget\DateInputWidget
Date input widget.
Definition: DateInputWidget.php:14
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:764
user
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
Definition: distributors.txt:9
SpecialPage\addFeedLinks
addFeedLinks( $params)
Adds RSS/atom links.
Definition: SpecialPage.php:814
wfScript
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Definition: GlobalFunctions.php:2771
$input
if(is_array( $mode)) switch( $mode) $input
Definition: postprocess-phan.php:141
in
null for the wiki Added in
Definition: hooks.txt:1627
User\isIP
static isIP( $name)
Does the string match an anonymous IP address?
Definition: User.php:971
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:531
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:735
$output
$output
Definition: SyntaxHighlight.php:334
LogEventsList\showLogExtract
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Definition: LogEventsList.php:606
string
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:175
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:698
$request
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:2675
links
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
Definition: sitelist.txt:3
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
ContribsPager
Definition: ContribsPager.php:31
Html\hidden
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:795
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:573
captcha-old.opts
opts
Definition: captcha-old.py:227
$value
$value
Definition: styleTest.css.php:49
Html\namespaceSelector
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:883
Xml\tags
static tags( $element, $attribs, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:132
SpecialContributions\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialContributions.php:773
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:715
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1617
SpecialContributions\$opts
$opts
Definition: SpecialContributions.php:33
Html\submitButton
static submitButton( $contents, array $attrs, array $modifiers=[])
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enab...
Definition: Html.php:186
Block\TYPE_AUTO
const TYPE_AUTO
Definition: Block.php:86
plain
either a plain
Definition: hooks.txt:2097
IP\isIPv4
static isIPv4( $ip)
Given a string, determine if it as valid IP in IPv4 only.
Definition: IP.php:99
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:908
text
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
Definition: All_system_messages.txt:1267
Xml\radioLabel
static radioLabel( $label, $name, $value, $id, $checked=false, $attribs=[])
Convenience function to build an HTML radio button with a label.
Definition: Xml.php:446
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:119
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 such as
Definition: distributors.txt:9
Block
Definition: Block.php:27
Html\openElement
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:252
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:210
NS_USER
const NS_USER
Definition: Defines.php:66
SpecialPage\$linkRenderer
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:66
SpecialContributions\contributionsSub
contributionsSub( $userObj)
Generates the subheading with links.
Definition: SpecialContributions.php:280
MediaWikiServices
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 MediaWikiServices
Definition: injection.txt:23
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
$username
this hook is for auditing only or null if authentication failed before getting that far $username
Definition: hooks.txt:813
ExternalUserNames\isExternal
static isExternal( $username)
Tells whether the username is external or not.
Definition: ExternalUserNames.php:135
SpecialContributions\__construct
__construct()
Definition: SpecialContributions.php:35
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:633
SpecialPage\including
including( $x=null)
Whether the special page is being evaluated via transclusion.
Definition: SpecialPage.php:228
MWNamespace\getCanonicalName
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
Definition: MWNamespace.php:255
SpecialContributions
Special:Contributions, show user contributions in a paged list.
Definition: SpecialContributions.php:32
IP\isIPAddress
static isIPAddress( $ip)
Determine if a string is as valid IP address or network (CIDR prefix).
Definition: IP.php:77
Xml\checkLabel
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:421
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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:813