25use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
36 use ProtectedHookAccessorTrait;
73 public function __construct( $obj, array $filterGroups = [] ) {
76 $this->skin = $obj->getSkin();
83 $this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
84 $this->filterGroups = $filterGroups;
99 if ( Hooks::runner()->onFetchChangesList( $user, $sk, $list, $groups ) ) {
100 $new = $context->
getRequest()->getBool(
'enhanced', $user->getOption(
'usenewrc' ) );
122 throw new RuntimeException(
'recentChangesLine should be implemented' );
132 $highlightColorDivs =
'';
133 foreach ( [
'none',
'c1',
'c2',
'c3',
'c4',
'c5' ] as $color ) {
134 $highlightColorDivs .= Html::rawElement(
137 'class' =>
'mw-rcfilters-ui-highlights-color-' . $color,
138 'data-color' => $color
143 return Html::rawElement(
145 [
'class' =>
'mw-rcfilters-ui-highlights' ],
155 $this->watchlist = $value;
163 return (
bool)$this->watchlist;
171 if ( !isset( $this->message ) ) {
174 'cur',
'diff',
'hist',
'enhancedrc-history',
'last',
'blocklink',
'history',
175 'semicolon-separator',
'pipe-separator' ] as $msg
177 $this->message[$msg] = $this->
msg( $msg )->escaped();
190 foreach ( array_keys( $this->
getConfig()->
get(
'RecentChangesFlags' ) ) as $flag ) {
191 $f .= isset( $flags[$flag] ) && $flags[$flag]
208 $classes = [ self::CSS_CLASS_PREFIX .
'line' ];
209 $logType = $rc->mAttribs[
'rc_log_type'];
212 $classes[] = self::CSS_CLASS_PREFIX .
'log';
213 $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX .
'log-' . $logType );
215 $classes[] = self::CSS_CLASS_PREFIX .
'edit';
216 $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX .
'ns' .
217 $rc->mAttribs[
'rc_namespace'] .
'-' . $rc->mAttribs[
'rc_title'] );
222 $classes[] = $watched && $rc->mAttribs[
'rc_timestamp'] >= $watched
223 ? self::CSS_CLASS_PREFIX .
'line-watched'
224 : self::CSS_CLASS_PREFIX .
'line-not-watched';
241 $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX .
'ns-' .
242 $rc->mAttribs[
'rc_namespace'] );
244 $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
245 $classes[] = Sanitizer::escapeClass(
246 self::CSS_CLASS_PREFIX .
248 ( $nsInfo->isTalk( $rc->mAttribs[
'rc_namespace'] ) ?
'talk' :
'subject' )
251 if ( $this->filterGroups !==
null ) {
252 foreach ( $this->filterGroups as $filterGroup ) {
253 foreach ( $filterGroup->getFilters() as $filter ) {
254 $filter->applyCssClassIfNeeded( $this, $rc, $classes );
273 static $map = [
'minoredit' =>
'minor',
'botedit' =>
'bot' ];
274 static $flagInfos =
null;
276 if ( $flagInfos ===
null ) {
280 $flagInfos[$key][
'letter'] = $value[
'letter'];
281 $flagInfos[$key][
'title'] = $value[
'title'];
283 $flagInfos[$key][
'class'] = $value[
'class'] ?? $key;
290 if ( isset( $map[$flag] ) ) {
294 $info = $flagInfos[$flag];
295 return Html::element(
'abbr', [
296 'class' => $info[
'class'],
306 $this->rc_cache = [];
307 $this->rcMoveIndex = 0;
308 $this->rcCacheIndex = 0;
309 $this->lastdate =
'';
310 $this->rclistOpen =
false;
312 'mediawiki.interface.helpers.styles',
313 'mediawiki.special.changeslist'
316 return '<div class="mw-changeslist">';
323 $this->getHookRunner()->onChangesListInitRows( $this, $rows );
338 $context = RequestContext::getMain();
343 $szdiff = $new - $old;
347 $code =
$lang->getCode();
348 static $fastCharDiff = [];
349 if ( !isset( $fastCharDiff[$code] ) ) {
350 $fastCharDiff[$code] = $config->get(
'MiserMode' )
351 ||
$context->
msg(
'rc-change-size' )->plain() ===
'$1';
354 $formattedSize =
$lang->formatNum( $szdiff );
356 if ( !$fastCharDiff[$code] ) {
357 $formattedSize =
$context->
msg(
'rc-change-size', $formattedSize )->text();
360 if ( abs( $szdiff ) > abs( $config->get(
'RCChangedSizeThreshold' ) ) ) {
366 if ( $szdiff === 0 ) {
367 $formattedSizeClass =
'mw-plusminus-null';
368 } elseif ( $szdiff > 0 ) {
369 $formattedSize =
'+' . $formattedSize;
370 $formattedSizeClass =
'mw-plusminus-pos';
372 $formattedSizeClass =
'mw-plusminus-neg';
374 $formattedSizeClass .=
' mw-diff-bytes';
376 $formattedTotalSize =
$context->
msg(
'rc-change-size-new' )->numParams( $new )->text();
378 return Html::element( $tag,
379 [
'dir' =>
'ltr',
'class' => $formattedSizeClass,
'title' => $formattedTotalSize ],
380 $formattedSize ) .
$lang->getDirMark();
391 $oldlen = $old->mAttribs[
'rc_old_len'];
394 $newlen = $new->mAttribs[
'rc_new_len'];
396 $newlen = $old->mAttribs[
'rc_new_len'];
399 if ( $oldlen ===
null || $newlen ===
null ) {
403 return self::showCharacterDifference( $oldlen, $newlen, $this->
getContext() );
411 $out = $this->rclistOpen ?
"</ul>\n" :
'';
435 $date =
$lang->userTimeAndDate( $ts, $performer->
getUser() );
436 if ( $rev->
userCan( RevisionRecord::DELETED_TEXT, $performer ) ) {
437 $link = MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
440 [
'class' =>
'mw-changeslist-date' ],
441 [
'oldid' => $rev->
getId() ]
444 $link = htmlspecialchars( $date );
446 if ( $rev->
isDeleted( RevisionRecord::DELETED_TEXT ) ) {
447 $link =
"<span class=\"history-deleted mw-changeslist-date\">$link</span>";
457 # Make date header if necessary
459 if ( $date != $this->lastdate ) {
460 if ( $this->lastdate !=
'' ) {
463 $s .= Xml::element(
'h4',
null, $date ) .
"\n<ul class=\"special\">";
464 $this->lastdate = $date;
465 $this->rclistOpen =
true;
476 $page =
new LogPage( $logtype );
477 $logname = $page->getName()->setContext( $this->
getContext() )->text();
478 $link = $this->linkRenderer->makeKnownLink(
$title, $logname, [
479 'class' => $useParentheses ?
'' :
'mw-changeslist-links'
481 if ( $useParentheses ) {
482 $s .= $this->
msg(
'parentheses' )->rawParams(
498 $rc->mAttribs[
'rc_type'] ==
RC_NEW ||
499 $rc->mAttribs[
'rc_type'] ==
RC_LOG ||
502 $diffLink = $this->message[
'diff'];
503 } elseif ( !self::userCan( $rc, RevisionRecord::DELETED_TEXT, $this->
getAuthority() ) ) {
504 $diffLink = $this->message[
'diff'];
507 'curid' => $rc->mAttribs[
'rc_cur_id'],
508 'diff' => $rc->mAttribs[
'rc_this_oldid'],
509 'oldid' => $rc->mAttribs[
'rc_last_oldid']
512 $diffLink = $this->linkRenderer->makeKnownLink(
515 [
'class' =>
'mw-changeslist-diff' ],
520 $histLink = $this->message[
'hist'];
522 $histLink = $this->linkRenderer->makeKnownLink(
525 [
'class' =>
'mw-changeslist-history' ],
527 'curid' => $rc->mAttribs[
'rc_cur_id'],
528 'action' =>
'history'
533 $s .= Html::rawElement(
'div', [
'class' =>
'mw-changeslist-links' ],
534 Html::rawElement(
'span', [], $diffLink ) .
535 Html::rawElement(
'span', [], $histLink )
537 ' <span class="mw-changeslist-separator"></span> ';
552 if ( $rc->getTitle()->isRedirect() ) {
553 $params = [
'redirect' =>
'no' ];
556 $articlelink = $this->linkRenderer->makeLink(
559 [
'class' =>
'mw-changeslist-title' ],
562 if ( $this->
isDeleted( $rc, RevisionRecord::DELETED_TEXT ) ) {
563 $articlelink =
'<span class="history-deleted">' . $articlelink .
'</span>';
565 # To allow for boldening pages watched by this user
566 $articlelink =
"<span class=\"mw-title\">{$articlelink}</span>";
568 $articlelink .= $this->
getLanguage()->getDirMark();
570 # TODO: Deprecate the $s argument, it seems happily unused.
572 $this->getHookRunner()->onChangesListInsertArticleLink( $this, $articlelink,
573 $s, $rc, $unpatrolled, $watched );
576 $watchlistExpiry =
'';
577 if ( isset( $rc->watchlistExpiry ) && $rc->watchlistExpiry ) {
581 return "{$s} {$articlelink}{$watchlistExpiry}";
593 if ( $item->isExpired() ) {
598 $widget =
new IconWidget( [
600 'title' => $daysLeftText,
601 'classes' => [
'mw-changesList-watchlistExpiry' ],
603 $widget->setAttributes( [
606 'aria-label' => $this->msg(
'watchlist-expires-in-aria-label' )->text(),
608 'data-days-left' => $item->getExpiryInDays(),
631 $separatorClass = $rc->watchlistExpiry ?
'mw-changeslist-separator' :
'mw-changeslist-separator--semicolon';
632 return Html::element(
'span', [
'class' => $separatorClass ] ) .
' ' .
633 '<span class="mw-changeslist-date">' .
634 htmlspecialchars( $this->getLanguage()->userTime(
635 $rc->mAttribs[
'rc_timestamp'],
637 ) ) .
'</span> <span class="mw-changeslist-separator"></span> ';
657 if ( $this->isDeleted( $rc, RevisionRecord::DELETED_USER ) ) {
658 $s .=
' <span class="history-deleted">' .
659 $this->msg(
'rev-deleted-user' )->escaped() .
'</span>';
661 $s .= $this->getLanguage()->getDirMark() .
Linker::userLink( $rc->mAttribs[
'rc_user'],
662 $rc->mAttribs[
'rc_user_text'] );
664 $rc->mAttribs[
'rc_user'], $rc->mAttribs[
'rc_user_text'],
681 $formatter->setContext( $this->
getContext() );
682 $formatter->setShowUserToolLinks(
true );
683 $mark = $this->getLanguage()->getDirMark();
685 return Html::openElement(
'span', [
'class' =>
'mw-changeslist-log-entry' ] )
686 . $formatter->getActionText() .
" $mark" . $formatter->getComment()
687 . Html::closeElement(
'span' );
696 if ( $this->isDeleted( $rc, RevisionRecord::DELETED_COMMENT ) ) {
697 return ' <span class="history-deleted comment">' .
698 $this->msg(
'rev-deleted-comment' )->escaped() .
'</span>';
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();
737 return ( $rc->mAttribs[
'rc_deleted'] & $field ) == $field;
750 if ( $performer ===
null ) {
751 $performer = RequestContext::getMain()->getAuthority();
754 if ( $rc->mAttribs[
'rc_type'] ==
RC_LOG ) {
755 return LogEventsList::userCanBitfield( $rc->mAttribs[
'rc_deleted'], $field, $performer );
758 return RevisionRecord::userCanBitfield( $rc->mAttribs[
'rc_deleted'], $field, $performer );
768 return '<strong class="mw-watched">' . $link .
'</strong>';
770 return '<span class="mw-rc-unwatched">' . $link .
'</span>';
781 if ( $rc->mAttribs[
'rc_type'] ==
RC_EDIT
782 && $rc->mAttribs[
'rc_this_oldid']
783 && $rc->mAttribs[
'rc_cur_id']
784 && $rc->getAttribute(
'page_latest' ) == $rc->mAttribs[
'rc_this_oldid']
792 $revRecord->setId( (
int)$rc->mAttribs[
'rc_this_oldid'] );
793 $revRecord->setVisibility( (
int)$rc->mAttribs[
'rc_deleted'] );
795 (
int)$rc->mAttribs[
'rc_user'],
796 $rc->mAttribs[
'rc_user_text']
798 $revRecord->setUser( $user );
817 $this->insertRollback(
$s, $rc );
827 if ( empty( $rc->mAttribs[
'ts_tags'] ) ) {
832 $rc->mAttribs[
'ts_tags'],
836 $classes = array_merge( $classes, $newClasses );
837 $s .=
' ' . $tagSummary;
848 $this->insertTags(
$s, $rc, $classes );
857 return self::isUnpatrolled( $rc, $this->getUser() );
867 $isPatrolled = $rc->mAttribs[
'rc_patrolled'];
868 $rcType = $rc->mAttribs[
'rc_type'];
869 $rcLogType = $rc->mAttribs[
'rc_log_type'];
871 $isPatrolled = $rc->rc_patrolled;
872 $rcType = $rc->rc_type;
873 $rcLogType = $rc->rc_log_type;
876 if ( !$isPatrolled ) {
901 return intval( $rcObj->getAttribute(
'rc_type' ) ) ===
RC_CATEGORIZE
902 && intval( $rcObj->getAttribute(
'rc_this_oldid' ) ) === 0;
915 case RecentChange::SRC_EDIT:
916 case RecentChange::SRC_NEW:
917 $attrs[
'data-mw-revid'] = $rc->mAttribs[
'rc_this_oldid'];
919 case RecentChange::SRC_LOG:
920 $attrs[
'data-mw-logid'] = $rc->mAttribs[
'rc_logid'];
921 $attrs[
'data-mw-logaction'] =
922 $rc->mAttribs[
'rc_log_type'] .
'/' . $rc->mAttribs[
'rc_log_action'];
926 $attrs[
'data-mw-ts' ] = $rc->
getAttribute(
'rc_timestamp' );
939 $this->changeLinePrefixer = $prefixer;
getWatchlistExpiry(WatchedItemStoreInterface $store, Title $title, UserIdentity $user)
Get existing expiry from the database.
$wgRecentChangesFlags
Flags (letter symbols) shown in recent changes and watchlist to indicate certain types of edits.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
static newFromContext(IContextSource $context, array $groups=[])
Fetch an appropriate changes list class for the specified context Some users might want to use an enh...
maybeWatchedLink( $link, $watched=false)
setWatchlistDivs( $value=true)
Sets the list to use a "<li class='watchlist-(namespace)-(page)'>" tag.
formatCharacterDifference(RecentChange $old, RecentChange $new=null)
Format the character difference of one or several changes.
insertDateHeader(&$s, $rc_timestamp)
insertRollback(&$s, &$rc)
Insert a rollback link.
showAsUnpatrolled(RecentChange $rc)
static isUnpatrolled( $rc, User $user)
getHighlightsContainerDiv()
Get the container for highlights that are used in the new StructuredFilters system.
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...
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line.
recentChangesFlags( $flags, $nothing="\u{00A0}")
Returns the appropriate flags for new page, minor change and patrolling.
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
getHTMLClasses( $rc, $watched)
Get an array of default HTML class attributes for the change.
getWatchlistExpiry(RecentChange $recentChange)
Get HTML to display the clock icon for watched items that have a watchlist expiry time.
callable $changeLinePrefixer
getTags(RecentChange $rc, array &$classes)
getArticleLink(&$rc, $unpatrolled, $watched)
Get the HTML link to the changed page, possibly with a prefix from hook handlers, and a suffix for te...
insertUserRelatedLinks(&$s, &$rc)
Insert links to user page, user talk page and eventually a blocking link.
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
getRollback(RecentChange $rc)
MapCacheLRU $watchMsgCache
endRecentChangesList()
Returns text for the end of RC.
static flag( $flag, IContextSource $context=null)
Make an "<abbr>" element for a given change flag.
LinkRenderer $linkRenderer
preCacheMessages()
As we use the same small set of messages in various methods and that they are called often,...
insertLogEntry( $rc)
Insert a formatted action.
setChangeLinePrefixer(callable $prefixer)
Sets the callable that generates a change line prefix added to the beginning of each line.
static isDeleted( $rc, $field)
Determine if said field of a revision is hidden.
insertLog(&$s, $title, $logtype, $useParentheses=true)
insertTags(&$s, &$rc, &$classes)
insertComment( $rc)
Insert a formatted comment.
static userCan( $rc, $field, Authority $performer=null)
Determine if the current user is allowed to view a particular field of this revision,...
insertExtra(&$s, &$rc, &$classes)
__construct( $obj, array $filterGroups=[])
initChangesListRows( $rows)
getTimestamp( $rc)
Get the timestamp from $rc formatted with current user's settings and a separator.
isCategorizationWithoutRevision( $rcObj)
Determines whether a revision is linked to this change; this may not be the case when the categorizat...
getHTMLClassesForFilters( $rc)
Get an array of CSS classes attributed to filters for this row.
insertDiffHist(&$s, &$rc, $unpatrolled=null)
insertTimestamp(&$s, $rc)
Insert time timestamp string from $rc into $s.
beginRecentChangesList()
Returns text for the start of the tabular part of RC.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
setContext(IContextSource $context)
Marks HTML that shouldn't be escaped.
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
static generateRollback( $rev, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
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...
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null, $useParentheses=true)
Generate standard user tool links (talk, contributions, block link, etc.)
Class to simplify the use of log pages.
Handles a simple LRU key/value map with a maximum number of entries.
Utility class for creating new RC entries.
getAttribute( $name)
Get an attribute value.
The main skin class which provides methods and properties for all other skins.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
useFilePatrol()
Check whether to enable new files patrol features for this user.
useNPPatrol()
Check whether to enable new pages patrol features for this user.
useRCPatrol()
Check whether to enable recent changes patrol features for this user.
Representation of a pair of user and title for watchlist entries.
getExpiryInDaysText(MessageLocalizer $msgLocalizer, $isDropdownOption=false)
Get days remaining until a watched item expires as a text.
Interface for objects which can provide a MediaWiki context on request.
getConfig()
Get the site configuration.
msg( $key,... $params)
This is the method for getting translated interface messages.
foreach( $mmfl['setupFiles'] as $fileName) if($queue) if(empty( $mmfl['quiet'])) $s
if(!isset( $args[0])) $lang