35 parent::__construct(
'Contributions' );
43 $out->addModuleStyles( [
45 'mediawiki.special.changeslist',
52 if ( $par !==
null ) {
55 $target =
$request->getVal(
'target' );
58 if (
$request->getVal(
'contribs' ) ==
'newbie' || $par ===
'newbies' ) {
60 $this->opts[
'contribs'] =
'newbie';
62 $this->opts[
'contribs'] =
'user';
65 $this->opts[
'deletedOnly'] =
$request->getBool(
'deletedOnly' );
67 if ( !strlen( $target ) ) {
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' );
84 if ( $this->opts[
'contribs'] ===
'newbie' ) {
86 $out->addSubtitle( $this->
msg(
'sp-contributions-newbies-sub' ) );
89 $this->
msg(
'sp-contributions-newbies-title' )->
plain()
90 )->inContentLanguage() );
101 $this->
msg(
'contributions-title', $target )->
plain()
102 )->inContentLanguage() );
104 $nt = Title::makeTitleSafe( NS_USER, $target );
114 $id = $userObj->getId();
116 $target = $nt->getText();
118 $out->setHTMLTitle( $this->
msg(
120 $this->
msg(
'contributions-title', $target )->
plain()
121 )->inContentLanguage() );
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 (
User::isIP( $target ) || $userObj->isLoggedIn() )
134 $this->
getSkin()->setRelevantUser( $userObj );
138 $ns =
$request->getVal(
'namespace',
null );
139 if ( $ns !==
null && $ns !==
'' ) {
140 $this->opts[
'namespace'] = intval( $ns );
142 $this->opts[
'namespace'] =
'';
145 $this->opts[
'associated'] =
$request->getBool(
'associated' );
146 $this->opts[
'nsInvert'] = (bool)
$request->getVal(
'nsInvert' );
147 $this->opts[
'tagfilter'] = (
string)
$request->getVal(
'tagfilter' );
151 if ( $user->isAllowed(
'markbotedits' ) &&
$request->getBool(
'bot' ) ) {
152 $this->opts[
'bot'] =
'1';
155 $skip =
$request->getText(
'offset' ) ||
$request->getText(
'dir' ) ==
'prev';
156 # Offset overrides year/month selection
158 $this->opts[
'year'] =
$request->getVal(
'year' );
159 $this->opts[
'month'] =
$request->getVal(
'month' );
161 $this->opts[
'start'] =
$request->getVal(
'start' );
162 $this->opts[
'end'] =
$request->getVal(
'end' );
166 $feedType =
$request->getVal(
'feed' );
169 'action' =>
'feedcontributions',
172 if ( $this->opts[
'topOnly'] ) {
173 $feedParams[
'toponly'] =
true;
175 if ( $this->opts[
'newOnly'] ) {
176 $feedParams[
'newonly'] =
true;
178 if ( $this->opts[
'hideMinor'] ) {
179 $feedParams[
'hideminor'] =
true;
181 if ( $this->opts[
'deletedOnly'] ) {
182 $feedParams[
'deletedonly'] =
true;
184 if ( $this->opts[
'tagfilter'] !==
'' ) {
185 $feedParams[
'tagfilter'] = $this->opts[
'tagfilter'];
187 if ( $this->opts[
'namespace'] !==
'' ) {
188 $feedParams[
'namespace'] = $this->opts[
'namespace'];
192 if ( $feedType && $this->opts[
'year'] !==
null ) {
193 $feedParams[
'year'] = $this->opts[
'year'];
195 if ( $feedType && $this->opts[
'month'] !==
null ) {
196 $feedParams[
'month'] = $this->opts[
'month'];
202 $feedParams[
'feedformat'] = $feedType;
205 $out->redirect( $url,
'301' );
213 if ( Hooks::run(
'SpecialContributionsBeforeMainOutput', [ $id, $userObj, $this ] ) ) {
219 'contribs' => $this->opts[
'contribs'],
220 'namespace' => $this->opts[
'namespace'],
221 'tagfilter' => $this->opts[
'tagfilter'],
222 'start' => $this->opts[
'start'],
223 'end' => $this->opts[
'end'],
224 'deletedOnly' => $this->opts[
'deletedOnly'],
225 'topOnly' => $this->opts[
'topOnly'],
226 'newOnly' => $this->opts[
'newOnly'],
227 'hideMinor' => $this->opts[
'hideMinor'],
228 'nsInvert' => $this->opts[
'nsInvert'],
229 'associated' => $this->opts[
'associated'],
232 if ( IP::isValidRange( $target ) && !$pager->isQueryableRange( $target ) ) {
234 $limits = $this->
getConfig()->get(
'RangeContributionsCIDRLimit' );
235 $limit = $limits[ IP::isIPv4( $target ) ?
'IPv4' :
'IPv6' ];
236 $out->addWikiMsg(
'sp-contributions-outofrange', $limit );
241 if ( $this->
getUser()->isAnon() ) {
242 $poolKey .=
'a:' . $this->
getUser()->getName();
244 $poolKey .=
'u:' . $this->
getUser()->getId();
247 'doWork' =>
function () use ( $pager,
$out, $target ) {
248 if ( !$pager->getNumRows() ) {
249 $out->addWikiMsg(
'nocontribs', $target );
251 # Show a message about replica DB lag, if applicable
252 $lag = $pager->getDatabase()->getSessionLagStatus()[
'lag'];
254 $out->showLagWarning( $lag );
259 $output = $pager->getNavigationBar() .
261 $pager->getNavigationBar();
266 'error' =>
function () use (
$out ) {
267 $msg = $this->
getUser()->isAnon()
268 ?
'sp-contributions-concurrency-ip'
269 :
'sp-contributions-concurrency-user';
270 $out->wrapWikiMsg(
"<div class='errorbox'>\n$1\n</div>", $msg );
276 $out->preventClickjacking( $pager->getPreventClickjacking() );
278 # Show the appropriate "footer" message - WHOIS tools, etc.
279 if ( $this->opts[
'contribs'] ==
'newbie' ) {
280 $message =
'sp-contributions-footer-newbies';
281 } elseif ( IP::isValidRange( $target ) ) {
282 $message =
'sp-contributions-footer-anon-range';
283 } elseif ( IP::isIPAddress( $target ) ) {
284 $message =
'sp-contributions-footer-anon';
285 } elseif ( $userObj->isAnon() ) {
288 } elseif ( $userObj->isHidden() && !$this->getUser()->isAllowed(
'hideuser' ) ) {
292 $message =
'sp-contributions-footer';
297 if ( !$this->
msg( $message, $target )->isDisabled() ) {
299 "<div class='mw-contributions-footer'>\n$1\n</div>",
300 [ $message, $target ] );
315 $isAnon = $userObj->isAnon();
316 if ( !$isAnon && $userObj->isHidden() && !$this->getUser->isAllowed(
'hideuser' ) ) {
327 if ( !
User::isIP( $userObj->getName() ) && !$userObj->isIPRange() ) {
328 $this->getOutput()->wrapWikiMsg(
329 "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
331 'contributions-userdoesnotexist',
336 $this->getOutput()->setStatusCode( 404 );
339 $user = htmlspecialchars( $userObj->getName() );
341 $user = $this->getLinkRenderer()->makeLink( $userObj->getUserPage(), $userObj->getName() );
343 $nt = $userObj->getUserPage();
344 $talk = $userObj->getTalkPage();
347 $tools = self::getUserLinks( $this, $userObj );
348 $links = $this->getLanguage()->pipeList( $tools );
355 if ( $userObj->isIPRange() ) {
363 $nt = MWNamespace::getCanonicalName( NS_USER ) .
':' . $block->getTarget();
366 $out = $this->getOutput();
374 'showIfEmpty' =>
false,
377 'sp-contributions-blocked-notice-anon' :
378 'sp-contributions-blocked-notice',
379 $userObj->getName() # Support GENDER in
'sp-contributions-blocked-notice'
381 'offset' =>
'' # don
't use WebRequest parameter offset
388 return $this->msg( 'contribsub2
' )->rawParams( $user, $links )->params( $userObj->getName() );
399 public static function getUserLinks( SpecialPage $sp, User $target ) {
400 $id = $target->getId();
401 $username = $target->getName();
402 $userpage = $target->getUserPage();
403 $talkpage = $target->getTalkPage();
405 $linkRenderer = $sp->getLinkRenderer();
407 # No talk pages for IP ranges.
408 if ( !IP::isValidRange( $username ) ) {
409 $tools['user-talk
'] = $linkRenderer->makeLink(
411 $sp->msg( 'sp-contributions-talk
' )->text()
415 if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
416 if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
417 if ( $target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO ) {
418 $tools['block'] = $linkRenderer->makeKnownLink( # Change block link
419 SpecialPage::getTitleFor( 'Block', $username ),
420 $sp->msg( 'change-blocklink
' )->text()
422 $tools['unblock
'] = $linkRenderer->makeKnownLink( # Unblock link
423 SpecialPage::getTitleFor( 'Unblock
', $username ),
424 $sp->msg( 'unblocklink
' )->text()
426 } else { # User is not blocked
427 $tools['block'] = $linkRenderer->makeKnownLink( # Block link
428 SpecialPage::getTitleFor( 'Block', $username ),
429 $sp->msg( 'blocklink
' )->text()
435 $tools['log-
block'] = $linkRenderer->makeKnownLink(
436 SpecialPage::getTitleFor( 'Log
', 'block' ),
437 $sp->msg( 'sp-contributions-blocklog
' )->text(),
439 [ 'page
' => $userpage->getPrefixedText() ]
442 # Suppression log link (T61120)
443 if ( $sp->getUser()->isAllowed( 'suppressionlog
' ) ) {
444 $tools['log-suppression
'] = $linkRenderer->makeKnownLink(
445 SpecialPage::getTitleFor( 'Log
', 'suppress
' ),
446 $sp->msg( 'sp-contributions-suppresslog
', $username )->text(),
448 [ 'offender
' => $username ]
458 $sp->msg(
'sp-contributions-uploads' )->text()
464 $sp->msg(
'sp-contributions-logs' )->text()
467 # Add link to deleted user contributions for priviledged users
468 if ( $sp->getUser()->isAllowed(
'deletedhistory' ) ) {
471 $sp->msg(
'sp-contributions-deleted',
$username )->text()
476 # Add a link to change user rights for privileged users
478 $userrightsPage->setContext( $sp->getContext() );
479 if ( $userrightsPage->userCanChangeRights( $target ) ) {
481 SpecialPage::getTitleFor(
'Userrights',
$username ),
482 $sp->msg(
'sp-contributions-userrights',
$username )->text()
486 Hooks::run(
'ContributionsToolLinks', [ $id, $userpage, &$tools, $sp ] );
496 $this->opts[
'title'] = $this->getPageTitle()->getPrefixedText();
497 if ( !isset( $this->opts[
'target'] ) ) {
498 $this->opts[
'target'] =
'';
500 $this->opts[
'target'] = str_replace(
'_',
' ', $this->opts[
'target'] );
503 if ( !isset( $this->opts[
'namespace'] ) ) {
504 $this->opts[
'namespace'] =
'';
507 if ( !isset( $this->opts[
'nsInvert'] ) ) {
508 $this->opts[
'nsInvert'] =
'';
511 if ( !isset( $this->opts[
'associated'] ) ) {
512 $this->opts[
'associated'] =
false;
515 if ( !isset( $this->opts[
'contribs'] ) ) {
516 $this->opts[
'contribs'] =
'user';
519 if ( !isset( $this->opts[
'start'] ) ) {
520 $this->opts[
'start'] =
'';
523 if ( !isset( $this->opts[
'end'] ) ) {
524 $this->opts[
'end'] =
'';
527 if ( $this->opts[
'contribs'] ==
'newbie' ) {
528 $this->opts[
'target'] =
'';
531 if ( !isset( $this->opts[
'tagfilter'] ) ) {
532 $this->opts[
'tagfilter'] =
'';
535 if ( !isset( $this->opts[
'topOnly'] ) ) {
536 $this->opts[
'topOnly'] =
false;
539 if ( !isset( $this->opts[
'newOnly'] ) ) {
540 $this->opts[
'newOnly'] =
false;
543 if ( !isset( $this->opts[
'hideMinor'] ) ) {
544 $this->opts[
'hideMinor'] =
false;
548 $this->getOutput()->addModules( [
549 'mediawiki.userSuggest',
550 'mediawiki.special.contributions',
552 $this->getOutput()->addModuleStyles(
'mediawiki.widgets.DateInputWidget.styles' );
553 $this->getOutput()->enableOOUI();
555 $form = Html::openElement(
560 'class' =>
'mw-contributions-form'
564 # Add hidden params for tracking except for parameters in $skipParameters
582 foreach ( $this->opts as $name =>
$value ) {
583 if ( in_array( $name, $skipParameters ) ) {
586 $form .=
"\t" . Html::hidden( $name,
$value ) .
"\n";
590 $this->opts[
'tagfilter'],
false, $this->
getContext() );
593 $filterSelection = Html::rawElement(
596 implode(
' ', $tagFilter )
599 $filterSelection = Html::rawElement(
'div', [],
'' );
602 $labelNewbies = Xml::radioLabel(
603 $this->msg(
'sp-contributions-newbies' )->
text(),
607 $this->opts[
'contribs'] ==
'newbie',
608 [
'class' =>
'mw-input' ]
610 $labelUsername = Xml::radioLabel(
611 $this->msg(
'sp-contributions-username' )->
text(),
615 $this->opts[
'contribs'] ==
'user',
616 [
'class' =>
'mw-input' ]
620 $this->opts[
'target'],
626 'mw-ui-input-inline',
627 'mw-autocomplete-user',
631 ( $this->opts[
'contribs'] ===
'newbie' || $this->opts[
'target'] )
632 ? [] : [
'autofocus' =>
true ]
636 $targetSelection = Html::rawElement(
639 $labelNewbies .
'<br>' . $labelUsername .
' ' .
$input .
' '
642 $namespaceSelection = Xml::tags(
646 $this->msg(
'namespace' )->
text(),
650 Html::namespaceSelector(
651 [
'selected' => $this->opts[
'namespace'],
'all' =>
'' ],
653 'name' =>
'namespace',
655 'class' =>
'namespaceselector',
660 [
'class' =>
'mw-input-with-label' ],
662 $this->msg(
'invert' )->
text(),
665 $this->opts[
'nsInvert'],
667 'title' => $this->msg(
'tooltip-invert' )->
text(),
668 'class' =>
'mw-input'
672 Html::rawElement(
'span', [
'class' =>
'mw-input-with-label' ],
674 $this->msg(
'namespace_association' )->
text(),
677 $this->opts[
'associated'],
679 'title' => $this->msg(
'tooltip-namespace_association' )->
text(),
680 'class' =>
'mw-input'
688 if ( $this->getUser()->isAllowed(
'deletedhistory' ) ) {
689 $filters[] = Html::rawElement(
691 [
'class' =>
'mw-input-with-label' ],
693 $this->msg(
'history-show-deleted' )->
text(),
695 'mw-show-deleted-only',
696 $this->opts[
'deletedOnly'],
697 [
'class' =>
'mw-input' ]
702 $filters[] = Html::rawElement(
704 [
'class' =>
'mw-input-with-label' ],
706 $this->msg(
'sp-contributions-toponly' )->
text(),
709 $this->opts[
'topOnly'],
710 [
'class' =>
'mw-input' ]
713 $filters[] = Html::rawElement(
715 [
'class' =>
'mw-input-with-label' ],
717 $this->msg(
'sp-contributions-newonly' )->
text(),
720 $this->opts[
'newOnly'],
721 [
'class' =>
'mw-input' ]
724 $filters[] = Html::rawElement(
726 [
'class' =>
'mw-input-with-label' ],
728 $this->msg(
'sp-contributions-hideminor' )->
text(),
730 'mw-hide-minor-edits',
731 $this->opts[
'hideMinor'],
732 [
'class' =>
'mw-input' ]
737 'SpecialContributions::getForm::filters',
741 $extraOptions = Html::rawElement(
744 implode(
'', $filters )
747 $dateRangeSelection = Html::rawElement(
750 Xml::label(
wfMessage(
'date-range-from' )->
text(),
'mw-date-start' ) .
' ' .
753 'id' =>
'mw-date-start',
755 'value' => $this->opts[
'start'],
756 'longDisplayFormat' =>
true,
758 Xml::label(
wfMessage(
'date-range-to' )->
text(),
'mw-date-end' ) .
' ' .
761 'id' =>
'mw-date-end',
763 'value' => $this->opts[
'end'],
764 'longDisplayFormat' =>
true,
768 $submit = Xml::tags(
'div', [],
770 $this->msg(
'sp-contributions-submit' )->
text(),
771 [
'class' =>
'mw-submit' ], [
'mw-ui-progressive' ]
775 $form .= Xml::fieldset(
776 $this->msg(
'sp-contributions-search' )->
text(),
778 $namespaceSelection .
781 $dateRangeSelection .
783 [
'class' =>
'mw-contributions-table' ]
786 $explain = $this->msg(
'sp-contributions-explain' );
787 if ( !$explain->isBlank() ) {
788 $form .=
"<p id='mw-sp-contributions-explain'>{$explain->parse()}</p>";
791 $form .= Xml::closeElement(
'form' );
within a display generated by the Derivative if and wherever such third party notices normally appear The contents of the NOTICE file are for informational purposes only and do not modify the License You may add Your own attribution notices within Derivative Works that You alongside or as an addendum to the NOTICE text from the provided that such additional attribution notices cannot be construed as modifying the License You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for or distribution of Your or for any such Derivative Works as a provided Your and distribution of the Work otherwise complies with the conditions stated in this License Submission of Contributions Unless You explicitly state any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this without any additional terms or conditions Notwithstanding the nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions Trademarks This License does not grant permission to use the trade service or product names of the except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file Disclaimer of Warranty Unless required by applicable law or agreed to in Licensor provides the WITHOUT WARRANTIES OR CONDITIONS OF ANY either express or including
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
static isExternal( $username)
Tells whether the username is external or not.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
A collection of public static functions to play with IP address and IP ranges.
Shortcut to construct an includable special page.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Convenience class for dealing with PoolCounters using callbacks.
execute( $skipcache=false)
Get the result of the work (whatever it is), or the result of the error() function.
Special:Contributions, show user contributions in a paged list.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
getForm()
Generates the namespace selector form with hidden attributes.
execute( $par)
Default execute method Checks user permissions.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
contributionsSub( $userObj)
Generates the subheading with links.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
getSkin()
Shortcut to get the skin being used for this instance.
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,...
addFeedLinks( $params)
Adds RSS/atom links.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static isIP( $name)
Does the string match an anonymous IP address?
Special page to allow managing user group membership.
static getCurrentWikiDbDomain()
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
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
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
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
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
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
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 "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
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
this hook is for auditing only or null if authentication failed before getting that far $username
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
if(is_array($mode)) switch( $mode) $input
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.