49 public function __construct( $context, array $filterGroups = [] ) {
68 'mediawiki.special.changeslist.enhanced',
71 'jquery.makeCollapsible',
74 parent::beginRecentChangesList();
75 return '<div class="mw-changeslist" aria-live="polite">';
89 $rc->mAttribs[
'rc_timestamp'],
92 if ( $this->lastdate ===
'' ) {
93 $this->lastdate = $date;
98 # If it's a new day, flush the cache and update $this->lastdate
99 if ( $date !== $this->lastdate ) {
100 # Process current cache (uses $this->lastdate to generate a heading)
102 $this->rc_cache = [];
103 $this->lastdate = $date;
106 $cacheEntry = $this->cacheEntryFactory->newFromRecentChange( $rc, $watched );
121 if ( !isset( $this->rc_cache[$cacheGroupingKey] ) ) {
122 $this->rc_cache[$cacheGroupingKey] = [];
125 array_push( $this->rc_cache[$cacheGroupingKey], $cacheEntry );
137 $cacheGroupingKey =
$title->getPrefixedDBkey();
139 $type = $cacheEntry->mAttribs[
'rc_type'];
145 $cacheEntry->mAttribs[
'rc_log_type']
146 )->getPrefixedDBkey();
149 return $cacheGroupingKey;
159 $recentChangesFlags = $this->
getConfig()->get( MainConfigNames::RecentChangesFlags );
161 # Add the namespace and title of the block as part of the class
162 $tableClasses = [
'mw-collapsible',
'mw-collapsed',
'mw-enhanced-rc',
'mw-changeslist-line' ];
163 if ( $block[0]->mAttribs[
'rc_log_type'] ) {
165 $tableClasses[] =
'mw-changeslist-log';
166 $tableClasses[] = Sanitizer::escapeClass(
'mw-changeslist-log-'
167 . $block[0]->mAttribs[
'rc_log_type'] );
169 $tableClasses[] =
'mw-changeslist-edit';
170 $tableClasses[] = Sanitizer::escapeClass(
'mw-changeslist-ns'
171 . $block[0]->mAttribs[
'rc_namespace'] .
'-' . $block[0]->mAttribs[
'rc_title'] );
173 if ( $block[0]->watched ) {
174 $tableClasses[] =
'mw-changeslist-line-watched';
176 $tableClasses[] =
'mw-changeslist-line-not-watched';
179 # Collate list of users
183 # Some catalyst variables...
186 $RCShowChangedSize = $this->
getConfig()->get( MainConfigNames::RCShowChangedSize );
188 # Default values for RC flags
189 $collectedRcFlags = [];
190 foreach ( $recentChangesFlags as $key => $value ) {
191 $flagGrouping = $value[
'grouping'] ??
'any';
192 switch ( $flagGrouping ) {
194 $collectedRcFlags[$key] =
true;
197 $collectedRcFlags[$key] =
false;
200 throw new DomainException(
"Unknown grouping type \"{$flagGrouping}\"" );
203 foreach ( $block as $rcObj ) {
209 $u = $rcObj->userlink;
210 if ( !isset( $userlinks[$u] ) ) {
213 if ( $rcObj->mAttribs[
'rc_type'] !=
RC_LOG ) {
216 # Get the latest entry with a page_id and oldid
217 # since logs may not have these.
218 if ( !$curId && $rcObj->mAttribs[
'rc_cur_id'] ) {
219 $curId = $rcObj->mAttribs[
'rc_cur_id'];
225 # Sort the list and convert to text
226 krsort( $userlinks );
229 foreach ( $userlinks as $userlink => $count ) {
233 $formattedCount = $this->
msg(
'ntimes' )->numParams( $count )->escaped();
234 $text .=
' ' . $this->
msg(
'parentheses' )->rawParams( $formattedCount )->escaped();
236 array_push( $users, $text );
241 $revDeletedMsg =
false;
243 $revDeletedMsg = $this->
msg(
'rev-deleted-event' )->escaped();
244 } elseif ( $allLogs ) {
245 $articleLink = $this->
maybeWatchedLink( $block[0]->link, $block[0]->watched );
248 $block[0], $block[0]->unpatrolled, $block[0]->watched );
251 $queryParams = [
'curid' => $curId ];
256 foreach ( $block as $i => $rcObj ) {
265 foreach (
$line[
'recentChangesFlagsRaw'] as $key => $value ) {
266 $flagGrouping = ( $recentChangesFlags[$key][
'grouping'] ??
'any' );
267 switch ( $flagGrouping ) {
270 $collectedRcFlags[$key] =
false;
275 $collectedRcFlags[$key] =
true;
279 throw new DomainException(
"Unknown grouping type \"{$flagGrouping}\"" );
286 $this->
getTags( $rcObj, $filterClasses );
287 $filterClasses = array_unique( $filterClasses );
294 $block = array_values( $block );
295 $filterClasses = array_values( $filterClasses );
297 if ( empty( $block ) || !
$lines ) {
302 $logText = $this->
getLogText( $block, $queryParams, $allLogs,
303 $collectedRcFlags[
'newpage'], $namehidden
306 # Character difference (does not apply if only log items)
307 $charDifference =
false;
308 if ( $RCShowChangedSize && !$allLogs ) {
310 $first = count( $block ) - 1;
311 # Some events (like logs and category changes) have an "empty" size, so we need to skip those...
312 while ( $last < $first && $block[$last]->mAttribs[
'rc_new_len'] ===
null ) {
315 while ( $last < $first && $block[$first]->mAttribs[
'rc_old_len'] ===
null ) {
323 $usersList = $this->
msg(
'brackets' )->rawParams(
324 implode( $this->message[
'semicolon-separator'], $users )
328 if ( is_callable( $this->changeLinePrefixer ) ) {
329 $prefix = call_user_func( $this->changeLinePrefixer, $block[0], $this,
true );
333 'articleLink' => $articleLink,
334 'charDifference' => $charDifference,
336 'filterClasses' => $filterClasses,
337 'languageDirMark' => $this->
getLanguage()->getDirMark(),
339 'logText' => $logText,
340 'numberofWatchingusers' => $numberofWatchingusers,
342 'rev-deleted-event' => $revDeletedMsg,
343 'tableClasses' => $tableClasses,
344 'timestamp' => $block[0]->timestamp,
345 'fullTimestamp' => $block[0]->getAttribute(
'rc_timestamp' ),
346 'users' => $usersList,
349 $this->rcCacheIndex++;
351 return $this->templateParser->processTemplate(
352 'EnhancedChangesListGroup',
367 $RCShowChangedSize = $this->
getConfig()->get( MainConfigNames::RCShowChangedSize );
369 $type = $rcObj->mAttribs[
'rc_type'];
371 $lineParams = [
'targetTitle' => $rcObj->
getTitle() ];
373 $classes = [
'mw-enhanced-rc' ];
374 if ( $rcObj->watched ) {
375 $classes[] =
'mw-enhanced-watched';
377 $classes = array_merge( $classes, $this->
getHTMLClasses( $rcObj, $rcObj->watched ) );
379 $separator =
' <span class="mw-changeslist-separator"></span> ';
381 $data[
'recentChangesFlags'] = [
383 'minor' => $rcObj->mAttribs[
'rc_minor'],
384 'unpatrolled' => $rcObj->unpatrolled,
385 'bot' => $rcObj->mAttribs[
'rc_bot'],
388 $params = $queryParams;
390 if ( $rcObj->mAttribs[
'rc_this_oldid'] != 0 ) {
391 $params[
'oldid'] = $rcObj->mAttribs[
'rc_this_oldid'];
396 $link = htmlspecialchars( $rcObj->timestamp );
399 $link = Html::element(
'span', [
'class' =>
'history-deleted' ], $rcObj->timestamp );
401 $link = $this->linkRenderer->makeKnownLink(
407 if ( static::isDeleted( $rcObj, RevisionRecord::DELETED_TEXT ) ) {
408 $link =
'<span class="history-deleted">' . $link .
'</span> ';
411 $data[
'timestampLink'] = $link;
413 $currentAndLastLinks =
'';
415 $currentAndLastLinks .=
' ' . $this->
msg(
'parentheses' )->rawParams(
417 $this->message[
'pipe-separator'] .
421 $data[
'currentAndLastLinks'] = $currentAndLastLinks;
422 $data[
'separatorAfterCurrentAndLastLinks'] = $separator;
425 if ( $RCShowChangedSize ) {
428 $data[
'characterDiff'] = $cd;
429 $data[
'separatorAfterCharacterDiff'] = $separator;
433 if ( $rcObj->mAttribs[
'rc_type'] ==
RC_LOG ) {
439 $data[
'userLink'] = $rcObj->userlink;
440 $data[
'userTalkLink'] = $rcObj->usertalklink;
448 $data[
'tags'] = $this->
getTags( $rcObj, $classes );
453 $success = $this->getHookRunner()->onEnhancedChangesListModifyLineData(
454 $this, $data, $block, $rcObj, $classes, $attribs );
459 $attribs = array_filter( $attribs,
460 [ Sanitizer::class,
'isReservedDataAttribute' ],
464 $lineParams[
'recentChangesFlagsRaw'] = [];
465 if ( isset( $data[
'recentChangesFlags'] ) ) {
466 $lineParams[
'recentChangesFlags'] = $this->
recentChangesFlags( $data[
'recentChangesFlags'] );
467 # FIXME: This is used by logic, don't return it in the template params.
468 $lineParams[
'recentChangesFlagsRaw'] = $data[
'recentChangesFlags'];
469 unset( $data[
'recentChangesFlags'] );
472 if ( isset( $data[
'timestampLink'] ) ) {
473 $lineParams[
'timestampLink'] = $data[
'timestampLink'];
474 unset( $data[
'timestampLink'] );
477 $lineParams[
'classes'] = array_values( $classes );
478 $lineParams[
'attribs'] = Html::expandAttributes( $attribs );
481 $lineParams[
'data'] = array_values( $data );
496 protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
497 if ( empty( $block ) ) {
502 static $nchanges = [];
503 static $sinceLastVisitMsg = [];
505 $n = count( $block );
506 if ( !isset( $nchanges[$n] ) ) {
507 $nchanges[$n] = $this->
msg(
'nchanges' )->numParams( $n )->escaped();
511 $unvisitedOldid =
null;
513 foreach ( $block as $rcObj ) {
515 if ( $rcObj->watched ) {
517 $unvisitedOldid = $rcObj->mAttribs[
'rc_last_oldid'];
520 if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
521 $sinceLastVisitMsg[$sinceLast] =
522 $this->
msg(
'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
525 $currentRevision = 0;
526 foreach ( $block as $rcObj ) {
527 if ( !$currentRevision ) {
528 $currentRevision = $rcObj->mAttribs[
'rc_this_oldid'];
536 $last = $block[count( $block ) - 1];
543 $links[
'total-changes'] = Html::rawElement(
'span', [], $nchanges[$n] );
545 $links[
'total-changes'] = Html::rawElement(
'span', [],
546 $this->linkRenderer->makeKnownLink(
549 [
'class' =>
'mw-changeslist-groupdiff' ],
551 'diff' => $currentRevision,
552 'oldid' => $last->mAttribs[
'rc_last_oldid'],
563 $links[
'total-changes-since-last'] = Html::rawElement(
'span', [],
564 $this->linkRenderer->makeKnownLink(
566 new HtmlArmor( $sinceLastVisitMsg[$sinceLast] ),
567 [
'class' =>
'mw-changeslist-groupdiff' ],
569 'diff' => $currentRevision,
570 'oldid' => $unvisitedOldid,
578 if ( $allLogs || $rcObj->mAttribs[
'rc_type'] ==
RC_CATEGORIZE ) {
580 } elseif ( $namehidden || !$block0->getTitle()->exists() ) {
581 $links[
'history'] = Html::rawElement(
'span', [], $this->message[
'enhancedrc-history'] );
583 $params = $queryParams;
584 $params[
'action'] =
'history';
586 $links[
'history'] = Html::rawElement(
'span', [],
587 $this->linkRenderer->makeKnownLink(
589 new HtmlArmor( $this->message[
'enhancedrc-history'] ),
590 [
'class' =>
'mw-changeslist-history' ],
596 # Allow others to alter, remove or add to these links
597 $this->getHookRunner()->onEnhancedChangesList__getLogText( $this, $links, $block );
603 $logtext = Html::rawElement(
'span', [
'class' =>
'mw-changeslist-links' ],
604 implode(
' ', $links ) );
605 return ' ' . $logtext;
617 $type = $rcObj->mAttribs[
'rc_type'];
618 $logType = $rcObj->mAttribs[
'rc_log_type'];
620 $classes[] =
'mw-enhanced-rc';
624 $classes[] =
'mw-changeslist-log';
625 $classes[] = Sanitizer::escapeClass(
'mw-changeslist-log-' . $logType );
627 $classes[] =
'mw-changeslist-edit';
628 $classes[] = Sanitizer::escapeClass(
'mw-changeslist-ns' .
629 $rcObj->mAttribs[
'rc_namespace'] .
'-' . $rcObj->mAttribs[
'rc_title'] );
633 $data[
'recentChangesFlags'] = [
635 'minor' => $rcObj->mAttribs[
'rc_minor'],
636 'unpatrolled' => $rcObj->unpatrolled,
637 'bot' => $rcObj->mAttribs[
'rc_bot'],
641 $data[
'timestampLink'] = htmlspecialchars( $rcObj->timestamp );
643 # Article or log link
645 $logPage =
new LogPage( $logType );
647 $logName = $logPage->getName()->text();
648 $data[
'logLink'] = Html::rawElement(
'span', [
'class' =>
'mw-changeslist-links' ],
649 $this->linkRenderer->makeKnownLink( $logTitle, $logName )
652 $data[
'articleLink'] = $this->
getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched );
655 # Diff and hist links
659 $data[
'separatorAfterLinks'] =
' <span class="mw-changeslist-separator"></span> ';
662 if ( $this->
getConfig()->
get( MainConfigNames::RCShowChangedSize ) ) {
665 $data[
'characterDiff'] = $cd;
666 $data[
'separatorAftercharacterDiff'] =
' <span class="mw-changeslist-separator"></span> ';
675 $data[
'userLink'] = $rcObj->userlink;
676 $data[
'userTalkLink'] = $rcObj->usertalklink;
685 $data[
'tags'] = $this->
getTags( $rcObj, $classes );
687 # Show how many people are watching this if enabled
690 $data[
'attribs'] = array_merge( $this->
getDataAttributes( $rcObj ), [
'class' => $classes ] );
693 $success = $this->getHookRunner()->onEnhancedChangesListModifyBlockLineData(
694 $this, $data, $rcObj );
699 $attribs = $data[
'attribs'];
700 unset( $data[
'attribs'] );
701 $attribs = array_filter( $attribs,
static function ( $key ) {
702 return $key ===
'class' || Sanitizer::isReservedDataAttribute( $key );
703 }, ARRAY_FILTER_USE_KEY );
706 if ( is_callable( $this->changeLinePrefixer ) ) {
707 $prefix = call_user_func( $this->changeLinePrefixer, $rcObj, $this,
false );
710 $line = Html::openElement(
'table', $attribs ) . Html::openElement(
'tr' );
712 $line .= Html::rawElement(
'td', [],
716 $line .= Html::rawElement(
'td', [],
'<span class="mw-enhancedchanges-arrow-space"></span>' );
717 $line .= Html::rawElement(
'td', [
'class' =>
'mw-changeslist-line-prefix' ], $prefix );
718 $line .=
'<td class="mw-enhanced-rc" colspan="2">';
720 if ( isset( $data[
'recentChangesFlags'] ) ) {
722 unset( $data[
'recentChangesFlags'] );
725 if ( isset( $data[
'timestampLink'] ) ) {
726 $line .=
"\u{00A0}" . $data[
'timestampLink'];
727 unset( $data[
'timestampLink'] );
729 $line .=
"\u{00A0}</td>";
730 $line .= Html::openElement(
'td', [
731 'class' =>
'mw-changeslist-line-inner',
733 'data-target-page' => $rcObj->getTitle(),
737 foreach ( $data as $key => $dataItem ) {
738 $line .= Html::rawElement(
'span', [
739 'class' =>
'mw-changeslist-line-inner-' . $key,
743 $line .=
"</td></tr></table>\n";
760 if ( is_bool( $query ) ) {
761 $useParentheses = $query;
762 } elseif ( $query !==
null ) {
763 wfDeprecated( __METHOD__ .
' with $query parameter',
'1.36' );
765 if ( $useParentheses ===
null ) {
766 $useParentheses =
true;
771 $pageTitle = Title::newFromID( $rc->
getAttribute(
'rc_cur_id' ) );
779 $histLink = $this->linkRenderer->makeKnownLink(
782 [
'class' =>
'mw-changeslist-history' ],
784 'action' =>
'history',
788 if ( $useParentheses ) {
789 $retVal = $this->
msg(
'parentheses' )
790 ->rawParams( $rc->difflink . $this->message[
'pipe-separator']
791 . $histLink )->escaped();
793 $retVal = Html::rawElement(
'span', [
'class' =>
'mw-changeslist-links' ],
794 Html::rawElement(
'span', [], $rc->difflink ) .
795 Html::rawElement(
'span', [], $histLink )
798 return ' ' . $retVal;
808 if ( count( $this->rc_cache ) == 0 ) {
813 foreach ( $this->rc_cache as $block ) {
814 if ( count( $block ) < 2 ) {
821 if ( $blockOut ===
'' ) {
825 return Xml::element(
'h4',
null, $this->lastdate ) .
"\n<div>" . $blockOut .
'</div>';
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
maybeWatchedLink( $link, $watched=false)
formatCharacterDifference(RecentChange $old, RecentChange $new=null)
Format the character difference of one or several changes.
getHighlightsContainerDiv()
Get the container for highlights that are used in the new StructuredFilters system.
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.
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...
getRollback(RecentChange $rc)
insertLogEntry( $rc)
Insert a formatted action.
ChangesListFilterGroup[] $filterGroups
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,...
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.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
RCCacheEntry[][] $rc_cache
TemplateParser $templateParser
recentChangesBlock()
If enhanced RC is in use, this function takes the previously cached RC lines, arranges them,...
getDiffHistLinks(RCCacheEntry $rc, $query=null, $useParentheses=null)
Returns value to be used in 'historyLink' element of $data param in EnhancedChangesListModifyBlockLin...
makeCacheGroupingKey(RCCacheEntry $cacheEntry)
beginRecentChangesList()
Add the JavaScript file for enhanced changeslist.
__construct( $context, array $filterGroups=[])
endRecentChangesList()
Returns text for the end of RC If enhanced RC is in use, returns pretty much all the text.
addCacheEntry(RCCacheEntry $cacheEntry)
Put accumulated information into the cache, for later display.
RCCacheEntryFactory $cacheEntryFactory
recentChangesBlockGroup( $block)
Enhanced RC group.
getLineData(array $block, RCCacheEntry $rcObj, array $queryParams=[])
recentChangesBlockLine( $rcObj)
Enhanced RC ungrouped line.
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line for enhanced recentchange (aka with javascript and block of lines).
getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden)
Generates amount of changes (linking to diff ) & link to history.
Marks HTML that shouldn't be escaped.
Class to simplify the use of log pages.
A class containing constants representing the names of configuration variables.
getAttribute( $name)
Get an attribute value.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
if(!file_exists( $CREDITS)) $lines