MediaWiki  1.30.0
ChangesList.php
Go to the documentation of this file.
1 <?php
27 
28 class ChangesList extends ContextSource {
29  const CSS_CLASS_PREFIX = 'mw-changeslist-';
30 
34  public $skin;
35 
36  protected $watchlist = false;
37  protected $lastdate;
38  protected $message;
39  protected $rc_cache;
40  protected $rcCacheIndex;
41  protected $rclistOpen;
42  protected $rcMoveIndex;
43 
46 
48  protected $watchMsgCache;
49 
53  protected $linkRenderer;
54 
58  protected $filterGroups;
59 
66  public function __construct( $obj, array $filterGroups = [] ) {
67  if ( $obj instanceof IContextSource ) {
68  $this->setContext( $obj );
69  $this->skin = $obj->getSkin();
70  } else {
71  $this->setContext( $obj->getContext() );
72  $this->skin = $obj;
73  }
74  $this->preCacheMessages();
75  $this->watchMsgCache = new HashBagOStuff( [ 'maxKeys' => 50 ] );
76  $this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
77  $this->filterGroups = $filterGroups;
78  }
79 
88  public static function newFromContext( IContextSource $context, array $groups = [] ) {
89  $user = $context->getUser();
90  $sk = $context->getSkin();
91  $list = null;
92  if ( Hooks::run( 'FetchChangesList', [ $user, &$sk, &$list ] ) ) {
93  $new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
94 
95  return $new ?
96  new EnhancedChangesList( $context, $groups ) :
97  new OldChangesList( $context, $groups );
98  } else {
99  return $list;
100  }
101  }
102 
114  public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
115  throw new RuntimeException( 'recentChangesLine should be implemented' );
116  }
117 
122  public function setWatchlistDivs( $value = true ) {
123  $this->watchlist = $value;
124  }
125 
130  public function isWatchlist() {
131  return (bool)$this->watchlist;
132  }
133 
138  private function preCacheMessages() {
139  if ( !isset( $this->message ) ) {
140  foreach ( [
141  'cur', 'diff', 'hist', 'enhancedrc-history', 'last', 'blocklink', 'history',
142  'semicolon-separator', 'pipe-separator' ] as $msg
143  ) {
144  $this->message[$msg] = $this->msg( $msg )->escaped();
145  }
146  }
147  }
148 
155  public function recentChangesFlags( $flags, $nothing = '&#160;' ) {
156  $f = '';
157  foreach ( array_keys( $this->getConfig()->get( 'RecentChangesFlags' ) ) as $flag ) {
158  $f .= isset( $flags[$flag] ) && $flags[$flag]
159  ? self::flag( $flag, $this->getContext() )
160  : $nothing;
161  }
162 
163  return $f;
164  }
165 
174  protected function getHTMLClasses( $rc, $watched ) {
175  $classes = [ self::CSS_CLASS_PREFIX . 'line' ];
176  $logType = $rc->mAttribs['rc_log_type'];
177 
178  if ( $logType ) {
179  $classes[] = self::CSS_CLASS_PREFIX . 'log';
180  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'log-' . $logType );
181  } else {
182  $classes[] = self::CSS_CLASS_PREFIX . 'edit';
183  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns' .
184  $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
185  }
186  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' .
187  $rc->mAttribs['rc_namespace'] );
188 
189  // Indicate watched status on the line to allow for more
190  // comprehensive styling.
191  $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched
192  ? self::CSS_CLASS_PREFIX . 'line-watched'
193  : self::CSS_CLASS_PREFIX . 'line-not-watched';
194 
195  $classes = array_merge( $classes, $this->getHTMLClassesForFilters( $rc ) );
196 
197  return $classes;
198  }
199 
206  protected function getHTMLClassesForFilters( $rc ) {
207  $classes = [];
208 
209  if ( $this->filterGroups !== null ) {
210  foreach ( $this->filterGroups as $filterGroup ) {
211  foreach ( $filterGroup->getFilters() as $filter ) {
212  $filter->applyCssClassIfNeeded( $this, $rc, $classes );
213  }
214  }
215  }
216 
217  return $classes;
218  }
219 
228  public static function flag( $flag, IContextSource $context = null ) {
229  static $map = [ 'minoredit' => 'minor', 'botedit' => 'bot' ];
230  static $flagInfos = null;
231 
232  if ( is_null( $flagInfos ) ) {
234  $flagInfos = [];
235  foreach ( $wgRecentChangesFlags as $key => $value ) {
236  $flagInfos[$key]['letter'] = $value['letter'];
237  $flagInfos[$key]['title'] = $value['title'];
238  // Allow customized class name, fall back to flag name
239  $flagInfos[$key]['class'] = isset( $value['class'] ) ? $value['class'] : $key;
240  }
241  }
242 
244 
245  // Inconsistent naming, kepted for b/c
246  if ( isset( $map[$flag] ) ) {
247  $flag = $map[$flag];
248  }
249 
250  $info = $flagInfos[$flag];
251  return Html::element( 'abbr', [
252  'class' => $info['class'],
253  'title' => wfMessage( $info['title'] )->setContext( $context )->text(),
254  ], wfMessage( $info['letter'] )->setContext( $context )->text() );
255  }
256 
261  public function beginRecentChangesList() {
262  $this->rc_cache = [];
263  $this->rcMoveIndex = 0;
264  $this->rcCacheIndex = 0;
265  $this->lastdate = '';
266  $this->rclistOpen = false;
267  $this->getOutput()->addModuleStyles( 'mediawiki.special.changeslist' );
268 
269  return '<div class="mw-changeslist">';
270  }
271 
275  public function initChangesListRows( $rows ) {
276  Hooks::run( 'ChangesListInitRows', [ $this, $rows ] );
277  }
278 
289  public static function showCharacterDifference( $old, $new, IContextSource $context = null ) {
290  if ( !$context ) {
292  }
293 
294  $new = (int)$new;
295  $old = (int)$old;
296  $szdiff = $new - $old;
297 
299  $config = $context->getConfig();
300  $code = $lang->getCode();
301  static $fastCharDiff = [];
302  if ( !isset( $fastCharDiff[$code] ) ) {
303  $fastCharDiff[$code] = $config->get( 'MiserMode' )
304  || $context->msg( 'rc-change-size' )->plain() === '$1';
305  }
306 
307  $formattedSize = $lang->formatNum( $szdiff );
308 
309  if ( !$fastCharDiff[$code] ) {
310  $formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text();
311  }
312 
313  if ( abs( $szdiff ) > abs( $config->get( 'RCChangedSizeThreshold' ) ) ) {
314  $tag = 'strong';
315  } else {
316  $tag = 'span';
317  }
318 
319  if ( $szdiff === 0 ) {
320  $formattedSizeClass = 'mw-plusminus-null';
321  } elseif ( $szdiff > 0 ) {
322  $formattedSize = '+' . $formattedSize;
323  $formattedSizeClass = 'mw-plusminus-pos';
324  } else {
325  $formattedSizeClass = 'mw-plusminus-neg';
326  }
327 
328  $formattedTotalSize = $context->msg( 'rc-change-size-new' )->numParams( $new )->text();
329 
330  return Html::element( $tag,
331  [ 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ],
332  $context->msg( 'parentheses', $formattedSize )->plain() ) . $lang->getDirMark();
333  }
334 
342  public function formatCharacterDifference( RecentChange $old, RecentChange $new = null ) {
343  $oldlen = $old->mAttribs['rc_old_len'];
344 
345  if ( $new ) {
346  $newlen = $new->mAttribs['rc_new_len'];
347  } else {
348  $newlen = $old->mAttribs['rc_new_len'];
349  }
350 
351  if ( $oldlen === null || $newlen === null ) {
352  return '';
353  }
354 
355  return self::showCharacterDifference( $oldlen, $newlen, $this->getContext() );
356  }
357 
362  public function endRecentChangesList() {
363  $out = $this->rclistOpen ? "</ul>\n" : '';
364  $out .= '</div>';
365 
366  return $out;
367  }
368 
373  public function insertDateHeader( &$s, $rc_timestamp ) {
374  # Make date header if necessary
375  $date = $this->getLanguage()->userDate( $rc_timestamp, $this->getUser() );
376  if ( $date != $this->lastdate ) {
377  if ( $this->lastdate != '' ) {
378  $s .= "</ul>\n";
379  }
380  $s .= Xml::element( 'h4', null, $date ) . "\n<ul class=\"special\">";
381  $this->lastdate = $date;
382  $this->rclistOpen = true;
383  }
384  }
385 
391  public function insertLog( &$s, $title, $logtype ) {
392  $page = new LogPage( $logtype );
393  $logname = $page->getName()->setContext( $this->getContext() )->text();
394  $s .= $this->msg( 'parentheses' )->rawParams(
395  $this->linkRenderer->makeKnownLink( $title, $logname )
396  )->escaped();
397  }
398 
404  public function insertDiffHist( &$s, &$rc, $unpatrolled = null ) {
405  # Diff link
406  if (
407  $rc->mAttribs['rc_type'] == RC_NEW ||
408  $rc->mAttribs['rc_type'] == RC_LOG ||
409  $rc->mAttribs['rc_type'] == RC_CATEGORIZE
410  ) {
411  $diffLink = $this->message['diff'];
412  } elseif ( !self::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
413  $diffLink = $this->message['diff'];
414  } else {
415  $query = [
416  'curid' => $rc->mAttribs['rc_cur_id'],
417  'diff' => $rc->mAttribs['rc_this_oldid'],
418  'oldid' => $rc->mAttribs['rc_last_oldid']
419  ];
420 
421  $diffLink = $this->linkRenderer->makeKnownLink(
422  $rc->getTitle(),
423  new HtmlArmor( $this->message['diff'] ),
424  [ 'class' => 'mw-changeslist-diff' ],
425  $query
426  );
427  }
428  if ( $rc->mAttribs['rc_type'] == RC_CATEGORIZE ) {
429  $diffhist = $diffLink . $this->message['pipe-separator'] . $this->message['hist'];
430  } else {
431  $diffhist = $diffLink . $this->message['pipe-separator'];
432  # History link
433  $diffhist .= $this->linkRenderer->makeKnownLink(
434  $rc->getTitle(),
435  new HtmlArmor( $this->message['hist'] ),
436  [ 'class' => 'mw-changeslist-history' ],
437  [
438  'curid' => $rc->mAttribs['rc_cur_id'],
439  'action' => 'history'
440  ]
441  );
442  }
443 
444  // @todo FIXME: Hard coded ". .". Is there a message for this? Should there be?
445  $s .= $this->msg( 'parentheses' )->rawParams( $diffhist )->escaped() .
446  ' <span class="mw-changeslist-separator">. .</span> ';
447  }
448 
456  public function insertArticleLink( &$s, RecentChange $rc, $unpatrolled, $watched ) {
457  $s .= $this->getArticleLink( $rc, $unpatrolled, $watched );
458  }
459 
467  public function getArticleLink( &$rc, $unpatrolled, $watched ) {
468  $params = [];
469  if ( $rc->getTitle()->isRedirect() ) {
470  $params = [ 'redirect' => 'no' ];
471  }
472 
473  $articlelink = $this->linkRenderer->makeLink(
474  $rc->getTitle(),
475  null,
476  [ 'class' => 'mw-changeslist-title' ],
477  $params
478  );
479  if ( $this->isDeleted( $rc, Revision::DELETED_TEXT ) ) {
480  $articlelink = '<span class="history-deleted">' . $articlelink . '</span>';
481  }
482  # To allow for boldening pages watched by this user
483  $articlelink = "<span class=\"mw-title\">{$articlelink}</span>";
484  # RTL/LTR marker
485  $articlelink .= $this->getLanguage()->getDirMark();
486 
487  # TODO: Deprecate the $s argument, it seems happily unused.
488  $s = '';
489  # Avoid PHP 7.1 warning from passing $this by reference
490  $changesList = $this;
491  Hooks::run( 'ChangesListInsertArticleLink',
492  [ &$changesList, &$articlelink, &$s, &$rc, $unpatrolled, $watched ] );
493 
494  return "{$s} {$articlelink}";
495  }
496 
504  public function getTimestamp( $rc ) {
505  // @todo FIXME: Hard coded ". .". Is there a message for this? Should there be?
506  return $this->message['semicolon-separator'] . '<span class="mw-changeslist-date">' .
507  $this->getLanguage()->userTime(
508  $rc->mAttribs['rc_timestamp'],
509  $this->getUser()
510  ) . '</span> <span class="mw-changeslist-separator">. .</span> ';
511  }
512 
519  public function insertTimestamp( &$s, $rc ) {
520  $s .= $this->getTimestamp( $rc );
521  }
522 
529  public function insertUserRelatedLinks( &$s, &$rc ) {
530  if ( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
531  $s .= ' <span class="history-deleted">' .
532  $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
533  } else {
534  $s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'],
535  $rc->mAttribs['rc_user_text'] );
536  $s .= Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
537  }
538  }
539 
546  public function insertLogEntry( $rc ) {
547  $formatter = LogFormatter::newFromRow( $rc->mAttribs );
548  $formatter->setContext( $this->getContext() );
549  $formatter->setShowUserToolLinks( true );
550  $mark = $this->getLanguage()->getDirMark();
551 
552  return $formatter->getActionText() . " $mark" . $formatter->getComment();
553  }
554 
560  public function insertComment( $rc ) {
561  if ( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) {
562  return ' <span class="history-deleted">' .
563  $this->msg( 'rev-deleted-comment' )->escaped() . '</span>';
564  } else {
565  return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
566  }
567  }
568 
574  protected function numberofWatchingusers( $count ) {
575  if ( $count <= 0 ) {
576  return '';
577  }
579  return $cache->getWithSetCallback( $count, $cache::TTL_INDEFINITE,
580  function () use ( $count ) {
581  return $this->msg( 'number_of_watching_users_RCview' )
582  ->numParams( $count )->escaped();
583  }
584  );
585  }
586 
593  public static function isDeleted( $rc, $field ) {
594  return ( $rc->mAttribs['rc_deleted'] & $field ) == $field;
595  }
596 
605  public static function userCan( $rc, $field, User $user = null ) {
606  if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
607  return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
608  } else {
609  return Revision::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
610  }
611  }
612 
618  protected function maybeWatchedLink( $link, $watched = false ) {
619  if ( $watched ) {
620  return '<strong class="mw-watched">' . $link . '</strong>';
621  } else {
622  return '<span class="mw-rc-unwatched">' . $link . '</span>';
623  }
624  }
625 
631  public function insertRollback( &$s, &$rc ) {
632  if ( $rc->mAttribs['rc_type'] == RC_EDIT
633  && $rc->mAttribs['rc_this_oldid']
634  && $rc->mAttribs['rc_cur_id']
635  ) {
636  $page = $rc->getTitle();
639  if ( $this->getUser()->isAllowed( 'rollback' )
640  && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid']
641  ) {
642  $rev = new Revision( [
643  'title' => $page,
644  'id' => $rc->mAttribs['rc_this_oldid'],
645  'user' => $rc->mAttribs['rc_user'],
646  'user_text' => $rc->mAttribs['rc_user_text'],
647  'deleted' => $rc->mAttribs['rc_deleted']
648  ] );
649  $s .= ' ' . Linker::generateRollback( $rev, $this->getContext() );
650  }
651  }
652  }
653 
659  public function getRollback( RecentChange $rc ) {
660  $s = '';
661  $this->insertRollback( $s, $rc );
662  return $s;
663  }
664 
670  public function insertTags( &$s, &$rc, &$classes ) {
671  if ( empty( $rc->mAttribs['ts_tags'] ) ) {
672  return;
673  }
674 
675  list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
676  $rc->mAttribs['ts_tags'],
677  'changeslist',
678  $this->getContext()
679  );
680  $classes = array_merge( $classes, $newClasses );
681  $s .= ' ' . $tagSummary;
682  }
683 
690  public function getTags( RecentChange $rc, array &$classes ) {
691  $s = '';
692  $this->insertTags( $s, $rc, $classes );
693  return $s;
694  }
695 
696  public function insertExtra( &$s, &$rc, &$classes ) {
697  // Empty, used for subclasses to add anything special.
698  }
699 
700  protected function showAsUnpatrolled( RecentChange $rc ) {
701  return self::isUnpatrolled( $rc, $this->getUser() );
702  }
703 
709  public static function isUnpatrolled( $rc, User $user ) {
710  if ( $rc instanceof RecentChange ) {
711  $isPatrolled = $rc->mAttribs['rc_patrolled'];
712  $rcType = $rc->mAttribs['rc_type'];
713  $rcLogType = $rc->mAttribs['rc_log_type'];
714  } else {
715  $isPatrolled = $rc->rc_patrolled;
716  $rcType = $rc->rc_type;
717  $rcLogType = $rc->rc_log_type;
718  }
719 
720  if ( !$isPatrolled ) {
721  if ( $user->useRCPatrol() ) {
722  return true;
723  }
724  if ( $user->useNPPatrol() && $rcType == RC_NEW ) {
725  return true;
726  }
727  if ( $user->useFilePatrol() && $rcLogType == 'upload' ) {
728  return true;
729  }
730  }
731 
732  return false;
733  }
734 
744  protected function isCategorizationWithoutRevision( $rcObj ) {
745  return intval( $rcObj->getAttribute( 'rc_type' ) ) === RC_CATEGORIZE
746  && intval( $rcObj->getAttribute( 'rc_this_oldid' ) ) === 0;
747  }
748 
754  protected function getDataAttributes( RecentChange $rc ) {
755  $attrs = [];
756 
757  $type = $rc->getAttribute( 'rc_source' );
758  switch ( $type ) {
761  $attrs['data-mw-revid'] = $rc->mAttribs['rc_this_oldid'];
762  break;
764  $attrs['data-mw-logid'] = $rc->mAttribs['rc_logid'];
765  $attrs['data-mw-logaction'] =
766  $rc->mAttribs['rc_log_type'] . '/' . $rc->mAttribs['rc_log_action'];
767  break;
768  }
769 
770  $attrs[ 'data-mw-ts' ] = $rc->getAttribute( 'rc_timestamp' );
771 
772  return $attrs;
773  }
774 
782  public function setChangeLinePrefixer( callable $prefixer ) {
783  $this->changeLinePrefixer = $prefixer;
784  }
785 }
Revision\DELETED_USER
const DELETED_USER
Definition: Revision.php:92
ChangesList\endRecentChangesList
endRecentChangesList()
Returns text for the end of RC.
Definition: ChangesList.php:362
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:34
ContextSource\getConfig
getConfig()
Get the Config object.
Definition: ContextSource.php:68
$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:244
ContextSource\getContext
getContext()
Get the base IContextSource object.
Definition: ContextSource.php:41
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:28
ChangesList\insertComment
insertComment( $rc)
Insert a formatted comment.
Definition: ChangesList.php:560
ChangesList\setWatchlistDivs
setWatchlistDivs( $value=true)
Sets the list to use a "<li class='watchlist-(namespace)-(page)'>" tag.
Definition: ChangesList.php:122
Revision\DELETED_COMMENT
const DELETED_COMMENT
Definition: Revision.php:91
ChangesList\setChangeLinePrefixer
setChangeLinePrefixer(callable $prefixer)
Sets the callable that generates a change line prefix added to the beginning of each line.
Definition: ChangesList.php:782
HashBagOStuff
Simple store for keeping values in an associative array for the current process.
Definition: HashBagOStuff.php:31
Revision\userCanBitfield
static userCanBitfield( $bitfield, $field, User $user=null, Title $title=null)
Determine if the current user is allowed to view a particular field of this revision,...
Definition: Revision.php:1798
IContextSource\getSkin
getSkin()
Get the Skin object.
Linker\userLink
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition: Linker.php:893
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
ChangesList\$watchMsgCache
BagOStuff $watchMsgCache
Definition: ChangesList.php:48
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
ContextSource\msg
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:189
RecentChange
Utility class for creating new RC entries.
Definition: RecentChange.php:67
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:42
ChangesList\maybeWatchedLink
maybeWatchedLink( $link, $watched=false)
Definition: ChangesList.php:618
RC_LOG
const RC_LOG
Definition: Defines.php:145
$changesList
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges $changesList
Definition: hooks.txt:1472
use
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
Definition: MIT-LICENSE.txt:10
ChangesList\insertLog
insertLog(&$s, $title, $logtype)
Definition: ChangesList.php:391
ChangesList\getTags
getTags(RecentChange $rc, array &$classes)
Definition: ChangesList.php:690
$params
$params
Definition: styleTest.css.php:40
RC_EDIT
const RC_EDIT
Definition: Defines.php:143
BagOStuff
interface is intended to be more or less compatible with the PHP memcached client.
Definition: BagOStuff.php:47
$s
$s
Definition: mergeMessageFileList.php:188
ChangesList\$rcCacheIndex
$rcCacheIndex
Definition: ChangesList.php:40
Wikimedia\Rdbms\ResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: ResultWrapper.php:24
ChangesList\formatCharacterDifference
formatCharacterDifference(RecentChange $old, RecentChange $new=null)
Format the character difference of one or several changes.
Definition: ChangesList.php:342
ContextSource\getUser
getUser()
Get the User object.
Definition: ContextSource.php:133
ChangesList\$lastdate
$lastdate
Definition: ChangesList.php:37
RecentChange\SRC_LOG
const SRC_LOG
Definition: RecentChange.php:72
ChangesList\isDeleted
static isDeleted( $rc, $field)
Determine if said field of a revision is hidden.
Definition: ChangesList.php:593
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
ContextSource\getLanguage
getLanguage()
Get the Language object.
Definition: ContextSource.php:143
Revision
Definition: Revision.php:33
ChangesList\insertDateHeader
insertDateHeader(&$s, $rc_timestamp)
Definition: ChangesList.php:373
ChangesList\$filterGroups
array $filterGroups
Definition: ChangesList.php:58
$query
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1581
$wgRecentChangesFlags
$wgRecentChangesFlags
Flags (letter symbols) shown in recent changes and watchlist to indicate certain types of edits.
Definition: DefaultSettings.php:6977
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:932
Linker\generateRollback
static generateRollback( $rev, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
Definition: Linker.php:1691
LogFormatter\newFromRow
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
Definition: LogFormatter.php:76
ChangesList\insertLogEntry
insertLogEntry( $rc)
Insert a formatted action.
Definition: ChangesList.php:546
ContextSource\getOutput
getOutput()
Get the OutputPage object.
Definition: ContextSource.php:123
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition: ContextSource.php:30
ChangesList\isWatchlist
isWatchlist()
Definition: ChangesList.php:130
ChangesList\insertTags
insertTags(&$s, &$rc, &$classes)
Definition: ChangesList.php:670
LogPage
Class to simplify the use of log pages.
Definition: LogPage.php:31
ContextSource\getSkin
getSkin()
Get the Skin object.
Definition: ContextSource.php:153
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
ChangesList\flag
static flag( $flag, IContextSource $context=null)
Make an "<abbr>" element for a given change flag.
Definition: ChangesList.php:228
ChangesList\CSS_CLASS_PREFIX
const CSS_CLASS_PREFIX
Definition: ChangesList.php:29
message
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 message
Definition: hooks.txt:2133
MessageLocalizer\msg
msg( $key)
This is the method for getting translated interface messages.
RecentChange\SRC_EDIT
const SRC_EDIT
Definition: RecentChange.php:70
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
RecentChange\SRC_NEW
const SRC_NEW
Definition: RecentChange.php:71
ChangesList\insertUserRelatedLinks
insertUserRelatedLinks(&$s, &$rc)
Insert links to user page, user talk page and eventually a blocking link.
Definition: ChangesList.php:529
ContextSource\setContext
setContext(IContextSource $context)
Set the IContextSource object.
Definition: ContextSource.php:58
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
ChangesList\getRollback
getRollback(RecentChange $rc)
Definition: ChangesList.php:659
ChangesList\getArticleLink
getArticleLink(&$rc, $unpatrolled, $watched)
Definition: ChangesList.php:467
ChangesList\newFromContext
static newFromContext(IContextSource $context, array $groups=[])
Fetch an appropriate changes list class for the specified context Some users might want to use an enh...
Definition: ChangesList.php:88
ChangesList\$rclistOpen
$rclistOpen
Definition: ChangesList.php:41
ChangesList\$changeLinePrefixer
callable $changeLinePrefixer
Definition: ChangesList.php:45
ChangesList\getDataAttributes
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
Definition: ChangesList.php:754
EnhancedChangesList
Definition: EnhancedChangesList.php:23
OldChangesList
Definition: OldChangesList.php:23
skin
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a skin(according to that user 's preference)
$value
$value
Definition: styleTest.css.php:45
Linker\userToolLinks
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null)
Generate standard user tool links (talk, contributions, block link, etc.)
Definition: Linker.php:926
ChangesList\insertTimestamp
insertTimestamp(&$s, $rc)
Insert time timestamp string from $rc into $s.
Definition: ChangesList.php:519
ChangesList\numberofWatchingusers
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
Definition: ChangesList.php:574
ChangesList\showAsUnpatrolled
showAsUnpatrolled(RecentChange $rc)
Definition: ChangesList.php:700
ChangesList\showCharacterDifference
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
Definition: ChangesList.php:289
IContextSource\getUser
getUser()
Get the User object.
RC_NEW
const RC_NEW
Definition: Defines.php:144
ChangesList\preCacheMessages
preCacheMessages()
As we use the same small set of messages in various methods and that they are called often,...
Definition: ChangesList.php:138
RequestContext\getMain
static getMain()
Static methods.
Definition: RequestContext.php:470
ChangesList\insertArticleLink
insertArticleLink(&$s, RecentChange $rc, $unpatrolled, $watched)
Definition: ChangesList.php:456
ChangesList\$watchlist
$watchlist
Definition: ChangesList.php:36
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:55
ChangesList\getHTMLClasses
getHTMLClasses( $rc, $watched)
Get an array of default HTML class attributes for the change.
Definition: ChangesList.php:174
ChangesList\__construct
__construct( $obj, array $filterGroups=[])
Changeslist constructor.
Definition: ChangesList.php:66
RecentChange\getAttribute
getAttribute( $name)
Get an attribute value.
Definition: RecentChange.php:967
ChangesList\beginRecentChangesList
beginRecentChangesList()
Returns text for the start of the tabular part of RC.
Definition: ChangesList.php:261
$cache
$cache
Definition: mcc.php:33
ChangesList\insertDiffHist
insertDiffHist(&$s, &$rc, $unpatrolled=null)
Definition: ChangesList.php:404
$rows
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 $rows
Definition: hooks.txt:2581
LogEventsList\userCanBitfield
static userCanBitfield( $bitfield, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
Definition: LogEventsList.php:542
ChangesList\initChangesListRows
initChangesListRows( $rows)
Definition: ChangesList.php:275
$code
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 modifiable & $code
Definition: hooks.txt:781
IContextSource\getConfig
getConfig()
Get the site configuration.
ChangesList\isCategorizationWithoutRevision
isCategorizationWithoutRevision( $rcObj)
Determines whether a revision is linked to this change; this may not be the case when the categorizat...
Definition: ChangesList.php:744
$rev
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1750
as
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
Definition: distributors.txt:9
ChangesList\recentChangesFlags
recentChangesFlags( $flags, $nothing='&#160;')
Returns the appropriate flags for new page, minor change and patrolling.
Definition: ChangesList.php:155
Linker\commentBlock
static commentBlock( $comment, $title=null, $local=false, $wikiId=null)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
Definition: Linker.php:1445
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2981
ChangesList\getTimestamp
getTimestamp( $rc)
Get the timestamp from $rc formatted with current user's settings and a separator.
Definition: ChangesList.php:504
IContextSource\getRequest
getRequest()
Get the WebRequest object.
ChangesList
Definition: ChangesList.php:28
wfMessage
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 "&lt
ChangesList\$skin
Skin $skin
Definition: ChangesList.php:34
RC_CATEGORIZE
const RC_CATEGORIZE
Definition: Defines.php:147
ChangesList\isUnpatrolled
static isUnpatrolled( $rc, User $user)
Definition: ChangesList.php:709
ChangesList\$rc_cache
$rc_cache
Definition: ChangesList.php:39
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
MediaWikiServices
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 MediaWikiServices
Definition: injection.txt:23
ChangesList\$rcMoveIndex
$rcMoveIndex
Definition: ChangesList.php:42
Skin
The main skin class which provides methods and properties for all other skins.
Definition: Skin.php:36
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:51
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203
ChangesList\$message
$message
Definition: ChangesList.php:38
ChangeTags\formatSummaryRow
static formatSummaryRow( $tags, $page, IContextSource $context=null)
Creates HTML for the given tags.
Definition: ChangeTags.php:53
Revision\DELETED_TEXT
const DELETED_TEXT
Definition: Revision.php:90
ChangesList\getHTMLClassesForFilters
getHTMLClassesForFilters( $rc)
Get an array of CSS classes attributed to filters for this row.
Definition: ChangesList.php:206
ChangesList\recentChangesLine
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line.
Definition: ChangesList.php:114
ChangesList\userCan
static userCan( $rc, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision,...
Definition: ChangesList.php:605
ChangesList\insertExtra
insertExtra(&$s, &$rc, &$classes)
Definition: ChangesList.php:696
ChangesList\insertRollback
insertRollback(&$s, &$rc)
Inserts a rollback link.
Definition: ChangesList.php:631
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2801
IContextSource\getLanguage
getLanguage()
Get the Language object.
array
the array() calling protocol came about after MediaWiki 1.4rc1.
ChangesList\$linkRenderer
LinkRenderer $linkRenderer
Definition: ChangesList.php:53
$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:781
$type
$type
Definition: testCompression.php:48