Go to the documentation of this file.
35 parent::__construct(
'Contributions' );
43 $out->addModuleStyles( [
44 'mediawiki.interface.helpers.styles',
46 'mediawiki.special.changeslist',
48 $out->addModules(
'mediawiki.special.recentchanges' );
54 $target = $par ??
$request->getVal(
'target' );
56 if (
$request->getVal(
'contribs' ) ==
'newbie' || $par ===
'newbies' ) {
58 $this->
opts[
'contribs'] =
'newbie';
60 $this->
opts[
'contribs'] =
'user';
63 $this->
opts[
'deletedOnly'] =
$request->getBool(
'deletedOnly' );
65 if ( !strlen( $target ) ) {
75 $this->
opts[
'limit'] =
$request->getInt(
'limit',
$user->getOption(
'rclimit' ) );
76 $this->
opts[
'target'] = $target;
79 $this->
opts[
'hideMinor'] =
$request->getBool(
'hideMinor' );
82 if ( $this->
opts[
'contribs'] ===
'newbie' ) {
84 $out->addSubtitle( $this->
msg(
'sp-contributions-newbies-sub' ) );
87 $this->
msg(
'sp-contributions-newbies-title' )->
plain()
88 )->inContentLanguage() );
99 $this->
msg(
'contributions-title', $target )->
plain()
100 )->inContentLanguage() );
112 $id = $userObj->getId();
114 $target = $nt->getText();
116 $out->setHTMLTitle( $this->
msg(
118 $this->
msg(
'contributions-title', $target )->
plain()
119 )->inContentLanguage() );
121 # For IP ranges, we want the contributionsSub, but not the skin-dependent
122 # links under 'Tools', which may include irrelevant links like 'Logs'.
124 $this->
getSkin()->setRelevantUser( $userObj );
128 $ns =
$request->getVal(
'namespace',
null );
129 if ( $ns !==
null && $ns !==
'' ) {
130 $this->
opts[
'namespace'] = intval( $ns );
132 $this->
opts[
'namespace'] =
'';
135 $this->
opts[
'associated'] =
$request->getBool(
'associated' );
136 $this->
opts[
'nsInvert'] = (bool)
$request->getVal(
'nsInvert' );
141 if (
$user->isAllowed(
'markbotedits' ) &&
$request->getBool(
'bot' ) ) {
142 $this->
opts[
'bot'] =
'1';
145 $skip =
$request->getText(
'offset' ) ||
$request->getText(
'dir' ) ==
'prev';
146 # Offset overrides year/month selection
158 "<div class=\"mw-negative-namespace-not-supported error\">\n\$1\n</div>",
159 [
'negative-namespace-not-supported' ]
165 $feedType =
$request->getVal(
'feed' );
168 'action' =>
'feedcontributions',
171 if ( $this->
opts[
'topOnly'] ) {
172 $feedParams[
'toponly'] =
true;
174 if ( $this->
opts[
'newOnly'] ) {
175 $feedParams[
'newonly'] =
true;
177 if ( $this->
opts[
'hideMinor'] ) {
178 $feedParams[
'hideminor'] =
true;
180 if ( $this->
opts[
'deletedOnly'] ) {
181 $feedParams[
'deletedonly'] =
true;
183 if ( $this->
opts[
'tagfilter'] !==
'' ) {
184 $feedParams[
'tagfilter'] = $this->
opts[
'tagfilter'];
186 if ( $this->
opts[
'namespace'] !==
'' ) {
187 $feedParams[
'namespace'] = $this->
opts[
'namespace'];
191 if ( $feedType && $this->
opts[
'year'] !==
null ) {
192 $feedParams[
'year'] = $this->
opts[
'year'];
194 if ( $feedType && $this->
opts[
'month'] !==
null ) {
195 $feedParams[
'month'] = $this->
opts[
'month'];
201 $feedParams[
'feedformat'] = $feedType;
204 $out->redirect( $url,
'301' );
212 if (
Hooks::run(
'SpecialContributionsBeforeMainOutput', [ $id, $userObj, $this ] ) ) {
218 'contribs' => $this->
opts[
'contribs'],
219 'namespace' => $this->
opts[
'namespace'],
220 'tagfilter' => $this->
opts[
'tagfilter'],
221 'start' => $this->
opts[
'start'],
222 'end' => $this->
opts[
'end'],
223 'deletedOnly' => $this->
opts[
'deletedOnly'],
224 'topOnly' => $this->
opts[
'topOnly'],
225 'newOnly' => $this->
opts[
'newOnly'],
226 'hideMinor' => $this->
opts[
'hideMinor'],
227 'nsInvert' => $this->
opts[
'nsInvert'],
228 'associated' => $this->
opts[
'associated'],
231 if (
IP::isValidRange( $target ) && !$pager->isQueryableRange( $target ) ) {
233 $limits = $this->
getConfig()->get(
'RangeContributionsCIDRLimit' );
234 $limit = $limits[
IP::isIPv4( $target ) ?
'IPv4' :
'IPv6' ];
235 $out->addWikiMsg(
'sp-contributions-outofrange', $limit );
236 } elseif ( !$pager->getNumRows() ) {
237 $out->addWikiMsg(
'nocontribs', $target );
239 # Show a message about replica DB lag, if applicable
240 $lag = $pager->getDatabase()->getSessionLagStatus()[
'lag'];
242 $out->showLagWarning( $lag );
247 $output = $pager->getNavigationBar() .
249 $pager->getNavigationBar();
254 $out->preventClickjacking( $pager->getPreventClickjacking() );
256 # Show the appropriate "footer" message - WHOIS tools, etc.
257 if ( $this->
opts[
'contribs'] ==
'newbie' ) {
258 $message =
'sp-contributions-footer-newbies';
260 $message =
'sp-contributions-footer-anon-range';
262 $message =
'sp-contributions-footer-anon';
263 } elseif ( $userObj->isAnon() ) {
267 $message =
'sp-contributions-footer';
270 if ( $message && !$this->
including() && !$this->
msg( $message, $target )->isDisabled() ) {
272 "<div class='mw-contributions-footer'>\n$1\n</div>",
273 [ $message, $target ] );
286 if ( $userObj->isAnon() ) {
291 if ( !
User::isIP( $userObj->getName() ) && !$userObj->isIPRange() ) {
293 "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
295 'contributions-userdoesnotexist',
300 $this->
getOutput()->setStatusCode( 404 );
303 $user = htmlspecialchars( $userObj->getName() );
307 $nt = $userObj->getUserPage();
308 $talk = $userObj->getTalkPage();
312 $links = Html::openElement(
'span', [
'class' =>
'mw-changeslist-links' ] );
313 foreach ( $tools
as $tool ) {
314 $links .= Html::rawElement(
'span', [], $tool ) .
' ';
316 $links = trim( $links ) . Html::closeElement(
'span' );
323 if ( $userObj->isIPRange() ) {
342 'showIfEmpty' =>
false,
345 'sp-contributions-blocked-notice-anon' :
346 'sp-contributions-blocked-notice',
347 $userObj->getName() # Support GENDER
in 'sp-contributions-blocked-notice'
349 'offset' =>
'' # don
't use WebRequest parameter offset
356 return Html::rawElement( 'div', [ 'class' => 'mw-contributions-
user-tools
' ],
357 $this->msg( 'contributions-subtitle
' )->rawParams( $user )->params( $userObj->getName() )
370 public static function getUserLinks( SpecialPage $sp, User $target ) {
371 $id = $target->getId();
372 $username = $target->getName();
373 $userpage = $target->getUserPage();
374 $talkpage = $target->getTalkPage();
376 $linkRenderer = $sp->getLinkRenderer();
378 # No talk pages for IP ranges.
379 if ( !IP::isValidRange( $username ) ) {
380 $tools['user-talk
'] = $linkRenderer->makeLink(
382 $sp->msg( 'sp-contributions-talk
' )->text()
386 if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
387 if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
388 if ( $target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO ) {
389 $tools['block'] = $linkRenderer->makeKnownLink( # Change block link
390 SpecialPage::getTitleFor( 'Block', $username ),
391 $sp->msg( 'change-blocklink
' )->text()
393 $tools['unblock
'] = $linkRenderer->makeKnownLink( # Unblock link
394 SpecialPage::getTitleFor( 'Unblock
', $username ),
395 $sp->msg( 'unblocklink
' )->text()
397 } else { # User is not blocked
398 $tools['block'] = $linkRenderer->makeKnownLink( # Block link
399 SpecialPage::getTitleFor( 'Block', $username ),
400 $sp->msg( 'blocklink
' )->text()
406 $tools['log-
block'] = $linkRenderer->makeKnownLink(
407 SpecialPage::getTitleFor( 'Log
', 'block' ),
408 $sp->msg( 'sp-contributions-blocklog
' )->text(),
410 [ 'page' => $userpage->getPrefixedText() ]
413 # Suppression log link (T61120)
414 if ( $sp->getUser()->isAllowed( 'suppressionlog
' ) ) {
415 $tools['log-suppression
'] = $linkRenderer->makeKnownLink(
416 SpecialPage::getTitleFor( 'Log
', 'suppress
' ),
417 $sp->msg( 'sp-contributions-suppresslog
', $username )->text(),
419 [ 'offender
' => $username ]
424 # Don't show some
links for IP ranges
429 $sp->msg(
'sp-contributions-uploads' )->text()
435 $sp->msg(
'sp-contributions-logs' )->text()
438 # Add link to deleted user contributions for priviledged users
439 if ( $sp->getUser()->isAllowed(
'deletedhistory' ) ) {
442 $sp->msg(
'sp-contributions-deleted',
$username )->text()
447 # Add a link to change user rights for privileged users
449 $userrightsPage->setContext( $sp->getContext() );
450 if ( $userrightsPage->userCanChangeRights( $target ) ) {
453 $sp->msg(
'sp-contributions-userrights',
$username )->text()
457 Hooks::run(
'ContributionsToolLinks', [ $id, $userpage, &$tools, $sp ] );
468 if ( !isset( $this->
opts[
'target'] ) ) {
469 $this->
opts[
'target'] =
'';
471 $this->
opts[
'target'] = str_replace(
'_',
' ', $this->
opts[
'target'] );
474 if ( !isset( $this->
opts[
'namespace'] ) ) {
475 $this->
opts[
'namespace'] =
'';
478 if ( !isset( $this->
opts[
'nsInvert'] ) ) {
479 $this->
opts[
'nsInvert'] =
'';
482 if ( !isset( $this->
opts[
'associated'] ) ) {
483 $this->
opts[
'associated'] =
false;
486 if ( !isset( $this->
opts[
'contribs'] ) ) {
487 $this->
opts[
'contribs'] =
'user';
490 if ( !isset( $this->
opts[
'start'] ) ) {
491 $this->
opts[
'start'] =
'';
494 if ( !isset( $this->
opts[
'end'] ) ) {
495 $this->
opts[
'end'] =
'';
498 if ( $this->
opts[
'contribs'] ==
'newbie' ) {
499 $this->
opts[
'target'] =
'';
502 if ( !isset( $this->
opts[
'tagfilter'] ) ) {
503 $this->
opts[
'tagfilter'] =
'';
506 if ( !isset( $this->
opts[
'topOnly'] ) ) {
507 $this->
opts[
'topOnly'] =
false;
510 if ( !isset( $this->
opts[
'newOnly'] ) ) {
511 $this->
opts[
'newOnly'] =
false;
514 if ( !isset( $this->
opts[
'hideMinor'] ) ) {
515 $this->
opts[
'hideMinor'] =
false;
520 'mediawiki.userSuggest',
521 'mediawiki.special.contributions',
523 $this->
getOutput()->addModuleStyles(
'mediawiki.widgets.DateInputWidget.styles' );
526 $form = Html::openElement(
531 'class' =>
'mw-contributions-form'
535 # Add hidden params for tracking except for parameters in $skipParameters
554 if ( in_array(
$name, $skipParameters ) ) {
557 $form .=
"\t" . Html::hidden(
$name,
$value ) .
"\n";
564 $filterSelection = Html::rawElement(
567 implode(
"\u{00A0}", $tagFilter )
570 $filterSelection = Html::rawElement(
'div', [],
'' );
574 $this->
msg(
'sp-contributions-newbies' )->
text(),
578 $this->
opts[
'contribs'] ==
'newbie',
579 [
'class' =>
'mw-input' ]
582 $this->
msg(
'sp-contributions-username' )->
text(),
586 $this->
opts[
'contribs'] ==
'user',
587 [
'class' =>
'mw-input' ]
591 $this->
opts[
'target'],
594 'id' =>
'mw-target-user-or-ip',
598 'mw-ui-input-inline',
599 'mw-autocomplete-user',
603 ( $this->
opts[
'contribs'] ===
'newbie' || $this->
opts[
'target'] )
604 ? [] : [
'autofocus' =>
true ]
608 $targetSelection = Html::rawElement(
611 $labelNewbies .
'<br>' . $labelUsername .
' ' .
$input .
' '
614 $hidden = $this->
opts[
'namespace'] ===
'' ?
' mw-input-hidden' :
'';
619 $this->
msg(
'namespace' )->
text(),
623 Html::namespaceSelector(
624 [
'selected' => $this->
opts[
'namespace'],
'all' =>
'',
'in-user-lang' =>
true ],
626 'name' =>
'namespace',
628 'class' =>
'namespaceselector',
633 [
'class' =>
'mw-input-with-label' . $hidden ],
635 $this->
msg(
'invert' )->
text(),
638 $this->
opts[
'nsInvert'],
640 'title' => $this->
msg(
'tooltip-invert' )->
text(),
641 'class' =>
'mw-input'
645 Html::rawElement(
'span', [
'class' =>
'mw-input-with-label' . $hidden ],
647 $this->
msg(
'namespace_association' )->
text(),
650 $this->
opts[
'associated'],
652 'title' => $this->
msg(
'tooltip-namespace_association' )->
text(),
653 'class' =>
'mw-input'
661 if ( $this->
getUser()->isAllowed(
'deletedhistory' ) ) {
662 $filters[] = Html::rawElement(
664 [
'class' =>
'mw-input-with-label' ],
666 $this->
msg(
'history-show-deleted' )->
text(),
668 'mw-show-deleted-only',
669 $this->
opts[
'deletedOnly'],
670 [
'class' =>
'mw-input' ]
675 $filters[] = Html::rawElement(
677 [
'class' =>
'mw-input-with-label' ],
679 $this->
msg(
'sp-contributions-toponly' )->
text(),
682 $this->
opts[
'topOnly'],
683 [
'class' =>
'mw-input' ]
686 $filters[] = Html::rawElement(
688 [
'class' =>
'mw-input-with-label' ],
690 $this->
msg(
'sp-contributions-newonly' )->
text(),
693 $this->
opts[
'newOnly'],
694 [
'class' =>
'mw-input' ]
697 $filters[] = Html::rawElement(
699 [
'class' =>
'mw-input-with-label' ],
701 $this->
msg(
'sp-contributions-hideminor' )->
text(),
703 'mw-hide-minor-edits',
704 $this->
opts[
'hideMinor'],
705 [
'class' =>
'mw-input' ]
710 'SpecialContributions::getForm::filters',
714 $extraOptions = Html::rawElement(
717 implode(
'', $filters )
720 $dateRangeSelection = Html::rawElement(
726 'id' =>
'mw-date-start',
728 'value' => $this->
opts[
'start'],
729 'longDisplayFormat' =>
true,
734 'id' =>
'mw-date-end',
736 'value' => $this->
opts[
'end'],
737 'longDisplayFormat' =>
true,
743 $this->
msg(
'sp-contributions-submit' )->
text(),
744 [
'class' =>
'mw-submit' ], [
'mw-ui-progressive' ]
749 $this->
msg(
'sp-contributions-search' )->
text(),
751 $namespaceSelection .
754 $dateRangeSelection .
756 [
'class' =>
'mw-contributions-table' ]
759 $explain = $this->
msg(
'sp-contributions-explain' );
760 if ( !$explain->isBlank() ) {
761 $form .= Html::rawElement(
762 'p', [
'id' =>
'mw-sp-contributions-explain' ], $explain->parse()
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
getPageTitle( $subpage=false)
Get a self-referential title object.
return true to allow those checks to and false if checking is done & $user
msg( $key)
Wrapper around wfMessage that sets the current context.
static getUserLinks(SpecialPage $sp, User $target)
Links to different places.
processing should stop and the error should be shown to the user * false
getOutput()
Get the OutputPage being used for this instance.
getForm()
Generates the namespace selector form with hidden attributes.
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could change
this 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
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging a wrapping ErrorException block
A collection of public static functions to play with IP address and IP ranges.
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
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,...
getSkin()
Shortcut to get the skin being used for this instance.
Shortcut to construct an includable special page.
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
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
execute( $par)
Default execute method Checks user permissions.
Special page to allow managing user group membership.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
static isValidRange( $ipRange)
Validate an IP range (valid address with a valid CIDR prefix).
getConfig()
Shortcut to get main config object.
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
addFeedLinks( $params)
Adds RSS/atom links.
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
if(is_array( $mode)) switch( $mode) $input
null for the wiki Added in
static isIP( $name)
Does the string match an anonymous IP address?
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
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
getContext()
Gets the context this SpecialPage is executed in.
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
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
Allows to change the fields on the form that will be generated $name
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
static tags( $element, $attribs, $contents)
Same as Xml::element(), but does not escape contents.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
getRequest()
Get the WebRequest being used for this instance.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
static isIPv4( $ip)
Given a string, determine if it as valid IP in IPv4 only.
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 radioLabel( $label, $name, $value, $id, $checked=false, $attribs=[])
Convenience function to build an HTML radio button with a label.
static closeElement( $element)
Shortcut to close an XML element.
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
MediaWiki Linker LinkRenderer null $linkRenderer
contributionsSub( $userObj)
Generates the subheading with links.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
this hook is for auditing only or null if authentication failed before getting that far $username
static isExternal( $username)
Tells whether the username is external or not.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
including( $x=null)
Whether the special page is being evaluated via transclusion.
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
Special:Contributions, show user contributions in a paged list.
static isIPAddress( $ip)
Determine if a string is as valid IP address or network (CIDR prefix).
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.