MediaWiki  master
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  if ( $this->opts['namespace'] < NS_MAIN ) {
156  $this->getOutput()->wrapWikiMsg(
157  "<div class=\"mw-invalid-namespace-assoc error\">\n\$1\n</div>",
158  [
159  'namespace-not-associated',
160  wfEscapeWikiText( $this->opts['namespace'] ),
161  ] );
162  $out->addHTML( $this->getForm() );
163  return;
164  }
165 
166  $feedType = $request->getVal( 'feed' );
167 
168  $feedParams = [
169  'action' => 'feedcontributions',
170  'user' => $target,
171  ];
172  if ( $this->opts['topOnly'] ) {
173  $feedParams['toponly'] = true;
174  }
175  if ( $this->opts['newOnly'] ) {
176  $feedParams['newonly'] = true;
177  }
178  if ( $this->opts['hideMinor'] ) {
179  $feedParams['hideminor'] = true;
180  }
181  if ( $this->opts['deletedOnly'] ) {
182  $feedParams['deletedonly'] = true;
183  }
184  if ( $this->opts['tagfilter'] !== '' ) {
185  $feedParams['tagfilter'] = $this->opts['tagfilter'];
186  }
187  if ( $this->opts['namespace'] !== '' ) {
188  $feedParams['namespace'] = $this->opts['namespace'];
189  }
190  // Don't use year and month for the feed URL, but pass them on if
191  // we redirect to API (if $feedType is specified)
192  if ( $feedType && $this->opts['year'] !== null ) {
193  $feedParams['year'] = $this->opts['year'];
194  }
195  if ( $feedType && $this->opts['month'] !== null ) {
196  $feedParams['month'] = $this->opts['month'];
197  }
198 
199  if ( $feedType ) {
200  // Maintain some level of backwards compatibility
201  // If people request feeds using the old parameters, redirect to API
202  $feedParams['feedformat'] = $feedType;
203  $url = wfAppendQuery( wfScript( 'api' ), $feedParams );
204 
205  $out->redirect( $url, '301' );
206 
207  return;
208  }
209 
210  // Add RSS/atom links
211  $this->addFeedLinks( $feedParams );
212 
213  if ( Hooks::run( 'SpecialContributionsBeforeMainOutput', [ $id, $userObj, $this ] ) ) {
214  if ( !$this->including() ) {
215  $out->addHTML( $this->getForm() );
216  }
217  $pager = new ContribsPager( $this->getContext(), [
218  'target' => $target,
219  'contribs' => $this->opts['contribs'],
220  'namespace' => $this->opts['namespace'],
221  'tagfilter' => $this->opts['tagfilter'],
222  'start' => $this->opts['start'],
223  'end' => $this->opts['end'],
224  'deletedOnly' => $this->opts['deletedOnly'],
225  'topOnly' => $this->opts['topOnly'],
226  'newOnly' => $this->opts['newOnly'],
227  'hideMinor' => $this->opts['hideMinor'],
228  'nsInvert' => $this->opts['nsInvert'],
229  'associated' => $this->opts['associated'],
230  ] );
231 
232  if ( IP::isValidRange( $target ) && !$pager->isQueryableRange( $target ) ) {
233  // Valid range, but outside CIDR limit.
234  $limits = $this->getConfig()->get( 'RangeContributionsCIDRLimit' );
235  $limit = $limits[ IP::isIPv4( $target ) ? 'IPv4' : 'IPv6' ];
236  $out->addWikiMsg( 'sp-contributions-outofrange', $limit );
237  } elseif ( !$pager->getNumRows() ) {
238  $out->addWikiMsg( 'nocontribs', $target );
239  } else {
240  # Show a message about replica DB lag, if applicable
241  $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
242  $lag = $lb->safeGetLag( $pager->getDatabase() );
243  if ( $lag > 0 ) {
244  $out->showLagWarning( $lag );
245  }
246 
247  $output = $pager->getBody();
248  if ( !$this->including() ) {
249  $output = '<p>' . $pager->getNavigationBar() . '</p>' .
250  $output .
251  '<p>' . $pager->getNavigationBar() . '</p>';
252  }
253  $out->addHTML( $output );
254  }
255 
256  $out->preventClickjacking( $pager->getPreventClickjacking() );
257 
258  # Show the appropriate "footer" message - WHOIS tools, etc.
259  if ( $this->opts['contribs'] == 'newbie' ) {
260  $message = 'sp-contributions-footer-newbies';
261  } elseif ( IP::isValidRange( $target ) ) {
262  $message = 'sp-contributions-footer-anon-range';
263  } elseif ( IP::isIPAddress( $target ) ) {
264  $message = 'sp-contributions-footer-anon';
265  } elseif ( $userObj->isAnon() ) {
266  // No message for non-existing users
267  $message = '';
268  } else {
269  $message = 'sp-contributions-footer';
270  }
271 
272  if ( $message ) {
273  if ( !$this->including() ) {
274  if ( !$this->msg( $message, $target )->isDisabled() ) {
275  $out->wrapWikiMsg(
276  "<div class='mw-contributions-footer'>\n$1\n</div>",
277  [ $message, $target ] );
278  }
279  }
280  }
281  }
282  }
283 
291  protected function contributionsSub( $userObj ) {
292  if ( $userObj->isAnon() ) {
293  // Show a warning message that the user being searched for doesn't exists.
294  // User::isIP returns true for IP address and usemod IPs like '123.123.123.xxx',
295  // but returns false for IP ranges. We don't want to suggest either of these are
296  // valid usernames which we would with the 'contributions-userdoesnotexist' message.
297  if ( !User::isIP( $userObj->getName() ) && !$userObj->isIPRange() ) {
298  $this->getOutput()->wrapWikiMsg(
299  "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
300  [
301  'contributions-userdoesnotexist',
302  wfEscapeWikiText( $userObj->getName() ),
303  ]
304  );
305  if ( !$this->including() ) {
306  $this->getOutput()->setStatusCode( 404 );
307  }
308  }
309  $user = htmlspecialchars( $userObj->getName() );
310  } else {
311  $user = $this->getLinkRenderer()->makeLink( $userObj->getUserPage(), $userObj->getName() );
312  }
313  $nt = $userObj->getUserPage();
314  $talk = $userObj->getTalkPage();
315  $links = '';
316  if ( $talk ) {
317  $tools = self::getUserLinks( $this, $userObj );
318  $links = $this->getLanguage()->pipeList( $tools );
319 
320  // Show a note if the user is blocked and display the last block log entry.
321  // Do not expose the autoblocks, since that may lead to a leak of accounts' IPs,
322  // and also this will display a totally irrelevant log entry as a current block.
323  if ( !$this->including() ) {
324  // For IP ranges you must give Block::newFromTarget the CIDR string and not a user object.
325  if ( $userObj->isIPRange() ) {
326  $block = Block::newFromTarget( $userObj->getName(), $userObj->getName() );
327  } else {
328  $block = Block::newFromTarget( $userObj, $userObj );
329  }
330 
331  if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
332  if ( $block->getType() == Block::TYPE_RANGE ) {
333  $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
334  }
335 
336  $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
338  $out,
339  'block',
340  $nt,
341  '',
342  [
343  'lim' => 1,
344  'showIfEmpty' => false,
345  'msgKey' => [
346  $userObj->isAnon() ?
347  'sp-contributions-blocked-notice-anon' :
348  'sp-contributions-blocked-notice',
349  $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
350  ],
351  'offset' => '' # don't use WebRequest parameter offset
352  ]
353  );
354  }
355  }
356  }
357 
358  return $this->msg( 'contribsub2' )->rawParams( $user, $links )->params( $userObj->getName() );
359  }
360 
369  public static function getUserLinks( SpecialPage $sp, User $target ) {
370  $id = $target->getId();
371  $username = $target->getName();
372  $userpage = $target->getUserPage();
373  $talkpage = $target->getTalkPage();
374 
375  $linkRenderer = $sp->getLinkRenderer();
376 
377  # No talk pages for IP ranges.
378  if ( !IP::isValidRange( $username ) ) {
379  $tools['user-talk'] = $linkRenderer->makeLink(
380  $talkpage,
381  $sp->msg( 'sp-contributions-talk' )->text()
382  );
383  }
384 
385  if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
386  if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
387  if ( $target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO ) {
388  $tools['block'] = $linkRenderer->makeKnownLink( # Change block link
389  SpecialPage::getTitleFor( 'Block', $username ),
390  $sp->msg( 'change-blocklink' )->text()
391  );
392  $tools['unblock'] = $linkRenderer->makeKnownLink( # Unblock link
393  SpecialPage::getTitleFor( 'Unblock', $username ),
394  $sp->msg( 'unblocklink' )->text()
395  );
396  } else { # User is not blocked
397  $tools['block'] = $linkRenderer->makeKnownLink( # Block link
398  SpecialPage::getTitleFor( 'Block', $username ),
399  $sp->msg( 'blocklink' )->text()
400  );
401  }
402  }
403 
404  # Block log link
405  $tools['log-block'] = $linkRenderer->makeKnownLink(
406  SpecialPage::getTitleFor( 'Log', 'block' ),
407  $sp->msg( 'sp-contributions-blocklog' )->text(),
408  [],
409  [ 'page' => $userpage->getPrefixedText() ]
410  );
411 
412  # Suppression log link (T61120)
413  if ( $sp->getUser()->isAllowed( 'suppressionlog' ) ) {
414  $tools['log-suppression'] = $linkRenderer->makeKnownLink(
415  SpecialPage::getTitleFor( 'Log', 'suppress' ),
416  $sp->msg( 'sp-contributions-suppresslog', $username )->text(),
417  [],
418  [ 'offender' => $username ]
419  );
420  }
421  }
422 
423  # Don't show some links for IP ranges
424  if ( !IP::isValidRange( $username ) ) {
425  # Uploads
426  $tools['uploads'] = $linkRenderer->makeKnownLink(
427  SpecialPage::getTitleFor( 'Listfiles', $username ),
428  $sp->msg( 'sp-contributions-uploads' )->text()
429  );
430 
431  # Other logs link
432  $tools['logs'] = $linkRenderer->makeKnownLink(
434  $sp->msg( 'sp-contributions-logs' )->text()
435  );
436 
437  # Add link to deleted user contributions for priviledged users
438  if ( $sp->getUser()->isAllowed( 'deletedhistory' ) ) {
439  $tools['deletedcontribs'] = $linkRenderer->makeKnownLink(
440  SpecialPage::getTitleFor( 'DeletedContributions', $username ),
441  $sp->msg( 'sp-contributions-deleted', $username )->text()
442  );
443  }
444  }
445 
446  # Add a link to change user rights for privileged users
447  $userrightsPage = new UserrightsPage();
448  $userrightsPage->setContext( $sp->getContext() );
449  if ( $userrightsPage->userCanChangeRights( $target ) ) {
450  $tools['userrights'] = $linkRenderer->makeKnownLink(
451  SpecialPage::getTitleFor( 'Userrights', $username ),
452  $sp->msg( 'sp-contributions-userrights', $username )->text()
453  );
454  }
455 
456  Hooks::run( 'ContributionsToolLinks', [ $id, $userpage, &$tools, $sp ] );
457 
458  return $tools;
459  }
460 
465  protected function getForm() {
466  $this->opts['title'] = $this->getPageTitle()->getPrefixedText();
467  if ( !isset( $this->opts['target'] ) ) {
468  $this->opts['target'] = '';
469  } else {
470  $this->opts['target'] = str_replace( '_', ' ', $this->opts['target'] );
471  }
472 
473  if ( !isset( $this->opts['namespace'] ) ) {
474  $this->opts['namespace'] = '';
475  }
476 
477  if ( !isset( $this->opts['nsInvert'] ) ) {
478  $this->opts['nsInvert'] = '';
479  }
480 
481  if ( !isset( $this->opts['associated'] ) ) {
482  $this->opts['associated'] = false;
483  }
484 
485  if ( !isset( $this->opts['contribs'] ) ) {
486  $this->opts['contribs'] = 'user';
487  }
488 
489  if ( !isset( $this->opts['start'] ) ) {
490  $this->opts['start'] = '';
491  }
492 
493  if ( !isset( $this->opts['end'] ) ) {
494  $this->opts['end'] = '';
495  }
496 
497  if ( $this->opts['contribs'] == 'newbie' ) {
498  $this->opts['target'] = '';
499  }
500 
501  if ( !isset( $this->opts['tagfilter'] ) ) {
502  $this->opts['tagfilter'] = '';
503  }
504 
505  if ( !isset( $this->opts['topOnly'] ) ) {
506  $this->opts['topOnly'] = false;
507  }
508 
509  if ( !isset( $this->opts['newOnly'] ) ) {
510  $this->opts['newOnly'] = false;
511  }
512 
513  if ( !isset( $this->opts['hideMinor'] ) ) {
514  $this->opts['hideMinor'] = false;
515  }
516 
517  // Modules required only for the form
518  $this->getOutput()->addModules( [
519  'mediawiki.userSuggest',
520  'mediawiki.special.contributions',
521  ] );
522  $this->getOutput()->addModuleStyles( 'mediawiki.widgets.DateInputWidget.styles' );
523  $this->getOutput()->enableOOUI();
524 
525  $form = Html::openElement(
526  'form',
527  [
528  'method' => 'get',
529  'action' => wfScript(),
530  'class' => 'mw-contributions-form'
531  ]
532  );
533 
534  # Add hidden params for tracking except for parameters in $skipParameters
535  $skipParameters = [
536  'namespace',
537  'nsInvert',
538  'deletedOnly',
539  'target',
540  'contribs',
541  'year',
542  'month',
543  'start',
544  'end',
545  'topOnly',
546  'newOnly',
547  'hideMinor',
548  'associated',
549  'tagfilter'
550  ];
551 
552  foreach ( $this->opts as $name => $value ) {
553  if ( in_array( $name, $skipParameters ) ) {
554  continue;
555  }
556  $form .= "\t" . Html::hidden( $name, $value ) . "\n";
557  }
558 
560  $this->opts['tagfilter'], false, $this->getContext() );
561 
562  if ( $tagFilter ) {
563  $filterSelection = Html::rawElement(
564  'div',
565  [],
566  implode( "\u{00A0}", $tagFilter )
567  );
568  } else {
569  $filterSelection = Html::rawElement( 'div', [], '' );
570  }
571 
572  $labelNewbies = Xml::radioLabel(
573  $this->msg( 'sp-contributions-newbies' )->text(),
574  'contribs',
575  'newbie',
576  'newbie',
577  $this->opts['contribs'] == 'newbie',
578  [ 'class' => 'mw-input' ]
579  );
580  $labelUsername = Xml::radioLabel(
581  $this->msg( 'sp-contributions-username' )->text(),
582  'contribs',
583  'user',
584  'user',
585  $this->opts['contribs'] == 'user',
586  [ 'class' => 'mw-input' ]
587  );
589  'target',
590  $this->opts['target'],
591  'text',
592  [
593  'size' => '40',
594  'class' => [
595  'mw-input',
596  'mw-ui-input-inline',
597  'mw-autocomplete-user', // used by mediawiki.userSuggest
598  ],
599  ] + (
600  // Only autofocus if target hasn't been specified or in non-newbies mode
601  ( $this->opts['contribs'] === 'newbie' || $this->opts['target'] )
602  ? [] : [ 'autofocus' => true ]
603  )
604  );
605 
606  $targetSelection = Html::rawElement(
607  'div',
608  [],
609  $labelNewbies . '<br>' . $labelUsername . ' ' . $input . ' '
610  );
611 
612  $namespaceSelection = Xml::tags(
613  'div',
614  [],
615  Xml::label(
616  $this->msg( 'namespace' )->text(),
617  'namespace',
618  ''
619  ) . "\u{00A0}" .
621  [ 'selected' => $this->opts['namespace'], 'all' => '', 'in-user-lang' => true ],
622  [
623  'name' => 'namespace',
624  'id' => 'namespace',
625  'class' => 'namespaceselector',
626  ]
627  ) . "\u{00A0}" .
629  'span',
630  [ 'class' => 'mw-input-with-label' ],
632  $this->msg( 'invert' )->text(),
633  'nsInvert',
634  'nsInvert',
635  $this->opts['nsInvert'],
636  [
637  'title' => $this->msg( 'tooltip-invert' )->text(),
638  'class' => 'mw-input'
639  ]
640  ) . "\u{00A0}"
641  ) .
642  Html::rawElement( 'span', [ 'class' => 'mw-input-with-label' ],
644  $this->msg( 'namespace_association' )->text(),
645  'associated',
646  'associated',
647  $this->opts['associated'],
648  [
649  'title' => $this->msg( 'tooltip-namespace_association' )->text(),
650  'class' => 'mw-input'
651  ]
652  ) . "\u{00A0}"
653  )
654  );
655 
656  $filters = [];
657 
658  if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
659  $filters[] = Html::rawElement(
660  'span',
661  [ 'class' => 'mw-input-with-label' ],
663  $this->msg( 'history-show-deleted' )->text(),
664  'deletedOnly',
665  'mw-show-deleted-only',
666  $this->opts['deletedOnly'],
667  [ 'class' => 'mw-input' ]
668  )
669  );
670  }
671 
672  $filters[] = Html::rawElement(
673  'span',
674  [ 'class' => 'mw-input-with-label' ],
676  $this->msg( 'sp-contributions-toponly' )->text(),
677  'topOnly',
678  'mw-show-top-only',
679  $this->opts['topOnly'],
680  [ 'class' => 'mw-input' ]
681  )
682  );
683  $filters[] = Html::rawElement(
684  'span',
685  [ 'class' => 'mw-input-with-label' ],
687  $this->msg( 'sp-contributions-newonly' )->text(),
688  'newOnly',
689  'mw-show-new-only',
690  $this->opts['newOnly'],
691  [ 'class' => 'mw-input' ]
692  )
693  );
694  $filters[] = Html::rawElement(
695  'span',
696  [ 'class' => 'mw-input-with-label' ],
698  $this->msg( 'sp-contributions-hideminor' )->text(),
699  'hideMinor',
700  'mw-hide-minor-edits',
701  $this->opts['hideMinor'],
702  [ 'class' => 'mw-input' ]
703  )
704  );
705 
706  Hooks::run(
707  'SpecialContributions::getForm::filters',
708  [ $this, &$filters ]
709  );
710 
711  $extraOptions = Html::rawElement(
712  'div',
713  [],
714  implode( '', $filters )
715  );
716 
717  $dateRangeSelection = Html::rawElement(
718  'div',
719  [],
720  Xml::label( $this->msg( 'date-range-from' )->text(), 'mw-date-start' ) . ' ' .
721  new DateInputWidget( [
722  'infusable' => true,
723  'id' => 'mw-date-start',
724  'name' => 'start',
725  'value' => $this->opts['start'],
726  'longDisplayFormat' => true,
727  ] ) . '<br>' .
728  Xml::label( $this->msg( 'date-range-to' )->text(), 'mw-date-end' ) . ' ' .
729  new DateInputWidget( [
730  'infusable' => true,
731  'id' => 'mw-date-end',
732  'name' => 'end',
733  'value' => $this->opts['end'],
734  'longDisplayFormat' => true,
735  ] )
736  );
737 
738  $submit = Xml::tags( 'div', [],
740  $this->msg( 'sp-contributions-submit' )->text(),
741  [ 'class' => 'mw-submit' ], [ 'mw-ui-progressive' ]
742  )
743  );
744 
745  $form .= Xml::fieldset(
746  $this->msg( 'sp-contributions-search' )->text(),
747  $targetSelection .
748  $namespaceSelection .
749  $filterSelection .
750  $extraOptions .
751  $dateRangeSelection .
752  $submit,
753  [ 'class' => 'mw-contributions-table' ]
754  );
755 
756  $explain = $this->msg( 'sp-contributions-explain' );
757  if ( !$explain->isBlank() ) {
758  $form .= Html::rawElement(
759  'p', [ 'id' => 'mw-sp-contributions-explain' ], $explain->parse()
760  );
761  }
762 
763  $form .= Xml::closeElement( 'form' );
764 
765  return $form;
766  }
767 
776  public function prefixSearchSubpages( $search, $limit, $offset ) {
777  $user = User::newFromName( $search );
778  if ( !$user ) {
779  // No prefix suggestion for invalid user
780  return [];
781  }
782  // Autocomplete subpage as user list - public to allow caching
783  return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
784  }
785 
786  protected function getGroupName() {
787  return 'users';
788  }
789 }
static isValidRange( $ipRange)
Validate an IP range (valid address with a valid CIDR prefix).
Definition: IP.php:138
static isIPAddress( $ip)
Determine if a string is as valid IP address or network (CIDR prefix).
Definition: IP.php:77
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
either a plain
Definition: hooks.txt:2056
static processDateFilter(array $opts)
Set up date filter options, given request data.
getContext()
Gets the context this SpecialPage is executed in.
const TYPE_RANGE
Definition: Block.php:98
if(is_array( $mode)) switch( $mode) $input
const NS_MAIN
Definition: Defines.php:64
getForm()
Generates the namespace selector form with hidden attributes.
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
including( $x=null)
Whether the special page is being evaluated via transclusion.
static isIP( $name)
Does the string match an anonymous IP address?
Definition: User.php:966
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target&#39;s type, get an existing Block object if possible.
Definition: Block.php:1279
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing &#39;/&#39;...
Definition: Html.php:252
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:210
null for the local wiki Added in
Definition: hooks.txt:1598
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
$value
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
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
getOutput()
Get the OutputPage being used for this instance.
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
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
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:2220
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
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
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
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Shortcut to construct an includable special page.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging a wrapping ErrorException block
Definition: hooks.txt:2172
Special:Contributions, show user contributions in a paged list.
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition: Xml.php:611
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.
Definition: distributors.txt:9
contributionsSub( $userObj)
Generates the subheading with links.
getSkin()
Shortcut to get the skin being used for this instance.
static tags( $element, $attribs, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:132
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
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 null
Definition: hooks.txt:780
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don&#39;t need a full Title object...
Definition: SpecialPage.php:82
static input( $name, $value='', $type='text', array $attribs=[])
Convenience function to produce an "<input>" element.
Definition: Html.php:672
const TYPE_AUTO
Definition: Block.php:99
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
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:360
static radioLabel( $label, $name, $value, $id, $checked=false, $attribs=[])
Convenience function to build an HTML radio button with a label.
Definition: Xml.php:446
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:573
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
addFeedLinks( $params)
Adds RSS/atom links.
this hook is for auditing only or null if authentication failed before getting that far $username
Definition: hooks.txt:780
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
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
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 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:780
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:119
getUser()
Shortcut to get the User executing this instance.
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:801
getConfig()
Shortcut to get main config object.
static isIPv4( $ip)
Given a string, determine if it as valid IP in IPv4 only.
Definition: IP.php:99
getLanguage()
Shortcut to get user&#39;s language.
msg( $key)
Wrapper around wfMessage that sets the current context.
Special page to allow managing user group membership.
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:421
getRequest()
Get the WebRequest being used for this instance.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:584
static buildTagFilterSelector( $selected='', $ooui=false, IContextSource $context=null)
Build a text box to select a change tag.
Definition: ChangeTags.php:828
Definition: Block.php:31
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:2625
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
getPageTitle( $subpage=false)
Get a self-referential title object.
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1486
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
static isExternal( $username)
Tells whether the username is external or not.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:66
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:893