71 'mediawiki.special.changeslist.enhanced',
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 );
120 $this->rc_cache[$cacheGroupingKey][] = $cacheEntry;
132 $cacheGroupingKey = $title->getPrefixedDBkey();
134 $type = $cacheEntry->mAttribs[
'rc_type'];
138 $cacheGroupingKey = SpecialPage::getTitleFor(
140 $cacheEntry->mAttribs[
'rc_log_type']
141 )->getPrefixedDBkey();
144 return $cacheGroupingKey;
153 $recentChangesFlags = $this->
getConfig()->get( MainConfigNames::RecentChangesFlags );
155 # Add the namespace and title of the block as part of the class
156 $tableClasses = [
'mw-enhanced-rc',
'mw-changeslist-line' ];
157 if ( $block[0]->mAttribs[
'rc_log_type'] ) {
159 $tableClasses[] =
'mw-changeslist-log';
160 $tableClasses[] = Sanitizer::escapeClass(
'mw-changeslist-log-'
161 . $block[0]->mAttribs[
'rc_log_type'] );
163 $tableClasses[] =
'mw-changeslist-edit';
164 $tableClasses[] = Sanitizer::escapeClass(
'mw-changeslist-ns'
165 . $block[0]->mAttribs[
'rc_namespace'] .
'-' . $block[0]->mAttribs[
'rc_title'] );
167 if ( $block[0]->watched ) {
168 $tableClasses[] =
'mw-changeslist-line-watched';
170 $tableClasses[] =
'mw-changeslist-line-not-watched';
173 # Collate list of users
176 # Some catalyst variables...
179 $RCShowChangedSize = $this->
getConfig()->get( MainConfigNames::RCShowChangedSize );
181 # Default values for RC flags
182 $collectedRcFlags = [];
183 foreach ( $recentChangesFlags as $key => $value ) {
184 $flagGrouping = $value[
'grouping'] ??
'any';
185 switch ( $flagGrouping ) {
187 $collectedRcFlags[$key] =
true;
190 $collectedRcFlags[$key] =
false;
193 throw new DomainException(
"Unknown grouping type \"{$flagGrouping}\"" );
196 foreach ( $block as $rcObj ) {
202 $username = $rcObj->getPerformerIdentity()->getName();
203 $userlink = $rcObj->userlink;
204 if ( !isset( $usercounts[$username] ) ) {
205 $usercounts[$username] = 0;
206 $userlinks[$username] = $userlink;
208 if ( $rcObj->mAttribs[
'rc_type'] !=
RC_LOG ) {
212 $usercounts[$username]++;
215 # Sort the list and convert to text
216 krsort( $usercounts );
217 asort( $usercounts );
219 foreach ( $usercounts as $username => $count ) {
220 $text = $userlinks[$username];
223 $formattedCount = $this->
msg(
'ntimes' )->numParams( $count )->escaped();
224 $text .=
' ' . $this->
msg(
'parentheses' )->rawParams( $formattedCount )->escaped();
231 $revDeletedMsg =
false;
233 $revDeletedMsg = $this->
msg(
'rev-deleted-event' )->escaped();
234 } elseif ( $allLogs ) {
235 $articleLink = $this->
maybeWatchedLink( $block[0]->link, $block[0]->watched );
238 $block[0], $block[0]->unpatrolled, $block[0]->watched );
244 foreach ( $block as $i => $rcObj ) {
253 foreach ( $line[
'recentChangesFlagsRaw'] as $key => $value ) {
254 $flagGrouping = ( $recentChangesFlags[$key][
'grouping'] ??
'any' );
255 switch ( $flagGrouping ) {
258 $collectedRcFlags[$key] =
false;
263 $collectedRcFlags[$key] =
true;
267 throw new DomainException(
"Unknown grouping type \"{$flagGrouping}\"" );
274 $this->
getTags( $rcObj, $filterClasses );
275 $filterClasses = array_unique( $filterClasses );
282 $block = array_values( $block );
283 $filterClasses = array_values( $filterClasses );
285 if ( !$block || !
$lines ) {
290 $logText = $this->
getLogText( $block, [], $allLogs,
291 $collectedRcFlags[
'newpage'], $namehidden
294 # Character difference (does not apply if only log items)
295 $charDifference =
false;
296 if ( $RCShowChangedSize && !$allLogs ) {
298 $first = count( $block ) - 1;
299 # Some events (like logs and category changes) have an "empty" size, so we need to skip those...
300 while ( $last < $first && $block[$last]->mAttribs[
'rc_new_len'] ===
null ) {
303 while ( $last < $first && $block[$first]->mAttribs[
'rc_old_len'] ===
null ) {
311 $usersList = $this->
msg(
'brackets' )->rawParams(
312 implode( $this->message[
'semicolon-separator'], $users )
316 if ( is_callable( $this->changeLinePrefixer ) ) {
317 $prefix = call_user_func( $this->changeLinePrefixer, $block[0], $this,
true );
321 'checkboxId' =>
'mw-checkbox-' . base64_encode( random_bytes( 3 ) ),
322 'articleLink' => $articleLink,
323 'charDifference' => $charDifference,
325 'filterClasses' => $filterClasses,
326 'languageDirMark' => $this->
getLanguage()->getDirMark(),
328 'logText' => $logText,
329 'numberofWatchingusers' => $numberofWatchingusers,
331 'rev-deleted-event' => $revDeletedMsg,
332 'tableClasses' => $tableClasses,
333 'timestamp' => $block[0]->timestamp,
334 'fullTimestamp' => $block[0]->getAttribute(
'rc_timestamp' ),
335 'users' => $usersList,
338 $this->rcCacheIndex++;
340 return $this->templateParser->processTemplate(
341 'EnhancedChangesListGroup',
353 $RCShowChangedSize = $this->
getConfig()->get( MainConfigNames::RCShowChangedSize );
355 $type = $rcObj->mAttribs[
'rc_type'];
357 $lineParams = [
'targetTitle' => $rcObj->
getTitle() ];
359 $classes = [
'mw-enhanced-rc' ];
360 if ( $rcObj->watched ) {
361 $classes[] =
'mw-enhanced-watched';
363 $classes = array_merge( $classes, $this->
getHTMLClasses( $rcObj, $rcObj->watched ) );
365 $separator =
' <span class="mw-changeslist-separator"></span> ';
367 $data[
'recentChangesFlags'] = [
368 'newpage' => $type ==
RC_NEW,
369 'minor' => $rcObj->mAttribs[
'rc_minor'],
370 'unpatrolled' => $rcObj->unpatrolled,
371 'bot' => $rcObj->mAttribs[
'rc_bot'],
376 $link = htmlspecialchars( $rcObj->timestamp );
379 $link = Html::element(
'span', [
'class' =>
'history-deleted' ], $rcObj->timestamp );
382 $params[
'curid'] = $rcObj->mAttribs[
'rc_cur_id'];
383 if ( $rcObj->mAttribs[
'rc_this_oldid'] != 0 ) {
384 $params[
'oldid'] = $rcObj->mAttribs[
'rc_this_oldid'];
389 $link = $this->linkRenderer->makeKnownLink(
393 $params + $queryParams
395 if ( static::isDeleted( $rcObj, RevisionRecord::DELETED_TEXT ) ) {
396 $link =
'<span class="history-deleted">' . $link .
'</span> ';
399 $data[
'timestampLink'] = $link;
401 $currentAndLastLinks =
'';
403 $currentAndLastLinks .=
' ' . $this->
msg(
'parentheses' )->rawParams(
405 $this->message[
'pipe-separator'] .
409 $data[
'currentAndLastLinks'] = $currentAndLastLinks;
410 $data[
'separatorAfterCurrentAndLastLinks'] = $separator;
413 if ( $RCShowChangedSize ) {
416 $data[
'characterDiff'] = $cd;
417 $data[
'separatorAfterCharacterDiff'] = $separator;
427 $data[
'userLink'] = $rcObj->userlink;
428 $data[
'userTalkLink'] = $rcObj->usertalklink;
433 # Rollback, thanks etc...
438 $data[
'tags'] = $this->
getTags( $rcObj, $classes );
443 $success = $this->getHookRunner()->onEnhancedChangesListModifyLineData(
444 $this, $data, $block, $rcObj, $classes, $attribs );
449 $attribs = array_filter( $attribs,
450 [ Sanitizer::class,
'isReservedDataAttribute' ],
454 $lineParams[
'recentChangesFlagsRaw'] = [];
455 if ( isset( $data[
'recentChangesFlags'] ) ) {
456 $lineParams[
'recentChangesFlags'] = $this->
recentChangesFlags( $data[
'recentChangesFlags'] );
457 # FIXME: This is used by logic, don't return it in the template params.
458 $lineParams[
'recentChangesFlagsRaw'] = $data[
'recentChangesFlags'];
459 unset( $data[
'recentChangesFlags'] );
462 if ( isset( $data[
'timestampLink'] ) ) {
463 $lineParams[
'timestampLink'] = $data[
'timestampLink'];
464 unset( $data[
'timestampLink'] );
467 $lineParams[
'classes'] = array_values( $classes );
468 $lineParams[
'attribs'] = Html::expandAttributes( $attribs );
471 $lineParams[
'data'] = array_values( $data );
486 protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
492 static $nchanges = [];
493 static $sinceLastVisitMsg = [];
495 $n = count( $block );
496 if ( !isset( $nchanges[$n] ) ) {
497 $nchanges[$n] = $this->
msg(
'nchanges' )->numParams( $n )->escaped();
501 $unvisitedOldid =
null;
502 $currentRevision = 0;
503 $previousRevision = 0;
505 $allCategorization =
true;
507 foreach ( $block as $rcObj ) {
514 $allCategorization =
false;
515 $previousRevision = $rcObj->mAttribs[
'rc_last_oldid'];
517 if ( $rcObj->watched ) {
519 $unvisitedOldid = $previousRevision;
521 if ( !$currentRevision ) {
522 $currentRevision = $rcObj->mAttribs[
'rc_this_oldid'];
525 $curId = $rcObj->mAttribs[
'rc_cur_id'];
531 $title = $block[0]->getTitle();
535 if ( $isnew || $allCategorization ) {
536 $links[
'total-changes'] = Html::rawElement(
'span', [], $nchanges[$n] );
538 $links[
'total-changes'] = Html::rawElement(
'span', [],
539 $this->linkRenderer->makeKnownLink(
542 [
'class' =>
'mw-changeslist-groupdiff' ],
545 'diff' => $currentRevision,
546 'oldid' => $previousRevision,
553 !$allCategorization &&
557 if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
558 $sinceLastVisitMsg[$sinceLast] =
559 $this->
msg(
'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
561 $links[
'total-changes-since-last'] = Html::rawElement(
'span', [],
562 $this->linkRenderer->makeKnownLink(
564 new HtmlArmor( $sinceLastVisitMsg[$sinceLast] ),
565 [
'class' =>
'mw-changeslist-groupdiff' ],
568 'diff' => $currentRevision,
569 'oldid' => $unvisitedOldid,
577 if ( $allLogs || $allCategorization ) {
579 } elseif ( $namehidden || !$title->exists() ) {
580 $links[
'history'] = Html::rawElement(
'span', [], $this->message[
'enhancedrc-history'] );
582 $links[
'history'] = Html::rawElement(
'span', [],
583 $this->linkRenderer->makeKnownLink(
585 new HtmlArmor( $this->message[
'enhancedrc-history'] ),
586 [
'class' =>
'mw-changeslist-history' ],
589 'action' =>
'history',
596 $this->getHookRunner()->onEnhancedChangesList__getLogText( $this, $links, $block );
602 $logtext = Html::rawElement(
'span', [
'class' =>
'mw-changeslist-links' ],
603 implode(
' ', $links ) );
604 return ' ' . $logtext;
616 $type = $rcObj->mAttribs[
'rc_type'];
617 $logType = $rcObj->mAttribs[
'rc_log_type'];
619 $classes[] =
'mw-enhanced-rc';
623 $classes[] =
'mw-changeslist-log';
624 $classes[] = Sanitizer::escapeClass(
'mw-changeslist-log-' . $logType );
626 $classes[] =
'mw-changeslist-edit';
627 $classes[] = Sanitizer::escapeClass(
'mw-changeslist-ns' .
628 $rcObj->mAttribs[
'rc_namespace'] .
'-' . $rcObj->mAttribs[
'rc_title'] );
632 $data[
'recentChangesFlags'] = [
633 'newpage' => $type ==
RC_NEW,
634 'minor' => $rcObj->mAttribs[
'rc_minor'],
635 'unpatrolled' => $rcObj->unpatrolled,
636 'bot' => $rcObj->mAttribs[
'rc_bot'],
640 $data[
'timestampLink'] = htmlspecialchars( $rcObj->timestamp );
642 # Article or log link
644 $logPage =
new LogPage( $logType );
645 $logTitle = SpecialPage::getTitleFor(
'Log', $logType );
646 $logName = $logPage->getName()->text();
647 $data[
'logLink'] = Html::rawElement(
'span', [
'class' =>
'mw-changeslist-links' ],
648 $this->linkRenderer->makeKnownLink( $logTitle, $logName )
651 $data[
'articleLink'] = $this->
getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched );
654 # Diff and hist links
658 $data[
'separatorAfterLinks'] =
' <span class="mw-changeslist-separator"></span> ';
661 if ( $this->
getConfig()->
get( MainConfigNames::RCShowChangedSize ) ) {
664 $data[
'characterDiff'] = $cd;
665 $data[
'separatorAftercharacterDiff'] =
' <span class="mw-changeslist-separator"></span> ';
674 $data[
'userLink'] = $rcObj->userlink;
675 $data[
'userTalkLink'] = $rcObj->usertalklink;
684 $data[
'tags'] = $this->
getTags( $rcObj, $classes );
686 # Show how many people are watching this if enabled
689 $data[
'attribs'] = array_merge( $this->
getDataAttributes( $rcObj ), [
'class' => $classes ] );
692 $success = $this->getHookRunner()->onEnhancedChangesListModifyBlockLineData(
693 $this, $data, $rcObj );
698 $attribs = $data[
'attribs'];
699 unset( $data[
'attribs'] );
700 $attribs = array_filter( $attribs,
static function ( $key ) {
701 return $key ===
'class' || Sanitizer::isReservedDataAttribute( $key );
702 }, ARRAY_FILTER_USE_KEY );
705 if ( is_callable( $this->changeLinePrefixer ) ) {
706 $prefix = call_user_func( $this->changeLinePrefixer, $rcObj, $this,
false );
709 $line = Html::openElement(
'table', $attribs ) . Html::openElement(
'tr' );
711 $line .= Html::rawElement(
'td', [],
715 $line .= Html::rawElement(
'td', [],
'<span class="mw-enhancedchanges-arrow-space"></span>' );
716 $line .= Html::rawElement(
'td', [
'class' =>
'mw-changeslist-line-prefix' ], $prefix );
717 $line .=
'<td class="mw-enhanced-rc" colspan="2">';
719 if ( isset( $data[
'recentChangesFlags'] ) ) {
721 unset( $data[
'recentChangesFlags'] );
724 if ( isset( $data[
'timestampLink'] ) ) {
725 $line .=
"\u{00A0}" . $data[
'timestampLink'];
726 unset( $data[
'timestampLink'] );
728 $line .=
"\u{00A0}</td>";
729 $line .= Html::openElement(
'td', [
730 'class' =>
'mw-changeslist-line-inner',
732 'data-target-page' => $rcObj->getTitle(),
736 foreach ( $data as $key => $dataItem ) {
737 $line .= Html::rawElement(
'span', [
738 'class' =>
'mw-changeslist-line-inner-' . $key,
742 $line .=
"</td></tr></table>\n";
759 if ( is_bool( $query ) ) {
760 $useParentheses = $query;
761 } elseif ( $query !==
null ) {
762 wfDeprecated( __METHOD__ .
' with $query parameter',
'1.36' );
767 $pageTitle = Title::newFromID( $rc->
getAttribute(
'rc_cur_id' ) );
775 $histLink = $this->linkRenderer->makeKnownLink(
778 [
'class' =>
'mw-changeslist-history' ],
781 'action' =>
'history'
784 if ( $useParentheses !==
false ) {
785 $retVal = $this->
msg(
'parentheses' )
786 ->rawParams( $rc->difflink . $this->message[
'pipe-separator']
787 . $histLink )->escaped();
789 $retVal = Html::rawElement(
'span', [
'class' =>
'mw-changeslist-links' ],
790 Html::rawElement(
'span', [], $rc->difflink ) .
791 Html::rawElement(
'span', [], $histLink )
794 return ' ' . $retVal;
804 if ( count( $this->rc_cache ) == 0 ) {
809 foreach ( $this->rc_cache as $block ) {
810 if ( count( $block ) < 2 ) {
817 if ( $blockOut ===
'' ) {
821 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.
Parent class for all special pages.
getAttribute( $name)
Get an attribute value.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
if(!file_exists( $CREDITS)) $lines