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 
40  protected $watchlist = false;
41  protected $lastdate;
42  protected $message;
43  protected $rc_cache;
44  protected $rcCacheIndex;
45  protected $rclistOpen;
46  protected $rcMoveIndex;
47 
50 
52  protected $watchMsgCache;
53 
57  protected $linkRenderer;
58 
62  protected $filterGroups;
63 
68  public function __construct( $context, array $filterGroups = [] ) {
69  $this->setContext( $context );
70  $this->preCacheMessages();
71  $this->watchMsgCache = new MapCacheLRU( 50 );
72  $this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
73  $this->filterGroups = $filterGroups;
74  }
75 
84  public static function newFromContext( IContextSource $context, array $groups = [] ) {
85  $user = $context->getUser();
86  $sk = $context->getSkin();
87  $list = null;
88  if ( Hooks::runner()->onFetchChangesList( $user, $sk, $list, $groups ) ) {
89  $new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
90 
91  return $new ?
92  new EnhancedChangesList( $context, $groups ) :
93  new OldChangesList( $context, $groups );
94  } else {
95  return $list;
96  }
97  }
98 
110  public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
111  throw new RuntimeException( 'recentChangesLine should be implemented' );
112  }
113 
120  protected function getHighlightsContainerDiv() {
121  $highlightColorDivs = '';
122  foreach ( [ 'none', 'c1', 'c2', 'c3', 'c4', 'c5' ] as $color ) {
123  $highlightColorDivs .= Html::rawElement(
124  'div',
125  [
126  'class' => 'mw-rcfilters-ui-highlights-color-' . $color,
127  'data-color' => $color
128  ]
129  );
130  }
131 
132  return Html::rawElement(
133  'div',
134  [ 'class' => 'mw-rcfilters-ui-highlights' ],
135  $highlightColorDivs
136  );
137  }
138 
143  public function setWatchlistDivs( $value = true ) {
144  $this->watchlist = $value;
145  }
146 
151  public function isWatchlist() {
152  return (bool)$this->watchlist;
153  }
154 
159  private function preCacheMessages() {
160  if ( !isset( $this->message ) ) {
161  $this->message = [];
162  foreach ( [
163  'cur', 'diff', 'hist', 'enhancedrc-history', 'last', 'blocklink', 'history',
164  'semicolon-separator', 'pipe-separator' ] as $msg
165  ) {
166  $this->message[$msg] = $this->msg( $msg )->escaped();
167  }
168  }
169  }
170 
177  public function recentChangesFlags( $flags, $nothing = "\u{00A0}" ) {
178  $f = '';
179  foreach ( array_keys( $this->getConfig()->get( 'RecentChangesFlags' ) ) as $flag ) {
180  $f .= isset( $flags[$flag] ) && $flags[$flag]
181  ? self::flag( $flag, $this->getContext() )
182  : $nothing;
183  }
184 
185  return $f;
186  }
187 
196  protected function getHTMLClasses( $rc, $watched ) {
197  $classes = [ self::CSS_CLASS_PREFIX . 'line' ];
198  $logType = $rc->mAttribs['rc_log_type'];
199 
200  if ( $logType ) {
201  $classes[] = self::CSS_CLASS_PREFIX . 'log';
202  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'log-' . $logType );
203  } else {
204  $classes[] = self::CSS_CLASS_PREFIX . 'edit';
205  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns' .
206  $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
207  }
208 
209  // Indicate watched status on the line to allow for more
210  // comprehensive styling.
211  $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched
212  ? self::CSS_CLASS_PREFIX . 'line-watched'
213  : self::CSS_CLASS_PREFIX . 'line-not-watched';
214 
215  $classes = array_merge( $classes, $this->getHTMLClassesForFilters( $rc ) );
216 
217  return $classes;
218  }
219 
227  protected function getHTMLClassesForFilters( $rc ) {
228  $classes = [];
229 
230  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' .
231  $rc->mAttribs['rc_namespace'] );
232 
233  $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
234  $classes[] = Sanitizer::escapeClass(
235  self::CSS_CLASS_PREFIX .
236  'ns-' .
237  ( $nsInfo->isTalk( $rc->mAttribs['rc_namespace'] ) ? 'talk' : 'subject' )
238  );
239 
240  foreach ( $this->filterGroups as $filterGroup ) {
241  foreach ( $filterGroup->getFilters() as $filter ) {
242  $filter->applyCssClassIfNeeded( $this, $rc, $classes );
243  }
244  }
245 
246  return $classes;
247  }
248 
259  public static function flag( $flag, IContextSource $context = null ) {
260  static $map = [ 'minoredit' => 'minor', 'botedit' => 'bot' ];
261  static $flagInfos = null;
262 
263  if ( $flagInfos === null ) {
264  global $wgRecentChangesFlags;
265  $flagInfos = [];
266  foreach ( $wgRecentChangesFlags as $key => $value ) {
267  $flagInfos[$key]['letter'] = $value['letter'];
268  $flagInfos[$key]['title'] = $value['title'];
269  // Allow customized class name, fall back to flag name
270  $flagInfos[$key]['class'] = $value['class'] ?? $key;
271  }
272  }
273 
275 
276  // Inconsistent naming, kepted for b/c
277  if ( isset( $map[$flag] ) ) {
278  $flag = $map[$flag];
279  }
280 
281  $info = $flagInfos[$flag];
282  return Html::element( 'abbr', [
283  'class' => $info['class'],
284  'title' => wfMessage( $info['title'] )->setContext( $context )->text(),
285  ], wfMessage( $info['letter'] )->setContext( $context )->text() );
286  }
287 
292  public function beginRecentChangesList() {
293  $this->rc_cache = [];
294  $this->rcMoveIndex = 0;
295  $this->rcCacheIndex = 0;
296  $this->lastdate = '';
297  $this->rclistOpen = false;
298  $this->getOutput()->addModuleStyles( [
299  'mediawiki.interface.helpers.styles',
300  'mediawiki.special.changeslist'
301  ] );
302 
303  return '<div class="mw-changeslist">';
304  }
305 
309  public function initChangesListRows( $rows ) {
310  $this->getHookRunner()->onChangesListInitRows( $this, $rows );
311  }
312 
323  public static function showCharacterDifference( $old, $new, IContextSource $context = null ) {
324  if ( !$context ) {
326  }
327 
328  $new = (int)$new;
329  $old = (int)$old;
330  $szdiff = $new - $old;
331 
333  $config = $context->getConfig();
334  $code = $lang->getCode();
335  static $fastCharDiff = [];
336  if ( !isset( $fastCharDiff[$code] ) ) {
337  $fastCharDiff[$code] = $config->get( 'MiserMode' )
338  || $context->msg( 'rc-change-size' )->plain() === '$1';
339  }
340 
341  $formattedSize = $lang->formatNum( $szdiff );
342 
343  if ( !$fastCharDiff[$code] ) {
344  $formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text();
345  }
346 
347  if ( abs( $szdiff ) > abs( $config->get( 'RCChangedSizeThreshold' ) ) ) {
348  $tag = 'strong';
349  } else {
350  $tag = 'span';
351  }
352 
353  if ( $szdiff === 0 ) {
354  $formattedSizeClass = 'mw-plusminus-null';
355  } elseif ( $szdiff > 0 ) {
356  $formattedSize = '+' . $formattedSize;
357  $formattedSizeClass = 'mw-plusminus-pos';
358  } else {
359  $formattedSizeClass = 'mw-plusminus-neg';
360  }
361  $formattedSizeClass .= ' mw-diff-bytes';
362 
363  $formattedTotalSize = $context->msg( 'rc-change-size-new' )->numParams( $new )->text();
364 
365  return Html::element( $tag,
366  [ 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ],
367  $formattedSize ) . $lang->getDirMark();
368  }
369 
377  public function formatCharacterDifference( RecentChange $old, RecentChange $new = null ) {
378  $oldlen = $old->mAttribs['rc_old_len'];
379 
380  if ( $new ) {
381  $newlen = $new->mAttribs['rc_new_len'];
382  } else {
383  $newlen = $old->mAttribs['rc_new_len'];
384  }
385 
386  if ( $oldlen === null || $newlen === null ) {
387  return '';
388  }
389 
390  return self::showCharacterDifference( $oldlen, $newlen, $this->getContext() );
391  }
392 
397  public function endRecentChangesList() {
398  $out = $this->rclistOpen ? "</ul>\n" : '';
399  $out .= '</div>';
400 
401  return $out;
402  }
403 
415  public static function revDateLink(
416  RevisionRecord $rev,
417  Authority $performer,
418  Language $lang,
419  $title = null
420  ) {
421  $ts = $rev->getTimestamp();
422  $date = $lang->userTimeAndDate( $ts, $performer->getUser() );
423  if ( $rev->userCan( RevisionRecord::DELETED_TEXT, $performer ) ) {
424  $link = MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
425  $title ?? $rev->getPageAsLinkTarget(),
426  $date,
427  [ 'class' => 'mw-changeslist-date' ],
428  [ 'oldid' => $rev->getId() ]
429  );
430  } else {
431  $link = htmlspecialchars( $date );
432  }
433  if ( $rev->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
434  $deletedClass = Linker::getRevisionDeletedClass( $rev );
435  $link = "<span class=\"$deletedClass mw-changeslist-date\">$link</span>";
436  }
437  return $link;
438  }
439 
444  public function insertDateHeader( &$s, $rc_timestamp ) {
445  # Make date header if necessary
446  $date = $this->getLanguage()->userDate( $rc_timestamp, $this->getUser() );
447  if ( $date != $this->lastdate ) {
448  if ( $this->lastdate != '' ) {
449  $s .= "</ul>\n";
450  }
451  $s .= Xml::element( 'h4', null, $date ) . "\n<ul class=\"special\">";
452  $this->lastdate = $date;
453  $this->rclistOpen = true;
454  }
455  }
456 
463  public function insertLog( &$s, $title, $logtype, $useParentheses = true ) {
464  $page = new LogPage( $logtype );
465  $logname = $page->getName()->setContext( $this->getContext() )->text();
466  $link = $this->linkRenderer->makeKnownLink( $title, $logname, [
467  'class' => $useParentheses ? '' : 'mw-changeslist-links'
468  ] );
469  if ( $useParentheses ) {
470  $s .= $this->msg( 'parentheses' )->rawParams(
471  $link
472  )->escaped();
473  } else {
474  $s .= $link;
475  }
476  }
477 
483  public function insertDiffHist( &$s, &$rc, $unpatrolled = null ) {
484  # Diff link
485  if (
486  $rc->mAttribs['rc_type'] == RC_NEW ||
487  $rc->mAttribs['rc_type'] == RC_LOG ||
488  $rc->mAttribs['rc_type'] == RC_CATEGORIZE
489  ) {
490  $diffLink = $this->message['diff'];
491  } elseif ( !self::userCan( $rc, RevisionRecord::DELETED_TEXT, $this->getAuthority() ) ) {
492  $diffLink = $this->message['diff'];
493  } else {
494  $query = [
495  'curid' => $rc->mAttribs['rc_cur_id'],
496  'diff' => $rc->mAttribs['rc_this_oldid'],
497  'oldid' => $rc->mAttribs['rc_last_oldid']
498  ];
499 
500  $diffLink = $this->linkRenderer->makeKnownLink(
501  $rc->getTitle(),
502  new HtmlArmor( $this->message['diff'] ),
503  [ 'class' => 'mw-changeslist-diff' ],
504  $query
505  );
506  }
507  if ( $rc->mAttribs['rc_type'] == RC_CATEGORIZE ) {
508  $histLink = $this->message['hist'];
509  } else {
510  $histLink = $this->linkRenderer->makeKnownLink(
511  $rc->getTitle(),
512  new HtmlArmor( $this->message['hist'] ),
513  [ 'class' => 'mw-changeslist-history' ],
514  [
515  'curid' => $rc->mAttribs['rc_cur_id'],
516  'action' => 'history'
517  ]
518  );
519  }
520 
521  $s .= Html::rawElement( 'div', [ 'class' => 'mw-changeslist-links' ],
522  Html::rawElement( 'span', [], $diffLink ) .
523  Html::rawElement( 'span', [], $histLink )
524  ) .
525  ' <span class="mw-changeslist-separator"></span> ';
526  }
527 
538  public function getArticleLink( &$rc, $unpatrolled, $watched ) {
539  $params = [];
540  if ( $rc->getTitle()->isRedirect() ) {
541  $params = [ 'redirect' => 'no' ];
542  }
543 
544  $articlelink = $this->linkRenderer->makeLink(
545  $rc->getTitle(),
546  null,
547  [ 'class' => 'mw-changeslist-title' ],
548  $params
549  );
550  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_TEXT ) ) {
551  $class = 'history-deleted';
552  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
553  $class .= ' mw-history-suppressed';
554  }
555  $articlelink = '<span class="' . $class . '">' . $articlelink . '</span>';
556  }
557  # To allow for boldening pages watched by this user
558  $articlelink = "<span class=\"mw-title\">{$articlelink}</span>";
559  # RTL/LTR marker
560  $articlelink .= $this->getLanguage()->getDirMark();
561 
562  # TODO: Deprecate the $s argument, it seems happily unused.
563  $s = '';
564  $this->getHookRunner()->onChangesListInsertArticleLink( $this, $articlelink,
565  $s, $rc, $unpatrolled, $watched );
566 
567  // Watchlist expiry icon.
568  $watchlistExpiry = '';
569  if ( isset( $rc->watchlistExpiry ) && $rc->watchlistExpiry ) {
570  $watchlistExpiry = $this->getWatchlistExpiry( $rc );
571  }
572 
573  return "{$s} {$articlelink}{$watchlistExpiry}";
574  }
575 
582  public function getWatchlistExpiry( RecentChange $recentChange ): string {
583  $item = WatchedItem::newFromRecentChange( $recentChange, $this->getUser() );
584  // Guard against expired items, even though they shouldn't come here.
585  if ( $item->isExpired() ) {
586  return '';
587  }
588  $daysLeftText = $item->getExpiryInDaysText( $this->getContext() );
589  // Matching widget is also created in ChangesListSpecialPage, for the legend.
590  $widget = new IconWidget( [
591  'icon' => 'clock',
592  'title' => $daysLeftText,
593  'classes' => [ 'mw-changesList-watchlistExpiry' ],
594  ] );
595  $widget->setAttributes( [
596  // Add labels for assistive technologies.
597  'role' => 'img',
598  'aria-label' => $this->msg( 'watchlist-expires-in-aria-label' )->text(),
599  // Days-left is used in resources/src/mediawiki.special.changeslist.watchlistexpiry/watchlistexpiry.js
600  'data-days-left' => $item->getExpiryInDays(),
601  ] );
602  // Add spaces around the widget (the page title is to one side,
603  // and a semicolon or opening-parenthesis to the other).
604  return " $widget ";
605  }
606 
615  public function getTimestamp( $rc ) {
616  // This uses the semi-colon separator unless there's a watchlist expiry date for the entry,
617  // because in that case the timestamp is preceeded by a clock icon.
618  // A space is important after mw-changeslist-separator--semicolon to make sure
619  // that whatever comes before it is distinguishable.
620  // (Otherwise your have the text of titles pushing up against the timestamp)
621  // A specific element is used for this purpose as `mw-changeslist-date` is used in a variety
622  // of other places with a different position and the information proceeding getTimestamp can vary.
623  $separatorClass = $rc->watchlistExpiry ? 'mw-changeslist-separator' : 'mw-changeslist-separator--semicolon';
624  return Html::element( 'span', [ 'class' => $separatorClass ] ) . ' ' .
625  '<span class="mw-changeslist-date">' .
626  htmlspecialchars( $this->getLanguage()->userTime(
627  $rc->mAttribs['rc_timestamp'],
628  $this->getUser()
629  ) ) . '</span> <span class="mw-changeslist-separator"></span> ';
630  }
631 
638  public function insertTimestamp( &$s, $rc ) {
639  $s .= $this->getTimestamp( $rc );
640  }
641 
648  public function insertUserRelatedLinks( &$s, &$rc ) {
649  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_USER ) ) {
650  $deletedClass = 'history-deleted';
651  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
652  $deletedClass = ' mw-history-suppressed';
653  }
654  $s .= ' <span class="' . $deletedClass . '">' .
655  $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
656  } else {
657  $s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'],
658  $rc->mAttribs['rc_user_text'] );
660  $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'],
661  false, 0, null,
662  // The text content of tools is not wrapped with parenthesises or "piped".
663  // This will be handled in CSS (T205581).
664  false
665  );
666  }
667  }
668 
675  public function insertLogEntry( $rc ) {
676  $formatter = LogFormatter::newFromRow( $rc->mAttribs );
677  $formatter->setContext( $this->getContext() );
678  $formatter->setShowUserToolLinks( true );
679  $mark = $this->getLanguage()->getDirMark();
680 
681  return Html::openElement( 'span', [ 'class' => 'mw-changeslist-log-entry' ] )
682  . $formatter->getActionText() . " $mark" . $formatter->getComment()
683  . Html::closeElement( 'span' );
684  }
685 
691  public function insertComment( $rc ) {
692  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_COMMENT ) ) {
693  $deletedClass = 'history-deleted';
694  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
695  $deletedClass .= ' mw-history-suppressed';
696  }
697  return ' <span class="' . $deletedClass . ' comment">' .
698  $this->msg( 'rev-deleted-comment' )->escaped() . '</span>';
699  } else {
700  return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle(),
701  // Whether section links should refer to local page (using default false)
702  false,
703  // wikid to generate links for (using default null) */
704  null,
705  // whether parentheses should be rendered as part of the message
706  false );
707  }
708  }
709 
715  protected function numberofWatchingusers( $count ) {
716  if ( $count <= 0 ) {
717  return '';
718  }
719 
720  return $this->watchMsgCache->getWithSetCallback(
721  "watching-users-msg:$count",
722  function () use ( $count ) {
723  return $this->msg( 'number-of-watching-users-for-recent-changes' )
724  ->numParams( $count )->escaped();
725  }
726  );
727  }
728 
735  public static function isDeleted( $rc, $field ) {
736  return ( $rc->mAttribs['rc_deleted'] & $field ) == $field;
737  }
738 
748  public static function userCan( $rc, $field, Authority $performer = null ) {
749  if ( $performer === null ) {
750  $performer = RequestContext::getMain()->getAuthority();
751  }
752 
753  if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
754  return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $performer );
755  }
756 
757  return RevisionRecord::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $performer );
758  }
759 
765  protected function maybeWatchedLink( $link, $watched = false ) {
766  if ( $watched ) {
767  return '<strong class="mw-watched">' . $link . '</strong>';
768  } else {
769  return '<span class="mw-rc-unwatched">' . $link . '</span>';
770  }
771  }
772 
779  public function insertRollback( &$s, &$rc ) {
780  if ( $rc->mAttribs['rc_type'] == RC_EDIT
781  && $rc->mAttribs['rc_this_oldid']
782  && $rc->mAttribs['rc_cur_id']
783  && $rc->getAttribute( 'page_latest' ) == $rc->mAttribs['rc_this_oldid']
784  ) {
785  $title = $rc->getTitle();
789  if ( $this->getAuthority()->probablyCan( 'rollback', $title ) ) {
790  $revRecord = new MutableRevisionRecord( $title );
791  $revRecord->setId( (int)$rc->mAttribs['rc_this_oldid'] );
792  $revRecord->setVisibility( (int)$rc->mAttribs['rc_deleted'] );
793  $user = new UserIdentityValue(
794  (int)$rc->mAttribs['rc_user'],
795  $rc->mAttribs['rc_user_text']
796  );
797  $revRecord->setUser( $user );
798 
799  $s .= ' ';
801  $revRecord,
802  $this->getContext(),
803  [ 'noBrackets' ]
804  );
805  }
806  }
807  }
808 
814  public function getRollback( RecentChange $rc ) {
815  $s = '';
816  $this->insertRollback( $s, $rc );
817  return $s;
818  }
819 
825  public function insertTags( &$s, &$rc, &$classes ) {
826  if ( empty( $rc->mAttribs['ts_tags'] ) ) {
827  return;
828  }
829 
830  list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
831  $rc->mAttribs['ts_tags'],
832  'changeslist',
833  $this->getContext()
834  );
835  $classes = array_merge( $classes, $newClasses );
836  $s .= ' ' . $tagSummary;
837  }
838 
845  public function getTags( RecentChange $rc, array &$classes ) {
846  $s = '';
847  $this->insertTags( $s, $rc, $classes );
848  return $s;
849  }
850 
851  public function insertExtra( &$s, &$rc, &$classes ) {
852  // Empty, used for subclasses to add anything special.
853  }
854 
855  protected function showAsUnpatrolled( RecentChange $rc ) {
856  return self::isUnpatrolled( $rc, $this->getUser() );
857  }
858 
864  public static function isUnpatrolled( $rc, User $user ) {
865  if ( $rc instanceof RecentChange ) {
866  $isPatrolled = $rc->mAttribs['rc_patrolled'];
867  $rcType = $rc->mAttribs['rc_type'];
868  $rcLogType = $rc->mAttribs['rc_log_type'];
869  } else {
870  $isPatrolled = $rc->rc_patrolled;
871  $rcType = $rc->rc_type;
872  $rcLogType = $rc->rc_log_type;
873  }
874 
875  if ( !$isPatrolled ) {
876  if ( $user->useRCPatrol() ) {
877  return true;
878  }
879  if ( $user->useNPPatrol() && $rcType == RC_NEW ) {
880  return true;
881  }
882  if ( $user->useFilePatrol() && $rcLogType == 'upload' ) {
883  return true;
884  }
885  }
886 
887  return false;
888  }
889 
899  protected function isCategorizationWithoutRevision( $rcObj ) {
900  return intval( $rcObj->getAttribute( 'rc_type' ) ) === RC_CATEGORIZE
901  && intval( $rcObj->getAttribute( 'rc_this_oldid' ) ) === 0;
902  }
903 
909  protected function getDataAttributes( RecentChange $rc ) {
910  $attrs = [];
911 
912  $type = $rc->getAttribute( 'rc_source' );
913  switch ( $type ) {
916  $attrs['data-mw-revid'] = $rc->mAttribs['rc_this_oldid'];
917  break;
919  $attrs['data-mw-logid'] = $rc->mAttribs['rc_logid'];
920  $attrs['data-mw-logaction'] =
921  $rc->mAttribs['rc_log_type'] . '/' . $rc->mAttribs['rc_log_action'];
922  break;
923  }
924 
925  $attrs[ 'data-mw-ts' ] = $rc->getAttribute( 'rc_timestamp' );
926 
927  return $attrs;
928  }
929 
937  public function setChangeLinePrefixer( callable $prefixer ) {
938  $this->changeLinePrefixer = $prefixer;
939  }
940 }
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:397
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:39
ContextSource\getConfig
getConfig()
Definition: ContextSource.php:72
ContextSource\getContext
getContext()
Get the base IContextSource object.
Definition: ContextSource.php:47
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:30
ChangesList\insertComment
insertComment( $rc)
Insert a formatted comment.
Definition: ChangesList.php:691
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:143
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:3061
ChangesList\setChangeLinePrefixer
setChangeLinePrefixer(callable $prefixer)
Sets the callable that generates a change line prefix added to the beginning of each line.
Definition: ChangesList.php:937
IContextSource\getSkin
getSkin()
Linker\userLink
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition: Linker.php:1064
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:191
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:37
ChangesList\__construct
__construct( $context, array $filterGroups=[])
Definition: ChangesList.php:68
RecentChange
Utility class for creating new RC entries.
Definition: RecentChange.php:80
ChangesList\$watchMsgCache
MapCacheLRU $watchMsgCache
Definition: ChangesList.php:52
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:1109
ChangesList\$filterGroups
ChangesListFilterGroup[] $filterGroups
Definition: ChangesList.php:62
ChangesList\maybeWatchedLink
maybeWatchedLink( $link, $watched=false)
Definition: ChangesList.php:765
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:535
ChangesList\getTags
getTags(RecentChange $rc, array &$classes)
Definition: ChangesList.php:845
ChangesList\getHighlightsContainerDiv
getHighlightsContainerDiv()
Get the container for highlights that are used in the new StructuredFilters system.
Definition: ChangesList.php:120
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1182
ChangesList\$rcCacheIndex
$rcCacheIndex
Definition: ChangesList.php:44
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:973
User\useNPPatrol
useNPPatrol()
Check whether to enable new pages patrol features for this user.
Definition: User.php:3049
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:377
User\useRCPatrol
useRCPatrol()
Check whether to enable recent changes patrol features for this user.
Definition: User.php:3040
ContextSource\getUser
getUser()
Definition: ContextSource.php:136
ChangesList\$lastdate
$lastdate
Definition: ChangesList.php:41
WatchedItem\newFromRecentChange
static newFromRecentChange(RecentChange $recentChange, UserIdentity $user)
Definition: WatchedItem.php:98
ChangesListFilterGroup
Represents a filter group (used on ChangesListSpecialPage and descendants)
Definition: ChangesListFilterGroup.php:37
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:735
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:153
ChangesList\insertLog
insertLog(&$s, $title, $logtype, $useParentheses=true)
Definition: ChangesList.php:463
ChangesList\insertDateHeader
insertDateHeader(&$s, $rc_timestamp)
Definition: ChangesList.php:444
Html\closeElement
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:316
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:8223
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:26
Linker\getRevisionDeletedClass
static getRevisionDeletedClass(RevisionRecord $revisionRecord)
Returns css class of a deleted revision.
Definition: Linker.php:1299
ChangesList\insertLogEntry
insertLogEntry( $rc)
Insert a formatted action.
Definition: ChangesList.php:675
ContextSource\getOutput
getOutput()
Definition: ContextSource.php:126
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition: ContextSource.php:33
ChangesList\isWatchlist
isWatchlist()
Definition: ChangesList.php:151
ChangesList\insertTags
insertTags(&$s, &$rc, &$classes)
Definition: ChangesList.php:825
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:36
ChangesList\flag
static flag( $flag, IContextSource $context=null)
Make an "<abbr>" element for a given change flag.
Definition: ChangesList.php:259
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:648
ContextSource\setContext
setContext(IContextSource $context)
Definition: ContextSource.php:63
ChangesList\getRollback
getRollback(RecentChange $rc)
Definition: ChangesList.php:814
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:538
Linker\generateRollback
static generateRollback(RevisionRecord $revRecord, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
Definition: Linker.php:2031
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:84
ChangesList\$rclistOpen
$rclistOpen
Definition: ChangesList.php:45
MediaWiki\Permissions\Authority
This interface represents the authority associated the current execution context, such as a web reque...
Definition: Authority.php:37
ChangesList\$changeLinePrefixer
callable $changeLinePrefixer
Definition: ChangesList.php:49
ChangesList\getDataAttributes
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
Definition: ChangesList.php:909
ContextSource\msg
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:197
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:1749
ContextSource\getAuthority
getAuthority()
Definition: ContextSource.php:144
MediaWiki\Revision\MutableRevisionRecord
Definition: MutableRevisionRecord.php:44
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:173
ChangesList\insertTimestamp
insertTimestamp(&$s, $rc)
Insert time timestamp string from $rc into $s.
Definition: ChangesList.php:638
ChangesList\numberofWatchingusers
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
Definition: ChangesList.php:715
ChangesList\showAsUnpatrolled
showAsUnpatrolled(RecentChange $rc)
Definition: ChangesList.php:855
ChangesList\showCharacterDifference
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
Definition: ChangesList.php:323
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:159
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:484
ChangesList\$watchlist
$watchlist
Definition: ChangesList.php:40
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:415
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:58
ChangesList\getHTMLClasses
getHTMLClasses( $rc, $watched)
Get an array of default HTML class attributes for the change.
Definition: ChangesList.php:196
RecentChange\getAttribute
getAttribute( $name)
Get an attribute value.
Definition: RecentChange.php:1169
ChangesList\recentChangesFlags
recentChangesFlags( $flags, $nothing="\u{00A0}")
Returns the appropriate flags for new page, minor change and patrolling.
Definition: ChangesList.php:177
ChangesList\beginRecentChangesList
beginRecentChangesList()
Returns text for the start of the tabular part of RC.
Definition: ChangesList.php:292
ChangesList\insertDiffHist
insertDiffHist(&$s, &$rc, $unpatrolled=null)
Definition: ChangesList.php:483
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 replaced Revision::isDeleted.
Definition: RevisionRecord.php:437
RC_CATEGORIZE
const RC_CATEGORIZE
Definition: Defines.php:119
ChangesList\initChangesListRows
initChangesListRows( $rows)
Definition: ChangesList.php:309
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:899
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:252
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:210
MediaWiki\Revision\RevisionRecord\getTimestamp
getTimestamp()
MCR migration note: this replaced 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:615
IContextSource\getRequest
getRequest()
ChangesList
Definition: ChangesList.php:35
ChangesList\isUnpatrolled
static isUnpatrolled( $rc, User $user)
Definition: ChangesList.php:864
ChangesList\$rc_cache
$rc_cache
Definition: ChangesList.php:43
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:232
ChangesList\$rcMoveIndex
$rcMoveIndex
Definition: ChangesList.php:46
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:748
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:68
ChangesList\$message
$message
Definition: ChangesList.php:42
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:227
ChangesList\recentChangesLine
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line.
Definition: ChangesList.php:110
ChangesList\insertExtra
insertExtra(&$s, &$rc, &$classes)
Definition: ChangesList.php:851
ChangesList\insertRollback
insertRollback(&$s, &$rc)
Insert a rollback link.
Definition: ChangesList.php:779
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:582
ChangesList\$linkRenderer
LinkRenderer $linkRenderer
Definition: ChangesList.php:57
$type
$type
Definition: testCompression.php:52