MediaWiki  1.32.5
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 MapCacheLRU( 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 
124  protected function getHighlightsContainerDiv() {
125  $highlightColorDivs = '';
126  foreach ( [ 'none', 'c1', 'c2', 'c3', 'c4', 'c5' ] as $color ) {
127  $highlightColorDivs .= Html::rawElement(
128  'div',
129  [
130  'class' => 'mw-rcfilters-ui-highlights-color-' . $color,
131  'data-color' => $color
132  ]
133  );
134  }
135 
136  return Html::rawElement(
137  'div',
138  [ 'class' => 'mw-rcfilters-ui-highlights' ],
139  $highlightColorDivs
140  );
141  }
142 
147  public function setWatchlistDivs( $value = true ) {
148  $this->watchlist = $value;
149  }
150 
155  public function isWatchlist() {
156  return (bool)$this->watchlist;
157  }
158 
163  private function preCacheMessages() {
164  if ( !isset( $this->message ) ) {
165  foreach ( [
166  'cur', 'diff', 'hist', 'enhancedrc-history', 'last', 'blocklink', 'history',
167  'semicolon-separator', 'pipe-separator' ] as $msg
168  ) {
169  $this->message[$msg] = $this->msg( $msg )->escaped();
170  }
171  }
172  }
173 
180  public function recentChangesFlags( $flags, $nothing = "\u{00A0}" ) {
181  $f = '';
182  foreach ( array_keys( $this->getConfig()->get( 'RecentChangesFlags' ) ) as $flag ) {
183  $f .= isset( $flags[$flag] ) && $flags[$flag]
184  ? self::flag( $flag, $this->getContext() )
185  : $nothing;
186  }
187 
188  return $f;
189  }
190 
199  protected function getHTMLClasses( $rc, $watched ) {
200  $classes = [ self::CSS_CLASS_PREFIX . 'line' ];
201  $logType = $rc->mAttribs['rc_log_type'];
202 
203  if ( $logType ) {
204  $classes[] = self::CSS_CLASS_PREFIX . 'log';
205  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'log-' . $logType );
206  } else {
207  $classes[] = self::CSS_CLASS_PREFIX . 'edit';
208  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns' .
209  $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
210  }
211 
212  // Indicate watched status on the line to allow for more
213  // comprehensive styling.
214  $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched
215  ? self::CSS_CLASS_PREFIX . 'line-watched'
216  : self::CSS_CLASS_PREFIX . 'line-not-watched';
217 
218  $classes = array_merge( $classes, $this->getHTMLClassesForFilters( $rc ) );
219 
220  return $classes;
221  }
222 
230  protected function getHTMLClassesForFilters( $rc ) {
231  $classes = [];
232 
233  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' .
234  $rc->mAttribs['rc_namespace'] );
235 
236  if ( $this->filterGroups !== null ) {
237  foreach ( $this->filterGroups as $filterGroup ) {
238  foreach ( $filterGroup->getFilters() as $filter ) {
239  $filter->applyCssClassIfNeeded( $this, $rc, $classes );
240  }
241  }
242  }
243 
244  return $classes;
245  }
246 
255  public static function flag( $flag, IContextSource $context = null ) {
256  static $map = [ 'minoredit' => 'minor', 'botedit' => 'bot' ];
257  static $flagInfos = null;
258 
259  if ( is_null( $flagInfos ) ) {
260  global $wgRecentChangesFlags;
261  $flagInfos = [];
262  foreach ( $wgRecentChangesFlags as $key => $value ) {
263  $flagInfos[$key]['letter'] = $value['letter'];
264  $flagInfos[$key]['title'] = $value['title'];
265  // Allow customized class name, fall back to flag name
266  $flagInfos[$key]['class'] = $value['class'] ?? $key;
267  }
268  }
269 
271 
272  // Inconsistent naming, kepted for b/c
273  if ( isset( $map[$flag] ) ) {
274  $flag = $map[$flag];
275  }
276 
277  $info = $flagInfos[$flag];
278  return Html::element( 'abbr', [
279  'class' => $info['class'],
280  'title' => wfMessage( $info['title'] )->setContext( $context )->text(),
281  ], wfMessage( $info['letter'] )->setContext( $context )->text() );
282  }
283 
288  public function beginRecentChangesList() {
289  $this->rc_cache = [];
290  $this->rcMoveIndex = 0;
291  $this->rcCacheIndex = 0;
292  $this->lastdate = '';
293  $this->rclistOpen = false;
294  $this->getOutput()->addModuleStyles( 'mediawiki.special.changeslist' );
295 
296  return '<div class="mw-changeslist">';
297  }
298 
302  public function initChangesListRows( $rows ) {
303  Hooks::run( 'ChangesListInitRows', [ $this, $rows ] );
304  }
305 
316  public static function showCharacterDifference( $old, $new, IContextSource $context = null ) {
317  if ( !$context ) {
319  }
320 
321  $new = (int)$new;
322  $old = (int)$old;
323  $szdiff = $new - $old;
324 
326  $config = $context->getConfig();
327  $code = $lang->getCode();
328  static $fastCharDiff = [];
329  if ( !isset( $fastCharDiff[$code] ) ) {
330  $fastCharDiff[$code] = $config->get( 'MiserMode' )
331  || $context->msg( 'rc-change-size' )->plain() === '$1';
332  }
333 
334  $formattedSize = $lang->formatNum( $szdiff );
335 
336  if ( !$fastCharDiff[$code] ) {
337  $formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text();
338  }
339 
340  if ( abs( $szdiff ) > abs( $config->get( 'RCChangedSizeThreshold' ) ) ) {
341  $tag = 'strong';
342  } else {
343  $tag = 'span';
344  }
345 
346  if ( $szdiff === 0 ) {
347  $formattedSizeClass = 'mw-plusminus-null';
348  } elseif ( $szdiff > 0 ) {
349  $formattedSize = '+' . $formattedSize;
350  $formattedSizeClass = 'mw-plusminus-pos';
351  } else {
352  $formattedSizeClass = 'mw-plusminus-neg';
353  }
354 
355  $formattedTotalSize = $context->msg( 'rc-change-size-new' )->numParams( $new )->text();
356 
357  return Html::element( $tag,
358  [ 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ],
359  $context->msg( 'parentheses', $formattedSize )->plain() ) . $lang->getDirMark();
360  }
361 
369  public function formatCharacterDifference( RecentChange $old, RecentChange $new = null ) {
370  $oldlen = $old->mAttribs['rc_old_len'];
371 
372  if ( $new ) {
373  $newlen = $new->mAttribs['rc_new_len'];
374  } else {
375  $newlen = $old->mAttribs['rc_new_len'];
376  }
377 
378  if ( $oldlen === null || $newlen === null ) {
379  return '';
380  }
381 
382  return self::showCharacterDifference( $oldlen, $newlen, $this->getContext() );
383  }
384 
389  public function endRecentChangesList() {
390  $out = $this->rclistOpen ? "</ul>\n" : '';
391  $out .= '</div>';
392 
393  return $out;
394  }
395 
400  public function insertDateHeader( &$s, $rc_timestamp ) {
401  # Make date header if necessary
402  $date = $this->getLanguage()->userDate( $rc_timestamp, $this->getUser() );
403  if ( $date != $this->lastdate ) {
404  if ( $this->lastdate != '' ) {
405  $s .= "</ul>\n";
406  }
407  $s .= Xml::element( 'h4', null, $date ) . "\n<ul class=\"special\">";
408  $this->lastdate = $date;
409  $this->rclistOpen = true;
410  }
411  }
412 
418  public function insertLog( &$s, $title, $logtype ) {
419  $page = new LogPage( $logtype );
420  $logname = $page->getName()->setContext( $this->getContext() )->text();
421  $s .= $this->msg( 'parentheses' )->rawParams(
422  $this->linkRenderer->makeKnownLink( $title, $logname )
423  )->escaped();
424  }
425 
431  public function insertDiffHist( &$s, &$rc, $unpatrolled = null ) {
432  # Diff link
433  if (
434  $rc->mAttribs['rc_type'] == RC_NEW ||
435  $rc->mAttribs['rc_type'] == RC_LOG ||
436  $rc->mAttribs['rc_type'] == RC_CATEGORIZE
437  ) {
438  $diffLink = $this->message['diff'];
439  } elseif ( !self::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
440  $diffLink = $this->message['diff'];
441  } else {
442  $query = [
443  'curid' => $rc->mAttribs['rc_cur_id'],
444  'diff' => $rc->mAttribs['rc_this_oldid'],
445  'oldid' => $rc->mAttribs['rc_last_oldid']
446  ];
447 
448  $diffLink = $this->linkRenderer->makeKnownLink(
449  $rc->getTitle(),
450  new HtmlArmor( $this->message['diff'] ),
451  [ 'class' => 'mw-changeslist-diff' ],
452  $query
453  );
454  }
455  if ( $rc->mAttribs['rc_type'] == RC_CATEGORIZE ) {
456  $diffhist = $diffLink . $this->message['pipe-separator'] . $this->message['hist'];
457  } else {
458  $diffhist = $diffLink . $this->message['pipe-separator'];
459  # History link
460  $diffhist .= $this->linkRenderer->makeKnownLink(
461  $rc->getTitle(),
462  new HtmlArmor( $this->message['hist'] ),
463  [ 'class' => 'mw-changeslist-history' ],
464  [
465  'curid' => $rc->mAttribs['rc_cur_id'],
466  'action' => 'history'
467  ]
468  );
469  }
470 
471  // @todo FIXME: Hard coded ". .". Is there a message for this? Should there be?
472  $s .= $this->msg( 'parentheses' )->rawParams( $diffhist )->escaped() .
473  ' <span class="mw-changeslist-separator">. .</span> ';
474  }
475 
483  public function insertArticleLink( &$s, RecentChange $rc, $unpatrolled, $watched ) {
484  $s .= $this->getArticleLink( $rc, $unpatrolled, $watched );
485  }
486 
494  public function getArticleLink( &$rc, $unpatrolled, $watched ) {
495  $params = [];
496  if ( $rc->getTitle()->isRedirect() ) {
497  $params = [ 'redirect' => 'no' ];
498  }
499 
500  $articlelink = $this->linkRenderer->makeLink(
501  $rc->getTitle(),
502  null,
503  [ 'class' => 'mw-changeslist-title' ],
504  $params
505  );
506  if ( $this->isDeleted( $rc, Revision::DELETED_TEXT ) ) {
507  $articlelink = '<span class="history-deleted">' . $articlelink . '</span>';
508  }
509  # To allow for boldening pages watched by this user
510  $articlelink = "<span class=\"mw-title\">{$articlelink}</span>";
511  # RTL/LTR marker
512  $articlelink .= $this->getLanguage()->getDirMark();
513 
514  # TODO: Deprecate the $s argument, it seems happily unused.
515  $s = '';
516  # Avoid PHP 7.1 warning from passing $this by reference
517  $changesList = $this;
518  Hooks::run( 'ChangesListInsertArticleLink',
519  [ &$changesList, &$articlelink, &$s, &$rc, $unpatrolled, $watched ] );
520 
521  return "{$s} {$articlelink}";
522  }
523 
531  public function getTimestamp( $rc ) {
532  // @todo FIXME: Hard coded ". .". Is there a message for this? Should there be?
533  return $this->message['semicolon-separator'] . '<span class="mw-changeslist-date">' .
534  htmlspecialchars( $this->getLanguage()->userTime(
535  $rc->mAttribs['rc_timestamp'],
536  $this->getUser()
537  ) ) . '</span> <span class="mw-changeslist-separator">. .</span> ';
538  }
539 
546  public function insertTimestamp( &$s, $rc ) {
547  $s .= $this->getTimestamp( $rc );
548  }
549 
556  public function insertUserRelatedLinks( &$s, &$rc ) {
557  if ( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
558  $s .= ' <span class="history-deleted">' .
559  $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
560  } else {
561  $s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'],
562  $rc->mAttribs['rc_user_text'] );
563  $s .= Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
564  }
565  }
566 
573  public function insertLogEntry( $rc ) {
574  $formatter = LogFormatter::newFromRow( $rc->mAttribs );
575  $formatter->setContext( $this->getContext() );
576  $formatter->setShowUserToolLinks( true );
577  $mark = $this->getLanguage()->getDirMark();
578 
579  return $formatter->getActionText() . " $mark" . $formatter->getComment();
580  }
581 
587  public function insertComment( $rc ) {
588  if ( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) {
589  return ' <span class="history-deleted">' .
590  $this->msg( 'rev-deleted-comment' )->escaped() . '</span>';
591  } else {
592  return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
593  }
594  }
595 
601  protected function numberofWatchingusers( $count ) {
602  if ( $count <= 0 ) {
603  return '';
604  }
605 
606  return $this->watchMsgCache->getWithSetCallback(
607  "watching-users-msg:$count",
608  function () use ( $count ) {
609  return $this->msg( 'number_of_watching_users_RCview' )
610  ->numParams( $count )->escaped();
611  }
612  );
613  }
614 
621  public static function isDeleted( $rc, $field ) {
622  return ( $rc->mAttribs['rc_deleted'] & $field ) == $field;
623  }
624 
633  public static function userCan( $rc, $field, User $user = null ) {
634  if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
635  return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
636  } else {
637  return Revision::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
638  }
639  }
640 
646  protected function maybeWatchedLink( $link, $watched = false ) {
647  if ( $watched ) {
648  return '<strong class="mw-watched">' . $link . '</strong>';
649  } else {
650  return '<span class="mw-rc-unwatched">' . $link . '</span>';
651  }
652  }
653 
660  public function insertRollback( &$s, &$rc ) {
661  if ( $rc->mAttribs['rc_type'] == RC_EDIT
662  && $rc->mAttribs['rc_this_oldid']
663  && $rc->mAttribs['rc_cur_id']
664  && $rc->getAttribute( 'page_latest' ) == $rc->mAttribs['rc_this_oldid']
665  ) {
666  $title = $rc->getTitle();
669  if ( $title->quickUserCan( 'rollback', $this->getUser() ) ) {
670  $rev = new Revision( [
671  'title' => $title,
672  'id' => $rc->mAttribs['rc_this_oldid'],
673  'user' => $rc->mAttribs['rc_user'],
674  'user_text' => $rc->mAttribs['rc_user_text'],
675  'actor' => $rc->mAttribs['rc_actor'] ?? null,
676  'deleted' => $rc->mAttribs['rc_deleted']
677  ] );
678  $s .= ' ' . Linker::generateRollback( $rev, $this->getContext() );
679  }
680  }
681  }
682 
688  public function getRollback( RecentChange $rc ) {
689  $s = '';
690  $this->insertRollback( $s, $rc );
691  return $s;
692  }
693 
699  public function insertTags( &$s, &$rc, &$classes ) {
700  if ( empty( $rc->mAttribs['ts_tags'] ) ) {
701  return;
702  }
703 
704  list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
705  $rc->mAttribs['ts_tags'],
706  'changeslist',
707  $this->getContext()
708  );
709  $classes = array_merge( $classes, $newClasses );
710  $s .= ' ' . $tagSummary;
711  }
712 
719  public function getTags( RecentChange $rc, array &$classes ) {
720  $s = '';
721  $this->insertTags( $s, $rc, $classes );
722  return $s;
723  }
724 
725  public function insertExtra( &$s, &$rc, &$classes ) {
726  // Empty, used for subclasses to add anything special.
727  }
728 
729  protected function showAsUnpatrolled( RecentChange $rc ) {
730  return self::isUnpatrolled( $rc, $this->getUser() );
731  }
732 
738  public static function isUnpatrolled( $rc, User $user ) {
739  if ( $rc instanceof RecentChange ) {
740  $isPatrolled = $rc->mAttribs['rc_patrolled'];
741  $rcType = $rc->mAttribs['rc_type'];
742  $rcLogType = $rc->mAttribs['rc_log_type'];
743  } else {
744  $isPatrolled = $rc->rc_patrolled;
745  $rcType = $rc->rc_type;
746  $rcLogType = $rc->rc_log_type;
747  }
748 
749  if ( !$isPatrolled ) {
750  if ( $user->useRCPatrol() ) {
751  return true;
752  }
753  if ( $user->useNPPatrol() && $rcType == RC_NEW ) {
754  return true;
755  }
756  if ( $user->useFilePatrol() && $rcLogType == 'upload' ) {
757  return true;
758  }
759  }
760 
761  return false;
762  }
763 
773  protected function isCategorizationWithoutRevision( $rcObj ) {
774  return intval( $rcObj->getAttribute( 'rc_type' ) ) === RC_CATEGORIZE
775  && intval( $rcObj->getAttribute( 'rc_this_oldid' ) ) === 0;
776  }
777 
783  protected function getDataAttributes( RecentChange $rc ) {
784  $attrs = [];
785 
786  $type = $rc->getAttribute( 'rc_source' );
787  switch ( $type ) {
790  $attrs['data-mw-revid'] = $rc->mAttribs['rc_this_oldid'];
791  break;
793  $attrs['data-mw-logid'] = $rc->mAttribs['rc_logid'];
794  $attrs['data-mw-logaction'] =
795  $rc->mAttribs['rc_log_type'] . '/' . $rc->mAttribs['rc_log_action'];
796  break;
797  }
798 
799  $attrs[ 'data-mw-ts' ] = $rc->getAttribute( 'rc_timestamp' );
800 
801  return $attrs;
802  }
803 
811  public function setChangeLinePrefixer( callable $prefixer ) {
812  $this->changeLinePrefixer = $prefixer;
813  }
814 }
Revision\DELETED_USER
const DELETED_USER
Definition: Revision.php:49
ChangesList\endRecentChangesList
endRecentChangesList()
Returns text for the end of RC.
Definition: ChangesList.php:389
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:33
ContextSource\getConfig
getConfig()
Definition: ContextSource.php:63
$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:40
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:28
ChangesList\insertComment
insertComment( $rc)
Insert a formatted comment.
Definition: ChangesList.php:587
ChangesList\setWatchlistDivs
setWatchlistDivs( $value=true)
Sets the list to use a "<li class='watchlist-(namespace)-(page)'>" tag.
Definition: ChangesList.php:147
Revision\DELETED_COMMENT
const DELETED_COMMENT
Definition: Revision.php:48
ChangesList\setChangeLinePrefixer
setChangeLinePrefixer(callable $prefixer)
Sets the callable that generates a change line prefix added to the beginning of each line.
Definition: ChangesList.php:811
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:1216
IContextSource\getSkin
getSkin()
Linker\userLink
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition: Linker.php:876
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
ContextSource\msg
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:168
RecentChange
Utility class for creating new RC entries.
Definition: RecentChange.php:68
ChangesList\$watchMsgCache
MapCacheLRU $watchMsgCache
Definition: ChangesList.php:48
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:41
ChangesList\maybeWatchedLink
maybeWatchedLink( $link, $watched=false)
Definition: ChangesList.php:646
RC_LOG
const RC_LOG
Definition: Defines.php:144
$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:1515
ChangesList\insertLog
insertLog(&$s, $title, $logtype)
Definition: ChangesList.php:418
ChangesList\getTags
getTags(RecentChange $rc, array &$classes)
Definition: ChangesList.php:719
$params
$params
Definition: styleTest.css.php:44
RC_EDIT
const RC_EDIT
Definition: Defines.php:142
ChangesList\getHighlightsContainerDiv
getHighlightsContainerDiv()
Get the container for highlights that are used in the new StructuredFilters system.
Definition: ChangesList.php:124
$s
$s
Definition: mergeMessageFileList.php:187
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:369
ContextSource\getUser
getUser()
Definition: ContextSource.php:120
ChangesList\$lastdate
$lastdate
Definition: ChangesList.php:37
RecentChange\SRC_LOG
const SRC_LOG
Definition: RecentChange.php:73
ChangesList\isDeleted
static isDeleted( $rc, $field)
Determine if said field of a revision is hidden.
Definition: ChangesList.php:621
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()
Definition: ContextSource.php:128
Revision
Definition: Revision.php:41
ChangesList\insertDateHeader
insertDateHeader(&$s, $rc_timestamp)
Definition: ChangesList.php:400
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:1627
$wgRecentChangesFlags
$wgRecentChangesFlags
Flags (letter symbols) shown in recent changes and watchlist to indicate certain types of edits.
Definition: DefaultSettings.php:7117
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:964
Linker\generateRollback
static generateRollback( $rev, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
Definition: Linker.php:1704
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:573
ContextSource\getOutput
getOutput()
Definition: ContextSource.php:112
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition: ContextSource.php:29
ChangesList\isWatchlist
isWatchlist()
Definition: ChangesList.php:155
ChangesList\insertTags
insertTags(&$s, &$rc, &$classes)
Definition: ChangesList.php:699
LogPage
Class to simplify the use of log pages.
Definition: LogPage.php:33
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:41
MapCacheLRU
Handles a simple LRU key/value map with a maximum number of entries.
Definition: MapCacheLRU.php:37
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
$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:813
ChangesList\flag
static flag( $flag, IContextSource $context=null)
Make an "<abbr>" element for a given change flag.
Definition: ChangesList.php:255
ChangesList\CSS_CLASS_PREFIX
const CSS_CLASS_PREFIX
Definition: ChangesList.php:29
MessageLocalizer\msg
msg( $key)
This is the method for getting translated interface messages.
RecentChange\SRC_EDIT
const SRC_EDIT
Definition: RecentChange.php:71
RecentChange\SRC_NEW
const SRC_NEW
Definition: RecentChange.php:72
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
ChangesList\insertUserRelatedLinks
insertUserRelatedLinks(&$s, &$rc)
Insert links to user page, user talk page and eventually a blocking link.
Definition: ChangesList.php:556
ContextSource\setContext
setContext(IContextSource $context)
Definition: ContextSource.php:55
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:688
ChangesList\getArticleLink
getArticleLink(&$rc, $unpatrolled, $watched)
Definition: ChangesList.php:494
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:783
EnhancedChangesList
Definition: EnhancedChangesList.php:23
OldChangesList
Definition: OldChangesList.php:25
$value
$value
Definition: styleTest.css.php:49
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:914
ChangesList\insertTimestamp
insertTimestamp(&$s, $rc)
Insert time timestamp string from $rc into $s.
Definition: ChangesList.php:546
ChangesList\numberofWatchingusers
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
Definition: ChangesList.php:601
ChangesList\showAsUnpatrolled
showAsUnpatrolled(RecentChange $rc)
Definition: ChangesList.php:729
ChangesList\showCharacterDifference
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
Definition: ChangesList.php:316
IContextSource\getUser
getUser()
RC_NEW
const RC_NEW
Definition: Defines.php:143
ChangesList\preCacheMessages
preCacheMessages()
As we use the same small set of messages in various methods and that they are called often,...
Definition: ChangesList.php:163
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:434
ChangesList\insertArticleLink
insertArticleLink(&$s, RecentChange $rc, $unpatrolled, $watched)
Definition: ChangesList.php:483
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 use $formDescriptor instead 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:2213
ChangesList\$watchlist
$watchlist
Definition: ChangesList.php:36
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:53
ChangesList\getHTMLClasses
getHTMLClasses( $rc, $watched)
Get an array of default HTML class attributes for the change.
Definition: ChangesList.php:199
ChangesList\__construct
__construct( $obj, array $filterGroups=[])
Changeslist constructor.
Definition: ChangesList.php:66
RecentChange\getAttribute
getAttribute( $name)
Get an attribute value.
Definition: RecentChange.php:1070
text
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
Definition: All_system_messages.txt:1267
ChangesList\recentChangesFlags
recentChangesFlags( $flags, $nothing="\u{00A0}")
Returns the appropriate flags for new page, minor change and patrolling.
Definition: ChangesList.php:180
ChangesList\beginRecentChangesList
beginRecentChangesList()
Returns text for the start of the tabular part of RC.
Definition: ChangesList.php:288
ChangesList\insertDiffHist
insertDiffHist(&$s, &$rc, $unpatrolled=null)
Definition: ChangesList.php:431
$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:2683
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:555
ChangesList\initChangesListRows
initChangesListRows( $rows)
Definition: ChangesList.php:302
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:773
$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:1808
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
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:210
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:1441
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3098
ChangesList\getTimestamp
getTimestamp( $rc)
Get the timestamp from $rc formatted with current user's settings and a separator.
Definition: ChangesList.php:531
IContextSource\getRequest
getRequest()
ChangesList
Definition: ChangesList.php:28
ChangesList\$skin
Skin $skin
Definition: ChangesList.php:34
RC_CATEGORIZE
const RC_CATEGORIZE
Definition: Defines.php:146
ChangesList\isUnpatrolled
static isUnpatrolled( $rc, User $user)
Definition: ChangesList.php:738
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:232
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:38
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 use $formDescriptor instead 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
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:47
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
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:93
Revision\DELETED_TEXT
const DELETED_TEXT
Definition: Revision.php:47
ChangesList\getHTMLClassesForFilters
getHTMLClassesForFilters( $rc)
Get an array of CSS classes attributed to filters for this row.
Definition: ChangesList.php:230
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:633
ChangesList\insertExtra
insertExtra(&$s, &$rc, &$classes)
Definition: ChangesList.php:725
ChangesList\insertRollback
insertRollback(&$s, &$rc)
Insert a rollback link.
Definition: ChangesList.php:660
IContextSource\getLanguage
getLanguage()
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:813
$type
$type
Definition: testCompression.php:48