Go to the documentation of this file.
35 parent::__construct(
'Contributions' );
42 $out->addModuleStyles( [
44 'mediawiki.special.changeslist',
45 'mediawiki.widgets.DateInputWidget.styles',
47 $out->addModules(
'mediawiki.special.contributions' );
54 if ( $par !==
null ) {
57 $target =
$request->getVal(
'target' );
60 if (
$request->getVal(
'contribs' ) ==
'newbie' || $par ===
'newbies' ) {
62 $this->
opts[
'contribs'] =
'newbie';
64 $this->
opts[
'contribs'] =
'user';
67 $this->
opts[
'deletedOnly'] =
$request->getBool(
'deletedOnly' );
69 if ( !strlen( $target ) ) {
79 $this->
opts[
'limit'] =
$request->getInt(
'limit',
$user->getOption(
'rclimit' ) );
80 $this->
opts[
'target'] = $target;
83 $this->
opts[
'hideMinor'] =
$request->getBool(
'hideMinor' );
97 $id = $userObj->getId();
99 if ( $this->
opts[
'contribs'] !=
'newbie' ) {
100 $target = $nt->getText();
102 $out->setHTMLTitle( $this->
msg(
104 $this->
msg(
'contributions-title', $target )->
plain()
105 )->inContentLanguage() );
107 # For IP ranges, we want the contributionsSub, but not the skin-dependent
108 # links under 'Tools', which may include irrelevant links like 'Logs'.
110 $this->
getSkin()->setRelevantUser( $userObj );
113 $out->addSubtitle( $this->
msg(
'sp-contributions-newbies-sub' ) );
114 $out->setHTMLTitle( $this->
msg(
116 $this->
msg(
'sp-contributions-newbies-title' )->
plain()
117 )->inContentLanguage() );
120 $ns =
$request->getVal(
'namespace',
null );
121 if ( $ns !==
null && $ns !==
'' ) {
122 $this->
opts[
'namespace'] = intval( $ns );
124 $this->
opts[
'namespace'] =
'';
127 $this->
opts[
'associated'] =
$request->getBool(
'associated' );
128 $this->
opts[
'nsInvert'] = (bool)
$request->getVal(
'nsInvert' );
133 if (
$user->isAllowed(
'markbotedits' ) &&
$request->getBool(
'bot' ) ) {
134 $this->
opts[
'bot'] =
'1';
137 $skip =
$request->getText(
'offset' ) ||
$request->getText(
'dir' ) ==
'prev';
138 # Offset overrides year/month selection
148 $feedType =
$request->getVal(
'feed' );
151 'action' =>
'feedcontributions',
154 if ( $this->
opts[
'topOnly'] ) {
155 $feedParams[
'toponly'] =
true;
157 if ( $this->
opts[
'newOnly'] ) {
158 $feedParams[
'newonly'] =
true;
160 if ( $this->
opts[
'hideMinor'] ) {
161 $feedParams[
'hideminor'] =
true;
163 if ( $this->
opts[
'deletedOnly'] ) {
164 $feedParams[
'deletedonly'] =
true;
166 if ( $this->
opts[
'tagfilter'] !==
'' ) {
167 $feedParams[
'tagfilter'] = $this->
opts[
'tagfilter'];
169 if ( $this->
opts[
'namespace'] !==
'' ) {
170 $feedParams[
'namespace'] = $this->
opts[
'namespace'];
174 if ( $feedType && $this->
opts[
'year'] !==
null ) {
175 $feedParams[
'year'] = $this->
opts[
'year'];
177 if ( $feedType && $this->
opts[
'month'] !==
null ) {
178 $feedParams[
'month'] = $this->
opts[
'month'];
184 $feedParams[
'feedformat'] = $feedType;
187 $out->redirect( $url,
'301' );
195 if (
Hooks::run(
'SpecialContributionsBeforeMainOutput', [ $id, $userObj, $this ] ) ) {
201 'contribs' => $this->
opts[
'contribs'],
202 'namespace' => $this->
opts[
'namespace'],
203 'tagfilter' => $this->
opts[
'tagfilter'],
204 'start' => $this->
opts[
'start'],
205 'end' => $this->
opts[
'end'],
206 'deletedOnly' => $this->
opts[
'deletedOnly'],
207 'topOnly' => $this->
opts[
'topOnly'],
208 'newOnly' => $this->
opts[
'newOnly'],
209 'hideMinor' => $this->
opts[
'hideMinor'],
210 'nsInvert' => $this->
opts[
'nsInvert'],
211 'associated' => $this->
opts[
'associated'],
214 if (
IP::isValidRange( $target ) && !$pager->isQueryableRange( $target ) ) {
216 $limits = $this->
getConfig()->get(
'RangeContributionsCIDRLimit' );
217 $limit = $limits[
IP::isIPv4( $target ) ?
'IPv4' :
'IPv6' ];
218 $out->addWikiMsg(
'sp-contributions-outofrange', $limit );
219 } elseif ( !$pager->getNumRows() ) {
220 $out->addWikiMsg(
'nocontribs', $target );
222 # Show a message about replica DB lag, if applicable
223 $lag =
wfGetLB()->safeGetLag( $pager->getDatabase() );
225 $out->showLagWarning( $lag );
230 $output =
'<p>' . $pager->getNavigationBar() .
'</p>' .
232 '<p>' . $pager->getNavigationBar() .
'</p>';
237 $out->preventClickjacking( $pager->getPreventClickjacking() );
239 # Show the appropriate "footer" message - WHOIS tools, etc.
240 if ( $this->
opts[
'contribs'] ==
'newbie' ) {
241 $message =
'sp-contributions-footer-newbies';
243 $message =
'sp-contributions-footer-anon-range';
245 $message =
'sp-contributions-footer-anon';
246 } elseif ( $userObj->isAnon() ) {
250 $message =
'sp-contributions-footer';
255 if ( !$this->
msg( $message, $target )->isDisabled() ) {
257 "<div class='mw-contributions-footer'>\n$1\n</div>",
258 [ $message, $target ] );
273 if ( $userObj->isAnon() ) {
278 if ( !
User::isIP( $userObj->getName() ) && !$userObj->isIPRange() ) {
280 "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
282 'contributions-userdoesnotexist',
287 $this->
getOutput()->setStatusCode( 404 );
290 $user = htmlspecialchars( $userObj->getName() );
294 $nt = $userObj->getUserPage();
295 $talk = $userObj->getTalkPage();
306 if ( $userObj->isIPRange() ) {
325 'showIfEmpty' =>
false,
328 'sp-contributions-blocked-notice-anon' :
329 'sp-contributions-blocked-notice',
330 $userObj->getName() # Support GENDER
in 'sp-contributions-blocked-notice'
332 'offset' =>
'' # don
't use WebRequest parameter offset
339 return $this->msg( 'contribsub2
' )->rawParams( $user, $links )->params( $userObj->getName() );
350 public static function getUserLinks( SpecialPage $sp, User $target ) {
351 $id = $target->getId();
352 $username = $target->getName();
353 $userpage = $target->getUserPage();
354 $talkpage = $target->getTalkPage();
356 $linkRenderer = $sp->getLinkRenderer();
358 # No talk pages for IP ranges.
359 if ( !IP::isValidRange( $username ) ) {
360 $tools['user-talk
'] = $linkRenderer->makeLink(
362 $sp->msg( 'sp-contributions-talk
' )->text()
366 if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
367 if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
368 if ( $target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO ) {
369 $tools['block'] = $linkRenderer->makeKnownLink( # Change block link
370 SpecialPage::getTitleFor( 'Block', $username ),
371 $sp->msg( 'change-blocklink
' )->text()
373 $tools['unblock
'] = $linkRenderer->makeKnownLink( # Unblock link
374 SpecialPage::getTitleFor( 'Unblock
', $username ),
375 $sp->msg( 'unblocklink
' )->text()
377 } else { # User is not blocked
378 $tools['block'] = $linkRenderer->makeKnownLink( # Block link
379 SpecialPage::getTitleFor( 'Block', $username ),
380 $sp->msg( 'blocklink
' )->text()
386 $tools['log-
block'] = $linkRenderer->makeKnownLink(
387 SpecialPage::getTitleFor( 'Log
', 'block' ),
388 $sp->msg( 'sp-contributions-blocklog
' )->text(),
390 [ 'page' => $userpage->getPrefixedText() ]
393 # Suppression log link (T61120)
394 if ( $sp->getUser()->isAllowed( 'suppressionlog
' ) ) {
395 $tools['log-suppression
'] = $linkRenderer->makeKnownLink(
396 SpecialPage::getTitleFor( 'Log
', 'suppress
' ),
397 $sp->msg( 'sp-contributions-suppresslog
', $username )->text(),
399 [ 'offender
' => $username ]
409 $sp->msg(
'sp-contributions-uploads' )->text()
415 $sp->msg(
'sp-contributions-logs' )->text()
418 # Add link to deleted user contributions for priviledged users
419 if ( $sp->getUser()->isAllowed(
'deletedhistory' ) ) {
422 $sp->msg(
'sp-contributions-deleted',
$username )->text()
427 # Add a link to change user rights for privileged users
429 $userrightsPage->setContext( $sp->getContext() );
430 if ( $userrightsPage->userCanChangeRights( $target ) ) {
433 $sp->msg(
'sp-contributions-userrights',
$username )->text()
437 Hooks::run(
'ContributionsToolLinks', [ $id, $userpage, &$tools, $sp ] );
448 if ( !isset( $this->
opts[
'target'] ) ) {
449 $this->
opts[
'target'] =
'';
451 $this->
opts[
'target'] = str_replace(
'_',
' ', $this->
opts[
'target'] );
454 if ( !isset( $this->
opts[
'namespace'] ) ) {
455 $this->
opts[
'namespace'] =
'';
458 if ( !isset( $this->
opts[
'nsInvert'] ) ) {
459 $this->
opts[
'nsInvert'] =
'';
462 if ( !isset( $this->
opts[
'associated'] ) ) {
463 $this->
opts[
'associated'] =
false;
466 if ( !isset( $this->
opts[
'contribs'] ) ) {
467 $this->
opts[
'contribs'] =
'user';
470 if ( !isset( $this->
opts[
'start'] ) ) {
471 $this->
opts[
'start'] =
'';
474 if ( !isset( $this->
opts[
'end'] ) ) {
475 $this->
opts[
'end'] =
'';
478 if ( $this->
opts[
'contribs'] ==
'newbie' ) {
479 $this->
opts[
'target'] =
'';
482 if ( !isset( $this->
opts[
'tagfilter'] ) ) {
483 $this->
opts[
'tagfilter'] =
'';
486 if ( !isset( $this->
opts[
'topOnly'] ) ) {
487 $this->
opts[
'topOnly'] =
false;
490 if ( !isset( $this->
opts[
'newOnly'] ) ) {
491 $this->
opts[
'newOnly'] =
false;
494 if ( !isset( $this->
opts[
'hideMinor'] ) ) {
495 $this->
opts[
'hideMinor'] =
false;
503 'class' =>
'mw-contributions-form'
507 # Add hidden params for tracking except for parameters in $skipParameters
526 if ( in_array(
$name, $skipParameters ) ) {
539 implode(
' ', $tagFilter )
545 $this->
getOutput()->addModules(
'mediawiki.userSuggest' );
548 $this->
msg(
'sp-contributions-newbies' )->
text(),
552 $this->
opts[
'contribs'] ==
'newbie',
553 [
'class' =>
'mw-input' ]
556 $this->
msg(
'sp-contributions-username' )->
text(),
560 $this->
opts[
'contribs'] ==
'user',
561 [
'class' =>
'mw-input' ]
565 $this->
opts[
'target'],
571 'mw-ui-input-inline',
572 'mw-autocomplete-user',
576 ( $this->
opts[
'contribs'] ===
'newbie' || $this->
opts[
'target'] )
577 ? [] : [
'autofocus' =>
true ]
584 $labelNewbies .
'<br>' . $labelUsername .
' ' .
$input .
' '
591 $this->
msg(
'namespace' )->
text(),
596 [
'selected' => $this->
opts[
'namespace'],
'all' =>
'' ],
598 'name' =>
'namespace',
600 'class' =>
'namespaceselector',
605 [
'class' =>
'mw-input-with-label' ],
607 $this->
msg(
'invert' )->
text(),
610 $this->
opts[
'nsInvert'],
612 'title' => $this->
msg(
'tooltip-invert' )->
text(),
613 'class' =>
'mw-input'
619 $this->
msg(
'namespace_association' )->
text(),
622 $this->
opts[
'associated'],
624 'title' => $this->
msg(
'tooltip-namespace_association' )->
text(),
625 'class' =>
'mw-input'
633 if ( $this->
getUser()->isAllowed(
'deletedhistory' ) ) {
636 [
'class' =>
'mw-input-with-label' ],
638 $this->
msg(
'history-show-deleted' )->
text(),
640 'mw-show-deleted-only',
641 $this->
opts[
'deletedOnly'],
642 [
'class' =>
'mw-input' ]
649 [
'class' =>
'mw-input-with-label' ],
651 $this->
msg(
'sp-contributions-toponly' )->
text(),
654 $this->
opts[
'topOnly'],
655 [
'class' =>
'mw-input' ]
660 [
'class' =>
'mw-input-with-label' ],
662 $this->
msg(
'sp-contributions-newonly' )->
text(),
665 $this->
opts[
'newOnly'],
666 [
'class' =>
'mw-input' ]
671 [
'class' =>
'mw-input-with-label' ],
673 $this->
msg(
'sp-contributions-hideminor' )->
text(),
675 'mw-hide-minor-edits',
676 $this->
opts[
'hideMinor'],
677 [
'class' =>
'mw-input' ]
682 'SpecialContributions::getForm::filters',
689 implode(
'', $filters )
698 'id' =>
'mw-date-start',
700 'value' => $this->
opts[
'start'],
701 'longDisplayFormat' =>
true,
706 'id' =>
'mw-date-end',
708 'value' => $this->
opts[
'end'],
709 'longDisplayFormat' =>
true,
715 $this->
msg(
'sp-contributions-submit' )->
text(),
716 [
'class' =>
'mw-submit' ], [
'mw-ui-progressive' ]
721 $this->
msg(
'sp-contributions-search' )->
text(),
723 $namespaceSelection .
726 $dateRangeSelection .
728 [
'class' =>
'mw-contributions-table' ]
731 $explain = $this->
msg(
'sp-contributions-explain' );
732 if ( !$explain->isBlank() ) {
733 $form .=
"<p id='mw-sp-contributions-explain'>{$explain->parse()}</p>";
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.
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
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
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
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.
wfGetLB( $wiki=false)
Get a load balancer object.
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
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
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
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
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.
Allows to change the fields on the form that will be generated $name
getLanguage()
Shortcut to get user's language.
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
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
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 input( $name, $value='', $type='text', array $attribs=[])
Convenience function to produce an "<input>" element.
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?
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
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
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
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 submitButton( $contents, array $attrs, array $modifiers=[])
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enab...
static isIPv4( $ip)
Given a string, determine if it as valid IP in IPv4 only.
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
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
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 "<
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
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.
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