71 'mediawiki.special.changeslist.enhanced',
74 'jquery.makeCollapsible',
77 parent::beginRecentChangesList();
78 return '<div class="mw-changeslist" aria-live="polite">';
92 $rc->mAttribs[
'rc_timestamp'],
95 if ( $this->lastdate ===
'' ) {
96 $this->lastdate = $date;
101 # If it's a new day, flush the cache and update $this->lastdate
102 if ( $date !== $this->lastdate ) {
103 # Process current cache (uses $this->lastdate to generate a heading)
105 $this->rc_cache = [];
106 $this->lastdate = $date;
109 $cacheEntry = $this->cacheEntryFactory->newFromRecentChange( $rc, $watched );
123 $this->rc_cache[$cacheGroupingKey][] = $cacheEntry;
135 $cacheGroupingKey =
$title->getPrefixedDBkey();
137 $type = $cacheEntry->mAttribs[
'rc_type'];
143 $cacheEntry->mAttribs[
'rc_log_type']
144 )->getPrefixedDBkey();
147 return $cacheGroupingKey;
157 $recentChangesFlags = $this->
getConfig()->get( MainConfigNames::RecentChangesFlags );
159 # Add the namespace and title of the block as part of the class
160 $tableClasses = [
'mw-collapsible',
'mw-collapsed',
'mw-enhanced-rc',
'mw-changeslist-line' ];
161 if ( $block[0]->mAttribs[
'rc_log_type'] ) {
163 $tableClasses[] =
'mw-changeslist-log';
165 . $block[0]->mAttribs[
'rc_log_type'] );
167 $tableClasses[] =
'mw-changeslist-edit';
169 . $block[0]->mAttribs[
'rc_namespace'] .
'-' . $block[0]->mAttribs[
'rc_title'] );
171 if ( $block[0]->watched ) {
172 $tableClasses[] =
'mw-changeslist-line-watched';
174 $tableClasses[] =
'mw-changeslist-line-not-watched';
177 # Collate list of users
180 # Some catalyst variables...
183 $RCShowChangedSize = $this->
getConfig()->get( MainConfigNames::RCShowChangedSize );
185 # Default values for RC flags
186 $collectedRcFlags = [];
187 foreach ( $recentChangesFlags as $key => $value ) {
188 $flagGrouping = $value[
'grouping'] ??
'any';
189 switch ( $flagGrouping ) {
191 $collectedRcFlags[$key] =
true;
194 $collectedRcFlags[$key] =
false;
197 throw new DomainException(
"Unknown grouping type \"{$flagGrouping}\"" );
200 foreach ( $block as $rcObj ) {
206 $username = $rcObj->getPerformerIdentity()->getName();
207 $userlink = $rcObj->userlink;
208 if ( !isset( $usercounts[$username] ) ) {
209 $usercounts[$username] = 0;
210 $userlinks[$username] = $userlink;
212 if ( $rcObj->mAttribs[
'rc_type'] !=
RC_LOG ) {
216 $usercounts[$username]++;
219 # Sort the list and convert to text
220 krsort( $usercounts );
221 asort( $usercounts );
223 foreach ( $usercounts as $username => $count ) {
224 $text = $userlinks[$username];
227 $formattedCount = $this->
msg(
'ntimes' )->numParams( $count )->escaped();
228 $text .=
' ' . $this->
msg(
'parentheses' )->rawParams( $formattedCount )->escaped();
235 $revDeletedMsg =
false;
237 $revDeletedMsg = $this->
msg(
'rev-deleted-event' )->escaped();
238 } elseif ( $allLogs ) {
239 $articleLink = $this->
maybeWatchedLink( $block[0]->link, $block[0]->watched );
242 $block[0], $block[0]->unpatrolled, $block[0]->watched );
248 foreach ( $block as $i => $rcObj ) {
257 foreach ( $line[
'recentChangesFlagsRaw'] as $key => $value ) {
258 $flagGrouping = ( $recentChangesFlags[$key][
'grouping'] ??
'any' );
259 switch ( $flagGrouping ) {
262 $collectedRcFlags[$key] =
false;
267 $collectedRcFlags[$key] =
true;
271 throw new DomainException(
"Unknown grouping type \"{$flagGrouping}\"" );
278 $this->
getTags( $rcObj, $filterClasses );
279 $filterClasses = array_unique( $filterClasses );
286 $block = array_values( $block );
287 $filterClasses = array_values( $filterClasses );
289 if ( empty( $block ) || !
$lines ) {
294 $logText = $this->
getLogText( $block, [], $allLogs,
295 $collectedRcFlags[
'newpage'], $namehidden
298 # Character difference (does not apply if only log items)
299 $charDifference =
false;
300 if ( $RCShowChangedSize && !$allLogs ) {
302 $first = count( $block ) - 1;
303 # Some events (like logs and category changes) have an "empty" size, so we need to skip those...
304 while ( $last < $first && $block[$last]->mAttribs[
'rc_new_len'] ===
null ) {
307 while ( $last < $first && $block[$first]->mAttribs[
'rc_old_len'] ===
null ) {
315 $usersList = $this->
msg(
'brackets' )->rawParams(
316 implode( $this->message[
'semicolon-separator'], $users )
320 if ( is_callable( $this->changeLinePrefixer ) ) {
321 $prefix = call_user_func( $this->changeLinePrefixer, $block[0], $this,
true );
325 'articleLink' => $articleLink,
326 'charDifference' => $charDifference,
328 'filterClasses' => $filterClasses,
329 'languageDirMark' => $this->
getLanguage()->getDirMark(),
331 'logText' => $logText,
332 'numberofWatchingusers' => $numberofWatchingusers,
334 'rev-deleted-event' => $revDeletedMsg,
335 'tableClasses' => $tableClasses,
336 'timestamp' => $block[0]->timestamp,
337 'fullTimestamp' => $block[0]->getAttribute(
'rc_timestamp' ),
338 'users' => $usersList,
341 $this->rcCacheIndex++;
343 return $this->templateParser->processTemplate(
344 'EnhancedChangesListGroup',
359 $RCShowChangedSize = $this->
getConfig()->get( MainConfigNames::RCShowChangedSize );
361 $type = $rcObj->mAttribs[
'rc_type'];
363 $lineParams = [
'targetTitle' => $rcObj->
getTitle() ];
365 $classes = [
'mw-enhanced-rc' ];
366 if ( $rcObj->watched ) {
367 $classes[] =
'mw-enhanced-watched';
369 $classes = array_merge( $classes, $this->
getHTMLClasses( $rcObj, $rcObj->watched ) );
371 $separator =
' <span class="mw-changeslist-separator"></span> ';
373 $data[
'recentChangesFlags'] = [
375 'minor' => $rcObj->mAttribs[
'rc_minor'],
376 'unpatrolled' => $rcObj->unpatrolled,
377 'bot' => $rcObj->mAttribs[
'rc_bot'],
382 $link = htmlspecialchars( $rcObj->timestamp );
385 $link = Html::element(
'span', [
'class' =>
'history-deleted' ], $rcObj->timestamp );
388 $params[
'curid'] = $rcObj->mAttribs[
'rc_cur_id'];
389 if ( $rcObj->mAttribs[
'rc_this_oldid'] != 0 ) {
390 $params[
'oldid'] = $rcObj->mAttribs[
'rc_this_oldid'];
395 $link = $this->linkRenderer->makeKnownLink(
399 $params + $queryParams
401 if ( static::isDeleted( $rcObj, RevisionRecord::DELETED_TEXT ) ) {
402 $link =
'<span class="history-deleted">' . $link .
'</span> ';
405 $data[
'timestampLink'] = $link;
407 $currentAndLastLinks =
'';
409 $currentAndLastLinks .=
' ' . $this->
msg(
'parentheses' )->rawParams(
411 $this->message[
'pipe-separator'] .
415 $data[
'currentAndLastLinks'] = $currentAndLastLinks;
416 $data[
'separatorAfterCurrentAndLastLinks'] = $separator;
419 if ( $RCShowChangedSize ) {
422 $data[
'characterDiff'] = $cd;
423 $data[
'separatorAfterCharacterDiff'] = $separator;
427 if ( $rcObj->mAttribs[
'rc_type'] ==
RC_LOG ) {
433 $data[
'userLink'] = $rcObj->userlink;
434 $data[
'userTalkLink'] = $rcObj->usertalklink;
438 # Rollback, thanks etc...
442 $data[
'tags'] = $this->
getTags( $rcObj, $classes );
447 $success = $this->getHookRunner()->onEnhancedChangesListModifyLineData(
448 $this, $data, $block, $rcObj, $classes, $attribs );
453 $attribs = array_filter( $attribs,
454 [ Sanitizer::class,
'isReservedDataAttribute' ],
458 $lineParams[
'recentChangesFlagsRaw'] = [];
459 if ( isset( $data[
'recentChangesFlags'] ) ) {
460 $lineParams[
'recentChangesFlags'] = $this->
recentChangesFlags( $data[
'recentChangesFlags'] );
461 # FIXME: This is used by logic, don't return it in the template params.
462 $lineParams[
'recentChangesFlagsRaw'] = $data[
'recentChangesFlags'];
463 unset( $data[
'recentChangesFlags'] );
466 if ( isset( $data[
'timestampLink'] ) ) {
467 $lineParams[
'timestampLink'] = $data[
'timestampLink'];
468 unset( $data[
'timestampLink'] );
471 $lineParams[
'classes'] = array_values( $classes );
472 $lineParams[
'attribs'] = Html::expandAttributes( $attribs );
475 $lineParams[
'data'] = array_values( $data );
490 protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
491 if ( empty( $block ) ) {
496 static $nchanges = [];
497 static $sinceLastVisitMsg = [];
499 $n = count( $block );
500 if ( !isset( $nchanges[$n] ) ) {
501 $nchanges[$n] = $this->
msg(
'nchanges' )->numParams( $n )->escaped();
505 $unvisitedOldid =
null;
506 $currentRevision = 0;
507 $previousRevision = 0;
509 $allCategorization =
true;
511 foreach ( $block as $rcObj ) {
518 $allCategorization =
false;
519 $previousRevision = $rcObj->mAttribs[
'rc_last_oldid'];
521 if ( $rcObj->watched ) {
523 $unvisitedOldid = $previousRevision;
525 if ( !$currentRevision ) {
526 $currentRevision = $rcObj->mAttribs[
'rc_this_oldid'];
529 $curId = $rcObj->mAttribs[
'rc_cur_id'];
535 $title = $block[0]->getTitle();
539 if ( $isnew || $allCategorization ) {
540 $links[
'total-changes'] = Html::rawElement(
'span', [], $nchanges[$n] );
542 $links[
'total-changes'] = Html::rawElement(
'span', [],
543 $this->linkRenderer->makeKnownLink(
546 [
'class' =>
'mw-changeslist-groupdiff' ],
549 'diff' => $currentRevision,
550 'oldid' => $previousRevision,
557 !$allCategorization &&
561 if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
562 $sinceLastVisitMsg[$sinceLast] =
563 $this->
msg(
'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
565 $links[
'total-changes-since-last'] = Html::rawElement(
'span', [],
566 $this->linkRenderer->makeKnownLink(
568 new HtmlArmor( $sinceLastVisitMsg[$sinceLast] ),
569 [
'class' =>
'mw-changeslist-groupdiff' ],
572 'diff' => $currentRevision,
573 'oldid' => $unvisitedOldid,
581 if ( $allLogs || $allCategorization ) {
583 } elseif ( $namehidden || !
$title->exists() ) {
584 $links[
'history'] = Html::rawElement(
'span', [], $this->message[
'enhancedrc-history'] );
586 $links[
'history'] = Html::rawElement(
'span', [],
587 $this->linkRenderer->makeKnownLink(
589 new HtmlArmor( $this->message[
'enhancedrc-history'] ),
590 [
'class' =>
'mw-changeslist-history' ],
593 'action' =>
'history',
600 $this->getHookRunner()->onEnhancedChangesList__getLogText( $this, $links, $block );
606 $logtext = Html::rawElement(
'span', [
'class' =>
'mw-changeslist-links' ],
607 implode(
' ', $links ) );
608 return ' ' . $logtext;
620 $type = $rcObj->mAttribs[
'rc_type'];
621 $logType = $rcObj->mAttribs[
'rc_log_type'];
623 $classes[] =
'mw-enhanced-rc';
627 $classes[] =
'mw-changeslist-log';
630 $classes[] =
'mw-changeslist-edit';
632 $rcObj->mAttribs[
'rc_namespace'] .
'-' . $rcObj->mAttribs[
'rc_title'] );
636 $data[
'recentChangesFlags'] = [
638 'minor' => $rcObj->mAttribs[
'rc_minor'],
639 'unpatrolled' => $rcObj->unpatrolled,
640 'bot' => $rcObj->mAttribs[
'rc_bot'],
644 $data[
'timestampLink'] = htmlspecialchars( $rcObj->timestamp );
646 # Article or log link
648 $logPage =
new LogPage( $logType );
650 $logName = $logPage->getName()->text();
651 $data[
'logLink'] = Html::rawElement(
'span', [
'class' =>
'mw-changeslist-links' ],
652 $this->linkRenderer->makeKnownLink( $logTitle, $logName )
655 $data[
'articleLink'] = $this->
getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched );
658 # Diff and hist links
662 $data[
'separatorAfterLinks'] =
' <span class="mw-changeslist-separator"></span> ';
665 if ( $this->
getConfig()->
get( MainConfigNames::RCShowChangedSize ) ) {
668 $data[
'characterDiff'] = $cd;
669 $data[
'separatorAftercharacterDiff'] =
' <span class="mw-changeslist-separator"></span> ';
678 $data[
'userLink'] = $rcObj->userlink;
679 $data[
'userTalkLink'] = $rcObj->usertalklink;
688 $data[
'tags'] = $this->
getTags( $rcObj, $classes );
690 # Show how many people are watching this if enabled
693 $data[
'attribs'] = array_merge( $this->
getDataAttributes( $rcObj ), [
'class' => $classes ] );
696 $success = $this->getHookRunner()->onEnhancedChangesListModifyBlockLineData(
697 $this, $data, $rcObj );
702 $attribs = $data[
'attribs'];
703 unset( $data[
'attribs'] );
704 $attribs = array_filter( $attribs,
static function ( $key ) {
706 }, ARRAY_FILTER_USE_KEY );
709 if ( is_callable( $this->changeLinePrefixer ) ) {
710 $prefix = call_user_func( $this->changeLinePrefixer, $rcObj, $this,
false );
713 $line = Html::openElement(
'table', $attribs ) . Html::openElement(
'tr' );
715 $line .= Html::rawElement(
'td', [],
719 $line .= Html::rawElement(
'td', [],
'<span class="mw-enhancedchanges-arrow-space"></span>' );
720 $line .= Html::rawElement(
'td', [
'class' =>
'mw-changeslist-line-prefix' ], $prefix );
721 $line .=
'<td class="mw-enhanced-rc" colspan="2">';
723 if ( isset( $data[
'recentChangesFlags'] ) ) {
725 unset( $data[
'recentChangesFlags'] );
728 if ( isset( $data[
'timestampLink'] ) ) {
729 $line .=
"\u{00A0}" . $data[
'timestampLink'];
730 unset( $data[
'timestampLink'] );
732 $line .=
"\u{00A0}</td>";
733 $line .= Html::openElement(
'td', [
734 'class' =>
'mw-changeslist-line-inner',
736 'data-target-page' => $rcObj->getTitle(),
740 foreach ( $data as $key => $dataItem ) {
741 $line .= Html::rawElement(
'span', [
742 'class' =>
'mw-changeslist-line-inner-' . $key,
746 $line .=
"</td></tr></table>\n";
763 if ( is_bool( $query ) ) {
764 $useParentheses = $query;
765 } elseif ( $query !==
null ) {
766 wfDeprecated( __METHOD__ .
' with $query parameter',
'1.36' );
771 $pageTitle = Title::newFromID( $rc->
getAttribute(
'rc_cur_id' ) );
779 $histLink = $this->linkRenderer->makeKnownLink(
782 [
'class' =>
'mw-changeslist-history' ],
785 'action' =>
'history'
788 if ( $useParentheses !==
false ) {
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 isReservedDataAttribute( $attr)
Given an attribute name, checks whether it is a reserved data attribute (such as data-mw-foo) which i...
static escapeClass( $class)
Given a value, escape it so that it can be used as a CSS class and return it.
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,...
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
if(!file_exists( $CREDITS)) $lines