MediaWiki  master
SpecialContributions.php
Go to the documentation of this file.
1 <?php
27 
34  protected $opts;
35 
36  public function __construct() {
37  parent::__construct( 'Contributions' );
38  }
39 
40  public function execute( $par ) {
41  $this->setHeaders();
42  $this->outputHeader();
43  $out = $this->getOutput();
44  // Modules required for viewing the list of contributions (also when included on other pages)
45  $out->addModuleStyles( [
46  'mediawiki.interface.helpers.styles',
47  'mediawiki.special',
48  'mediawiki.special.changeslist',
49  ] );
50  $out->addModules( 'mediawiki.special.recentchanges' );
51  $this->addHelpLink( 'Help:User contributions' );
52 
53  $this->opts = [];
54  $request = $this->getRequest();
55 
56  $target = $par ?? $request->getVal( 'target' );
57 
58  if ( $request->getVal( 'contribs' ) == 'newbie' || $par === 'newbies' ) {
59  $target = 'newbies';
60  $this->opts['contribs'] = 'newbie';
61  } else {
62  $this->opts['contribs'] = 'user';
63  }
64 
65  $this->opts['deletedOnly'] = $request->getBool( 'deletedOnly' );
66 
67  if ( !strlen( $target ) ) {
68  if ( !$this->including() ) {
69  $out->addHTML( $this->getForm() );
70  }
71 
72  return;
73  }
74 
75  $user = $this->getUser();
76 
77  $this->opts['limit'] = $request->getInt( 'limit', $user->getOption( 'rclimit' ) );
78  $this->opts['target'] = $target;
79  $this->opts['topOnly'] = $request->getBool( 'topOnly' );
80  $this->opts['newOnly'] = $request->getBool( 'newOnly' );
81  $this->opts['hideMinor'] = $request->getBool( 'hideMinor' );
82 
83  $id = 0;
84  if ( $this->opts['contribs'] === 'newbie' ) {
85  $userObj = User::newFromName( $target ); // hysterical raisins
86  $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
87  $out->setHTMLTitle( $this->msg(
88  'pagetitle',
89  $this->msg( 'sp-contributions-newbies-title' )->plain()
90  )->inContentLanguage() );
91  } elseif ( ExternalUserNames::isExternal( $target ) ) {
92  $userObj = User::newFromName( $target, false );
93  if ( !$userObj ) {
94  $out->addHTML( $this->getForm() );
95  return;
96  }
97 
98  $out->addSubtitle( $this->contributionsSub( $userObj ) );
99  $out->setHTMLTitle( $this->msg(
100  'pagetitle',
101  $this->msg( 'contributions-title', $target )->plain()
102  )->inContentLanguage() );
103  } else {
104  $nt = Title::makeTitleSafe( NS_USER, $target );
105  if ( !$nt ) {
106  $out->addHTML( $this->getForm() );
107  return;
108  }
109  $userObj = User::newFromName( $nt->getText(), false );
110  if ( !$userObj ) {
111  $out->addHTML( $this->getForm() );
112  return;
113  }
114  $id = $userObj->getId();
115 
116  $target = $nt->getText();
117  $out->addSubtitle( $this->contributionsSub( $userObj ) );
118  $out->setHTMLTitle( $this->msg(
119  'pagetitle',
120  $this->msg( 'contributions-title', $target )->plain()
121  )->inContentLanguage() );
122 
123  # For IP ranges, we want the contributionsSub, but not the skin-dependent
124  # links under 'Tools', which may include irrelevant links like 'Logs'.
125  if ( !IP::isValidRange( $target ) ) {
126  $this->getSkin()->setRelevantUser( $userObj );
127  }
128  }
129 
130  $ns = $request->getVal( 'namespace', null );
131  if ( $ns !== null && $ns !== '' ) {
132  $this->opts['namespace'] = intval( $ns );
133  } else {
134  $this->opts['namespace'] = '';
135  }
136 
137  $this->opts['associated'] = $request->getBool( 'associated' );
138  $this->opts['nsInvert'] = (bool)$request->getVal( 'nsInvert' );
139  $this->opts['tagfilter'] = (string)$request->getVal( 'tagfilter' );
140 
141  // Allows reverts to have the bot flag in recent changes. It is just here to
142  // be passed in the form at the top of the page
143  if ( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) {
144  $this->opts['bot'] = '1';
145  }
146 
147  $skip = $request->getText( 'offset' ) || $request->getText( 'dir' ) == 'prev';
148  # Offset overrides year/month selection
149  if ( !$skip ) {
150  $this->opts['year'] = $request->getVal( 'year' );
151  $this->opts['month'] = $request->getVal( 'month' );
152 
153  $this->opts['start'] = $request->getVal( 'start' );
154  $this->opts['end'] = $request->getVal( 'end' );
155  }
156  $this->opts = ContribsPager::processDateFilter( $this->opts );
157 
158  if ( $this->opts['namespace'] < NS_MAIN ) {
159  $this->getOutput()->wrapWikiMsg(
160  "<div class=\"mw-negative-namespace-not-supported error\">\n\$1\n</div>",
161  [ 'negative-namespace-not-supported' ]
162  );
163  $out->addHTML( $this->getForm() );
164  return;
165  }
166 
167  $feedType = $request->getVal( 'feed' );
168 
169  $feedParams = [
170  'action' => 'feedcontributions',
171  'user' => $target,
172  ];
173  if ( $this->opts['topOnly'] ) {
174  $feedParams['toponly'] = true;
175  }
176  if ( $this->opts['newOnly'] ) {
177  $feedParams['newonly'] = true;
178  }
179  if ( $this->opts['hideMinor'] ) {
180  $feedParams['hideminor'] = true;
181  }
182  if ( $this->opts['deletedOnly'] ) {
183  $feedParams['deletedonly'] = true;
184  }
185  if ( $this->opts['tagfilter'] !== '' ) {
186  $feedParams['tagfilter'] = $this->opts['tagfilter'];
187  }
188  if ( $this->opts['namespace'] !== '' ) {
189  $feedParams['namespace'] = $this->opts['namespace'];
190  }
191  // Don't use year and month for the feed URL, but pass them on if
192  // we redirect to API (if $feedType is specified)
193  if ( $feedType && $this->opts['year'] !== null ) {
194  $feedParams['year'] = $this->opts['year'];
195  }
196  if ( $feedType && $this->opts['month'] !== null ) {
197  $feedParams['month'] = $this->opts['month'];
198  }
199 
200  if ( $feedType ) {
201  // Maintain some level of backwards compatibility
202  // If people request feeds using the old parameters, redirect to API
203  $feedParams['feedformat'] = $feedType;
204  $url = wfAppendQuery( wfScript( 'api' ), $feedParams );
205 
206  $out->redirect( $url, '301' );
207 
208  return;
209  }
210 
211  // Add RSS/atom links
212  $this->addFeedLinks( $feedParams );
213 
214  if ( Hooks::run( 'SpecialContributionsBeforeMainOutput', [ $id, $userObj, $this ] ) ) {
215  if ( !$this->including() ) {
216  $out->addHTML( $this->getForm() );
217  }
218  $pager = new ContribsPager( $this->getContext(), [
219  'target' => $target,
220  'contribs' => $this->opts['contribs'],
221  'namespace' => $this->opts['namespace'],
222  'tagfilter' => $this->opts['tagfilter'],
223  'start' => $this->opts['start'],
224  'end' => $this->opts['end'],
225  'deletedOnly' => $this->opts['deletedOnly'],
226  'topOnly' => $this->opts['topOnly'],
227  'newOnly' => $this->opts['newOnly'],
228  'hideMinor' => $this->opts['hideMinor'],
229  'nsInvert' => $this->opts['nsInvert'],
230  'associated' => $this->opts['associated'],
231  ] );
232 
233  if ( IP::isValidRange( $target ) && !$pager->isQueryableRange( $target ) ) {
234  // Valid range, but outside CIDR limit.
235  $limits = $this->getConfig()->get( 'RangeContributionsCIDRLimit' );
236  $limit = $limits[ IP::isIPv4( $target ) ? 'IPv4' : 'IPv6' ];
237  $out->addWikiMsg( 'sp-contributions-outofrange', $limit );
238  } elseif ( !$pager->getNumRows() ) {
239  $out->addWikiMsg( 'nocontribs', $target );
240  } else {
241  # Show a message about replica DB lag, if applicable
242  $lag = $pager->getDatabase()->getSessionLagStatus()['lag'];
243  if ( $lag > 0 ) {
244  $out->showLagWarning( $lag );
245  }
246 
247  $output = $pager->getBody();
248  if ( !$this->including() ) {
249  $output = $pager->getNavigationBar() .
250  $output .
251  $pager->getNavigationBar();
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 && !$this->including() && !$this->msg( $message, $target )->isDisabled() ) {
273  $out->wrapWikiMsg(
274  "<div class='mw-contributions-footer'>\n$1\n</div>",
275  [ $message, $target ] );
276  }
277  }
278  }
279 
287  protected function contributionsSub( $userObj ) {
288  if ( $userObj->isAnon() ) {
289  // Show a warning message that the user being searched for doesn't exist.
290  // User::isIP returns true for IP address and usemod IPs like '123.123.123.xxx',
291  // but returns false for IP ranges. We don't want to suggest either of these are
292  // valid usernames which we would with the 'contributions-userdoesnotexist' message.
293  if ( !User::isIP( $userObj->getName() ) && !$userObj->isIPRange() ) {
294  $this->getOutput()->wrapWikiMsg(
295  "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
296  [
297  'contributions-userdoesnotexist',
298  wfEscapeWikiText( $userObj->getName() ),
299  ]
300  );
301  if ( !$this->including() ) {
302  $this->getOutput()->setStatusCode( 404 );
303  }
304  }
305  $user = htmlspecialchars( $userObj->getName() );
306  } else {
307  $user = $this->getLinkRenderer()->makeLink( $userObj->getUserPage(), $userObj->getName() );
308  }
309  $nt = $userObj->getUserPage();
310  $talk = $userObj->getTalkPage();
311  $links = '';
312  if ( $talk ) {
313  $tools = self::getUserLinks( $this, $userObj );
314  $links = Html::openElement( 'span', [ 'class' => 'mw-changeslist-links' ] );
315  foreach ( $tools as $tool ) {
316  $links .= Html::rawElement( 'span', [], $tool ) . ' ';
317  }
318  $links = trim( $links ) . Html::closeElement( 'span' );
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 DatabaseBlock::newFromTarget the CIDR string
325  // and not a user object.
326  if ( $userObj->isIPRange() ) {
327  $block = DatabaseBlock::newFromTarget( $userObj->getName(), $userObj->getName() );
328  } else {
329  $block = DatabaseBlock::newFromTarget( $userObj, $userObj );
330  }
331 
332  if ( !is_null( $block ) && $block->getType() != DatabaseBlock::TYPE_AUTO ) {
333  if ( $block->getType() == DatabaseBlock::TYPE_RANGE ) {
334  $nt = MediaWikiServices::getInstance()->getNamespaceInfo()->
335  getCanonicalName( NS_USER ) . ':' . $block->getTarget();
336  }
337 
338  $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
340  $out,
341  'block',
342  $nt,
343  '',
344  [
345  'lim' => 1,
346  'showIfEmpty' => false,
347  'msgKey' => [
348  $userObj->isAnon() ?
349  'sp-contributions-blocked-notice-anon' :
350  'sp-contributions-blocked-notice',
351  $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
352  ],
353  'offset' => '' # don't use WebRequest parameter offset
354  ]
355  );
356  }
357  }
358  }
359 
360  return Html::rawElement( 'div', [ 'class' => 'mw-contributions-user-tools' ],
361  $this->msg( 'contributions-subtitle' )->rawParams( $user )->params( $userObj->getName() )
362  . ' ' . $links
363  );
364  }
365 
374  public static function getUserLinks( SpecialPage $sp, User $target ) {
375  $id = $target->getId();
376  $username = $target->getName();
377  $userpage = $target->getUserPage();
378  $talkpage = $target->getTalkPage();
379  $isIP = IP::isValid( $username );
380  $isRange = IP::isValidRange( $username );
381 
382  $linkRenderer = $sp->getLinkRenderer();
383 
384  # No talk pages for IP ranges.
385  if ( !$isRange ) {
386  $tools['user-talk'] = $linkRenderer->makeLink(
387  $talkpage,
388  $sp->msg( 'sp-contributions-talk' )->text()
389  );
390  }
391 
392  if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
393  if ( $target->getBlock() && $target->getBlock()->getType() != DatabaseBlock::TYPE_AUTO ) {
394  $tools['block'] = $linkRenderer->makeKnownLink( # Change block link
395  SpecialPage::getTitleFor( 'Block', $username ),
396  $sp->msg( 'change-blocklink' )->text()
397  );
398  $tools['unblock'] = $linkRenderer->makeKnownLink( # Unblock link
399  SpecialPage::getTitleFor( 'Unblock', $username ),
400  $sp->msg( 'unblocklink' )->text()
401  );
402  } else { # User is not blocked
403  $tools['block'] = $linkRenderer->makeKnownLink( # Block link
404  SpecialPage::getTitleFor( 'Block', $username ),
405  $sp->msg( 'blocklink' )->text()
406  );
407  }
408  }
409 
410  # Block log link
411  $tools['log-block'] = $linkRenderer->makeKnownLink(
412  SpecialPage::getTitleFor( 'Log', 'block' ),
413  $sp->msg( 'sp-contributions-blocklog' )->text(),
414  [],
415  [ 'page' => $userpage->getPrefixedText() ]
416  );
417 
418  # Suppression log link (T61120)
419  if ( $sp->getUser()->isAllowed( 'suppressionlog' ) ) {
420  $tools['log-suppression'] = $linkRenderer->makeKnownLink(
421  SpecialPage::getTitleFor( 'Log', 'suppress' ),
422  $sp->msg( 'sp-contributions-suppresslog', $username )->text(),
423  [],
424  [ 'offender' => $username ]
425  );
426  }
427 
428  # Don't show some links for IP ranges
429  if ( !$isRange ) {
430  # Uploads: hide if IPs cannot upload (T220674)
431  if ( !$isIP || $target->isAllowed( 'upload' ) ) {
432  $tools['uploads'] = $linkRenderer->makeKnownLink(
433  SpecialPage::getTitleFor( 'Listfiles', $username ),
434  $sp->msg( 'sp-contributions-uploads' )->text()
435  );
436  }
437 
438  # Other logs link
439  # Todo: T146628
440  $tools['logs'] = $linkRenderer->makeKnownLink(
442  $sp->msg( 'sp-contributions-logs' )->text()
443  );
444 
445  # Add link to deleted user contributions for priviledged users
446  # Todo: T183457
447  if ( $sp->getUser()->isAllowed( 'deletedhistory' ) ) {
448  $tools['deletedcontribs'] = $linkRenderer->makeKnownLink(
449  SpecialPage::getTitleFor( 'DeletedContributions', $username ),
450  $sp->msg( 'sp-contributions-deleted', $username )->text()
451  );
452  }
453  }
454 
455  # Add a link to change user rights for privileged users
456  $userrightsPage = new UserrightsPage();
457  $userrightsPage->setContext( $sp->getContext() );
458  if ( $userrightsPage->userCanChangeRights( $target ) ) {
459  $tools['userrights'] = $linkRenderer->makeKnownLink(
460  SpecialPage::getTitleFor( 'Userrights', $username ),
461  $sp->msg( 'sp-contributions-userrights', $username )->text()
462  );
463  }
464 
465  Hooks::run( 'ContributionsToolLinks', [ $id, $userpage, &$tools, $sp ] );
466 
467  return $tools;
468  }
469 
474  protected function getForm() {
475  $this->opts['title'] = $this->getPageTitle()->getPrefixedText();
476  if ( !isset( $this->opts['target'] ) ) {
477  $this->opts['target'] = '';
478  } else {
479  $this->opts['target'] = str_replace( '_', ' ', $this->opts['target'] );
480  }
481 
482  if ( !isset( $this->opts['namespace'] ) ) {
483  $this->opts['namespace'] = '';
484  }
485 
486  if ( !isset( $this->opts['nsInvert'] ) ) {
487  $this->opts['nsInvert'] = '';
488  }
489 
490  if ( !isset( $this->opts['associated'] ) ) {
491  $this->opts['associated'] = false;
492  }
493 
494  if ( !isset( $this->opts['contribs'] ) ) {
495  $this->opts['contribs'] = 'user';
496  }
497 
498  if ( !isset( $this->opts['start'] ) ) {
499  $this->opts['start'] = '';
500  }
501 
502  if ( !isset( $this->opts['end'] ) ) {
503  $this->opts['end'] = '';
504  }
505 
506  if ( $this->opts['contribs'] == 'newbie' ) {
507  $this->opts['target'] = '';
508  }
509 
510  if ( !isset( $this->opts['tagfilter'] ) ) {
511  $this->opts['tagfilter'] = '';
512  }
513 
514  if ( !isset( $this->opts['topOnly'] ) ) {
515  $this->opts['topOnly'] = false;
516  }
517 
518  if ( !isset( $this->opts['newOnly'] ) ) {
519  $this->opts['newOnly'] = false;
520  }
521 
522  if ( !isset( $this->opts['hideMinor'] ) ) {
523  $this->opts['hideMinor'] = false;
524  }
525 
526  // Modules required only for the form
527  $this->getOutput()->addModules( [
528  'mediawiki.userSuggest',
529  'mediawiki.special.contributions',
530  ] );
531  $this->getOutput()->addModuleStyles( 'mediawiki.widgets.DateInputWidget.styles' );
532  $this->getOutput()->enableOOUI();
533 
534  $form = Html::openElement(
535  'form',
536  [
537  'method' => 'get',
538  'action' => wfScript(),
539  'class' => 'mw-contributions-form'
540  ]
541  );
542 
543  # Add hidden params for tracking except for parameters in $skipParameters
544  $skipParameters = [
545  'namespace',
546  'nsInvert',
547  'deletedOnly',
548  'target',
549  'contribs',
550  'year',
551  'month',
552  'start',
553  'end',
554  'topOnly',
555  'newOnly',
556  'hideMinor',
557  'associated',
558  'tagfilter'
559  ];
560 
561  foreach ( $this->opts as $name => $value ) {
562  if ( in_array( $name, $skipParameters ) ) {
563  continue;
564  }
565  $form .= "\t" . Html::hidden( $name, $value ) . "\n";
566  }
567 
569  $this->opts['tagfilter'], false, $this->getContext() );
570 
571  if ( $tagFilter ) {
572  $filterSelection = Html::rawElement(
573  'div',
574  [],
575  implode( "\u{00A0}", $tagFilter )
576  );
577  } else {
578  $filterSelection = Html::rawElement( 'div', [], '' );
579  }
580 
581  $labelNewbies = Xml::radioLabel(
582  $this->msg( 'sp-contributions-newbies' )->text(),
583  'contribs',
584  'newbie',
585  'newbie',
586  $this->opts['contribs'] == 'newbie',
587  [ 'class' => 'mw-input' ]
588  );
589  $labelUsername = Xml::radioLabel(
590  $this->msg( 'sp-contributions-username' )->text(),
591  'contribs',
592  'user',
593  'user',
594  $this->opts['contribs'] == 'user',
595  [ 'class' => 'mw-input' ]
596  );
598  'target',
599  $this->opts['target'],
600  'text',
601  [
602  'id' => 'mw-target-user-or-ip',
603  'size' => '40',
604  'class' => [
605  'mw-input',
606  'mw-ui-input-inline',
607  'mw-autocomplete-user', // used by mediawiki.userSuggest
608  ],
609  ] + (
610  // Only autofocus if target hasn't been specified or in non-newbies mode
611  ( $this->opts['contribs'] === 'newbie' || $this->opts['target'] )
612  ? [] : [ 'autofocus' => true ]
613  )
614  );
615 
616  $targetSelection = Html::rawElement(
617  'div',
618  [],
619  $labelNewbies . '<br>' . $labelUsername . ' ' . $input . ' '
620  );
621 
622  $hidden = $this->opts['namespace'] === '' ? ' mw-input-hidden' : '';
623  $namespaceSelection = Xml::tags(
624  'div',
625  [],
626  Xml::label(
627  $this->msg( 'namespace' )->text(),
628  'namespace'
629  ) . "\u{00A0}" .
631  [ 'selected' => $this->opts['namespace'], 'all' => '', 'in-user-lang' => true ],
632  [
633  'name' => 'namespace',
634  'id' => 'namespace',
635  'class' => 'namespaceselector',
636  ]
637  ) . "\u{00A0}" .
639  'span',
640  [ 'class' => 'mw-input-with-label' . $hidden ],
642  $this->msg( 'invert' )->text(),
643  'nsInvert',
644  'nsinvert',
645  $this->opts['nsInvert'],
646  [
647  'title' => $this->msg( 'tooltip-invert' )->text(),
648  'class' => 'mw-input'
649  ]
650  ) . "\u{00A0}"
651  ) .
652  Html::rawElement( 'span', [ 'class' => 'mw-input-with-label' . $hidden ],
654  $this->msg( 'namespace_association' )->text(),
655  'associated',
656  'nsassociated',
657  $this->opts['associated'],
658  [
659  'title' => $this->msg( 'tooltip-namespace_association' )->text(),
660  'class' => 'mw-input'
661  ]
662  ) . "\u{00A0}"
663  )
664  );
665 
666  $filters = [];
667 
668  if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
669  $filters[] = Html::rawElement(
670  'span',
671  [ 'class' => 'mw-input-with-label' ],
673  $this->msg( 'history-show-deleted' )->text(),
674  'deletedOnly',
675  'mw-show-deleted-only',
676  $this->opts['deletedOnly'],
677  [ 'class' => 'mw-input' ]
678  )
679  );
680  }
681 
682  $filters[] = Html::rawElement(
683  'span',
684  [ 'class' => 'mw-input-with-label' ],
686  $this->msg( 'sp-contributions-toponly' )->text(),
687  'topOnly',
688  'mw-show-top-only',
689  $this->opts['topOnly'],
690  [ 'class' => 'mw-input' ]
691  )
692  );
693  $filters[] = Html::rawElement(
694  'span',
695  [ 'class' => 'mw-input-with-label' ],
697  $this->msg( 'sp-contributions-newonly' )->text(),
698  'newOnly',
699  'mw-show-new-only',
700  $this->opts['newOnly'],
701  [ 'class' => 'mw-input' ]
702  )
703  );
704  $filters[] = Html::rawElement(
705  'span',
706  [ 'class' => 'mw-input-with-label' ],
708  $this->msg( 'sp-contributions-hideminor' )->text(),
709  'hideMinor',
710  'mw-hide-minor-edits',
711  $this->opts['hideMinor'],
712  [ 'class' => 'mw-input' ]
713  )
714  );
715 
716  Hooks::run(
717  'SpecialContributions::getForm::filters',
718  [ $this, &$filters ]
719  );
720 
721  $extraOptions = Html::rawElement(
722  'div',
723  [],
724  implode( '', $filters )
725  );
726 
727  $dateRangeSelection = Html::rawElement(
728  'div',
729  [],
730  Xml::label( $this->msg( 'date-range-from' )->text(), 'mw-date-start' ) . ' ' .
731  new DateInputWidget( [
732  'infusable' => true,
733  'id' => 'mw-date-start',
734  'name' => 'start',
735  'value' => $this->opts['start'],
736  'longDisplayFormat' => true,
737  ] ) . '<br>' .
738  Xml::label( $this->msg( 'date-range-to' )->text(), 'mw-date-end' ) . ' ' .
739  new DateInputWidget( [
740  'infusable' => true,
741  'id' => 'mw-date-end',
742  'name' => 'end',
743  'value' => $this->opts['end'],
744  'longDisplayFormat' => true,
745  ] )
746  );
747 
748  $submit = Xml::tags( 'div', [],
750  $this->msg( 'sp-contributions-submit' )->text(),
751  [ 'class' => 'mw-submit' ], [ 'mw-ui-progressive' ]
752  )
753  );
754 
755  $form .= Xml::fieldset(
756  $this->msg( 'sp-contributions-search' )->text(),
757  $targetSelection .
758  $namespaceSelection .
759  $filterSelection .
760  $extraOptions .
761  $dateRangeSelection .
762  $submit,
763  [ 'class' => 'mw-contributions-table' ]
764  );
765 
766  $explain = $this->msg( 'sp-contributions-explain' );
767  if ( !$explain->isBlank() ) {
768  $form .= Html::rawElement(
769  'p', [ 'id' => 'mw-sp-contributions-explain' ], $explain->parse()
770  );
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 }
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used $groups Array of ChangesListFilterGroup objects(added in 1.34) 'FileDeleteComplete' null for the local wiki Added in
Definition: hooks.txt:1529
static isValidRange( $ipRange)
Validate an IP range (valid address with a valid CIDR prefix).
Definition: IP.php:125
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:2033
static processDateFilter(array $opts)
Set up date filter options, given request data.
getContext()
Gets the context this SpecialPage is executed in.
if(is_array( $mode)) switch( $mode) $input
const NS_MAIN
Definition: Defines.php:60
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:926
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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:251
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
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:2205
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:185
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:767
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:2147
Special:Contributions, show user contributions in a paged list.
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition: Xml.php:609
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:130
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:315
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:767
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:83
static input( $name, $value='', $type='text', array $attribs=[])
Convenience function to produce an "<input>" element.
Definition: Html.php:667
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:358
static radioLabel( $label, $name, $value, $id, $checked=false, $attribs=[])
Convenience function to build an HTML radio button with a label.
Definition: Xml.php:444
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:620
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:767
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 closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:117
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:796
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
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:419
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:535
static buildTagFilterSelector( $selected='', $ooui=false, IContextSource $context=null)
Build a text box to select a change tag.
Definition: ChangeTags.php:874
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:2621
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:1454
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:67
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:886