MediaWiki  master
ChangesList.php
Go to the documentation of this file.
1 <?php
25 use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
31 use OOUI\IconWidget;
33 
34 class ChangesList extends ContextSource {
35  use ProtectedHookAccessorTrait;
36 
37  public const CSS_CLASS_PREFIX = 'mw-changeslist-';
38 
42  public $skin;
43 
44  protected $watchlist = false;
45  protected $lastdate;
46  protected $message;
47  protected $rc_cache;
48  protected $rcCacheIndex;
49  protected $rclistOpen;
50  protected $rcMoveIndex;
51 
54 
56  protected $watchMsgCache;
57 
61  protected $linkRenderer;
62 
66  protected $filterGroups;
67 
72  public function __construct( $obj, array $filterGroups = [] ) {
73  if ( $obj instanceof IContextSource ) {
74  $this->setContext( $obj );
75  $this->skin = $obj->getSkin();
76  } else {
77  $this->setContext( $obj->getContext() );
78  $this->skin = $obj;
79  }
80  $this->preCacheMessages();
81  $this->watchMsgCache = new MapCacheLRU( 50 );
82  $this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
83  $this->filterGroups = $filterGroups;
84  }
85 
94  public static function newFromContext( IContextSource $context, array $groups = [] ) {
95  $user = $context->getUser();
96  $sk = $context->getSkin();
97  $list = null;
98  if ( Hooks::runner()->onFetchChangesList( $user, $sk, $list, $groups ) ) {
99  $new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
100 
101  return $new ?
102  new EnhancedChangesList( $context, $groups ) :
103  new OldChangesList( $context, $groups );
104  } else {
105  return $list;
106  }
107  }
108 
120  public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
121  throw new RuntimeException( 'recentChangesLine should be implemented' );
122  }
123 
130  protected function getHighlightsContainerDiv() {
131  $highlightColorDivs = '';
132  foreach ( [ 'none', 'c1', 'c2', 'c3', 'c4', 'c5' ] as $color ) {
133  $highlightColorDivs .= Html::rawElement(
134  'div',
135  [
136  'class' => 'mw-rcfilters-ui-highlights-color-' . $color,
137  'data-color' => $color
138  ]
139  );
140  }
141 
142  return Html::rawElement(
143  'div',
144  [ 'class' => 'mw-rcfilters-ui-highlights' ],
145  $highlightColorDivs
146  );
147  }
148 
153  public function setWatchlistDivs( $value = true ) {
154  $this->watchlist = $value;
155  }
156 
161  public function isWatchlist() {
162  return (bool)$this->watchlist;
163  }
164 
169  private function preCacheMessages() {
170  if ( !isset( $this->message ) ) {
171  $this->message = [];
172  foreach ( [
173  'cur', 'diff', 'hist', 'enhancedrc-history', 'last', 'blocklink', 'history',
174  'semicolon-separator', 'pipe-separator' ] as $msg
175  ) {
176  $this->message[$msg] = $this->msg( $msg )->escaped();
177  }
178  }
179  }
180 
187  public function recentChangesFlags( $flags, $nothing = "\u{00A0}" ) {
188  $f = '';
189  foreach ( array_keys( $this->getConfig()->get( 'RecentChangesFlags' ) ) as $flag ) {
190  $f .= isset( $flags[$flag] ) && $flags[$flag]
191  ? self::flag( $flag, $this->getContext() )
192  : $nothing;
193  }
194 
195  return $f;
196  }
197 
206  protected function getHTMLClasses( $rc, $watched ) {
207  $classes = [ self::CSS_CLASS_PREFIX . 'line' ];
208  $logType = $rc->mAttribs['rc_log_type'];
209 
210  if ( $logType ) {
211  $classes[] = self::CSS_CLASS_PREFIX . 'log';
212  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'log-' . $logType );
213  } else {
214  $classes[] = self::CSS_CLASS_PREFIX . 'edit';
215  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns' .
216  $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
217  }
218 
219  // Indicate watched status on the line to allow for more
220  // comprehensive styling.
221  $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched
222  ? self::CSS_CLASS_PREFIX . 'line-watched'
223  : self::CSS_CLASS_PREFIX . 'line-not-watched';
224 
225  $classes = array_merge( $classes, $this->getHTMLClassesForFilters( $rc ) );
226 
227  return $classes;
228  }
229 
237  protected function getHTMLClassesForFilters( $rc ) {
238  $classes = [];
239 
240  $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' .
241  $rc->mAttribs['rc_namespace'] );
242 
243  $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
244  $classes[] = Sanitizer::escapeClass(
245  self::CSS_CLASS_PREFIX .
246  'ns-' .
247  ( $nsInfo->isTalk( $rc->mAttribs['rc_namespace'] ) ? 'talk' : 'subject' )
248  );
249 
250  if ( $this->filterGroups !== null ) {
251  foreach ( $this->filterGroups as $filterGroup ) {
252  foreach ( $filterGroup->getFilters() as $filter ) {
253  $filter->applyCssClassIfNeeded( $this, $rc, $classes );
254  }
255  }
256  }
257 
258  return $classes;
259  }
260 
269  public static function flag( $flag, IContextSource $context = null ) {
270  static $map = [ 'minoredit' => 'minor', 'botedit' => 'bot' ];
271  static $flagInfos = null;
272 
273  if ( $flagInfos === null ) {
274  global $wgRecentChangesFlags;
275  $flagInfos = [];
276  foreach ( $wgRecentChangesFlags as $key => $value ) {
277  $flagInfos[$key]['letter'] = $value['letter'];
278  $flagInfos[$key]['title'] = $value['title'];
279  // Allow customized class name, fall back to flag name
280  $flagInfos[$key]['class'] = $value['class'] ?? $key;
281  }
282  }
283 
285 
286  // Inconsistent naming, kepted for b/c
287  if ( isset( $map[$flag] ) ) {
288  $flag = $map[$flag];
289  }
290 
291  $info = $flagInfos[$flag];
292  return Html::element( 'abbr', [
293  'class' => $info['class'],
294  'title' => wfMessage( $info['title'] )->setContext( $context )->text(),
295  ], wfMessage( $info['letter'] )->setContext( $context )->text() );
296  }
297 
302  public function beginRecentChangesList() {
303  $this->rc_cache = [];
304  $this->rcMoveIndex = 0;
305  $this->rcCacheIndex = 0;
306  $this->lastdate = '';
307  $this->rclistOpen = false;
308  $this->getOutput()->addModuleStyles( [
309  'mediawiki.interface.helpers.styles',
310  'mediawiki.special.changeslist'
311  ] );
312 
313  return '<div class="mw-changeslist">';
314  }
315 
319  public function initChangesListRows( $rows ) {
320  $this->getHookRunner()->onChangesListInitRows( $this, $rows );
321  }
322 
333  public static function showCharacterDifference( $old, $new, IContextSource $context = null ) {
334  if ( !$context ) {
336  }
337 
338  $new = (int)$new;
339  $old = (int)$old;
340  $szdiff = $new - $old;
341 
343  $config = $context->getConfig();
344  $code = $lang->getCode();
345  static $fastCharDiff = [];
346  if ( !isset( $fastCharDiff[$code] ) ) {
347  $fastCharDiff[$code] = $config->get( 'MiserMode' )
348  || $context->msg( 'rc-change-size' )->plain() === '$1';
349  }
350 
351  $formattedSize = $lang->formatNum( $szdiff );
352 
353  if ( !$fastCharDiff[$code] ) {
354  $formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text();
355  }
356 
357  if ( abs( $szdiff ) > abs( $config->get( 'RCChangedSizeThreshold' ) ) ) {
358  $tag = 'strong';
359  } else {
360  $tag = 'span';
361  }
362 
363  if ( $szdiff === 0 ) {
364  $formattedSizeClass = 'mw-plusminus-null';
365  } elseif ( $szdiff > 0 ) {
366  $formattedSize = '+' . $formattedSize;
367  $formattedSizeClass = 'mw-plusminus-pos';
368  } else {
369  $formattedSizeClass = 'mw-plusminus-neg';
370  }
371  $formattedSizeClass .= ' mw-diff-bytes';
372 
373  $formattedTotalSize = $context->msg( 'rc-change-size-new' )->numParams( $new )->text();
374 
375  return Html::element( $tag,
376  [ 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ],
377  $formattedSize ) . $lang->getDirMark();
378  }
379 
387  public function formatCharacterDifference( RecentChange $old, RecentChange $new = null ) {
388  $oldlen = $old->mAttribs['rc_old_len'];
389 
390  if ( $new ) {
391  $newlen = $new->mAttribs['rc_new_len'];
392  } else {
393  $newlen = $old->mAttribs['rc_new_len'];
394  }
395 
396  if ( $oldlen === null || $newlen === null ) {
397  return '';
398  }
399 
400  return self::showCharacterDifference( $oldlen, $newlen, $this->getContext() );
401  }
402 
407  public function endRecentChangesList() {
408  $out = $this->rclistOpen ? "</ul>\n" : '';
409  $out .= '</div>';
410 
411  return $out;
412  }
413 
425  public static function revDateLink(
426  RevisionRecord $rev,
427  User $user,
428  Language $lang,
429  $title = null
430  ) {
431  $ts = $rev->getTimestamp();
432  $date = $lang->userTimeAndDate( $ts, $user );
433  if ( RevisionRecord::userCanBitfield(
434  $rev->getVisibility(),
435  RevisionRecord::DELETED_TEXT,
436  $user
437  ) ) {
438  $link = MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
439  $title ?? $rev->getPageAsLinkTarget(),
440  $date,
441  [ 'class' => 'mw-changeslist-date' ],
442  [ 'oldid' => $rev->getId() ]
443  );
444  } else {
445  $link = htmlspecialchars( $date );
446  }
447  if ( $rev->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
448  $link = "<span class=\"history-deleted 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->getUser() ) ) {
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  $articlelink = '<span class="history-deleted">' . $articlelink . '</span>';
565  }
566  # To allow for boldening pages watched by this user
567  $articlelink = "<span class=\"mw-title\">{$articlelink}</span>";
568  # RTL/LTR marker
569  $articlelink .= $this->getLanguage()->getDirMark();
570 
571  # TODO: Deprecate the $s argument, it seems happily unused.
572  $s = '';
573  $this->getHookRunner()->onChangesListInsertArticleLink( $this, $articlelink,
574  $s, $rc, $unpatrolled, $watched );
575 
576  // Watchlist expiry icon.
577  $watchlistExpiry = '';
578  if ( isset( $rc->watchlistExpiry ) && $rc->watchlistExpiry ) {
579  $watchlistExpiry = $this->getWatchlistExpiry( $rc );
580  }
581 
582  return "{$s} {$articlelink}{$watchlistExpiry}";
583  }
584 
591  public function getWatchlistExpiry( RecentChange $recentChange ): string {
592  $item = WatchedItem::newFromRecentChange( $recentChange, $this->getUser() );
593  // Guard against expired items, even though they shouldn't come here.
594  if ( $item->isExpired() ) {
595  return '';
596  }
597  $daysLeftText = $item->getExpiryInDaysText( $this->getContext() );
598  // Matching widget is also created in ChangesListSpecialPage, for the legend.
599  $widget = new IconWidget( [
600  'icon' => 'clock',
601  'title' => $daysLeftText,
602  'classes' => [ 'mw-changesList-watchlistExpiry' ],
603  ] );
604  // Add labels for assistive technologies.
605  $widget->setAttributes( [
606  'role' => 'img',
607  'aria-label' => $this->msg( 'watchlist-expires-in-aria-label' )->text(),
608  ] );
609  // Add spaces around the widget (the page title is to one side,
610  // and a semicolon or opening-parenthesis to the other).
611  return " $widget ";
612  }
613 
622  public function getTimestamp( $rc ) {
623  // This uses the semi-colon separator unless there's a watchlist expiry date for the entry,
624  // because in that case the timestamp is preceeded by a clock icon.
625  // A space is important after mw-changeslist-separator--semicolon to make sure
626  // that whatever comes before it is distinguishable.
627  // (Otherwise your have the text of titles pushing up against the timestamp)
628  // A specific element is used for this purpose as `mw-changeslist-date` is used in a variety
629  // of other places with a different position and the information proceeding getTimestamp can vary.
630  $separatorClass = $rc->watchlistExpiry ? 'mw-changeslist-separator' : 'mw-changeslist-separator--semicolon';
631  return Html::element( 'span', [ 'class' => $separatorClass ] ) . ' ' .
632  '<span class="mw-changeslist-date">' .
633  htmlspecialchars( $this->getLanguage()->userTime(
634  $rc->mAttribs['rc_timestamp'],
635  $this->getUser()
636  ) ) . '</span> <span class="mw-changeslist-separator"></span> ';
637  }
638 
645  public function insertTimestamp( &$s, $rc ) {
646  $s .= $this->getTimestamp( $rc );
647  }
648 
655  public function insertUserRelatedLinks( &$s, &$rc ) {
656  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_USER ) ) {
657  $s .= ' <span class="history-deleted">' .
658  $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
659  } else {
660  $s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'],
661  $rc->mAttribs['rc_user_text'] );
663  $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'],
664  false, 0, null,
665  // The text content of tools is not wrapped with parenthesises or "piped".
666  // This will be handled in CSS (T205581).
667  false
668  );
669  }
670  }
671 
678  public function insertLogEntry( $rc ) {
679  $formatter = LogFormatter::newFromRow( $rc->mAttribs );
680  $formatter->setContext( $this->getContext() );
681  $formatter->setShowUserToolLinks( true );
682  $mark = $this->getLanguage()->getDirMark();
683 
684  return Html::openElement( 'span', [ 'class' => 'mw-changeslist-log-entry' ] )
685  . $formatter->getActionText() . " $mark" . $formatter->getComment()
686  . Html::closeElement( 'span' );
687  }
688 
694  public function insertComment( $rc ) {
695  if ( $this->isDeleted( $rc, RevisionRecord::DELETED_COMMENT ) ) {
696  return ' <span class="history-deleted comment">' .
697  $this->msg( 'rev-deleted-comment' )->escaped() . '</span>';
698  } else {
699  return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle(),
700  // Whether section links should refer to local page (using default false)
701  false,
702  // wikid to generate links for (using default null) */
703  null,
704  // whether parentheses should be rendered as part of the message
705  false );
706  }
707  }
708 
714  protected function numberofWatchingusers( $count ) {
715  if ( $count <= 0 ) {
716  return '';
717  }
718 
719  return $this->watchMsgCache->getWithSetCallback(
720  "watching-users-msg:$count",
721  function () use ( $count ) {
722  return $this->msg( 'number-of-watching-users-for-recent-changes' )
723  ->numParams( $count )->escaped();
724  }
725  );
726  }
727 
734  public static function isDeleted( $rc, $field ) {
735  return ( $rc->mAttribs['rc_deleted'] & $field ) == $field;
736  }
737 
747  public static function userCan( $rc, $field, User $user = null ) {
748  if ( $user === null ) {
749  $user = RequestContext::getMain()->getUser();
750  }
751 
752  if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
753  return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
754  }
755 
756  return RevisionRecord::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
757  }
758 
764  protected function maybeWatchedLink( $link, $watched = false ) {
765  if ( $watched ) {
766  return '<strong class="mw-watched">' . $link . '</strong>';
767  } else {
768  return '<span class="mw-rc-unwatched">' . $link . '</span>';
769  }
770  }
771 
778  public function insertRollback( &$s, &$rc ) {
779  if ( $rc->mAttribs['rc_type'] == RC_EDIT
780  && $rc->mAttribs['rc_this_oldid']
781  && $rc->mAttribs['rc_cur_id']
782  && $rc->getAttribute( 'page_latest' ) == $rc->mAttribs['rc_this_oldid']
783  ) {
784  $title = $rc->getTitle();
788  if ( MediaWikiServices::getInstance()->getPermissionManager()
789  ->quickUserCan( 'rollback', $this->getUser(), $title )
790  ) {
791  $revRecord = new MutableRevisionRecord( $title );
792  $revRecord->setId( (int)$rc->mAttribs['rc_this_oldid'] );
793  $revRecord->setVisibility( (int)$rc->mAttribs['rc_deleted'] );
794  $user = new UserIdentityValue(
795  (int)$rc->mAttribs['rc_user'],
796  $rc->mAttribs['rc_user_text'],
797  (int)( $rc->mAttribs['rc_actor'] ?? 0 )
798  );
799  $revRecord->setUser( $user );
800 
801  $s .= ' ';
803  $revRecord,
804  $this->getContext(),
805  [ 'noBrackets' ]
806  );
807  }
808  }
809  }
810 
816  public function getRollback( RecentChange $rc ) {
817  $s = '';
818  $this->insertRollback( $s, $rc );
819  return $s;
820  }
821 
827  public function insertTags( &$s, &$rc, &$classes ) {
828  if ( empty( $rc->mAttribs['ts_tags'] ) ) {
829  return;
830  }
831 
832  list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
833  $rc->mAttribs['ts_tags'],
834  'changeslist',
835  $this->getContext()
836  );
837  $classes = array_merge( $classes, $newClasses );
838  $s .= ' ' . $tagSummary;
839  }
840 
847  public function getTags( RecentChange $rc, array &$classes ) {
848  $s = '';
849  $this->insertTags( $s, $rc, $classes );
850  return $s;
851  }
852 
853  public function insertExtra( &$s, &$rc, &$classes ) {
854  // Empty, used for subclasses to add anything special.
855  }
856 
857  protected function showAsUnpatrolled( RecentChange $rc ) {
858  return self::isUnpatrolled( $rc, $this->getUser() );
859  }
860 
866  public static function isUnpatrolled( $rc, User $user ) {
867  if ( $rc instanceof RecentChange ) {
868  $isPatrolled = $rc->mAttribs['rc_patrolled'];
869  $rcType = $rc->mAttribs['rc_type'];
870  $rcLogType = $rc->mAttribs['rc_log_type'];
871  } else {
872  $isPatrolled = $rc->rc_patrolled;
873  $rcType = $rc->rc_type;
874  $rcLogType = $rc->rc_log_type;
875  }
876 
877  if ( !$isPatrolled ) {
878  if ( $user->useRCPatrol() ) {
879  return true;
880  }
881  if ( $user->useNPPatrol() && $rcType == RC_NEW ) {
882  return true;
883  }
884  if ( $user->useFilePatrol() && $rcLogType == 'upload' ) {
885  return true;
886  }
887  }
888 
889  return false;
890  }
891 
901  protected function isCategorizationWithoutRevision( $rcObj ) {
902  return intval( $rcObj->getAttribute( 'rc_type' ) ) === RC_CATEGORIZE
903  && intval( $rcObj->getAttribute( 'rc_this_oldid' ) ) === 0;
904  }
905 
911  protected function getDataAttributes( RecentChange $rc ) {
912  $attrs = [];
913 
914  $type = $rc->getAttribute( 'rc_source' );
915  switch ( $type ) {
918  $attrs['data-mw-revid'] = $rc->mAttribs['rc_this_oldid'];
919  break;
921  $attrs['data-mw-logid'] = $rc->mAttribs['rc_logid'];
922  $attrs['data-mw-logaction'] =
923  $rc->mAttribs['rc_log_type'] . '/' . $rc->mAttribs['rc_log_action'];
924  break;
925  }
926 
927  $attrs[ 'data-mw-ts' ] = $rc->getAttribute( 'rc_timestamp' );
928 
929  return $attrs;
930  }
931 
939  public function setChangeLinePrefixer( callable $prefixer ) {
940  $this->changeLinePrefixer = $prefixer;
941  }
942 }
MediaWiki\User\UserIdentityValue
Value object representing a user's identity.
Definition: UserIdentityValue.php:34
ChangesList\endRecentChangesList
endRecentChangesList()
Returns text for the end of RC.
Definition: ChangesList.php:407
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:37
ContextSource\getConfig
getConfig()
Definition: ContextSource.php:70
ContextSource\getContext
getContext()
Get the base IContextSource object.
Definition: ContextSource.php:45
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:30
ChangesList\insertComment
insertComment( $rc)
Insert a formatted comment.
Definition: ChangesList.php:694
Revision\RevisionRecord
Page revision base class.
Definition: RevisionRecord.php:46
ChangesList\setWatchlistDivs
setWatchlistDivs( $value=true)
Sets the list to use a "<li class='watchlist-(namespace)-(page)'>" tag.
Definition: ChangesList.php:153
User\useFilePatrol
useFilePatrol()
Check whether to enable new files patrol features for this user.
Definition: User.php:3102
ChangesList\setChangeLinePrefixer
setChangeLinePrefixer(callable $prefixer)
Sets the callable that generates a change line prefix added to the beginning of each line.
Definition: ChangesList.php:939
IContextSource\getSkin
getSkin()
Linker\userLink
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition: Linker.php:896
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:160
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:37
Revision\RevisionRecord\isDeleted
isDeleted( $field)
MCR migration note: this replaces Revision::isDeleted.
Definition: RevisionRecord.php:412
RecentChange
Utility class for creating new RC entries.
Definition: RecentChange.php:73
ChangesList\$watchMsgCache
MapCacheLRU $watchMsgCache
Definition: ChangesList.php:56
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:41
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:941
ChangesList\maybeWatchedLink
maybeWatchedLink( $link, $watched=false)
Definition: ChangesList.php:764
RC_LOG
const RC_LOG
Definition: Defines.php:133
Revision\RevisionRecord\getTimestamp
getTimestamp()
MCR migration note: this replaces Revision::getTimestamp.
Definition: RevisionRecord.php:434
ChangesList\getTags
getTags(RecentChange $rc, array &$classes)
Definition: ChangesList.php:847
RC_EDIT
const RC_EDIT
Definition: Defines.php:131
ChangesList\getHighlightsContainerDiv
getHighlightsContainerDiv()
Get the container for highlights that are used in the new StructuredFilters system.
Definition: ChangesList.php:130
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1220
$s
$s
Definition: mergeMessageFileList.php:184
ChangesList\$rcCacheIndex
$rcCacheIndex
Definition: ChangesList.php:48
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:976
User\useNPPatrol
useNPPatrol()
Check whether to enable new pages patrol features for this user.
Definition: User.php:3090
ChangesList\formatCharacterDifference
formatCharacterDifference(RecentChange $old, RecentChange $new=null)
Format the character difference of one or several changes.
Definition: ChangesList.php:387
LogEventsList\userCanBitfield
static userCanBitfield( $bitfield, $field, User $user)
Determine if the current user is allowed to view a particular field of this log row,...
Definition: LogEventsList.php:540
User\useRCPatrol
useRCPatrol()
Check whether to enable recent changes patrol features for this user.
Definition: User.php:3081
ContextSource\getUser
getUser()
Stable to override.
Definition: ContextSource.php:134
ChangesList\$lastdate
$lastdate
Definition: ChangesList.php:45
WatchedItem\newFromRecentChange
static newFromRecentChange(RecentChange $recentChange, UserIdentity $user)
Definition: WatchedItem.php:87
RecentChange\SRC_LOG
const SRC_LOG
Definition: RecentChange.php:78
ChangesList\isDeleted
static isDeleted( $rc, $field)
Determine if said field of a revision is hidden.
Definition: ChangesList.php:734
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:143
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:66
Html\closeElement
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:315
$wgRecentChangesFlags
$wgRecentChangesFlags
Flags (letter symbols) shown in recent changes and watchlist to indicate certain types of edits.
Definition: DefaultSettings.php:7516
MessageLocalizer\msg
msg( $key,... $params)
This is the method for getting translated interface messages.
Linker\generateRollback
static generateRollback( $rev, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
Definition: Linker.php:1861
LogFormatter\newFromRow
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
Definition: LogFormatter.php:72
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
ChangesList\insertLogEntry
insertLogEntry( $rc)
Insert a formatted action.
Definition: ChangesList.php:678
getPermissionManager
getPermissionManager()
ContextSource\getOutput
getOutput()
Definition: ContextSource.php:124
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition: ContextSource.php:31
ChangesList\isWatchlist
isWatchlist()
Definition: ChangesList.php:161
ChangesList\insertTags
insertTags(&$s, &$rc, &$classes)
Definition: ChangesList.php:827
LogPage
Class to simplify the use of log pages.
Definition: LogPage.php:37
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:38
ChangesList\flag
static flag( $flag, IContextSource $context=null)
Make an "<abbr>" element for a given change flag.
Definition: ChangesList.php:269
ChangesList\CSS_CLASS_PREFIX
const CSS_CLASS_PREFIX
Definition: ChangesList.php:37
$title
$title
Definition: testCompression.php:38
RecentChange\SRC_EDIT
const SRC_EDIT
Definition: RecentChange.php:76
RecentChange\SRC_NEW
const SRC_NEW
Definition: RecentChange.php:77
ChangesList\insertUserRelatedLinks
insertUserRelatedLinks(&$s, &$rc)
Insert links to user page, user talk page and eventually a blocking link.
Definition: ChangesList.php:655
ContextSource\setContext
setContext(IContextSource $context)
Definition: ContextSource.php:61
ChangesList\getRollback
getRollback(RecentChange $rc)
Definition: ChangesList.php:816
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
Revision\RevisionRecord\getId
getId()
Get revision ID.
Definition: RevisionRecord.php:271
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:94
ChangesList\$rclistOpen
$rclistOpen
Definition: ChangesList.php:49
ChangesList\$changeLinePrefixer
callable $changeLinePrefixer
Definition: ChangesList.php:53
ChangesList\getDataAttributes
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
Definition: ChangesList.php:911
ContextSource\msg
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:187
EnhancedChangesList
Definition: EnhancedChangesList.php:26
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:1574
Revision\MutableRevisionRecord
Definition: MutableRevisionRecord.php:45
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:645
ChangesList\numberofWatchingusers
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
Definition: ChangesList.php:714
ChangesList\showAsUnpatrolled
showAsUnpatrolled(RecentChange $rc)
Definition: ChangesList.php:857
ChangesList\showCharacterDifference
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
Definition: ChangesList.php:333
IContextSource\getUser
getUser()
RC_NEW
const RC_NEW
Definition: Defines.php:132
ChangesList\preCacheMessages
preCacheMessages()
As we use the same small set of messages in various methods and that they are called often,...
Definition: ChangesList.php:169
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:454
ChangesList\$watchlist
$watchlist
Definition: ChangesList.php:44
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:55
ChangesList\getHTMLClasses
getHTMLClasses( $rc, $watched)
Get an array of default HTML class attributes for the change.
Definition: ChangesList.php:206
ChangesList\__construct
__construct( $obj, array $filterGroups=[])
Definition: ChangesList.php:72
RecentChange\getAttribute
getAttribute( $name)
Get an attribute value.
Definition: RecentChange.php:1058
Revision\RevisionRecord\getVisibility
getVisibility()
Get the deletion bitfield of the revision.
Definition: RevisionRecord.php:423
ChangesList\recentChangesFlags
recentChangesFlags( $flags, $nothing="\u{00A0}")
Returns the appropriate flags for new page, minor change and patrolling.
Definition: ChangesList.php:187
Revision\RevisionRecord\getPageAsLinkTarget
getPageAsLinkTarget()
Returns the title of the page this revision is associated with as a LinkTarget object.
Definition: RevisionRecord.php:343
ChangesList\beginRecentChangesList
beginRecentChangesList()
Returns text for the start of the tabular part of RC.
Definition: ChangesList.php:302
ChangesList\insertDiffHist
insertDiffHist(&$s, &$rc, $unpatrolled=null)
Definition: ChangesList.php:496
ChangesList\initChangesListRows
initChangesListRows( $rows)
Definition: ChangesList.php:319
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:901
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:251
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
ChangesList\getTimestamp
getTimestamp( $rc)
Get the timestamp from $rc formatted with current user's settings and a separator.
Definition: ChangesList.php:622
IContextSource\getRequest
getRequest()
ChangesList
Definition: ChangesList.php:34
ChangesList\$skin
Skin $skin
Definition: ChangesList.php:42
RC_CATEGORIZE
const RC_CATEGORIZE
Definition: Defines.php:135
ChangesList\isUnpatrolled
static isUnpatrolled( $rc, User $user)
Definition: ChangesList.php:866
ChangesList\$rc_cache
$rc_cache
Definition: ChangesList.php:47
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
ChangesList\$rcMoveIndex
$rcMoveIndex
Definition: ChangesList.php:50
ChangesList\revDateLink
static revDateLink(RevisionRecord $rev, User $user, 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:425
Skin
The main skin class which provides methods and properties for all other skins.
Definition: Skin.php:42
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:56
ChangesList\$message
$message
Definition: ChangesList.php:46
ChangeTags\formatSummaryRow
static formatSummaryRow( $tags, $page, IContextSource $context=null)
Creates HTML for the given tags.
Definition: ChangeTags.php:114
Language
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition: Language.php:41
ChangesList\getHTMLClassesForFilters
getHTMLClassesForFilters( $rc)
Get an array of CSS classes attributed to filters for this row.
Definition: ChangesList.php:237
ChangesList\recentChangesLine
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line.
Definition: ChangesList.php:120
ChangesList\userCan
static userCan( $rc, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this revision,...
Definition: ChangesList.php:747
ChangesList\insertExtra
insertExtra(&$s, &$rc, &$classes)
Definition: ChangesList.php:853
ChangesList\insertRollback
insertRollback(&$s, &$rc)
Insert a rollback link.
Definition: ChangesList.php:778
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:591
ChangesList\$linkRenderer
LinkRenderer $linkRenderer
Definition: ChangesList.php:61
$type
$type
Definition: testCompression.php:52