MediaWiki  master
ChangesList.php
Go to the documentation of this file.
1 <?php
26 use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
33 use OOUI\IconWidget;
35 
36 class ChangesList extends ContextSource {
37  use ProtectedHookAccessorTrait;
38 
39  public const CSS_CLASS_PREFIX = 'mw-changeslist-';
40 
41  protected $watchlist = false;
42  protected $lastdate;
43  protected $message;
44  protected $rc_cache;
45  protected $rcCacheIndex;
46  protected $rclistOpen;
47  protected $rcMoveIndex;
48 
51 
53  protected $watchMsgCache;
54 
58  protected $linkRenderer;
59 
63  protected $commentFormatter;
64 
68  protected $formattedComments;
69 
73  protected $filterGroups;
74 
79  public function __construct( $context, array $filterGroups = [] ) {
80  $this->setContext( $context );
81  $this->preCacheMessages();
82  $this->watchMsgCache = new MapCacheLRU( 50 );
83  $this->filterGroups = $filterGroups;
84 
85  $services = MediaWikiServices::getInstance();
86  $this->linkRenderer = $services->getLinkRenderer();
87  $this->commentFormatter = $services->getRowCommentFormatter();
88  }
89 
98  public static function newFromContext( IContextSource $context, array $groups = [] ) {
99  $user = $context->getUser();
100  $sk = $context->getSkin();
101  $list = null;
102  if ( Hooks::runner()->onFetchChangesList( $user, $sk, $list, $groups ) ) {
103  $new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
104 
105  return $new ?
106  new EnhancedChangesList( $context, $groups ) :
107  new OldChangesList( $context, $groups );
108  } else {
109  return $list;
110  }
111  }
112 
124  public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
125  throw new RuntimeException( 'recentChangesLine should be implemented' );
126  }
127 
134  protected function getHighlightsContainerDiv() {
135  $highlightColorDivs = '';
136  foreach ( [ 'none', 'c1', 'c2', 'c3', 'c4', 'c5' ] as $color ) {
137  $highlightColorDivs .= Html::rawElement(
138  'div',
139  [
140  'class' => 'mw-rcfilters-ui-highlights-color-' . $color,
141  'data-color' => $color
142  ]
143  );
144  }
145 
146  return Html::rawElement(
147  'div',
148  [ 'class' => 'mw-rcfilters-ui-highlights' ],
149  $highlightColorDivs
150  );
151  }
152 
157  public function setWatchlistDivs( $value = true ) {
158  $this->watchlist = $value;
159  }
160 
165  public function isWatchlist() {
166  return (bool)$this->watchlist;
167  }
168 
173  private function preCacheMessages() {
174  if ( !isset( $this->message ) ) {
175  $this->message = [];
176  foreach ( [
177  'cur', 'diff', 'hist', 'enhancedrc-history', 'last', 'blocklink', 'history',
178  'semicolon-separator', 'pipe-separator' ] as $msg
179  ) {
180  $this->message[$msg] = $this->msg( $msg )->escaped();
181  }
182  }
183  }
184 
191  public function recentChangesFlags( $flags, $nothing = "\u{00A0}" ) {
192  $f = '';
193  foreach ( array_keys( $this->getConfig()->get( 'RecentChangesFlags' ) ) as $flag ) {
194  $f .= isset( $flags[$flag] ) && $flags[$flag]
195  ? self::flag( $flag, $this->getContext() )
196  : $nothing;
197  }
198 
199  return $f;
200  }
201 
210  protected function getHTMLClasses( $rc, $watched ) {
211  $classes = [ self::CSS_CLASS_PREFIX . 'line' ];
212  $logType = $rc->mAttribs['rc_log_type'];
213 
214  if ( $logType ) {
215  $classes[] = self::CSS_CLASS_PREFIX . 'log';
216  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'log-' . $logType );
217  } else {
218  $classes[] = self::CSS_CLASS_PREFIX . 'edit';
219  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns' .
220  $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
221  }
222 
223  // Indicate watched status on the line to allow for more
224  // comprehensive styling.
225  $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched
226  ? self::CSS_CLASS_PREFIX . 'line-watched'
227  : self::CSS_CLASS_PREFIX . 'line-not-watched';
228 
229  $classes = array_merge( $classes, $this->getHTMLClassesForFilters( $rc ) );
230 
231  return $classes;
232  }
233 
241  protected function getHTMLClassesForFilters( $rc ) {
242  $classes = [];
243 
244  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' .
245  $rc->mAttribs['rc_namespace'] );
246 
247  $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
248  $classes[] = Sanitizer::escapeClass(
249  self::CSS_CLASS_PREFIX .
250  'ns-' .
251  ( $nsInfo->isTalk( $rc->mAttribs['rc_namespace'] ) ? 'talk' : 'subject' )
252  );
253 
254  foreach ( $this->filterGroups as $filterGroup ) {
255  foreach ( $filterGroup->getFilters() as $filter ) {
256  $filter->applyCssClassIfNeeded( $this, $rc, $classes );
257  }
258  }
259 
260  return $classes;
261  }
262 
273  public static function flag( $flag, IContextSource $context = null ) {
274  static $map = [ 'minoredit' => 'minor', 'botedit' => 'bot' ];
275  static $flagInfos = null;
276 
277  if ( $flagInfos === null ) {
278  global $wgRecentChangesFlags;
279  $flagInfos = [];
280  foreach ( $wgRecentChangesFlags as $key => $value ) {
281  $flagInfos[$key]['letter'] = $value['letter'];
282  $flagInfos[$key]['title'] = $value['title'];
283  // Allow customized class name, fall back to flag name
284  $flagInfos[$key]['class'] = $value['class'] ?? $key;
285  }
286  }
287 
289 
290  // Inconsistent naming, kepted for b/c
291  if ( isset( $map[$flag] ) ) {
292  $flag = $map[$flag];
293  }
294 
295  $info = $flagInfos[$flag];
296  return Html::element( 'abbr', [
297  'class' => $info['class'],
298  'title' => wfMessage( $info['title'] )->setContext( $context )->text(),
299  ], wfMessage( $info['letter'] )->setContext( $context )->text() );
300  }
301 
306  public function beginRecentChangesList() {
307  $this->rc_cache = [];
308  $this->rcMoveIndex = 0;
309  $this->rcCacheIndex = 0;
310  $this->lastdate = '';
311  $this->rclistOpen = false;
312  $this->getOutput()->addModuleStyles( [
313  'mediawiki.interface.helpers.styles',
314  'mediawiki.special.changeslist'
315  ] );
316 
317  return '<div class="mw-changeslist">';
318  }
319 
323  public function initChangesListRows( $rows ) {
324  $this->getHookRunner()->onChangesListInitRows( $this, $rows );
325  $this->formattedComments = $this->commentFormatter->createBatch()
326  ->comments(
327  $this->commentFormatter->rows( $rows )
328  ->commentKey( 'rc_comment' )
329  ->namespaceField( 'rc_namespace' )
330  ->titleField( 'rc_title' )
331  ->indexField( 'rc_id' )
332  )
333  ->useBlock()
334  ->execute();
335  }
336 
347  public static function showCharacterDifference( $old, $new, IContextSource $context = null ) {
348  if ( !$context ) {
350  }
351 
352  $new = (int)$new;
353  $old = (int)$old;
354  $szdiff = $new - $old;
355 
357  $config = $context->getConfig();
358  $code = $lang->getCode();
359  static $fastCharDiff = [];
360  if ( !isset( $fastCharDiff[$code] ) ) {
361  $fastCharDiff[$code] = $config->get( 'MiserMode' )
362  || $context->msg( 'rc-change-size' )->plain() === '$1';
363  }
364 
365  $formattedSize = $lang->formatNum( $szdiff );
366 
367  if ( !$fastCharDiff[$code] ) {
368  $formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text();
369  }
370 
371  if ( abs( $szdiff ) > abs( $config->get( 'RCChangedSizeThreshold' ) ) ) {
372  $tag = 'strong';
373  } else {
374  $tag = 'span';
375  }
376 
377  if ( $szdiff === 0 ) {
378  $formattedSizeClass = 'mw-plusminus-null';
379  } elseif ( $szdiff > 0 ) {
380  $formattedSize = '+' . $formattedSize;
381  $formattedSizeClass = 'mw-plusminus-pos';
382  } else {
383  $formattedSizeClass = 'mw-plusminus-neg';
384  }
385  $formattedSizeClass .= ' mw-diff-bytes';
386 
387  $formattedTotalSize = $context->msg( 'rc-change-size-new' )->numParams( $new )->text();
388 
389  return Html::element( $tag,
390  [ 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ],
391  $formattedSize ) . $lang->getDirMark();
392  }
393 
401  public function formatCharacterDifference( RecentChange $old, RecentChange $new = null ) {
402  $oldlen = $old->mAttribs['rc_old_len'];
403 
404  if ( $new ) {
405  $newlen = $new->mAttribs['rc_new_len'];
406  } else {
407  $newlen = $old->mAttribs['rc_new_len'];
408  }
409 
410  if ( $oldlen === null || $newlen === null ) {
411  return '';
412  }
413 
414  return self::showCharacterDifference( $oldlen, $newlen, $this->getContext() );
415  }
416 
421  public function endRecentChangesList() {
422  $out = $this->rclistOpen ? "</ul>\n" : '';
423  $out .= '</div>';
424 
425  return $out;
426  }
427 
439  public static function revDateLink(
440  RevisionRecord $rev,
441  Authority $performer,
442  Language $lang,
443  $title = null
444  ) {
445  $ts = $rev->getTimestamp();
446  $date = $lang->userTimeAndDate( $ts, $performer->getUser() );
447  if ( $rev->userCan( RevisionRecord::DELETED_TEXT, $performer ) ) {
448  $link = MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
449  $title ?? $rev->getPageAsLinkTarget(),
450  $date,
451  [ 'class' => 'mw-changeslist-date' ],
452  [ 'oldid' => $rev->getId() ]
453  );
454  } else {
455  $link = htmlspecialchars( $date );
456  }
457  if ( $rev->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
458  $deletedClass = Linker::getRevisionDeletedClass( $rev );
459  $link = "<span class=\"$deletedClass mw-changeslist-date\">$link</span>";
460  }
461  return $link;
462  }
463 
468  public function insertDateHeader( &$s, $rc_timestamp ) {
469  # Make date header if necessary
470  $date = $this->getLanguage()->userDate( $rc_timestamp, $this->getUser() );
471  if ( $date != $this->lastdate ) {
472  if ( $this->lastdate != '' ) {
473  $s .= "</ul>\n";
474  }
475  $s .= Xml::element( 'h4', null, $date ) . "\n<ul class=\"special\">";
476  $this->lastdate = $date;
477  $this->rclistOpen = true;
478  }
479  }
480 
487  public function insertLog( &$s, $title, $logtype, $useParentheses = true ) {
488  $page = new LogPage( $logtype );
489  $logname = $page->getName()->setContext( $this->getContext() )->text();
490  $link = $this->linkRenderer->makeKnownLink( $title, $logname, [
491  'class' => $useParentheses ? '' : 'mw-changeslist-links'
492  ] );
493  if ( $useParentheses ) {
494  $s .= $this->msg( 'parentheses' )->rawParams(
495  $link
496  )->escaped();
497  } else {
498  $s .= $link;
499  }
500  }
501 
507  public function insertDiffHist( &$s, &$rc, $unpatrolled = null ) {
508  # Diff link
509  if (
510  $rc->mAttribs['rc_type'] == RC_NEW ||
511  $rc->mAttribs['rc_type'] == RC_LOG ||
512  $rc->mAttribs['rc_type'] == RC_CATEGORIZE
513  ) {
514  $diffLink = $this->message['diff'];
515  } elseif ( !self::userCan( $rc, RevisionRecord::DELETED_TEXT, $this->getAuthority() ) ) {
516  $diffLink = $this->message['diff'];
517  } else {
518  $query = [
519  'curid' => $rc->mAttribs['rc_cur_id'],
520  'diff' => $rc->mAttribs['rc_this_oldid'],
521  'oldid' => $rc->mAttribs['rc_last_oldid']
522  ];
523 
524  $diffLink = $this->linkRenderer->makeKnownLink(
525  $rc->getTitle(),
526  new HtmlArmor( $this->message['diff'] ),
527  [ 'class' => 'mw-changeslist-diff' ],
528  $query
529  );
530  }
531  if ( $rc->mAttribs['rc_type'] == RC_CATEGORIZE ) {
532  $histLink = $this->message['hist'];
533  } else {
534  $histLink = $this->linkRenderer->makeKnownLink(
535  $rc->getTitle(),
536  new HtmlArmor( $this->message['hist'] ),
537  [ 'class' => 'mw-changeslist-history' ],
538  [
539  'curid' => $rc->mAttribs['rc_cur_id'],
540  'action' => 'history'
541  ]
542  );
543  }
544 
545  $s .= Html::rawElement( 'div', [ 'class' => 'mw-changeslist-links' ],
546  Html::rawElement( 'span', [], $diffLink ) .
547  Html::rawElement( 'span', [], $histLink )
548  ) .
549  ' <span class="mw-changeslist-separator"></span> ';
550  }
551 
562  public function getArticleLink( &$rc, $unpatrolled, $watched ) {
563  $params = [];
564  if ( $rc->getTitle()->isRedirect() ) {
565  $params = [ 'redirect' => 'no' ];
566  }
567 
568  $articlelink = $this->linkRenderer->makeLink(
569  $rc->getTitle(),
570  null,
571  [ 'class' => 'mw-changeslist-title' ],
572  $params
573  );
574  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_TEXT ) ) {
575  $class = 'history-deleted';
576  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
577  $class .= ' mw-history-suppressed';
578  }
579  $articlelink = '<span class="' . $class . '">' . $articlelink . '</span>';
580  }
581  # To allow for boldening pages watched by this user
582  $articlelink = "<span class=\"mw-title\">{$articlelink}</span>";
583  # RTL/LTR marker
584  $articlelink .= $this->getLanguage()->getDirMark();
585 
586  # TODO: Deprecate the $s argument, it seems happily unused.
587  $s = '';
588  $this->getHookRunner()->onChangesListInsertArticleLink( $this, $articlelink,
589  $s, $rc, $unpatrolled, $watched );
590 
591  // Watchlist expiry icon.
592  $watchlistExpiry = '';
593  if ( isset( $rc->watchlistExpiry ) && $rc->watchlistExpiry ) {
594  $watchlistExpiry = $this->getWatchlistExpiry( $rc );
595  }
596 
597  return "{$s} {$articlelink}{$watchlistExpiry}";
598  }
599 
606  public function getWatchlistExpiry( RecentChange $recentChange ): string {
607  $item = WatchedItem::newFromRecentChange( $recentChange, $this->getUser() );
608  // Guard against expired items, even though they shouldn't come here.
609  if ( $item->isExpired() ) {
610  return '';
611  }
612  $daysLeftText = $item->getExpiryInDaysText( $this->getContext() );
613  // Matching widget is also created in ChangesListSpecialPage, for the legend.
614  $widget = new IconWidget( [
615  'icon' => 'clock',
616  'title' => $daysLeftText,
617  'classes' => [ 'mw-changesList-watchlistExpiry' ],
618  ] );
619  $widget->setAttributes( [
620  // Add labels for assistive technologies.
621  'role' => 'img',
622  'aria-label' => $this->msg( 'watchlist-expires-in-aria-label' )->text(),
623  // Days-left is used in resources/src/mediawiki.special.changeslist.watchlistexpiry/watchlistexpiry.js
624  'data-days-left' => $item->getExpiryInDays(),
625  ] );
626  // Add spaces around the widget (the page title is to one side,
627  // and a semicolon or opening-parenthesis to the other).
628  return " $widget ";
629  }
630 
639  public function getTimestamp( $rc ) {
640  // This uses the semi-colon separator unless there's a watchlist expiry date for the entry,
641  // because in that case the timestamp is preceeded by a clock icon.
642  // A space is important after mw-changeslist-separator--semicolon to make sure
643  // that whatever comes before it is distinguishable.
644  // (Otherwise your have the text of titles pushing up against the timestamp)
645  // A specific element is used for this purpose as `mw-changeslist-date` is used in a variety
646  // of other places with a different position and the information proceeding getTimestamp can vary.
647  $separatorClass = $rc->watchlistExpiry ? 'mw-changeslist-separator' : 'mw-changeslist-separator--semicolon';
648  return Html::element( 'span', [ 'class' => $separatorClass ] ) . ' ' .
649  '<span class="mw-changeslist-date">' .
650  htmlspecialchars( $this->getLanguage()->userTime(
651  $rc->mAttribs['rc_timestamp'],
652  $this->getUser()
653  ) ) . '</span> <span class="mw-changeslist-separator"></span> ';
654  }
655 
662  public function insertTimestamp( &$s, $rc ) {
663  $s .= $this->getTimestamp( $rc );
664  }
665 
672  public function insertUserRelatedLinks( &$s, &$rc ) {
673  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_USER ) ) {
674  $deletedClass = 'history-deleted';
675  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
676  $deletedClass .= ' mw-history-suppressed';
677  }
678  $s .= ' <span class="' . $deletedClass . '">' .
679  $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
680  } else {
681  // @phan-suppress-next-line SecurityCheck-DoubleEscaped
682  $s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'],
683  $rc->mAttribs['rc_user_text'] );
685  $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'],
686  false, 0, null,
687  // The text content of tools is not wrapped with parenthesises or "piped".
688  // This will be handled in CSS (T205581).
689  false
690  );
691  }
692  }
693 
700  public function insertLogEntry( $rc ) {
701  $formatter = LogFormatter::newFromRow( $rc->mAttribs );
702  $formatter->setContext( $this->getContext() );
703  $formatter->setShowUserToolLinks( true );
704  $mark = $this->getLanguage()->getDirMark();
705 
706  return Html::openElement( 'span', [ 'class' => 'mw-changeslist-log-entry' ] )
707  . $formatter->getActionText() . " $mark" . $formatter->getComment()
708  . Html::closeElement( 'span' );
709  }
710 
716  public function insertComment( $rc ) {
717  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_COMMENT ) ) {
718  $deletedClass = 'history-deleted';
719  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_RESTRICTED ) ) {
720  $deletedClass .= ' mw-history-suppressed';
721  }
722  return ' <span class="' . $deletedClass . ' comment">' .
723  $this->msg( 'rev-deleted-comment' )->escaped() . '</span>';
724  } elseif ( isset( $rc->mAttribs['rc_id'] )
725  && isset( $this->formattedComments[$rc->mAttribs['rc_id']] )
726  ) {
727  return $this->formattedComments[$rc->mAttribs['rc_id']];
728  } else {
729  return $this->commentFormatter->formatBlock(
730  $rc->mAttribs['rc_comment'],
731  $rc->getTitle(),
732  // Whether section links should refer to local page (using default false)
733  false,
734  // wikid to generate links for (using default null) */
735  null,
736  // whether parentheses should be rendered as part of the message
737  false
738  );
739  }
740  }
741 
747  protected function numberofWatchingusers( $count ) {
748  if ( $count <= 0 ) {
749  return '';
750  }
751 
752  return $this->watchMsgCache->getWithSetCallback(
753  "watching-users-msg:$count",
754  function () use ( $count ) {
755  return $this->msg( 'number-of-watching-users-for-recent-changes' )
756  ->numParams( $count )->escaped();
757  }
758  );
759  }
760 
767  public static function isDeleted( $rc, $field ) {
768  return ( $rc->mAttribs['rc_deleted'] & $field ) == $field;
769  }
770 
780  public static function userCan( $rc, $field, Authority $performer = null ) {
781  if ( $performer === null ) {
782  $performer = RequestContext::getMain()->getAuthority();
783  }
784 
785  if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
786  return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $performer );
787  }
788 
789  return RevisionRecord::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $performer );
790  }
791 
797  protected function maybeWatchedLink( $link, $watched = false ) {
798  if ( $watched ) {
799  return '<strong class="mw-watched">' . $link . '</strong>';
800  } else {
801  return '<span class="mw-rc-unwatched">' . $link . '</span>';
802  }
803  }
804 
811  public function insertRollback( &$s, &$rc ) {
812  if ( $rc->mAttribs['rc_type'] == RC_EDIT
813  && $rc->mAttribs['rc_this_oldid']
814  && $rc->mAttribs['rc_cur_id']
815  && $rc->getAttribute( 'page_latest' ) == $rc->mAttribs['rc_this_oldid']
816  ) {
817  $title = $rc->getTitle();
821  if ( $this->getAuthority()->probablyCan( 'rollback', $title ) ) {
822  $revRecord = new MutableRevisionRecord( $title );
823  $revRecord->setId( (int)$rc->mAttribs['rc_this_oldid'] );
824  $revRecord->setVisibility( (int)$rc->mAttribs['rc_deleted'] );
825  $user = new UserIdentityValue(
826  (int)$rc->mAttribs['rc_user'],
827  $rc->mAttribs['rc_user_text']
828  );
829  $revRecord->setUser( $user );
830 
831  $s .= ' ';
833  $revRecord,
834  $this->getContext(),
835  [ 'noBrackets' ]
836  );
837  }
838  }
839  }
840 
846  public function getRollback( RecentChange $rc ) {
847  $s = '';
848  $this->insertRollback( $s, $rc );
849  return $s;
850  }
851 
857  public function insertTags( &$s, &$rc, &$classes ) {
858  if ( empty( $rc->mAttribs['ts_tags'] ) ) {
859  return;
860  }
861 
862  list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
863  $rc->mAttribs['ts_tags'],
864  'changeslist',
865  $this->getContext()
866  );
867  $classes = array_merge( $classes, $newClasses );
868  $s .= ' ' . $tagSummary;
869  }
870 
877  public function getTags( RecentChange $rc, array &$classes ) {
878  $s = '';
879  $this->insertTags( $s, $rc, $classes );
880  return $s;
881  }
882 
883  public function insertExtra( &$s, &$rc, &$classes ) {
884  // Empty, used for subclasses to add anything special.
885  }
886 
887  protected function showAsUnpatrolled( RecentChange $rc ) {
888  return self::isUnpatrolled( $rc, $this->getUser() );
889  }
890 
896  public static function isUnpatrolled( $rc, User $user ) {
897  if ( $rc instanceof RecentChange ) {
898  $isPatrolled = $rc->mAttribs['rc_patrolled'];
899  $rcType = $rc->mAttribs['rc_type'];
900  $rcLogType = $rc->mAttribs['rc_log_type'];
901  } else {
902  $isPatrolled = $rc->rc_patrolled;
903  $rcType = $rc->rc_type;
904  $rcLogType = $rc->rc_log_type;
905  }
906 
907  if ( !$isPatrolled ) {
908  if ( $user->useRCPatrol() ) {
909  return true;
910  }
911  if ( $user->useNPPatrol() && $rcType == RC_NEW ) {
912  return true;
913  }
914  if ( $user->useFilePatrol() && $rcLogType == 'upload' ) {
915  return true;
916  }
917  }
918 
919  return false;
920  }
921 
931  protected function isCategorizationWithoutRevision( $rcObj ) {
932  return intval( $rcObj->getAttribute( 'rc_type' ) ) === RC_CATEGORIZE
933  && intval( $rcObj->getAttribute( 'rc_this_oldid' ) ) === 0;
934  }
935 
941  protected function getDataAttributes( RecentChange $rc ) {
942  $attrs = [];
943 
944  $type = $rc->getAttribute( 'rc_source' );
945  switch ( $type ) {
948  $attrs['data-mw-revid'] = $rc->mAttribs['rc_this_oldid'];
949  break;
951  $attrs['data-mw-logid'] = $rc->mAttribs['rc_logid'];
952  $attrs['data-mw-logaction'] =
953  $rc->mAttribs['rc_log_type'] . '/' . $rc->mAttribs['rc_log_action'];
954  break;
955  }
956 
957  $attrs[ 'data-mw-ts' ] = $rc->getAttribute( 'rc_timestamp' );
958 
959  return $attrs;
960  }
961 
969  public function setChangeLinePrefixer( callable $prefixer ) {
970  $this->changeLinePrefixer = $prefixer;
971  }
972 }
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:421
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:716
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:157
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:2612
ChangesList\setChangeLinePrefixer
setChangeLinePrefixer(callable $prefixer)
Sets the callable that generates a change line prefix added to the beginning of each line.
Definition: ChangesList.php:969
IContextSource\getSkin
getSkin()
Linker\userLink
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition: Linker.php:1065
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:202
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:37
ChangesList\__construct
__construct( $context, array $filterGroups=[])
Definition: ChangesList.php:79
RecentChange
Utility class for creating new RC entries.
Definition: RecentChange.php:80
ChangesList\$watchMsgCache
MapCacheLRU $watchMsgCache
Definition: ChangesList.php:53
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:1110
ChangesList\$filterGroups
ChangesListFilterGroup[] $filterGroups
Definition: ChangesList.php:73
ChangesList\maybeWatchedLink
maybeWatchedLink( $link, $watched=false)
Definition: ChangesList.php:797
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:877
ChangesList\$formattedComments
string[] $formattedComments
Comments indexed by rc_id.
Definition: ChangesList.php:68
ChangesList\getHighlightsContainerDiv
getHighlightsContainerDiv()
Get the container for highlights that are used in the new StructuredFilters system.
Definition: ChangesList.php:134
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1183
ChangesList\$rcCacheIndex
$rcCacheIndex
Definition: ChangesList.php:45
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:2600
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:401
User\useRCPatrol
useRCPatrol()
Check whether to enable recent changes patrol features for this user.
Definition: User.php:2591
ContextSource\getUser
getUser()
Definition: ContextSource.php:136
ChangesList\$lastdate
$lastdate
Definition: ChangesList.php:42
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:767
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:153
ChangesList\insertLog
insertLog(&$s, $title, $logtype, $useParentheses=true)
Definition: ChangesList.php:487
ChangesList\insertDateHeader
insertDateHeader(&$s, $rc_timestamp)
Definition: ChangesList.php:468
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:8206
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:1300
ChangesList\insertLogEntry
insertLogEntry( $rc)
Insert a formatted action.
Definition: ChangesList.php:700
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:165
ChangesList\insertTags
insertTags(&$s, &$rc, &$classes)
Definition: ChangesList.php:857
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:42
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:273
ChangesList\CSS_CLASS_PREFIX
const CSS_CLASS_PREFIX
Definition: ChangesList.php:39
$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:672
ContextSource\setContext
setContext(IContextSource $context)
Definition: ContextSource.php:63
ChangesList\getRollback
getRollback(RecentChange $rc)
Definition: ChangesList.php:846
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:562
Linker\generateRollback
static generateRollback(RevisionRecord $revRecord, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
Definition: Linker.php:1783
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:98
ChangesList\$rclistOpen
$rclistOpen
Definition: ChangesList.php:46
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:50
ChangesList\getDataAttributes
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
Definition: ChangesList.php:941
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
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:662
ChangesList\numberofWatchingusers
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
Definition: ChangesList.php:747
ChangesList\showAsUnpatrolled
showAsUnpatrolled(RecentChange $rc)
Definition: ChangesList.php:887
ChangesList\showCharacterDifference
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
Definition: ChangesList.php:347
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:173
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:484
ChangesList\$watchlist
$watchlist
Definition: ChangesList.php:41
ChangesList\$commentFormatter
RowCommentFormatter $commentFormatter
Definition: ChangesList.php:63
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:439
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:210
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:191
ChangesList\beginRecentChangesList
beginRecentChangesList()
Returns text for the start of the tabular part of RC.
Definition: ChangesList.php:306
MediaWiki\CommentFormatter\RowCommentFormatter
This is basically a CommentFormatter with a CommentStore dependency, allowing it to retrieve comment ...
Definition: RowCommentFormatter.php:15
ChangesList\insertDiffHist
insertDiffHist(&$s, &$rc, $unpatrolled=null)
Definition: ChangesList.php:507
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:323
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:931
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:639
IContextSource\getRequest
getRequest()
ChangesList
Definition: ChangesList.php:36
ChangesList\isUnpatrolled
static isUnpatrolled( $rc, User $user)
Definition: ChangesList.php:896
ChangesList\$rc_cache
$rc_cache
Definition: ChangesList.php:44
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:47
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:780
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:43
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:241
ChangesList\recentChangesLine
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line.
Definition: ChangesList.php:124
ChangesList\insertExtra
insertExtra(&$s, &$rc, &$classes)
Definition: ChangesList.php:883
ChangesList\insertRollback
insertRollback(&$s, &$rc)
Insert a rollback link.
Definition: ChangesList.php:811
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:606
ChangesList\$linkRenderer
LinkRenderer $linkRenderer
Definition: ChangesList.php:58
$type
$type
Definition: testCompression.php:52