MediaWiki  1.29.1
SpecialContributions.php
Go to the documentation of this file.
1 <?php
30  protected $opts;
31 
32  public function __construct() {
33  parent::__construct( 'Contributions' );
34  }
35 
36  public function execute( $par ) {
37  $this->setHeaders();
38  $this->outputHeader();
39  $out = $this->getOutput();
40  $out->addModuleStyles( [
41  'mediawiki.special',
42  'mediawiki.special.changeslist',
43  ] );
44  $this->addHelpLink( 'Help:User contributions' );
45 
46  $this->opts = [];
47  $request = $this->getRequest();
48 
49  if ( $par !== null ) {
50  $target = $par;
51  } else {
52  $target = $request->getVal( 'target' );
53  }
54 
55  if ( $request->getVal( 'contribs' ) == 'newbie' || $par === 'newbies' ) {
56  $target = 'newbies';
57  $this->opts['contribs'] = 'newbie';
58  } else {
59  $this->opts['contribs'] = 'user';
60  }
61 
62  $this->opts['deletedOnly'] = $request->getBool( 'deletedOnly' );
63 
64  if ( !strlen( $target ) ) {
65  if ( !$this->including() ) {
66  $out->addHTML( $this->getForm() );
67  }
68 
69  return;
70  }
71 
72  $user = $this->getUser();
73 
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' );
79 
80  $nt = Title::makeTitleSafe( NS_USER, $target );
81  if ( !$nt ) {
82  $out->addHTML( $this->getForm() );
83 
84  return;
85  }
86  $userObj = User::newFromName( $nt->getText(), false );
87  if ( !$userObj ) {
88  $out->addHTML( $this->getForm() );
89 
90  return;
91  }
92  $id = $userObj->getId();
93 
94  if ( $this->opts['contribs'] != 'newbie' ) {
95  $target = $nt->getText();
96  $out->addSubtitle( $this->contributionsSub( $userObj ) );
97  $out->setHTMLTitle( $this->msg(
98  'pagetitle',
99  $this->msg( 'contributions-title', $target )->plain()
100  )->inContentLanguage() );
101  $this->getSkin()->setRelevantUser( $userObj );
102  } else {
103  $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
104  $out->setHTMLTitle( $this->msg(
105  'pagetitle',
106  $this->msg( 'sp-contributions-newbies-title' )->plain()
107  )->inContentLanguage() );
108  }
109 
110  $ns = $request->getVal( 'namespace', null );
111  if ( $ns !== null && $ns !== '' ) {
112  $this->opts['namespace'] = intval( $ns );
113  } else {
114  $this->opts['namespace'] = '';
115  }
116 
117  $this->opts['associated'] = $request->getBool( 'associated' );
118  $this->opts['nsInvert'] = (bool)$request->getVal( 'nsInvert' );
119  $this->opts['tagfilter'] = (string)$request->getVal( 'tagfilter' );
120 
121  // Allows reverts to have the bot flag in recent changes. It is just here to
122  // be passed in the form at the top of the page
123  if ( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) {
124  $this->opts['bot'] = '1';
125  }
126 
127  $skip = $request->getText( 'offset' ) || $request->getText( 'dir' ) == 'prev';
128  # Offset overrides year/month selection
129  if ( $skip ) {
130  $this->opts['year'] = '';
131  $this->opts['month'] = '';
132  } else {
133  $this->opts['year'] = $request->getIntOrNull( 'year' );
134  $this->opts['month'] = $request->getIntOrNull( 'month' );
135  }
136 
137  $feedType = $request->getVal( 'feed' );
138 
139  $feedParams = [
140  'action' => 'feedcontributions',
141  'user' => $target,
142  ];
143  if ( $this->opts['topOnly'] ) {
144  $feedParams['toponly'] = true;
145  }
146  if ( $this->opts['newOnly'] ) {
147  $feedParams['newonly'] = true;
148  }
149  if ( $this->opts['hideMinor'] ) {
150  $feedParams['hideminor'] = true;
151  }
152  if ( $this->opts['deletedOnly'] ) {
153  $feedParams['deletedonly'] = true;
154  }
155  if ( $this->opts['tagfilter'] !== '' ) {
156  $feedParams['tagfilter'] = $this->opts['tagfilter'];
157  }
158  if ( $this->opts['namespace'] !== '' ) {
159  $feedParams['namespace'] = $this->opts['namespace'];
160  }
161  // Don't use year and month for the feed URL, but pass them on if
162  // we redirect to API (if $feedType is specified)
163  if ( $feedType && $this->opts['year'] !== null ) {
164  $feedParams['year'] = $this->opts['year'];
165  }
166  if ( $feedType && $this->opts['month'] !== null ) {
167  $feedParams['month'] = $this->opts['month'];
168  }
169 
170  if ( $feedType ) {
171  // Maintain some level of backwards compatibility
172  // If people request feeds using the old parameters, redirect to API
173  $feedParams['feedformat'] = $feedType;
174  $url = wfAppendQuery( wfScript( 'api' ), $feedParams );
175 
176  $out->redirect( $url, '301' );
177 
178  return;
179  }
180 
181  // Add RSS/atom links
182  $this->addFeedLinks( $feedParams );
183 
184  if ( Hooks::run( 'SpecialContributionsBeforeMainOutput', [ $id, $userObj, $this ] ) ) {
185  if ( !$this->including() ) {
186  $out->addHTML( $this->getForm() );
187  }
188  $pager = new ContribsPager( $this->getContext(), [
189  'target' => $target,
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'],
201  ] );
202 
203  if ( !$pager->getNumRows() ) {
204  $out->addWikiMsg( 'nocontribs', $target );
205  } else {
206  # Show a message about replica DB lag, if applicable
207  $lag = wfGetLB()->safeGetLag( $pager->getDatabase() );
208  if ( $lag > 0 ) {
209  $out->showLagWarning( $lag );
210  }
211 
212  $output = $pager->getBody();
213  if ( !$this->including() ) {
214  $output = '<p>' . $pager->getNavigationBar() . '</p>' .
215  $output .
216  '<p>' . $pager->getNavigationBar() . '</p>';
217  }
218  $out->addHTML( $output );
219  }
220  $out->preventClickjacking( $pager->getPreventClickjacking() );
221 
222  # Show the appropriate "footer" message - WHOIS tools, etc.
223  if ( $this->opts['contribs'] == 'newbie' ) {
224  $message = 'sp-contributions-footer-newbies';
225  } elseif ( IP::isIPAddress( $target ) ) {
226  $message = 'sp-contributions-footer-anon';
227  } elseif ( $userObj->isAnon() ) {
228  // No message for non-existing users
229  $message = '';
230  } else {
231  $message = 'sp-contributions-footer';
232  }
233 
234  if ( $message ) {
235  if ( !$this->including() ) {
236  if ( !$this->msg( $message, $target )->isDisabled() ) {
237  $out->wrapWikiMsg(
238  "<div class='mw-contributions-footer'>\n$1\n</div>",
239  [ $message, $target ] );
240  }
241  }
242  }
243  }
244  }
245 
253  protected function contributionsSub( $userObj ) {
254  if ( $userObj->isAnon() ) {
255  // Show a warning message that the user being searched for doesn't exists
256  if ( !User::isIP( $userObj->getName() ) ) {
257  $this->getOutput()->wrapWikiMsg(
258  "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
259  [
260  'contributions-userdoesnotexist',
261  wfEscapeWikiText( $userObj->getName() ),
262  ]
263  );
264  if ( !$this->including() ) {
265  $this->getOutput()->setStatusCode( 404 );
266  }
267  }
268  $user = htmlspecialchars( $userObj->getName() );
269  } else {
270  $user = $this->getLinkRenderer()->makeLink( $userObj->getUserPage(), $userObj->getName() );
271  }
272  $nt = $userObj->getUserPage();
273  $talk = $userObj->getTalkPage();
274  $links = '';
275  if ( $talk ) {
276  $tools = self::getUserLinks( $this, $userObj );
277  $links = $this->getLanguage()->pipeList( $tools );
278 
279  // Show a note if the user is blocked and display the last block log entry.
280  // Do not expose the autoblocks, since that may lead to a leak of accounts' IPs,
281  // and also this will display a totally irrelevant log entry as a current block.
282  if ( !$this->including() ) {
283  $block = Block::newFromTarget( $userObj, $userObj );
284  if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
285  if ( $block->getType() == Block::TYPE_RANGE ) {
286  $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
287  }
288 
289  $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
291  $out,
292  'block',
293  $nt,
294  '',
295  [
296  'lim' => 1,
297  'showIfEmpty' => false,
298  'msgKey' => [
299  $userObj->isAnon() ?
300  'sp-contributions-blocked-notice-anon' :
301  'sp-contributions-blocked-notice',
302  $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
303  ],
304  'offset' => '' # don't use WebRequest parameter offset
305  ]
306  );
307  }
308  }
309  }
310 
311  return $this->msg( 'contribsub2' )->rawParams( $user, $links )->params( $userObj->getName() );
312  }
313 
322  public static function getUserLinks( SpecialPage $sp, User $target ) {
323 
324  $id = $target->getId();
325  $username = $target->getName();
326  $userpage = $target->getUserPage();
327  $talkpage = $target->getTalkPage();
328 
329  $linkRenderer = $sp->getLinkRenderer();
330  $tools['user-talk'] = $linkRenderer->makeLink(
331  $talkpage,
332  $sp->msg( 'sp-contributions-talk' )->text()
333  );
334 
335  if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
336  if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
337  if ( $target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO ) {
338  $tools['block'] = $linkRenderer->makeKnownLink( # Change block link
339  SpecialPage::getTitleFor( 'Block', $username ),
340  $sp->msg( 'change-blocklink' )->text()
341  );
342  $tools['unblock'] = $linkRenderer->makeKnownLink( # Unblock link
343  SpecialPage::getTitleFor( 'Unblock', $username ),
344  $sp->msg( 'unblocklink' )->text()
345  );
346  } else { # User is not blocked
347  $tools['block'] = $linkRenderer->makeKnownLink( # Block link
348  SpecialPage::getTitleFor( 'Block', $username ),
349  $sp->msg( 'blocklink' )->text()
350  );
351  }
352  }
353 
354  # Block log link
355  $tools['log-block'] = $linkRenderer->makeKnownLink(
356  SpecialPage::getTitleFor( 'Log', 'block' ),
357  $sp->msg( 'sp-contributions-blocklog' )->text(),
358  [],
359  [ 'page' => $userpage->getPrefixedText() ]
360  );
361 
362  # Suppression log link (T61120)
363  if ( $sp->getUser()->isAllowed( 'suppressionlog' ) ) {
364  $tools['log-suppression'] = $linkRenderer->makeKnownLink(
365  SpecialPage::getTitleFor( 'Log', 'suppress' ),
366  $sp->msg( 'sp-contributions-suppresslog', $username )->text(),
367  [],
368  [ 'offender' => $username ]
369  );
370  }
371  }
372  # Uploads
373  $tools['uploads'] = $linkRenderer->makeKnownLink(
374  SpecialPage::getTitleFor( 'Listfiles', $username ),
375  $sp->msg( 'sp-contributions-uploads' )->text()
376  );
377 
378  # Other logs link
379  $tools['logs'] = $linkRenderer->makeKnownLink(
380  SpecialPage::getTitleFor( 'Log', $username ),
381  $sp->msg( 'sp-contributions-logs' )->text()
382  );
383 
384  # Add link to deleted user contributions for priviledged users
385  if ( $sp->getUser()->isAllowed( 'deletedhistory' ) ) {
386  $tools['deletedcontribs'] = $linkRenderer->makeKnownLink(
387  SpecialPage::getTitleFor( 'DeletedContributions', $username ),
388  $sp->msg( 'sp-contributions-deleted', $username )->text()
389  );
390  }
391 
392  # Add a link to change user rights for privileged users
393  $userrightsPage = new UserrightsPage();
394  $userrightsPage->setContext( $sp->getContext() );
395  if ( $userrightsPage->userCanChangeRights( $target ) ) {
396  $tools['userrights'] = $linkRenderer->makeKnownLink(
397  SpecialPage::getTitleFor( 'Userrights', $username ),
398  $sp->msg( 'sp-contributions-userrights', $username )->text()
399  );
400  }
401 
402  Hooks::run( 'ContributionsToolLinks', [ $id, $userpage, &$tools, $sp ] );
403 
404  return $tools;
405  }
406 
411  protected function getForm() {
412  $this->opts['title'] = $this->getPageTitle()->getPrefixedText();
413  if ( !isset( $this->opts['target'] ) ) {
414  $this->opts['target'] = '';
415  } else {
416  $this->opts['target'] = str_replace( '_', ' ', $this->opts['target'] );
417  }
418 
419  if ( !isset( $this->opts['namespace'] ) ) {
420  $this->opts['namespace'] = '';
421  }
422 
423  if ( !isset( $this->opts['nsInvert'] ) ) {
424  $this->opts['nsInvert'] = '';
425  }
426 
427  if ( !isset( $this->opts['associated'] ) ) {
428  $this->opts['associated'] = false;
429  }
430 
431  if ( !isset( $this->opts['contribs'] ) ) {
432  $this->opts['contribs'] = 'user';
433  }
434 
435  if ( !isset( $this->opts['year'] ) ) {
436  $this->opts['year'] = '';
437  }
438 
439  if ( !isset( $this->opts['month'] ) ) {
440  $this->opts['month'] = '';
441  }
442 
443  if ( $this->opts['contribs'] == 'newbie' ) {
444  $this->opts['target'] = '';
445  }
446 
447  if ( !isset( $this->opts['tagfilter'] ) ) {
448  $this->opts['tagfilter'] = '';
449  }
450 
451  if ( !isset( $this->opts['topOnly'] ) ) {
452  $this->opts['topOnly'] = false;
453  }
454 
455  if ( !isset( $this->opts['newOnly'] ) ) {
456  $this->opts['newOnly'] = false;
457  }
458 
459  if ( !isset( $this->opts['hideMinor'] ) ) {
460  $this->opts['hideMinor'] = false;
461  }
462 
463  $form = Html::openElement(
464  'form',
465  [
466  'method' => 'get',
467  'action' => wfScript(),
468  'class' => 'mw-contributions-form'
469  ]
470  );
471 
472  # Add hidden params for tracking except for parameters in $skipParameters
473  $skipParameters = [
474  'namespace',
475  'nsInvert',
476  'deletedOnly',
477  'target',
478  'contribs',
479  'year',
480  'month',
481  'topOnly',
482  'newOnly',
483  'hideMinor',
484  'associated',
485  'tagfilter'
486  ];
487 
488  foreach ( $this->opts as $name => $value ) {
489  if ( in_array( $name, $skipParameters ) ) {
490  continue;
491  }
492  $form .= "\t" . Html::hidden( $name, $value ) . "\n";
493  }
494 
495  $tagFilter = ChangeTags::buildTagFilterSelector(
496  $this->opts['tagfilter'], false, $this->getContext() );
497 
498  if ( $tagFilter ) {
499  $filterSelection = Html::rawElement(
500  'div',
501  [],
502  implode( '&#160;', $tagFilter )
503  );
504  } else {
505  $filterSelection = Html::rawElement( 'div', [], '' );
506  }
507 
508  $this->getOutput()->addModules( 'mediawiki.userSuggest' );
509 
510  $labelNewbies = Xml::radioLabel(
511  $this->msg( 'sp-contributions-newbies' )->text(),
512  'contribs',
513  'newbie',
514  'newbie',
515  $this->opts['contribs'] == 'newbie',
516  [ 'class' => 'mw-input' ]
517  );
518  $labelUsername = Xml::radioLabel(
519  $this->msg( 'sp-contributions-username' )->text(),
520  'contribs',
521  'user',
522  'user',
523  $this->opts['contribs'] == 'user',
524  [ 'class' => 'mw-input' ]
525  );
526  $input = Html::input(
527  'target',
528  $this->opts['target'],
529  'text',
530  [
531  'size' => '40',
532  'class' => [
533  'mw-input',
534  'mw-ui-input-inline',
535  'mw-autocomplete-user', // used by mediawiki.userSuggest
536  ],
537  ] + (
538  // Only autofocus if target hasn't been specified or in non-newbies mode
539  ( $this->opts['contribs'] === 'newbie' || $this->opts['target'] )
540  ? [] : [ 'autofocus' => true ]
541  )
542  );
543 
544  $targetSelection = Html::rawElement(
545  'div',
546  [],
547  $labelNewbies . '<br>' . $labelUsername . ' ' . $input . ' '
548  );
549 
550  $namespaceSelection = Xml::tags(
551  'div',
552  [],
553  Xml::label(
554  $this->msg( 'namespace' )->text(),
555  'namespace',
556  ''
557  ) . '&#160;' .
559  [ 'selected' => $this->opts['namespace'], 'all' => '' ],
560  [
561  'name' => 'namespace',
562  'id' => 'namespace',
563  'class' => 'namespaceselector',
564  ]
565  ) . '&#160;' .
567  'span',
568  [ 'class' => 'mw-input-with-label' ],
570  $this->msg( 'invert' )->text(),
571  'nsInvert',
572  'nsInvert',
573  $this->opts['nsInvert'],
574  [
575  'title' => $this->msg( 'tooltip-invert' )->text(),
576  'class' => 'mw-input'
577  ]
578  ) . '&#160;'
579  ) .
580  Html::rawElement( 'span', [ 'class' => 'mw-input-with-label' ],
582  $this->msg( 'namespace_association' )->text(),
583  'associated',
584  'associated',
585  $this->opts['associated'],
586  [
587  'title' => $this->msg( 'tooltip-namespace_association' )->text(),
588  'class' => 'mw-input'
589  ]
590  ) . '&#160;'
591  )
592  );
593 
594  $filters = [];
595 
596  if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
597  $filters[] = Html::rawElement(
598  'span',
599  [ 'class' => 'mw-input-with-label' ],
601  $this->msg( 'history-show-deleted' )->text(),
602  'deletedOnly',
603  'mw-show-deleted-only',
604  $this->opts['deletedOnly'],
605  [ 'class' => 'mw-input' ]
606  )
607  );
608  }
609 
610  $filters[] = Html::rawElement(
611  'span',
612  [ 'class' => 'mw-input-with-label' ],
614  $this->msg( 'sp-contributions-toponly' )->text(),
615  'topOnly',
616  'mw-show-top-only',
617  $this->opts['topOnly'],
618  [ 'class' => 'mw-input' ]
619  )
620  );
621  $filters[] = Html::rawElement(
622  'span',
623  [ 'class' => 'mw-input-with-label' ],
625  $this->msg( 'sp-contributions-newonly' )->text(),
626  'newOnly',
627  'mw-show-new-only',
628  $this->opts['newOnly'],
629  [ 'class' => 'mw-input' ]
630  )
631  );
632  $filters[] = Html::rawElement(
633  'span',
634  [ 'class' => 'mw-input-with-label' ],
636  $this->msg( 'sp-contributions-hideminor' )->text(),
637  'hideMinor',
638  'mw-hide-minor-edits',
639  $this->opts['hideMinor'],
640  [ 'class' => 'mw-input' ]
641  )
642  );
643 
644  Hooks::run(
645  'SpecialContributions::getForm::filters',
646  [ $this, &$filters ]
647  );
648 
649  $extraOptions = Html::rawElement(
650  'div',
651  [],
652  implode( '', $filters )
653  );
654 
655  $dateSelectionAndSubmit = Xml::tags( 'div', [],
657  $this->opts['year'] === '' ? MWTimestamp::getInstance()->format( 'Y' ) : $this->opts['year'],
658  $this->opts['month']
659  ) . ' ' .
661  $this->msg( 'sp-contributions-submit' )->text(),
662  [ 'class' => 'mw-submit' ], [ 'mw-ui-progressive' ]
663  )
664  );
665 
666  $form .= Xml::fieldset(
667  $this->msg( 'sp-contributions-search' )->text(),
668  $targetSelection .
669  $namespaceSelection .
670  $filterSelection .
671  $extraOptions .
672  $dateSelectionAndSubmit,
673  [ 'class' => 'mw-contributions-table' ]
674  );
675 
676  $explain = $this->msg( 'sp-contributions-explain' );
677  if ( !$explain->isBlank() ) {
678  $form .= "<p id='mw-sp-contributions-explain'>{$explain->parse()}</p>";
679  }
680 
681  $form .= Xml::closeElement( 'form' );
682 
683  return $form;
684  }
685 
694  public function prefixSearchSubpages( $search, $limit, $offset ) {
695  $user = User::newFromName( $search );
696  if ( !$user ) {
697  // No prefix suggestion for invalid user
698  return [];
699  }
700  // Autocomplete subpage as user list - public to allow caching
701  return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
702  }
703 
704  protected function getGroupName() {
705  return 'users';
706  }
707 }
SpecialContributions\prefixSearchSubpages
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
Definition: SpecialContributions.php:694
$request
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2612
SpecialContributions\getUserLinks
static getUserLinks(SpecialPage $sp, User $target)
Links to different places.
Definition: SpecialContributions.php:322
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
Xml\tags
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:675
SpecialContributions\getForm
getForm()
Generates the namespace selector form with hidden attributes.
Definition: SpecialContributions.php:411
Xml\label
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:358
wfGetLB
wfGetLB( $wiki=false)
Get a load balancer object.
Definition: GlobalFunctions.php:3073
Block\TYPE_RANGE
const TYPE_RANGE
Definition: Block.php:85
text
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
Definition: design.txt:12
change
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could change
Definition: distributors.txt:9
UserNamePrefixSearch\search
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
Definition: UserNamePrefixSearch.php:39
$user
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
Definition: hooks.txt:246
Block\newFromTarget
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
Definition: Block.php:1113
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:556
SpecialPage\getSkin
getSkin()
Shortcut to get the skin being used for this instance.
Definition: SpecialPage.php:695
IncludableSpecialPage
Shortcut to construct an includable special page.
Definition: IncludableSpecialPage.php:29
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:705
block
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
Definition: hooks.txt:2122
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Xml\fieldset
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition: Xml.php:577
wfAppendQuery
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Definition: GlobalFunctions.php:500
logs
as see the revision history and logs
Definition: MIT-LICENSE.txt:5
SpecialContributions\execute
execute( $par)
Default execute method Checks user permissions.
Definition: SpecialContributions.php:36
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:785
user
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
Definition: distributors.txt:9
SpecialPage\addFeedLinks
addFeedLinks( $params)
Adds RSS/atom links.
Definition: SpecialPage.php:767
wfScript
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Definition: GlobalFunctions.php:3138
$input
if(is_array( $mode)) switch( $mode) $input
Definition: postprocess-phan.php:141
in
null for the wiki Added in
Definition: hooks.txt:1572
mode
if write to the Free Software Franklin Fifth MA USA Also add information on how to contact you by electronic and paper mail If the program is make it output a short notice like this when it starts in an interactive mode
Definition: COPYING.txt:307
$limit
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup 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 please use GetContentModels hook to make them known to core 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
Definition: hooks.txt:1049
User\isIP
static isIP( $name)
Does the string match an anonymous IP address?
Definition: User.php:819
div
div
Definition: parserTests.txt:6533
form
null means default in associative array form
Definition: hooks.txt:1956
MWTimestamp\getInstance
static getInstance( $ts=false)
Get a timestamp instance in GMT.
Definition: MWTimestamp.php:39
$output
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup 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
Definition: hooks.txt:1049
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:484
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:685
LogEventsList\showLogExtract
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Definition: LogEventsList.php:564
string
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Definition: hooks.txt:177
specified
! hooks source ! endhooks ! test Non existent language !input< source lang="doesnotexist"> foobar</source > ! result< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > foobar</pre ></div > ! end ! test No language specified ! wikitext< source > foo</source > ! html< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > foo</pre ></div > ! end ! test No language specified(no wellformed xml) !! config !! wikitext< source > bar</source > !! html< div class
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:648
captcha-old.action
action
Definition: captcha-old.py:189
or
or
Definition: COPYING.txt:140
ContribsPager
Definition: ContribsPager.php:31
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:538
captcha-old.opts
opts
Definition: captcha-old.py:203
SpecialPage\msg
msg()
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:746
Html\namespaceSelector
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:834
SpecialContributions\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialContributions.php:704
title
title
Definition: parserTests.txt:211
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:665
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1657
SpecialContributions\$opts
$opts
Definition: SpecialContributions.php:30
Html\submitButton
static submitButton( $contents, array $attrs, array $modifiers=[])
Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enab...
Definition: Html.php:185
Block\TYPE_AUTO
const TYPE_AUTO
Definition: Block.php:86
format
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1630
plain
either a plain
Definition: hooks.txt:2007
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:856
page
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 my talk page
Definition: hooks.txt:2536
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:118
Xml\dateMenu
static dateMenu( $year, $month)
Definition: Xml.php:167
Block
Definition: Block.php:27
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
NS_USER
const NS_USER
Definition: Defines.php:64
true
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
Definition: hooks.txt:1956
SpecialContributions\contributionsSub
contributionsSub( $userObj)
Generates the subheading with links.
Definition: SpecialContributions.php:253
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
SpecialContributions\__construct
__construct()
Definition: SpecialContributions.php:32
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:583
SpecialPage\including
including( $x=null)
Whether the special page is being evaluated via transclusion.
Definition: SpecialPage.php:226
MWNamespace\getCanonicalName
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
Definition: MWNamespace.php:228
SpecialContributions
Special:Contributions, show user contributions in a paged list.
Definition: SpecialContributions.php:29
IP\isIPAddress
static isIPAddress( $ip)
Determine if a string is as valid IP address or network (CIDR prefix).
Definition: IP.php:79
Xml\checkLabel
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:419
$out
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
Definition: hooks.txt:783