MediaWiki  master
ChangesList.php
Go to the documentation of this file.
1 <?php
25 use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
32 use OOUI\IconWidget;
34 
35 class ChangesList extends ContextSource {
36  use ProtectedHookAccessorTrait;
37 
38  public const CSS_CLASS_PREFIX = 'mw-changeslist-';
39 
43  public $skin;
44 
45  protected $watchlist = false;
46  protected $lastdate;
47  protected $message;
48  protected $rc_cache;
49  protected $rcCacheIndex;
50  protected $rclistOpen;
51  protected $rcMoveIndex;
52 
55 
57  protected $watchMsgCache;
58 
62  protected $linkRenderer;
63 
67  protected $filterGroups;
68 
73  public function __construct( $obj, array $filterGroups = [] ) {
74  if ( $obj instanceof IContextSource ) {
75  $this->setContext( $obj );
76  $this->skin = $obj->getSkin();
77  } else {
78  $this->setContext( $obj->getContext() );
79  $this->skin = $obj;
80  }
81  $this->preCacheMessages();
82  $this->watchMsgCache = new MapCacheLRU( 50 );
83  $this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
84  $this->filterGroups = $filterGroups;
85  }
86 
95  public static function newFromContext( IContextSource $context, array $groups = [] ) {
96  $user = $context->getUser();
97  $sk = $context->getSkin();
98  $list = null;
99  if ( Hooks::runner()->onFetchChangesList( $user, $sk, $list, $groups ) ) {
100  $new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
101 
102  return $new ?
103  new EnhancedChangesList( $context, $groups ) :
104  new OldChangesList( $context, $groups );
105  } else {
106  return $list;
107  }
108  }
109 
121  public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
122  throw new RuntimeException( 'recentChangesLine should be implemented' );
123  }
124 
131  protected function getHighlightsContainerDiv() {
132  $highlightColorDivs = '';
133  foreach ( [ 'none', 'c1', 'c2', 'c3', 'c4', 'c5' ] as $color ) {
134  $highlightColorDivs .= Html::rawElement(
135  'div',
136  [
137  'class' => 'mw-rcfilters-ui-highlights-color-' . $color,
138  'data-color' => $color
139  ]
140  );
141  }
142 
143  return Html::rawElement(
144  'div',
145  [ 'class' => 'mw-rcfilters-ui-highlights' ],
146  $highlightColorDivs
147  );
148  }
149 
154  public function setWatchlistDivs( $value = true ) {
155  $this->watchlist = $value;
156  }
157 
162  public function isWatchlist() {
163  return (bool)$this->watchlist;
164  }
165 
170  private function preCacheMessages() {
171  if ( !isset( $this->message ) ) {
172  $this->message = [];
173  foreach ( [
174  'cur', 'diff', 'hist', 'enhancedrc-history', 'last', 'blocklink', 'history',
175  'semicolon-separator', 'pipe-separator' ] as $msg
176  ) {
177  $this->message[$msg] = $this->msg( $msg )->escaped();
178  }
179  }
180  }
181 
188  public function recentChangesFlags( $flags, $nothing = "\u{00A0}" ) {
189  $f = '';
190  foreach ( array_keys( $this->getConfig()->get( 'RecentChangesFlags' ) ) as $flag ) {
191  $f .= isset( $flags[$flag] ) && $flags[$flag]
192  ? self::flag( $flag, $this->getContext() )
193  : $nothing;
194  }
195 
196  return $f;
197  }
198 
207  protected function getHTMLClasses( $rc, $watched ) {
208  $classes = [ self::CSS_CLASS_PREFIX . 'line' ];
209  $logType = $rc->mAttribs['rc_log_type'];
210 
211  if ( $logType ) {
212  $classes[] = self::CSS_CLASS_PREFIX . 'log';
213  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'log-' . $logType );
214  } else {
215  $classes[] = self::CSS_CLASS_PREFIX . 'edit';
216  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns' .
217  $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
218  }
219 
220  // Indicate watched status on the line to allow for more
221  // comprehensive styling.
222  $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched
223  ? self::CSS_CLASS_PREFIX . 'line-watched'
224  : self::CSS_CLASS_PREFIX . 'line-not-watched';
225 
226  $classes = array_merge( $classes, $this->getHTMLClassesForFilters( $rc ) );
227 
228  return $classes;
229  }
230 
238  protected function getHTMLClassesForFilters( $rc ) {
239  $classes = [];
240 
241  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' .
242  $rc->mAttribs['rc_namespace'] );
243 
244  $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
245  $classes[] = Sanitizer::escapeClass(
246  self::CSS_CLASS_PREFIX .
247  'ns-' .
248  ( $nsInfo->isTalk( $rc->mAttribs['rc_namespace'] ) ? 'talk' : 'subject' )
249  );
250 
251  if ( $this->filterGroups !== null ) {
252  foreach ( $this->filterGroups as $filterGroup ) {
253  foreach ( $filterGroup->getFilters() as $filter ) {
254  $filter->applyCssClassIfNeeded( $this, $rc, $classes );
255  }
256  }
257  }
258 
259  return $classes;
260  }
261 
272  public static function flag( $flag, IContextSource $context = null ) {
273  static $map = [ 'minoredit' => 'minor', 'botedit' => 'bot' ];
274  static $flagInfos = null;
275 
276  if ( $flagInfos === null ) {
277  global $wgRecentChangesFlags;
278  $flagInfos = [];
279  foreach ( $wgRecentChangesFlags as $key => $value ) {
280  $flagInfos[$key]['letter'] = $value['letter'];
281  $flagInfos[$key]['title'] = $value['title'];
282  // Allow customized class name, fall back to flag name
283  $flagInfos[$key]['class'] = $value['class'] ?? $key;
284  }
285  }
286 
288 
289  // Inconsistent naming, kepted for b/c
290  if ( isset( $map[$flag] ) ) {
291  $flag = $map[$flag];
292  }
293 
294  $info = $flagInfos[$flag];
295  return Html::element( 'abbr', [
296  'class' => $info['class'],
297  'title' => wfMessage( $info['title'] )->setContext( $context )->text(),
298  ], wfMessage( $info['letter'] )->setContext( $context )->text() );
299  }
300 
305  public function beginRecentChangesList() {
306  $this->rc_cache = [];
307  $this->rcMoveIndex = 0;
308  $this->rcCacheIndex = 0;
309  $this->lastdate = '';
310  $this->rclistOpen = false;
311  $this->getOutput()->addModuleStyles( [
312  'mediawiki.interface.helpers.styles',
313  'mediawiki.special.changeslist'
314  ] );
315 
316  return '<div class="mw-changeslist">';
317  }
318 
322  public function initChangesListRows( $rows ) {
323  $this->getHookRunner()->onChangesListInitRows( $this, $rows );
324  }
325 
336  public static function showCharacterDifference( $old, $new, IContextSource $context = null ) {
337  if ( !$context ) {
339  }
340 
341  $new = (int)$new;
342  $old = (int)$old;
343  $szdiff = $new - $old;
344 
346  $config = $context->getConfig();
347  $code = $lang->getCode();
348  static $fastCharDiff = [];
349  if ( !isset( $fastCharDiff[$code] ) ) {
350  $fastCharDiff[$code] = $config->get( 'MiserMode' )
351  || $context->msg( 'rc-change-size' )->plain() === '$1';
352  }
353 
354  $formattedSize = $lang->formatNum( $szdiff );
355 
356  if ( !$fastCharDiff[$code] ) {
357  $formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text();
358  }
359 
360  if ( abs( $szdiff ) > abs( $config->get( 'RCChangedSizeThreshold' ) ) ) {
361  $tag = 'strong';
362  } else {
363  $tag = 'span';
364  }
365 
366  if ( $szdiff === 0 ) {
367  $formattedSizeClass = 'mw-plusminus-null';
368  } elseif ( $szdiff > 0 ) {
369  $formattedSize = '+' . $formattedSize;
370  $formattedSizeClass = 'mw-plusminus-pos';
371  } else {
372  $formattedSizeClass = 'mw-plusminus-neg';
373  }
374  $formattedSizeClass .= ' mw-diff-bytes';
375 
376  $formattedTotalSize = $context->msg( 'rc-change-size-new' )->numParams( $new )->text();
377 
378  return Html::element( $tag,
379  [ 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ],
380  $formattedSize ) . $lang->getDirMark();
381  }
382 
390  public function formatCharacterDifference( RecentChange $old, RecentChange $new = null ) {
391  $oldlen = $old->mAttribs['rc_old_len'];
392 
393  if ( $new ) {
394  $newlen = $new->mAttribs['rc_new_len'];
395  } else {
396  $newlen = $old->mAttribs['rc_new_len'];
397  }
398 
399  if ( $oldlen === null || $newlen === null ) {
400  return '';
401  }
402 
403  return self::showCharacterDifference( $oldlen, $newlen, $this->getContext() );
404  }
405 
410  public function endRecentChangesList() {
411  $out = $this->rclistOpen ? "</ul>\n" : '';
412  $out .= '</div>';
413 
414  return $out;
415  }
416 
428  public static function revDateLink(
429  RevisionRecord $rev,
430  Authority $performer,
431  Language $lang,
432  $title = null
433  ) {
434  $ts = $rev->getTimestamp();
435  $date = $lang->userTimeAndDate( $ts, $performer->getUser() );
436  if ( $rev->userCan( RevisionRecord::DELETED_TEXT, $performer ) ) {
437  $link = MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
438  $title ?? $rev->getPageAsLinkTarget(),
439  $date,
440  [ 'class' => 'mw-changeslist-date' ],
441  [ 'oldid' => $rev->getId() ]
442  );
443  } else {
444  $link = htmlspecialchars( $date );
445  }
446  if ( $rev->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
447  $deletedClass = Linker::getRevisionDeletedClass( $rev );
448  $link = "<span class=\"$deletedClass mw-changeslist-date\">$link</span>";
449  }
450  return $link;
451  }
452 
457  public function insertDateHeader( &$s, $rc_timestamp ) {
458  # Make date header if necessary
459  $date = $this->getLanguage()->userDate( $rc_timestamp, $this->getUser() );
460  if ( $date != $this->lastdate ) {
461  if ( $this->lastdate != '' ) {
462  $s .= "</ul>\n";
463  }
464  $s .= Xml::element( 'h4', null, $date ) . "\n<ul class=\"special\">";
465  $this->lastdate = $date;
466  $this->rclistOpen = true;
467  }
468  }
469 
476  public function insertLog( &$s, $title, $logtype, $useParentheses = true ) {
477  $page = new LogPage( $logtype );
478  $logname = $page->getName()->setContext( $this->getContext() )->text();
479  $link = $this->linkRenderer->makeKnownLink( $title, $logname, [
480  'class' => $useParentheses ? '' : 'mw-changeslist-links'
481  ] );
482  if ( $useParentheses ) {
483  $s .= $this->msg( 'parentheses' )->rawParams(
484  $link
485  )->escaped();
486  } else {
487  $s .= $link;
488  }
489  }
490 
496  public function insertDiffHist( &$s, &$rc, $unpatrolled = null ) {
497  # Diff link
498  if (
499  $rc->mAttribs['rc_type'] == RC_NEW ||
500  $rc->mAttribs['rc_type'] == RC_LOG ||
501  $rc->mAttribs['rc_type'] == RC_CATEGORIZE
502  ) {
503  $diffLink = $this->message['diff'];
504  } elseif ( !self::userCan( $rc, RevisionRecord::DELETED_TEXT, $this->getAuthority() ) ) {
505  $diffLink = $this->message['diff'];
506  } else {
507  $query = [
508  'curid' => $rc->mAttribs['rc_cur_id'],
509  'diff' => $rc->mAttribs['rc_this_oldid'],
510  'oldid' => $rc->mAttribs['rc_last_oldid']
511  ];
512 
513  $diffLink = $this->linkRenderer->makeKnownLink(
514  $rc->getTitle(),
515  new HtmlArmor( $this->message['diff'] ),
516  [ 'class' => 'mw-changeslist-diff' ],
517  $query
518  );
519  }
520  if ( $rc->mAttribs['rc_type'] == RC_CATEGORIZE ) {
521  $histLink = $this->message['hist'];
522  } else {
523  $histLink = $this->linkRenderer->makeKnownLink(
524  $rc->getTitle(),
525  new HtmlArmor( $this->message['hist'] ),
526  [ 'class' => 'mw-changeslist-history' ],
527  [
528  'curid' => $rc->mAttribs['rc_cur_id'],
529  'action' => 'history'
530  ]
531  );
532  }
533 
534  $s .= Html::rawElement( 'div', [ 'class' => 'mw-changeslist-links' ],
535  Html::rawElement( 'span', [], $diffLink ) .
536  Html::rawElement( 'span', [], $histLink )
537  ) .
538  ' <span class="mw-changeslist-separator"></span> ';
539  }
540 
551  public function getArticleLink( &$rc, $unpatrolled, $watched ) {
552  $params = [];
553  if ( $rc->getTitle()->isRedirect() ) {
554  $params = [ 'redirect' => 'no' ];
555  }
556 
557  $articlelink = $this->linkRenderer->makeLink(
558  $rc->getTitle(),
559  null,
560  [ 'class' => 'mw-changeslist-title' ],
561  $params
562  );
563  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_TEXT ) ) {
564  $class = 'history-deleted';
565  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
566  $class .= ' mw-history-suppressed';
567  }
568  $articlelink = '<span class="' . $class . '">' . $articlelink . '</span>';
569  }
570  # To allow for boldening pages watched by this user
571  $articlelink = "<span class=\"mw-title\">{$articlelink}</span>";
572  # RTL/LTR marker
573  $articlelink .= $this->getLanguage()->getDirMark();
574 
575  # TODO: Deprecate the $s argument, it seems happily unused.
576  $s = '';
577  $this->getHookRunner()->onChangesListInsertArticleLink( $this, $articlelink,
578  $s, $rc, $unpatrolled, $watched );
579 
580  // Watchlist expiry icon.
581  $watchlistExpiry = '';
582  if ( isset( $rc->watchlistExpiry ) && $rc->watchlistExpiry ) {
583  $watchlistExpiry = $this->getWatchlistExpiry( $rc );
584  }
585 
586  return "{$s} {$articlelink}{$watchlistExpiry}";
587  }
588 
595  public function getWatchlistExpiry( RecentChange $recentChange ): string {
596  $item = WatchedItem::newFromRecentChange( $recentChange, $this->getUser() );
597  // Guard against expired items, even though they shouldn't come here.
598  if ( $item->isExpired() ) {
599  return '';
600  }
601  $daysLeftText = $item->getExpiryInDaysText( $this->getContext() );
602  // Matching widget is also created in ChangesListSpecialPage, for the legend.
603  $widget = new IconWidget( [
604  'icon' => 'clock',
605  'title' => $daysLeftText,
606  'classes' => [ 'mw-changesList-watchlistExpiry' ],
607  ] );
608  $widget->setAttributes( [
609  // Add labels for assistive technologies.
610  'role' => 'img',
611  'aria-label' => $this->msg( 'watchlist-expires-in-aria-label' )->text(),
612  // Days-left is used in resources/src/mediawiki.special.changeslist.watchlistexpiry/watchlistexpiry.js
613  'data-days-left' => $item->getExpiryInDays(),
614  ] );
615  // Add spaces around the widget (the page title is to one side,
616  // and a semicolon or opening-parenthesis to the other).
617  return " $widget ";
618  }
619 
628  public function getTimestamp( $rc ) {
629  // This uses the semi-colon separator unless there's a watchlist expiry date for the entry,
630  // because in that case the timestamp is preceeded by a clock icon.
631  // A space is important after mw-changeslist-separator--semicolon to make sure
632  // that whatever comes before it is distinguishable.
633  // (Otherwise your have the text of titles pushing up against the timestamp)
634  // A specific element is used for this purpose as `mw-changeslist-date` is used in a variety
635  // of other places with a different position and the information proceeding getTimestamp can vary.
636  $separatorClass = $rc->watchlistExpiry ? 'mw-changeslist-separator' : 'mw-changeslist-separator--semicolon';
637  return Html::element( 'span', [ 'class' => $separatorClass ] ) . ' ' .
638  '<span class="mw-changeslist-date">' .
639  htmlspecialchars( $this->getLanguage()->userTime(
640  $rc->mAttribs['rc_timestamp'],
641  $this->getUser()
642  ) ) . '</span> <span class="mw-changeslist-separator"></span> ';
643  }
644 
651  public function insertTimestamp( &$s, $rc ) {
652  $s .= $this->getTimestamp( $rc );
653  }
654 
661  public function insertUserRelatedLinks( &$s, &$rc ) {
662  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_USER ) ) {
663  $deletedClass = 'history-deleted';
664  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
665  $deletedClass = ' mw-history-suppressed';
666  }
667  $s .= ' <span class="' . $deletedClass . '">' .
668  $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
669  } else {
670  $s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'],
671  $rc->mAttribs['rc_user_text'] );
673  $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'],
674  false, 0, null,
675  // The text content of tools is not wrapped with parenthesises or "piped".
676  // This will be handled in CSS (T205581).
677  false
678  );
679  }
680  }
681 
688  public function insertLogEntry( $rc ) {
689  $formatter = LogFormatter::newFromRow( $rc->mAttribs );
690  $formatter->setContext( $this->getContext() );
691  $formatter->setShowUserToolLinks( true );
692  $mark = $this->getLanguage()->getDirMark();
693 
694  return Html::openElement( 'span', [ 'class' => 'mw-changeslist-log-entry' ] )
695  . $formatter->getActionText() . " $mark" . $formatter->getComment()
696  . Html::closeElement( 'span' );
697  }
698 
704  public function insertComment( $rc ) {
705  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_COMMENT ) ) {
706  $deletedClass = 'history-deleted';
707  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
708  $deletedClass .= ' mw-history-suppressed';
709  }
710  return ' <span class="' . $deletedClass . ' comment">' .
711  $this->msg( 'rev-deleted-comment' )->escaped() . '</span>';
712  } else {
713  return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle(),
714  // Whether section links should refer to local page (using default false)
715  false,
716  // wikid to generate links for (using default null) */
717  null,
718  // whether parentheses should be rendered as part of the message
719  false );
720  }
721  }
722 
728  protected function numberofWatchingusers( $count ) {
729  if ( $count <= 0 ) {
730  return '';
731  }
732 
733  return $this->watchMsgCache->getWithSetCallback(
734  "watching-users-msg:$count",
735  function () use ( $count ) {
736  return $this->msg( 'number-of-watching-users-for-recent-changes' )
737  ->numParams( $count )->escaped();
738  }
739  );
740  }
741 
748  public static function isDeleted( $rc, $field ) {
749  // @phan-suppress-next-line PhanTypeInvalidLeftOperandOfBitwiseOp false positive
750  return ( $rc->mAttribs['rc_deleted'] & $field ) == $field;
751  }
752 
762  public static function userCan( $rc, $field, Authority $performer = null ) {
763  if ( $performer === null ) {
764  $performer = RequestContext::getMain()->getAuthority();
765  }
766 
767  if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
768  return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $performer );
769  }
770 
771  return RevisionRecord::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $performer );
772  }
773 
779  protected function maybeWatchedLink( $link, $watched = false ) {
780  if ( $watched ) {
781  return '<strong class="mw-watched">' . $link . '</strong>';
782  } else {
783  return '<span class="mw-rc-unwatched">' . $link . '</span>';
784  }
785  }
786 
793  public function insertRollback( &$s, &$rc ) {
794  if ( $rc->mAttribs['rc_type'] == RC_EDIT
795  && $rc->mAttribs['rc_this_oldid']
796  && $rc->mAttribs['rc_cur_id']
797  && $rc->getAttribute( 'page_latest' ) == $rc->mAttribs['rc_this_oldid']
798  ) {
799  $title = $rc->getTitle();
803  if ( $this->getAuthority()->probablyCan( 'rollback', $title ) ) {
804  $revRecord = new MutableRevisionRecord( $title );
805  $revRecord->setId( (int)$rc->mAttribs['rc_this_oldid'] );
806  $revRecord->setVisibility( (int)$rc->mAttribs['rc_deleted'] );
807  $user = new UserIdentityValue(
808  (int)$rc->mAttribs['rc_user'],
809  $rc->mAttribs['rc_user_text']
810  );
811  $revRecord->setUser( $user );
812 
813  $s .= ' ';
815  $revRecord,
816  $this->getContext(),
817  [ 'noBrackets' ]
818  );
819  }
820  }
821  }
822 
828  public function getRollback( RecentChange $rc ) {
829  $s = '';
830  $this->insertRollback( $s, $rc );
831  return $s;
832  }
833 
839  public function insertTags( &$s, &$rc, &$classes ) {
840  if ( empty( $rc->mAttribs['ts_tags'] ) ) {
841  return;
842  }
843 
844  list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
845  $rc->mAttribs['ts_tags'],
846  'changeslist',
847  $this->getContext()
848  );
849  $classes = array_merge( $classes, $newClasses );
850  $s .= ' ' . $tagSummary;
851  }
852 
859  public function getTags( RecentChange $rc, array &$classes ) {
860  $s = '';
861  $this->insertTags( $s, $rc, $classes );
862  return $s;
863  }
864 
865  public function insertExtra( &$s, &$rc, &$classes ) {
866  // Empty, used for subclasses to add anything special.
867  }
868 
869  protected function showAsUnpatrolled( RecentChange $rc ) {
870  return self::isUnpatrolled( $rc, $this->getUser() );
871  }
872 
878  public static function isUnpatrolled( $rc, User $user ) {
879  if ( $rc instanceof RecentChange ) {
880  $isPatrolled = $rc->mAttribs['rc_patrolled'];
881  $rcType = $rc->mAttribs['rc_type'];
882  $rcLogType = $rc->mAttribs['rc_log_type'];
883  } else {
884  $isPatrolled = $rc->rc_patrolled;
885  $rcType = $rc->rc_type;
886  $rcLogType = $rc->rc_log_type;
887  }
888 
889  if ( !$isPatrolled ) {
890  if ( $user->useRCPatrol() ) {
891  return true;
892  }
893  if ( $user->useNPPatrol() && $rcType == RC_NEW ) {
894  return true;
895  }
896  if ( $user->useFilePatrol() && $rcLogType == 'upload' ) {
897  return true;
898  }
899  }
900 
901  return false;
902  }
903 
913  protected function isCategorizationWithoutRevision( $rcObj ) {
914  return intval( $rcObj->getAttribute( 'rc_type' ) ) === RC_CATEGORIZE
915  && intval( $rcObj->getAttribute( 'rc_this_oldid' ) ) === 0;
916  }
917 
923  protected function getDataAttributes( RecentChange $rc ) {
924  $attrs = [];
925 
926  $type = $rc->getAttribute( 'rc_source' );
927  switch ( $type ) {
930  $attrs['data-mw-revid'] = $rc->mAttribs['rc_this_oldid'];
931  break;
933  $attrs['data-mw-logid'] = $rc->mAttribs['rc_logid'];
934  $attrs['data-mw-logaction'] =
935  $rc->mAttribs['rc_log_type'] . '/' . $rc->mAttribs['rc_log_action'];
936  break;
937  }
938 
939  $attrs[ 'data-mw-ts' ] = $rc->getAttribute( 'rc_timestamp' );
940 
941  return $attrs;
942  }
943 
951  public function setChangeLinePrefixer( callable $prefixer ) {
952  $this->changeLinePrefixer = $prefixer;
953  }
954 }
MediaWiki\User\UserIdentityValue
Value object representing a user's identity.
Definition: UserIdentityValue.php:35
ChangesList\endRecentChangesList
endRecentChangesList()
Returns text for the end of RC.
Definition: ChangesList.php:410
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:38
ContextSource\getConfig
getConfig()
Definition: ContextSource.php:71
ContextSource\getContext
getContext()
Get the base IContextSource object.
Definition: ContextSource.php:46
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:30
ChangesList\insertComment
insertComment( $rc)
Insert a formatted comment.
Definition: ChangesList.php:704
MediaWiki\Revision\RevisionRecord
Page revision base class.
Definition: RevisionRecord.php:47
ChangesList\setWatchlistDivs
setWatchlistDivs( $value=true)
Sets the list to use a "<li class='watchlist-(namespace)-(page)'>" tag.
Definition: ChangesList.php:154
RC_EDIT
const RC_EDIT
Definition: Defines.php:115
User\useFilePatrol
useFilePatrol()
Check whether to enable new files patrol features for this user.
Definition: User.php:3014
ChangesList\setChangeLinePrefixer
setChangeLinePrefixer(callable $prefixer)
Sets the callable that generates a change line prefix added to the beginning of each line.
Definition: ChangesList.php:951
IContextSource\getSkin
getSkin()
Linker\userLink
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition: Linker.php:900
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:180
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:37
RecentChange
Utility class for creating new RC entries.
Definition: RecentChange.php:80
ChangesList\$watchMsgCache
MapCacheLRU $watchMsgCache
Definition: ChangesList.php:57
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:43
Linker\userToolLinks
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null, $useParentheses=true)
Generate standard user tool links (talk, contributions, block link, etc.)
Definition: Linker.php:945
ChangesList\maybeWatchedLink
maybeWatchedLink( $link, $watched=false)
Definition: ChangesList.php:779
LogEventsList\userCanBitfield
static userCanBitfield( $bitfield, $field, Authority $performer)
Determine if the current user is allowed to view a particular field of this log row,...
Definition: LogEventsList.php:545
ChangesList\getTags
getTags(RecentChange $rc, array &$classes)
Definition: ChangesList.php:859
ChangesList\getHighlightsContainerDiv
getHighlightsContainerDiv()
Get the container for highlights that are used in the new StructuredFilters system.
Definition: ChangesList.php:131
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1182
ChangesList\$rcCacheIndex
$rcCacheIndex
Definition: ChangesList.php:49
Sanitizer\escapeClass
static escapeClass( $class)
Given a value, escape it so that it can be used as a CSS class and return it.
Definition: Sanitizer.php:972
User\useNPPatrol
useNPPatrol()
Check whether to enable new pages patrol features for this user.
Definition: User.php:3002
RC_NEW
const RC_NEW
Definition: Defines.php:116
ChangesList\formatCharacterDifference
formatCharacterDifference(RecentChange $old, RecentChange $new=null)
Format the character difference of one or several changes.
Definition: ChangesList.php:390
User\useRCPatrol
useRCPatrol()
Check whether to enable recent changes patrol features for this user.
Definition: User.php:2993
ContextSource\getUser
getUser()
Definition: ContextSource.php:135
ChangesList\$lastdate
$lastdate
Definition: ChangesList.php:46
WatchedItem\newFromRecentChange
static newFromRecentChange(RecentChange $recentChange, UserIdentity $user)
Definition: WatchedItem.php:98
MediaWiki\Permissions\Authority\getUser
getUser()
Returns the performer of the actions associated with this authority.
RecentChange\SRC_LOG
const SRC_LOG
Definition: RecentChange.php:87
ChangesList\isDeleted
static isDeleted( $rc, $field)
Determine if said field of a revision is hidden.
Definition: ChangesList.php:748
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:152
ChangesList\insertLog
insertLog(&$s, $title, $logtype, $useParentheses=true)
Definition: ChangesList.php:476
ChangesList\insertDateHeader
insertDateHeader(&$s, $rc_timestamp)
Definition: ChangesList.php:457
ChangesList\$filterGroups
array $filterGroups
Definition: ChangesList.php:67
Html\closeElement
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:318
RC_LOG
const RC_LOG
Definition: Defines.php:117
$wgRecentChangesFlags
$wgRecentChangesFlags
Flags (letter symbols) shown in recent changes and watchlist to indicate certain types of edits.
Definition: DefaultSettings.php:8187
MessageLocalizer\msg
msg( $key,... $params)
This is the method for getting translated interface messages.
LogFormatter\newFromRow
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
Definition: LogFormatter.php:74
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
Linker\getRevisionDeletedClass
static getRevisionDeletedClass(RevisionRecord $revisionRecord)
Returns css class of a deleted revision.
Definition: Linker.php:1135
ChangesList\insertLogEntry
insertLogEntry( $rc)
Insert a formatted action.
Definition: ChangesList.php:688
ContextSource\getOutput
getOutput()
Definition: ContextSource.php:125
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition: ContextSource.php:32
ChangesList\isWatchlist
isWatchlist()
Definition: ChangesList.php:162
ChangesList\insertTags
insertTags(&$s, &$rc, &$classes)
Definition: ChangesList.php:839
LogPage
Class to simplify the use of log pages.
Definition: LogPage.php:38
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
ChangesList\flag
static flag( $flag, IContextSource $context=null)
Make an "<abbr>" element for a given change flag.
Definition: ChangesList.php:272
ChangesList\CSS_CLASS_PREFIX
const CSS_CLASS_PREFIX
Definition: ChangesList.php:38
$title
$title
Definition: testCompression.php:38
RecentChange\SRC_EDIT
const SRC_EDIT
Definition: RecentChange.php:85
RecentChange\SRC_NEW
const SRC_NEW
Definition: RecentChange.php:86
ChangesList\insertUserRelatedLinks
insertUserRelatedLinks(&$s, &$rc)
Insert links to user page, user talk page and eventually a blocking link.
Definition: ChangesList.php:661
ContextSource\setContext
setContext(IContextSource $context)
Definition: ContextSource.php:62
ChangesList\getRollback
getRollback(RecentChange $rc)
Definition: ChangesList.php:828
ChangesList\getArticleLink
getArticleLink(&$rc, $unpatrolled, $watched)
Get the HTML link to the changed page, possibly with a prefix from hook handlers, and a suffix for te...
Definition: ChangesList.php:551
Linker\generateRollback
static generateRollback(RevisionRecord $revRecord, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
Definition: Linker.php:1865
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:95
ChangesList\$rclistOpen
$rclistOpen
Definition: ChangesList.php:50
MediaWiki\Permissions\Authority
This interface represents the authority associated the current execution context, such as a web reque...
Definition: Authority.php:35
ChangesList\$changeLinePrefixer
callable $changeLinePrefixer
Definition: ChangesList.php:54
ChangesList\getDataAttributes
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
Definition: ChangesList.php:923
ContextSource\msg
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:196
EnhancedChangesList
Definition: EnhancedChangesList.php:26
$s
foreach( $mmfl['setupFiles'] as $fileName) if( $queue) if(empty( $mmfl['quiet'])) $s
Definition: mergeMessageFileList.php:206
OldChangesList
Definition: OldChangesList.php:25
Linker\commentBlock
static commentBlock( $comment, $title=null, $local=false, $wikiId=null, $useParentheses=true)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
Definition: Linker.php:1583
ContextSource\getAuthority
getAuthority()
Definition: ContextSource.php:143
MediaWiki\Revision\MutableRevisionRecord
Definition: MutableRevisionRecord.php:45
MediaWiki\Revision\RevisionRecord\getPageAsLinkTarget
getPageAsLinkTarget()
Returns the title of the page this revision is associated with as a LinkTarget object.
Definition: RevisionRecord.php:355
Hooks\runner
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
Definition: Hooks.php:172
ChangesList\insertTimestamp
insertTimestamp(&$s, $rc)
Insert time timestamp string from $rc into $s.
Definition: ChangesList.php:651
ChangesList\numberofWatchingusers
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
Definition: ChangesList.php:728
ChangesList\showAsUnpatrolled
showAsUnpatrolled(RecentChange $rc)
Definition: ChangesList.php:869
ChangesList\showCharacterDifference
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
Definition: ChangesList.php:336
IContextSource\getUser
getUser()
ChangesList\preCacheMessages
preCacheMessages()
As we use the same small set of messages in various methods and that they are called often,...
Definition: ChangesList.php:170
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:483
ChangesList\$watchlist
$watchlist
Definition: ChangesList.php:45
ChangesList\revDateLink
static revDateLink(RevisionRecord $rev, Authority $performer, Language $lang, $title=null)
Render the date and time of a revision in the current user language based on whether the user is able...
Definition: ChangesList.php:428
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:57
ChangesList\getHTMLClasses
getHTMLClasses( $rc, $watched)
Get an array of default HTML class attributes for the change.
Definition: ChangesList.php:207
ChangesList\__construct
__construct( $obj, array $filterGroups=[])
Definition: ChangesList.php:73
RecentChange\getAttribute
getAttribute( $name)
Get an attribute value.
Definition: RecentChange.php:1167
ChangesList\recentChangesFlags
recentChangesFlags( $flags, $nothing="\u{00A0}")
Returns the appropriate flags for new page, minor change and patrolling.
Definition: ChangesList.php:188
ChangesList\beginRecentChangesList
beginRecentChangesList()
Returns text for the start of the tabular part of RC.
Definition: ChangesList.php:305
ChangesList\insertDiffHist
insertDiffHist(&$s, &$rc, $unpatrolled=null)
Definition: ChangesList.php:496
MediaWiki\Revision\RevisionRecord\getId
getId( $wikiId=self::LOCAL)
Get revision ID.
Definition: RevisionRecord.php:279
MediaWiki\Revision\RevisionRecord\isDeleted
isDeleted( $field)
MCR migration note: this replaces Revision::isDeleted.
Definition: RevisionRecord.php:437
RC_CATEGORIZE
const RC_CATEGORIZE
Definition: Defines.php:119
ChangesList\initChangesListRows
initChangesListRows( $rows)
Definition: ChangesList.php:322
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:913
MediaWiki\Revision\RevisionRecord\userCan
userCan( $field, Authority $performer)
Determine if the give authority is allowed to view a particular field of this revision,...
Definition: RevisionRecord.php:509
Html\openElement
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:254
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:212
MediaWiki\Revision\RevisionRecord\getTimestamp
getTimestamp()
MCR migration note: this replaces Revision::getTimestamp.
Definition: RevisionRecord.php:459
ChangesList\getTimestamp
getTimestamp( $rc)
Get the timestamp from $rc formatted with current user's settings and a separator.
Definition: ChangesList.php:628
IContextSource\getRequest
getRequest()
ChangesList
Definition: ChangesList.php:35
ChangesList\$skin
Skin $skin
Definition: ChangesList.php:43
ChangesList\isUnpatrolled
static isUnpatrolled( $rc, User $user)
Definition: ChangesList.php:878
ChangesList\$rc_cache
$rc_cache
Definition: ChangesList.php:48
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:234
ChangesList\$rcMoveIndex
$rcMoveIndex
Definition: ChangesList.php:51
Skin
The main skin class which provides methods and properties for all other skins.
Definition: Skin.php:42
ChangesList\userCan
static userCan( $rc, $field, Authority $performer=null)
Determine if the current user is allowed to view a particular field of this revision,...
Definition: ChangesList.php:762
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:67
ChangesList\$message
$message
Definition: ChangesList.php:47
ChangeTags\formatSummaryRow
static formatSummaryRow( $tags, $page, IContextSource $context=null)
Creates HTML for the given tags.
Definition: ChangeTags.php:194
Language
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition: Language.php:42
ChangesList\getHTMLClassesForFilters
getHTMLClassesForFilters( $rc)
Get an array of CSS classes attributed to filters for this row.
Definition: ChangesList.php:238
ChangesList\recentChangesLine
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line.
Definition: ChangesList.php:121
ChangesList\insertExtra
insertExtra(&$s, &$rc, &$classes)
Definition: ChangesList.php:865
ChangesList\insertRollback
insertRollback(&$s, &$rc)
Insert a rollback link.
Definition: ChangesList.php:793
IContextSource\getLanguage
getLanguage()
ChangesList\getWatchlistExpiry
getWatchlistExpiry(RecentChange $recentChange)
Get HTML to display the clock icon for watched items that have a watchlist expiry time.
Definition: ChangesList.php:595
ChangesList\$linkRenderer
LinkRenderer $linkRenderer
Definition: ChangesList.php:62
$type
$type
Definition: testCompression.php:52