MediaWiki  REL1_31
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  if ( $par !== null ) {
54  $target = $par;
55  } else {
56  $target = $request->getVal( 'target' );
57  }
58 
59  if ( $request->getVal( 'contribs' ) == 'newbie' || $par === 'newbies' ) {
60  $target = 'newbies';
61  $this->opts['contribs'] = 'newbie';
62  } else {
63  $this->opts['contribs'] = 'user';
64  }
65 
66  $this->opts['deletedOnly'] = $request->getBool( 'deletedOnly' );
67 
68  if ( !strlen( $target ) ) {
69  if ( !$this->including() ) {
70  $out->addHTML( $this->getForm() );
71  }
72 
73  return;
74  }
75 
76  $user = $this->getUser();
77 
78  $this->opts['limit'] = $request->getInt( 'limit', $user->getOption( 'rclimit' ) );
79  $this->opts['target'] = $target;
80  $this->opts['topOnly'] = $request->getBool( 'topOnly' );
81  $this->opts['newOnly'] = $request->getBool( 'newOnly' );
82  $this->opts['hideMinor'] = $request->getBool( 'hideMinor' );
83 
84  $id = 0;
85  if ( $this->opts['contribs'] === 'newbie' ) {
86  $userObj = User::newFromName( $target ); // hysterical raisins
87  $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
88  $out->setHTMLTitle( $this->msg(
89  'pagetitle',
90  $this->msg( 'sp-contributions-newbies-title' )->plain()
91  )->inContentLanguage() );
92  } elseif ( ExternalUserNames::isExternal( $target ) ) {
93  $userObj = User::newFromName( $target, false );
94  if ( !$userObj ) {
95  $out->addHTML( $this->getForm() );
96  return;
97  }
98 
99  $out->addSubtitle( $this->contributionsSub( $userObj ) );
100  $out->setHTMLTitle( $this->msg(
101  'pagetitle',
102  $this->msg( 'contributions-title', $target )->plain()
103  )->inContentLanguage() );
104  } else {
105  $nt = Title::makeTitleSafe( NS_USER, $target );
106  if ( !$nt ) {
107  $out->addHTML( $this->getForm() );
108  return;
109  }
110  $userObj = User::newFromName( $nt->getText(), false );
111  if ( !$userObj ) {
112  $out->addHTML( $this->getForm() );
113  return;
114  }
115  $id = $userObj->getId();
116 
117  $target = $nt->getText();
118  $out->addSubtitle( $this->contributionsSub( $userObj ) );
119  $out->setHTMLTitle( $this->msg(
120  'pagetitle',
121  $this->msg( 'contributions-title', $target )->plain()
122  )->inContentLanguage() );
123 
124  # For IP ranges, we want the contributionsSub, but not the skin-dependent
125  # links under 'Tools', which may include irrelevant links like 'Logs'.
126  if ( !IP::isValidRange( $target ) ) {
127  $this->getSkin()->setRelevantUser( $userObj );
128  }
129  }
130 
131  $ns = $request->getVal( 'namespace', null );
132  if ( $ns !== null && $ns !== '' ) {
133  $this->opts['namespace'] = intval( $ns );
134  } else {
135  $this->opts['namespace'] = '';
136  }
137 
138  $this->opts['associated'] = $request->getBool( 'associated' );
139  $this->opts['nsInvert'] = (bool)$request->getVal( 'nsInvert' );
140  $this->opts['tagfilter'] = (string)$request->getVal( 'tagfilter' );
141 
142  // Allows reverts to have the bot flag in recent changes. It is just here to
143  // be passed in the form at the top of the page
144  if ( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) {
145  $this->opts['bot'] = '1';
146  }
147 
148  $skip = $request->getText( 'offset' ) || $request->getText( 'dir' ) == 'prev';
149  # Offset overrides year/month selection
150  if ( !$skip ) {
151  $this->opts['year'] = $request->getVal( 'year' );
152  $this->opts['month'] = $request->getVal( 'month' );
153 
154  $this->opts['start'] = $request->getVal( 'start' );
155  $this->opts['end'] = $request->getVal( 'end' );
156  }
157  $this->opts = ContribsPager::processDateFilter( $this->opts );
158 
159  $feedType = $request->getVal( 'feed' );
160 
161  $feedParams = [
162  'action' => 'feedcontributions',
163  'user' => $target,
164  ];
165  if ( $this->opts['topOnly'] ) {
166  $feedParams['toponly'] = true;
167  }
168  if ( $this->opts['newOnly'] ) {
169  $feedParams['newonly'] = true;
170  }
171  if ( $this->opts['hideMinor'] ) {
172  $feedParams['hideminor'] = true;
173  }
174  if ( $this->opts['deletedOnly'] ) {
175  $feedParams['deletedonly'] = true;
176  }
177  if ( $this->opts['tagfilter'] !== '' ) {
178  $feedParams['tagfilter'] = $this->opts['tagfilter'];
179  }
180  if ( $this->opts['namespace'] !== '' ) {
181  $feedParams['namespace'] = $this->opts['namespace'];
182  }
183  // Don't use year and month for the feed URL, but pass them on if
184  // we redirect to API (if $feedType is specified)
185  if ( $feedType && $this->opts['year'] !== null ) {
186  $feedParams['year'] = $this->opts['year'];
187  }
188  if ( $feedType && $this->opts['month'] !== null ) {
189  $feedParams['month'] = $this->opts['month'];
190  }
191 
192  if ( $feedType ) {
193  // Maintain some level of backwards compatibility
194  // If people request feeds using the old parameters, redirect to API
195  $feedParams['feedformat'] = $feedType;
196  $url = wfAppendQuery( wfScript( 'api' ), $feedParams );
197 
198  $out->redirect( $url, '301' );
199 
200  return;
201  }
202 
203  // Add RSS/atom links
204  $this->addFeedLinks( $feedParams );
205 
206  if ( Hooks::run( 'SpecialContributionsBeforeMainOutput', [ $id, $userObj, $this ] ) ) {
207  if ( !$this->including() ) {
208  $out->addHTML( $this->getForm() );
209  }
210  $pager = new ContribsPager( $this->getContext(), [
211  'target' => $target,
212  'contribs' => $this->opts['contribs'],
213  'namespace' => $this->opts['namespace'],
214  'tagfilter' => $this->opts['tagfilter'],
215  'start' => $this->opts['start'],
216  'end' => $this->opts['end'],
217  'deletedOnly' => $this->opts['deletedOnly'],
218  'topOnly' => $this->opts['topOnly'],
219  'newOnly' => $this->opts['newOnly'],
220  'hideMinor' => $this->opts['hideMinor'],
221  'nsInvert' => $this->opts['nsInvert'],
222  'associated' => $this->opts['associated'],
223  ] );
224 
225  if ( IP::isValidRange( $target ) && !$pager->isQueryableRange( $target ) ) {
226  // Valid range, but outside CIDR limit.
227  $limits = $this->getConfig()->get( 'RangeContributionsCIDRLimit' );
228  $limit = $limits[ IP::isIPv4( $target ) ? 'IPv4' : 'IPv6' ];
229  $out->addWikiMsg( 'sp-contributions-outofrange', $limit );
230  } elseif ( !$pager->getNumRows() ) {
231  $out->addWikiMsg( 'nocontribs', $target );
232  } else {
233  // @todo We just want a wiki ID here, not a "DB domain", but
234  // current status of MediaWiki conflates the two. See T235955.
235  $poolKey = WikiMap::getCurrentWikiDbDomain() . ':SpecialContributions:';
236  if ( $this->getUser()->isAnon() ) {
237  $poolKey .= 'a:' . $this->getUser()->getName();
238  } else {
239  $poolKey .= 'u:' . $this->getUser()->getId();
240  }
241  $work = new PoolCounterWorkViaCallback( 'SpecialContributions', $poolKey, [
242  'doWork' => function () use ( $pager, $out ) {
243  # Show a message about replica DB lag, if applicable
244  $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
245  $lag = $lb->safeGetLag( $pager->getDatabase() );
246  if ( $lag > 0 ) {
247  $out->showLagWarning( $lag );
248  }
249 
250  $output = $pager->getBody();
251  if ( !$this->including() ) {
252  $output = '<p>' . $pager->getNavigationBar() . '</p>' .
253  $output .
254  '<p>' . $pager->getNavigationBar() . '</p>';
255  }
256  $out->addHTML( $output );
257  },
258  'error' => function () use ( $out ) {
259  $msg = $this->getUser()->isAnon()
260  ? 'sp-contributions-concurrency-ip'
261  : 'sp-contributions-concurrency-user';
262  $out->wrapWikiMsg( "<div class='errorbox'>\n$1\n</div>", $msg );
263  }
264  ] );
265  $work->execute();
266  }
267 
268  $out->preventClickjacking( $pager->getPreventClickjacking() );
269 
270  # Show the appropriate "footer" message - WHOIS tools, etc.
271  if ( $this->opts['contribs'] == 'newbie' ) {
272  $message = 'sp-contributions-footer-newbies';
273  } elseif ( IP::isValidRange( $target ) ) {
274  $message = 'sp-contributions-footer-anon-range';
275  } elseif ( IP::isIPAddress( $target ) ) {
276  $message = 'sp-contributions-footer-anon';
277  } elseif ( $userObj->isAnon() ) {
278  // No message for non-existing users
279  $message = '';
280  } else {
281  $message = 'sp-contributions-footer';
282  }
283 
284  if ( $message ) {
285  if ( !$this->including() ) {
286  if ( !$this->msg( $message, $target )->isDisabled() ) {
287  $out->wrapWikiMsg(
288  "<div class='mw-contributions-footer'>\n$1\n</div>",
289  [ $message, $target ] );
290  }
291  }
292  }
293  }
294  }
295 
303  protected function contributionsSub( $userObj ) {
304  if ( $userObj->isAnon() ) {
305  // Show a warning message that the user being searched for doesn't exists.
306  // User::isIP returns true for IP address and usemod IPs like '123.123.123.xxx',
307  // but returns false for IP ranges. We don't want to suggest either of these are
308  // valid usernames which we would with the 'contributions-userdoesnotexist' message.
309  if ( !User::isIP( $userObj->getName() ) && !$userObj->isIPRange() ) {
310  $this->getOutput()->wrapWikiMsg(
311  "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
312  [
313  'contributions-userdoesnotexist',
314  wfEscapeWikiText( $userObj->getName() ),
315  ]
316  );
317  if ( !$this->including() ) {
318  $this->getOutput()->setStatusCode( 404 );
319  }
320  }
321  $user = htmlspecialchars( $userObj->getName() );
322  } else {
323  $user = $this->getLinkRenderer()->makeLink( $userObj->getUserPage(), $userObj->getName() );
324  }
325  $nt = $userObj->getUserPage();
326  $talk = $userObj->getTalkPage();
327  $links = '';
328  if ( $talk ) {
329  $tools = self::getUserLinks( $this, $userObj );
330  $links = $this->getLanguage()->pipeList( $tools );
331 
332  // Show a note if the user is blocked and display the last block log entry.
333  // Do not expose the autoblocks, since that may lead to a leak of accounts' IPs,
334  // and also this will display a totally irrelevant log entry as a current block.
335  if ( !$this->including() ) {
336  // For IP ranges you must give Block::newFromTarget the CIDR string and not a user object.
337  if ( $userObj->isIPRange() ) {
338  $block = Block::newFromTarget( $userObj->getName(), $userObj->getName() );
339  } else {
340  $block = Block::newFromTarget( $userObj, $userObj );
341  }
342 
343  if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
344  if ( $block->getType() == Block::TYPE_RANGE ) {
345  $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
346  }
347 
348  $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
350  $out,
351  'block',
352  $nt,
353  '',
354  [
355  'lim' => 1,
356  'showIfEmpty' => false,
357  'msgKey' => [
358  $userObj->isAnon() ?
359  'sp-contributions-blocked-notice-anon' :
360  'sp-contributions-blocked-notice',
361  $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
362  ],
363  'offset' => '' # don't use WebRequest parameter offset
364  ]
365  );
366  }
367  }
368  }
369 
370  return $this->msg( 'contribsub2' )->rawParams( $user, $links )->params( $userObj->getName() );
371  }
372 
381  public static function getUserLinks( SpecialPage $sp, User $target ) {
382  $id = $target->getId();
383  $username = $target->getName();
384  $userpage = $target->getUserPage();
385  $talkpage = $target->getTalkPage();
386 
387  $linkRenderer = $sp->getLinkRenderer();
388 
389  # No talk pages for IP ranges.
390  if ( !IP::isValidRange( $username ) ) {
391  $tools['user-talk'] = $linkRenderer->makeLink(
392  $talkpage,
393  $sp->msg( 'sp-contributions-talk' )->text()
394  );
395  }
396 
397  if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
398  if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
399  if ( $target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO ) {
400  $tools['block'] = $linkRenderer->makeKnownLink( # Change block link
401  SpecialPage::getTitleFor( 'Block', $username ),
402  $sp->msg( 'change-blocklink' )->text()
403  );
404  $tools['unblock'] = $linkRenderer->makeKnownLink( # Unblock link
405  SpecialPage::getTitleFor( 'Unblock', $username ),
406  $sp->msg( 'unblocklink' )->text()
407  );
408  } else { # User is not blocked
409  $tools['block'] = $linkRenderer->makeKnownLink( # Block link
410  SpecialPage::getTitleFor( 'Block', $username ),
411  $sp->msg( 'blocklink' )->text()
412  );
413  }
414  }
415 
416  # Block log link
417  $tools['log-block'] = $linkRenderer->makeKnownLink(
418  SpecialPage::getTitleFor( 'Log', 'block' ),
419  $sp->msg( 'sp-contributions-blocklog' )->text(),
420  [],
421  [ 'page' => $userpage->getPrefixedText() ]
422  );
423 
424  # Suppression log link (T61120)
425  if ( $sp->getUser()->isAllowed( 'suppressionlog' ) ) {
426  $tools['log-suppression'] = $linkRenderer->makeKnownLink(
427  SpecialPage::getTitleFor( 'Log', 'suppress' ),
428  $sp->msg( 'sp-contributions-suppresslog', $username )->text(),
429  [],
430  [ 'offender' => $username ]
431  );
432  }
433  }
434 
435  # Don't show some links for IP ranges
436  if ( !IP::isValidRange( $username ) ) {
437  # Uploads
438  $tools['uploads'] = $linkRenderer->makeKnownLink(
439  SpecialPage::getTitleFor( 'Listfiles', $username ),
440  $sp->msg( 'sp-contributions-uploads' )->text()
441  );
442 
443  # Other logs link
444  $tools['logs'] = $linkRenderer->makeKnownLink(
446  $sp->msg( 'sp-contributions-logs' )->text()
447  );
448 
449  # Add link to deleted user contributions for priviledged users
450  if ( $sp->getUser()->isAllowed( 'deletedhistory' ) ) {
451  $tools['deletedcontribs'] = $linkRenderer->makeKnownLink(
452  SpecialPage::getTitleFor( 'DeletedContributions', $username ),
453  $sp->msg( 'sp-contributions-deleted', $username )->text()
454  );
455  }
456  }
457 
458  # Add a link to change user rights for privileged users
459  $userrightsPage = new UserrightsPage();
460  $userrightsPage->setContext( $sp->getContext() );
461  if ( $userrightsPage->userCanChangeRights( $target ) ) {
462  $tools['userrights'] = $linkRenderer->makeKnownLink(
463  SpecialPage::getTitleFor( 'Userrights', $username ),
464  $sp->msg( 'sp-contributions-userrights', $username )->text()
465  );
466  }
467 
468  Hooks::run( 'ContributionsToolLinks', [ $id, $userpage, &$tools, $sp ] );
469 
470  return $tools;
471  }
472 
477  protected function getForm() {
478  $this->opts['title'] = $this->getPageTitle()->getPrefixedText();
479  if ( !isset( $this->opts['target'] ) ) {
480  $this->opts['target'] = '';
481  } else {
482  $this->opts['target'] = str_replace( '_', ' ', $this->opts['target'] );
483  }
484 
485  if ( !isset( $this->opts['namespace'] ) ) {
486  $this->opts['namespace'] = '';
487  }
488 
489  if ( !isset( $this->opts['nsInvert'] ) ) {
490  $this->opts['nsInvert'] = '';
491  }
492 
493  if ( !isset( $this->opts['associated'] ) ) {
494  $this->opts['associated'] = false;
495  }
496 
497  if ( !isset( $this->opts['contribs'] ) ) {
498  $this->opts['contribs'] = 'user';
499  }
500 
501  if ( !isset( $this->opts['start'] ) ) {
502  $this->opts['start'] = '';
503  }
504 
505  if ( !isset( $this->opts['end'] ) ) {
506  $this->opts['end'] = '';
507  }
508 
509  if ( $this->opts['contribs'] == 'newbie' ) {
510  $this->opts['target'] = '';
511  }
512 
513  if ( !isset( $this->opts['tagfilter'] ) ) {
514  $this->opts['tagfilter'] = '';
515  }
516 
517  if ( !isset( $this->opts['topOnly'] ) ) {
518  $this->opts['topOnly'] = false;
519  }
520 
521  if ( !isset( $this->opts['newOnly'] ) ) {
522  $this->opts['newOnly'] = false;
523  }
524 
525  if ( !isset( $this->opts['hideMinor'] ) ) {
526  $this->opts['hideMinor'] = false;
527  }
528 
529  // Modules required only for the form
530  $this->getOutput()->addModules( [
531  'mediawiki.userSuggest',
532  'mediawiki.special.contributions',
533  ] );
534  $this->getOutput()->addModuleStyles( 'mediawiki.widgets.DateInputWidget.styles' );
535  $this->getOutput()->enableOOUI();
536 
537  $form = Html::openElement(
538  'form',
539  [
540  'method' => 'get',
541  'action' => wfScript(),
542  'class' => 'mw-contributions-form'
543  ]
544  );
545 
546  # Add hidden params for tracking except for parameters in $skipParameters
547  $skipParameters = [
548  'namespace',
549  'nsInvert',
550  'deletedOnly',
551  'target',
552  'contribs',
553  'year',
554  'month',
555  'start',
556  'end',
557  'topOnly',
558  'newOnly',
559  'hideMinor',
560  'associated',
561  'tagfilter'
562  ];
563 
564  foreach ( $this->opts as $name => $value ) {
565  if ( in_array( $name, $skipParameters ) ) {
566  continue;
567  }
568  $form .= "\t" . Html::hidden( $name, $value ) . "\n";
569  }
570 
572  $this->opts['tagfilter'], false, $this->getContext() );
573 
574  if ( $tagFilter ) {
575  $filterSelection = Html::rawElement(
576  'div',
577  [],
578  implode( '&#160;', $tagFilter )
579  );
580  } else {
581  $filterSelection = Html::rawElement( 'div', [], '' );
582  }
583 
584  $labelNewbies = Xml::radioLabel(
585  $this->msg( 'sp-contributions-newbies' )->text(),
586  'contribs',
587  'newbie',
588  'newbie',
589  $this->opts['contribs'] == 'newbie',
590  [ 'class' => 'mw-input' ]
591  );
592  $labelUsername = Xml::radioLabel(
593  $this->msg( 'sp-contributions-username' )->text(),
594  'contribs',
595  'user',
596  'user',
597  $this->opts['contribs'] == 'user',
598  [ 'class' => 'mw-input' ]
599  );
601  'target',
602  $this->opts['target'],
603  'text',
604  [
605  'size' => '40',
606  'class' => [
607  'mw-input',
608  'mw-ui-input-inline',
609  'mw-autocomplete-user', // used by mediawiki.userSuggest
610  ],
611  ] + (
612  // Only autofocus if target hasn't been specified or in non-newbies mode
613  ( $this->opts['contribs'] === 'newbie' || $this->opts['target'] )
614  ? [] : [ 'autofocus' => true ]
615  )
616  );
617 
618  $targetSelection = Html::rawElement(
619  'div',
620  [],
621  $labelNewbies . '<br>' . $labelUsername . ' ' . $input . ' '
622  );
623 
624  $namespaceSelection = Xml::tags(
625  'div',
626  [],
627  Xml::label(
628  $this->msg( 'namespace' )->text(),
629  'namespace',
630  ''
631  ) . '&#160;' .
633  [ 'selected' => $this->opts['namespace'], 'all' => '' ],
634  [
635  'name' => 'namespace',
636  'id' => 'namespace',
637  'class' => 'namespaceselector',
638  ]
639  ) . '&#160;' .
641  'span',
642  [ 'class' => 'mw-input-with-label' ],
644  $this->msg( 'invert' )->text(),
645  'nsInvert',
646  'nsInvert',
647  $this->opts['nsInvert'],
648  [
649  'title' => $this->msg( 'tooltip-invert' )->text(),
650  'class' => 'mw-input'
651  ]
652  ) . '&#160;'
653  ) .
654  Html::rawElement( 'span', [ 'class' => 'mw-input-with-label' ],
656  $this->msg( 'namespace_association' )->text(),
657  'associated',
658  'associated',
659  $this->opts['associated'],
660  [
661  'title' => $this->msg( 'tooltip-namespace_association' )->text(),
662  'class' => 'mw-input'
663  ]
664  ) . '&#160;'
665  )
666  );
667 
668  $filters = [];
669 
670  if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
671  $filters[] = Html::rawElement(
672  'span',
673  [ 'class' => 'mw-input-with-label' ],
675  $this->msg( 'history-show-deleted' )->text(),
676  'deletedOnly',
677  'mw-show-deleted-only',
678  $this->opts['deletedOnly'],
679  [ 'class' => 'mw-input' ]
680  )
681  );
682  }
683 
684  $filters[] = Html::rawElement(
685  'span',
686  [ 'class' => 'mw-input-with-label' ],
688  $this->msg( 'sp-contributions-toponly' )->text(),
689  'topOnly',
690  'mw-show-top-only',
691  $this->opts['topOnly'],
692  [ 'class' => 'mw-input' ]
693  )
694  );
695  $filters[] = Html::rawElement(
696  'span',
697  [ 'class' => 'mw-input-with-label' ],
699  $this->msg( 'sp-contributions-newonly' )->text(),
700  'newOnly',
701  'mw-show-new-only',
702  $this->opts['newOnly'],
703  [ 'class' => 'mw-input' ]
704  )
705  );
706  $filters[] = Html::rawElement(
707  'span',
708  [ 'class' => 'mw-input-with-label' ],
710  $this->msg( 'sp-contributions-hideminor' )->text(),
711  'hideMinor',
712  'mw-hide-minor-edits',
713  $this->opts['hideMinor'],
714  [ 'class' => 'mw-input' ]
715  )
716  );
717 
718  Hooks::run(
719  'SpecialContributions::getForm::filters',
720  [ $this, &$filters ]
721  );
722 
723  $extraOptions = Html::rawElement(
724  'div',
725  [],
726  implode( '', $filters )
727  );
728 
729  $dateRangeSelection = Html::rawElement(
730  'div',
731  [],
732  Xml::label( wfMessage( 'date-range-from' )->text(), 'mw-date-start' ) . ' ' .
733  new DateInputWidget( [
734  'infusable' => true,
735  'id' => 'mw-date-start',
736  'name' => 'start',
737  'value' => $this->opts['start'],
738  'longDisplayFormat' => true,
739  ] ) . '<br>' .
740  Xml::label( wfMessage( 'date-range-to' )->text(), 'mw-date-end' ) . ' ' .
741  new DateInputWidget( [
742  'infusable' => true,
743  'id' => 'mw-date-end',
744  'name' => 'end',
745  'value' => $this->opts['end'],
746  'longDisplayFormat' => true,
747  ] )
748  );
749 
750  $submit = Xml::tags( 'div', [],
752  $this->msg( 'sp-contributions-submit' )->text(),
753  [ 'class' => 'mw-submit' ], [ 'mw-ui-progressive' ]
754  )
755  );
756 
757  $form .= Xml::fieldset(
758  $this->msg( 'sp-contributions-search' )->text(),
759  $targetSelection .
760  $namespaceSelection .
761  $filterSelection .
762  $extraOptions .
763  $dateRangeSelection .
764  $submit,
765  [ 'class' => 'mw-contributions-table' ]
766  );
767 
768  $explain = $this->msg( 'sp-contributions-explain' );
769  if ( !$explain->isBlank() ) {
770  $form .= "<p id='mw-sp-contributions-explain'>{$explain->parse()}</p>";
771  }
772 
773  $form .= Xml::closeElement( 'form' );
774 
775  return $form;
776  }
777 
786  public function prefixSearchSubpages( $search, $limit, $offset ) {
787  $user = User::newFromName( $search );
788  if ( !$user ) {
789  // No prefix suggestion for invalid user
790  return [];
791  }
792  // Autocomplete subpage as user list - public to allow caching
793  return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
794  }
795 
796  protected function getGroupName() {
797  return 'users';
798  }
799 }
$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:247
SpecialContributions\prefixSearchSubpages
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
Definition: SpecialContributions.php:786
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:675
SpecialPage\msg
msg( $key)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:793
WikiMap\getCurrentWikiDbDomain
static getCurrentWikiDbDomain()
Definition: WikiMap.php:289
SpecialContributions\getUserLinks
static getUserLinks(SpecialPage $sp, User $target)
Links to different places.
Definition: SpecialContributions.php:381
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
Xml\tags
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:722
wfMessage
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
$output
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
Definition: hooks.txt:2255
plain
either a plain
Definition: hooks.txt:2056
SpecialContributions\getForm
getForm()
Generates the namespace selector form with hidden attributes.
Definition: SpecialContributions.php:477
Xml\label
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:359
Block\TYPE_RANGE
const TYPE_RANGE
Definition: Block.php:85
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:18
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:181
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
$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:864
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:1173
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:591
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:742
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:777
PoolCounterWorkViaCallback
Convenience class for dealing with PoolCounters using callbacks.
Definition: PoolCounterWorkViaCallback.php:28
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:752
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:37
ContribsPager\processDateFilter
static processDateFilter(array $opts)
Set up date filter options, given request data.
Definition: ContribsPager.php:642
Html\input
static input( $name, $value='', $type='text', array $attribs=[])
Convenience function to produce an "<input>" element.
Definition: Html.php:645
Xml\fieldset
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition: Xml.php:610
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:469
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:761
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
Wikitext formatted, in the key only.
Definition: distributors.txt:25
SpecialPage\addFeedLinks
addFeedLinks( $params)
Adds RSS/atom links.
Definition: SpecialPage.php:814
if
if(file_exists("$IP/StartProfiler.php"))
Definition: Setup.php:42
wfScript
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Definition: GlobalFunctions.php:2890
$input
if(is_array( $mode)) switch( $mode) $input
Definition: postprocess-phan.php:145
PoolCounterWork\execute
execute( $skipcache=false)
Get the result of the work (whatever it is), or the result of the error() function.
Definition: PoolCounterWork.php:104
User\isIP
static isIP( $name)
Does the string match an anonymous IP address?
Definition: User.php:943
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:527
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:732
LogEventsList\showLogExtract
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Definition: LogEventsList.php:616
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:695
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
in the order they appear.
Definition: sitelist.txt:3
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:774
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:562
$value
$value
Definition: styleTest.css.php:45
logs
as see the revision history and logs
Definition: LICENSE.txt:6
Html\namespaceSelector
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:862
some
I won t presume to tell you how to I m just describing the methods I chose to use for myself If you do choose to follow these it will probably be easier for you to collaborate with others on the but if you want to contribute without by all means do which work well I also use K &R brace matching style I know that s a religious issue for some
Definition: design.txt:79
SpecialContributions\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialContributions.php:796
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:712
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1643
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:185
Block\TYPE_AUTO
const TYPE_AUTO
Definition: Block.php:86
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:907
link
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template to be included in the link
Definition: hooks.txt:3023
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
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:2198
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:445
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:118
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:22
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:251
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
NS_USER
const NS_USER
Definition: Defines.php:76
$username
this hook is for auditing only or null if authentication failed before getting that far $username
Definition: hooks.txt:785
in
null for the wiki Added in
Definition: hooks.txt:1591
SpecialPage\$linkRenderer
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:66
$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:2806
SpecialContributions\contributionsSub
contributionsSub( $userObj)
Generates the subheading with links.
Definition: SpecialContributions.php:303
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:25
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203
ExternalUserNames\isExternal
static isExternal( $username)
Tells whether the username is external or not.
Definition: ExternalUserNames.php:115
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:629
SpecialPage\including
including( $x=null)
Whether the special page is being evaluated via transclusion.
Definition: SpecialPage.php:226
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:420