33 parent::__construct(
'Contributions' );
40 $out->addModuleStyles( [
42 'mediawiki.special.changeslist',
49 if ( $par !== null ) {
52 $target =
$request->getVal(
'target' );
55 if (
$request->getVal(
'contribs' ) ==
'newbie' || $par ===
'newbies' ) {
57 $this->opts[
'contribs'] =
'newbie';
59 $this->opts[
'contribs'] =
'user';
62 $this->opts[
'deletedOnly'] =
$request->getBool(
'deletedOnly' );
64 if ( !strlen( $target ) ) {
74 $this->opts[
'limit'] =
$request->getInt(
'limit',
$user->getOption(
'rclimit' ) );
75 $this->opts[
'target'] = $target;
76 $this->opts[
'topOnly'] =
$request->getBool(
'topOnly' );
77 $this->opts[
'newOnly'] =
$request->getBool(
'newOnly' );
78 $this->opts[
'hideMinor'] =
$request->getBool(
'hideMinor' );
92 $id = $userObj->getId();
94 if ( $this->opts[
'contribs'] !=
'newbie' ) {
95 $target = $nt->getText();
99 $this->
msg(
'contributions-title', $target )->plain()
100 )->inContentLanguage() );
101 $this->
getSkin()->setRelevantUser( $userObj );
103 $out->addSubtitle( $this->
msg(
'sp-contributions-newbies-sub' ) );
104 $out->setHTMLTitle( $this->
msg(
106 $this->
msg(
'sp-contributions-newbies-title' )->plain()
107 )->inContentLanguage() );
110 $ns =
$request->getVal(
'namespace', null );
111 if ( $ns !== null && $ns !==
'' ) {
112 $this->opts[
'namespace'] = intval( $ns );
114 $this->opts[
'namespace'] =
'';
117 $this->opts[
'associated'] =
$request->getBool(
'associated' );
118 $this->opts[
'nsInvert'] = (bool)
$request->getVal(
'nsInvert' );
119 $this->opts[
'tagfilter'] = (
string)
$request->getVal(
'tagfilter' );
123 if (
$user->isAllowed(
'markbotedits' ) &&
$request->getBool(
'bot' ) ) {
124 $this->opts[
'bot'] =
'1';
127 $skip =
$request->getText(
'offset' ) ||
$request->getText(
'dir' ) ==
'prev';
128 # Offset overrides year/month selection
130 $this->opts[
'year'] =
'';
131 $this->opts[
'month'] =
'';
133 $this->opts[
'year'] =
$request->getIntOrNull(
'year' );
134 $this->opts[
'month'] =
$request->getIntOrNull(
'month' );
137 $feedType =
$request->getVal(
'feed' );
140 'action' =>
'feedcontributions',
143 if ( $this->opts[
'topOnly'] ) {
144 $feedParams[
'toponly'] =
true;
146 if ( $this->opts[
'newOnly'] ) {
147 $feedParams[
'newonly'] =
true;
149 if ( $this->opts[
'hideMinor'] ) {
150 $feedParams[
'hideminor'] =
true;
152 if ( $this->opts[
'deletedOnly'] ) {
153 $feedParams[
'deletedonly'] =
true;
155 if ( $this->opts[
'tagfilter'] !==
'' ) {
156 $feedParams[
'tagfilter'] = $this->opts[
'tagfilter'];
158 if ( $this->opts[
'namespace'] !==
'' ) {
159 $feedParams[
'namespace'] = $this->opts[
'namespace'];
163 if ( $feedType && $this->opts[
'year'] !== null ) {
164 $feedParams[
'year'] = $this->opts[
'year'];
166 if ( $feedType && $this->opts[
'month'] !== null ) {
167 $feedParams[
'month'] = $this->opts[
'month'];
173 $feedParams[
'feedformat'] = $feedType;
176 $out->redirect( $url,
'301' );
184 if (
Hooks::run(
'SpecialContributionsBeforeMainOutput', [ $id, $userObj, $this ] ) ) {
190 'contribs' => $this->opts[
'contribs'],
191 'namespace' => $this->opts[
'namespace'],
192 'tagfilter' => $this->opts[
'tagfilter'],
193 'year' => $this->opts[
'year'],
194 'month' => $this->opts[
'month'],
195 'deletedOnly' => $this->opts[
'deletedOnly'],
196 'topOnly' => $this->opts[
'topOnly'],
197 'newOnly' => $this->opts[
'newOnly'],
198 'hideMinor' => $this->opts[
'hideMinor'],
199 'nsInvert' => $this->opts[
'nsInvert'],
200 'associated' => $this->opts[
'associated'],
203 if ( !$pager->getNumRows() ) {
204 $out->addWikiMsg(
'nocontribs', $target );
206 # Show a message about slave lag, if applicable
207 $lag =
wfGetLB()->safeGetLag( $pager->getDatabase() );
209 $out->showLagWarning( $lag );
214 $output =
'<p>' . $pager->getNavigationBar() .
'</p>' .
216 '<p>' . $pager->getNavigationBar() .
'</p>';
220 $out->preventClickjacking( $pager->getPreventClickjacking() );
222 # Show the appropriate "footer" message - WHOIS tools, etc.
223 if ( $this->opts[
'contribs'] ==
'newbie' ) {
224 $message =
'sp-contributions-footer-newbies';
226 $message =
'sp-contributions-footer-anon';
227 } elseif ( $userObj->isAnon() ) {
231 $message =
'sp-contributions-footer';
236 if ( !$this->
msg( $message, $target )->isDisabled() ) {
238 "<div class='mw-contributions-footer'>\n$1\n</div>",
239 [ $message, $target ] );
254 if ( $userObj->isAnon() ) {
258 "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
260 'contributions-userdoesnotexist',
265 $this->
getOutput()->setStatusCode( 404 );
268 $user = htmlspecialchars( $userObj->getName() );
270 $user =
Linker::link( $userObj->getUserPage(), htmlspecialchars( $userObj->getName() ) );
272 $nt = $userObj->getUserPage();
273 $talk = $userObj->getTalkPage();
297 'showIfEmpty' =>
false,
300 'sp-contributions-blocked-notice-anon' :
301 'sp-contributions-blocked-notice',
302 $userObj->getName() # Support GENDER
in 'sp-contributions-blocked-notice'
304 'offset' =>
'' # don
't use WebRequest parameter offset
311 return $this->msg( 'contribsub2
' )->rawParams( $user, $links )->params( $userObj->getName() );
321 public function getUserLinks( Title $userpage, Title $talkpage, User $target ) {
323 $id = $target->getId();
324 $username = $target->getName();
326 $tools[] = Linker::link( $talkpage, $this->msg( 'sp-contributions-talk
' )->escaped() );
328 if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
329 if ( $this->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
330 if ( $target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO ) {
331 $tools[] = Linker::linkKnown( # Change block link
332 SpecialPage::getTitleFor( 'Block', $username ),
333 $this->msg( 'change-blocklink
' )->escaped()
335 $tools[] = Linker::linkKnown( # Unblock link
336 SpecialPage::getTitleFor( 'Unblock
', $username ),
337 $this->msg( 'unblocklink
' )->escaped()
339 } else { # User is not blocked
340 $tools[] = Linker::linkKnown( # Block link
341 SpecialPage::getTitleFor( 'Block', $username ),
342 $this->msg( 'blocklink
' )->escaped()
348 $tools[] = Linker::linkKnown(
349 SpecialPage::getTitleFor( 'Log
', 'block' ),
350 $this->msg( 'sp-contributions-blocklog
' )->escaped(),
352 [ 'page' => $userpage->getPrefixedText() ]
355 # Suppression log link (bug 59120)
356 if ( $this->getUser()->isAllowed( 'suppressionlog
' ) ) {
357 $tools[] = Linker::linkKnown(
358 SpecialPage::getTitleFor( 'Log
', 'suppress
' ),
359 $this->msg( 'sp-contributions-suppresslog
' )->escaped(),
361 [ 'offender
' => $username ]
366 $tools[] = Linker::linkKnown(
367 SpecialPage::getTitleFor( 'Listfiles
', $username ),
368 $this->msg( 'sp-contributions-uploads
' )->escaped()
372 $tools[] = Linker::linkKnown(
373 SpecialPage::getTitleFor( 'Log
', $username ),
374 $this->msg( 'sp-contributions-
logs' )->escaped()
377 # Add link to deleted user contributions for priviledged users
378 if ( $this->getUser()->isAllowed( 'deletedhistory
' ) ) {
379 $tools[] = Linker::linkKnown(
380 SpecialPage::getTitleFor( 'DeletedContributions
', $username ),
381 $this->msg( 'sp-contributions-deleted
' )->escaped()
385 # Add a link to change user rights for privileged users
386 $userrightsPage = new UserrightsPage();
387 $userrightsPage->setContext( $this->getContext() );
388 if ( $userrightsPage->userCanChangeRights( $target ) ) {
389 $tools[] = Linker::linkKnown(
390 SpecialPage::getTitleFor( 'Userrights
', $username ),
391 $this->msg( 'sp-contributions-userrights
' )->escaped()
395 Hooks::run( 'ContributionsToolLinks
', [ $id, $userpage, &$tools ] );
404 protected function getForm() {
405 $this->opts['title'] = $this->getPageTitle()->getPrefixedText();
406 if ( !isset( $this->opts['target
'] ) ) {
407 $this->opts['target
'] = '';
409 $this->opts['target
'] = str_replace( '_
', ' ', $this->opts['target
'] );
412 if ( !isset( $this->opts['namespace'] ) ) {
413 $this->opts['namespace'] = '';
416 if ( !isset( $this->opts['nsInvert
'] ) ) {
417 $this->opts['nsInvert
'] = '';
420 if ( !isset( $this->opts['associated
'] ) ) {
421 $this->opts['associated
'] = false;
424 if ( !isset( $this->opts['contribs
'] ) ) {
425 $this->opts['contribs
'] = 'user';
428 if ( !isset( $this->opts['year
'] ) ) {
429 $this->opts['year
'] = '';
432 if ( !isset( $this->opts['month
'] ) ) {
433 $this->opts['month
'] = '';
436 if ( $this->opts['contribs
'] == 'newbie
' ) {
437 $this->opts['target
'] = '';
440 if ( !isset( $this->opts['tagfilter
'] ) ) {
441 $this->opts['tagfilter
'] = '';
444 if ( !isset( $this->opts['topOnly
'] ) ) {
445 $this->opts['topOnly
'] = false;
448 if ( !isset( $this->opts['newOnly
'] ) ) {
449 $this->opts['newOnly
'] = false;
452 if ( !isset( $this->opts['hideMinor
'] ) ) {
453 $this->opts['hideMinor
'] = false;
456 $form = Html::openElement(
460 'action
' => wfScript(),
461 'class' => 'mw-contributions-
form'
465 # Add hidden params for tracking except for parameters in $skipParameters
481 foreach ( $this->opts as $name => $value ) {
482 if ( in_array( $name, $skipParameters ) ) {
485 $form .= "\t" . Html::hidden( $name, $value ) . "\n";
488 $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagfilter
'] );
491 $filterSelection = Html::rawElement(
494 implode( ' 
', $tagFilter )
497 $filterSelection = Html::rawElement( 'td
', [ 'colspan
' => 2 ], '' );
500 $this->getOutput()->addModules( 'mediawiki.userSuggest
' );
502 $labelNewbies = Xml::radioLabel(
503 $this->msg( 'sp-contributions-newbies
' )->text(),
507 $this->opts['contribs
'] == 'newbie
',
508 [ 'class' => 'mw-input
' ]
510 $labelUsername = Xml::radioLabel(
511 $this->msg( 'sp-contributions-username
' )->text(),
515 $this->opts['contribs
'] == 'user',
516 [ 'class' => 'mw-input
' ]
518 $input = Html::input(
520 $this->opts['target
'],
527 'mw-ui-input-
inline',
528 'mw-autocomplete-
user', // used by mediawiki.userSuggest
531 // Only autofocus if target hasn't been specified
or in non-newbies mode
532 ( $this->opts[
'contribs'] ===
'newbie' || $this->opts[
'target'] )
533 ? [] : [
'autofocus' =>
true ]
540 $labelNewbies .
'<br />' . $labelUsername .
' ' . $input .
' '
547 $this->
msg(
'namespace' )->
text(),
552 [
'selected' => $this->opts[
'namespace'],
'all' =>
'' ],
554 'name' =>
'namespace',
556 'class' =>
'namespaceselector',
561 [
'class' =>
'mw-input-with-label' ],
563 $this->
msg(
'invert' )->
text(),
566 $this->opts[
'nsInvert'],
568 'title' => $this->
msg(
'tooltip-invert' )->
text(),
569 'class' =>
'mw-input'
575 $this->
msg(
'namespace_association' )->
text(),
578 $this->opts[
'associated'],
580 'title' => $this->
msg(
'tooltip-namespace_association' )->
text(),
581 'class' =>
'mw-input'
589 if ( $this->
getUser()->isAllowed(
'deletedhistory' ) ) {
592 [
'class' =>
'mw-input-with-label' ],
594 $this->
msg(
'history-show-deleted' )->
text(),
596 'mw-show-deleted-only',
597 $this->opts[
'deletedOnly'],
598 [
'class' =>
'mw-input' ]
605 [
'class' =>
'mw-input-with-label' ],
607 $this->
msg(
'sp-contributions-toponly' )->
text(),
610 $this->opts[
'topOnly'],
611 [
'class' =>
'mw-input' ]
616 [
'class' =>
'mw-input-with-label' ],
618 $this->
msg(
'sp-contributions-newonly' )->
text(),
621 $this->opts[
'newOnly'],
622 [
'class' =>
'mw-input' ]
627 [
'class' =>
'mw-input-with-label' ],
629 $this->
msg(
'sp-contributions-hideminor' )->
text(),
631 'mw-hide-minor-edits',
632 $this->opts[
'hideMinor'],
633 [
'class' =>
'mw-input' ]
638 'SpecialContributions::getForm::filters',
645 implode(
'', $filters )
648 $dateSelectionAndSubmit =
Xml::tags(
'td', [
'colspan' => 2 ],
654 $this->
msg(
'sp-contributions-submit' )->
text(),
655 [
'class' =>
'mw-submit' ], [
'mw-ui-progressive' ]
660 $form .=
Html::rawElement(
'table', [
'class' =>
'mw-contributions-table' ],
"\n" .
668 $explain = $this->
msg(
'sp-contributions-explain' );
669 if ( !$explain->isBlank() ) {
670 $form .=
"<p id='mw-sp-contributions-explain'>{$explain->parse()}</p>";
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
prefixSearchSubpages($search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
null means default in associative array form
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
getContext()
Gets the context this SpecialPage is executed in.
wfScript($script= 'index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
getForm()
Generates the namespace selector form with hidden attributes.
processing should stop and the error should be shown to the user * false
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
addFeedLinks($params)
Adds RSS/atom links.
null for the local wiki Added in
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
msg()
Wrapper around wfMessage that sets the current context.
including($x=null)
Whether the special page is being evaluated via transclusion.
getOutput()
Get the OutputPage being used for this instance.
static isIPAddress($ip)
Determine if a string is as valid IP address or network (CIDR prefix).
addHelpLink($to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
static label($label, $id, $attribs=[])
Convenience function to build an HTML form label.
static showLogExtract(&$out, $types=[], $page= '', $user= '', $param=[])
Show log extract.
outputHeader($summaryMessageKey= '')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
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
static fieldset($legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
static closeElement($element)
Shortcut to close an XML element.
wfGetLB($wiki=false)
Get a load balancer object.
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
Shortcut to construct an includable special page.
static getCanonicalName($index)
Returns the canonical (English) name for a given index.
wfAppendQuery($url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Special:Contributions, show user contributions in a paged list.
static newFromTarget($specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
static search($audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
static getInstance($ts=false)
Get a timestamp instance in GMT.
static dateMenu($year, $month)
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.
getSkin()
Shortcut to get the skin being used for this instance.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
static isIP($name)
Does the string match an anonymous IP address?
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
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
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 local account $user
static link($target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $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
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 tags($element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
static submitButton($contents, array $attrs, array $modifiers=[])
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enab...
error also a ContextSource you ll probably need to make sure the header is varied on $request
getUser()
Shortcut to get the User executing this instance.
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
getLanguage()
Shortcut to get user's language.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
static checkLabel($label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
contributionsSub($userObj)
Generates the subheading with links.
getUserLinks(Title $userpage, Title $talkpage, User $target)
Links to different places.
getRequest()
Get the WebRequest being used for this instance.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk page
if the prop value should be in the metadata multi language array format
this hook is for auditing only etc 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 namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.