3 use MediaWiki\Storage\RevisionRecord
;
6 * Generates a list of changes using an Enhanced system (uses javascript).
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
26 class EnhancedChangesList
extends ChangesList
{
29 * @var RCCacheEntryFactory
31 protected $cacheEntryFactory;
34 * @var array Array of array of RCCacheEntry
41 protected $templateParser;
44 * @param IContextSource|Skin $obj
45 * @param array $filterGroups Array of ChangesListFilterGroup objects (currently optional)
48 public function __construct( $obj, array $filterGroups = [] ) {
49 if ( $obj instanceof Skin
) {
50 // @todo: deprecate constructing with Skin
51 $context = $obj->getContext();
53 if ( !$obj instanceof IContextSource
) {
54 throw new MWException( 'EnhancedChangesList must be constructed with a '
55 . 'context source or skin.' );
61 parent
::__construct( $context, $filterGroups );
63 // message is set by the parent ChangesList class
64 $this->cacheEntryFactory
= new RCCacheEntryFactory(
69 $this->templateParser
= new TemplateParser();
73 * Add the JavaScript file for enhanced changeslist
76 public function beginRecentChangesList() {
78 $this->rcMoveIndex
= 0;
79 $this->rcCacheIndex
= 0;
81 $this->rclistOpen
= false;
82 $this->getOutput()->addModuleStyles( [
84 'mediawiki.interface.helpers.styles',
85 'mediawiki.special.changeslist',
86 'mediawiki.special.changeslist.enhanced',
88 $this->getOutput()->addModules( [
89 'jquery.makeCollapsible',
92 return '<div class="mw-changeslist">';
96 * Format a line for enhanced recentchange (aka with javascript and block of lines).
98 * @param RecentChange &$rc
99 * @param bool $watched
100 * @param int|null $linenumber (default null)
104 public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
105 $date = $this->getLanguage()->userDate(
106 $rc->mAttribs
['rc_timestamp'],
109 if ( $this->lastdate
=== '' ) {
110 $this->lastdate
= $date;
115 # If it's a new day, flush the cache and update $this->lastdate
116 if ( $date !== $this->lastdate
) {
117 # Process current cache (uses $this->lastdate to generate a heading)
118 $ret = $this->recentChangesBlock();
119 $this->rc_cache
= [];
120 $this->lastdate
= $date;
123 $cacheEntry = $this->cacheEntryFactory
->newFromRecentChange( $rc, $watched );
124 $this->addCacheEntry( $cacheEntry );
130 * Put accumulated information into the cache, for later display.
131 * Page moves go on their own line.
133 * @param RCCacheEntry $cacheEntry
135 protected function addCacheEntry( RCCacheEntry
$cacheEntry ) {
136 $cacheGroupingKey = $this->makeCacheGroupingKey( $cacheEntry );
138 if ( !isset( $this->rc_cache
[$cacheGroupingKey] ) ) {
139 $this->rc_cache
[$cacheGroupingKey] = [];
142 array_push( $this->rc_cache
[$cacheGroupingKey], $cacheEntry );
146 * @todo use rc_source to group, if set; fallback to rc_type
148 * @param RCCacheEntry $cacheEntry
152 protected function makeCacheGroupingKey( RCCacheEntry
$cacheEntry ) {
153 $title = $cacheEntry->getTitle();
154 $cacheGroupingKey = $title->getPrefixedDBkey();
156 $type = $cacheEntry->mAttribs
['rc_type'];
158 if ( $type == RC_LOG
) {
160 $cacheGroupingKey = SpecialPage
::getTitleFor(
162 $cacheEntry->mAttribs
['rc_log_type']
163 )->getPrefixedDBkey();
166 return $cacheGroupingKey;
171 * @param RCCacheEntry[] $block
173 * @throws DomainException
175 protected function recentChangesBlockGroup( $block ) {
176 $recentChangesFlags = $this->getConfig()->get( 'RecentChangesFlags' );
178 # Add the namespace and title of the block as part of the class
179 $tableClasses = [ 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc', 'mw-changeslist-line' ];
180 if ( $block[0]->mAttribs
['rc_log_type'] ) {
182 $tableClasses[] = 'mw-changeslist-log';
183 $tableClasses[] = Sanitizer
::escapeClass( 'mw-changeslist-log-'
184 . $block[0]->mAttribs
['rc_log_type'] );
186 $tableClasses[] = 'mw-changeslist-edit';
187 $tableClasses[] = Sanitizer
::escapeClass( 'mw-changeslist-ns'
188 . $block[0]->mAttribs
['rc_namespace'] . '-' . $block[0]->mAttribs
['rc_title'] );
190 if ( $block[0]->watched
) {
191 $tableClasses[] = 'mw-changeslist-line-watched';
193 $tableClasses[] = 'mw-changeslist-line-not-watched';
196 # Collate list of users
200 # Some catalyst variables...
203 $RCShowChangedSize = $this->getConfig()->get( 'RCShowChangedSize' );
205 # Default values for RC flags
206 $collectedRcFlags = [];
207 foreach ( $recentChangesFlags as $key => $value ) {
208 $flagGrouping = ( $recentChangesFlags[$key]['grouping'] ??
'any' );
209 switch ( $flagGrouping ) {
211 $collectedRcFlags[$key] = true;
214 $collectedRcFlags[$key] = false;
217 throw new DomainException( "Unknown grouping type \"{$flagGrouping}\"" );
220 foreach ( $block as $rcObj ) {
221 // If all log actions to this page were hidden, then don't
222 // give the name of the affected page for this block!
223 if ( !static::isDeleted( $rcObj, LogPage
::DELETED_ACTION
) ) {
226 $u = $rcObj->userlink
;
227 if ( !isset( $userlinks[$u] ) ) {
230 if ( $rcObj->mAttribs
['rc_type'] != RC_LOG
) {
233 # Get the latest entry with a page_id and oldid
234 # since logs may not have these.
235 if ( !$curId && $rcObj->mAttribs
['rc_cur_id'] ) {
236 $curId = $rcObj->mAttribs
['rc_cur_id'];
242 # Sort the list and convert to text
243 krsort( $userlinks );
246 foreach ( $userlinks as $userlink => $count ) {
248 $text .= $this->getLanguage()->getDirMark();
250 $formattedCount = $this->msg( 'ntimes' )->numParams( $count )->escaped();
251 $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $formattedCount )->escaped();
253 array_push( $users, $text );
258 $revDeletedMsg = false;
260 $revDeletedMsg = $this->msg( 'rev-deleted-event' )->escaped();
261 } elseif ( $allLogs ) {
262 $articleLink = $this->maybeWatchedLink( $block[0]->link
, $block[0]->watched
);
264 $articleLink = $this->getArticleLink(
265 $block[0], $block[0]->unpatrolled
, $block[0]->watched
);
268 $queryParams['curid'] = $curId;
273 foreach ( $block as $i => $rcObj ) {
274 $line = $this->getLineData( $block, $rcObj, $queryParams );
276 // completely ignore this RC entry if we don't want to render it
282 foreach ( $line['recentChangesFlagsRaw'] as $key => $value ) {
283 $flagGrouping = ( $recentChangesFlags[$key]['grouping'] ??
'any' );
284 switch ( $flagGrouping ) {
287 $collectedRcFlags[$key] = false;
292 $collectedRcFlags[$key] = true;
296 throw new DomainException( "Unknown grouping type \"{$flagGrouping}\"" );
300 // Roll up filter-based CSS classes
301 $filterClasses = array_merge( $filterClasses, $this->getHTMLClassesForFilters( $rcObj ) );
302 // Add classes for change tags separately, getHTMLClassesForFilters() doesn't add them
303 $this->getTags( $rcObj, $filterClasses );
304 $filterClasses = array_unique( $filterClasses );
309 // Further down are some assumptions that $block is a 0-indexed array
310 // with (count-1) as last key. Let's make sure it is.
311 $block = array_values( $block );
312 $filterClasses = array_values( $filterClasses );
314 if ( empty( $block ) ||
!$lines ) {
315 // if we can't show anything, don't display this block altogether
319 $logText = $this->getLogText( $block, $queryParams, $allLogs,
320 $collectedRcFlags['newpage'], $namehidden
323 # Character difference (does not apply if only log items)
324 $charDifference = false;
325 if ( $RCShowChangedSize && !$allLogs ) {
327 $first = count( $block ) - 1;
328 # Some events (like logs and category changes) have an "empty" size, so we need to skip those...
329 while ( $last < $first && $block[$last]->mAttribs
['rc_new_len'] === null ) {
332 while ( $last < $first && $block[$first]->mAttribs
['rc_old_len'] === null ) {
336 $charDifference = $this->formatCharacterDifference( $block[$first], $block[$last] ) ?
: false;
339 $numberofWatchingusers = $this->numberofWatchingusers( $block[0]->numberofWatchingusers
);
340 $usersList = $this->msg( 'brackets' )->rawParams(
341 implode( $this->message
['semicolon-separator'], $users )
345 if ( is_callable( $this->changeLinePrefixer
) ) {
346 $prefix = call_user_func( $this->changeLinePrefixer
, $block[0], $this, true );
350 'articleLink' => $articleLink,
351 'charDifference' => $charDifference,
352 'collectedRcFlags' => $this->recentChangesFlags( $collectedRcFlags ),
353 'filterClasses' => $filterClasses,
354 'languageDirMark' => $this->getLanguage()->getDirMark(),
356 'logText' => $logText,
357 'numberofWatchingusers' => $numberofWatchingusers,
359 'rev-deleted-event' => $revDeletedMsg,
360 'tableClasses' => $tableClasses,
361 'timestamp' => $block[0]->timestamp
,
362 'fullTimestamp' => $block[0]->getAttribute( 'rc_timestamp' ),
363 'users' => $usersList,
366 $this->rcCacheIndex++
;
368 return $this->templateParser
->processTemplate(
369 'EnhancedChangesListGroup',
375 * @param RCCacheEntry[] $block
376 * @param RCCacheEntry $rcObj
377 * @param array $queryParams
381 * @throws MWException
383 protected function getLineData( array $block, RCCacheEntry
$rcObj, array $queryParams = [] ) {
384 $RCShowChangedSize = $this->getConfig()->get( 'RCShowChangedSize' );
386 $type = $rcObj->mAttribs
['rc_type'];
388 $lineParams = [ 'targetTitle' => $rcObj->getTitle() ];
390 $classes = [ 'mw-enhanced-rc' ];
391 if ( $rcObj->watched
) {
392 $classes[] = 'mw-enhanced-watched';
394 $classes = array_merge( $classes, $this->getHTMLClasses( $rcObj, $rcObj->watched
) );
396 $separator = ' <span class="mw-changeslist-separator"></span> ';
398 $data['recentChangesFlags'] = [
399 'newpage' => $type == RC_NEW
,
400 'minor' => $rcObj->mAttribs
['rc_minor'],
401 'unpatrolled' => $rcObj->unpatrolled
,
402 'bot' => $rcObj->mAttribs
['rc_bot'],
405 $params = $queryParams;
407 if ( $rcObj->mAttribs
['rc_this_oldid'] != 0 ) {
408 $params['oldid'] = $rcObj->mAttribs
['rc_this_oldid'];
412 if ( $type == RC_LOG
) {
413 $link = htmlspecialchars( $rcObj->timestamp
);
415 } elseif ( !ChangesList
::userCan( $rcObj, RevisionRecord
::DELETED_TEXT
, $this->getUser() ) ) {
416 $link = Html
::element( 'span', [ 'class' => 'history-deleted' ], $rcObj->timestamp
);
418 $link = $this->linkRenderer
->makeKnownLink(
424 if ( static::isDeleted( $rcObj, RevisionRecord
::DELETED_TEXT
) ) {
425 $link = '<span class="history-deleted">' . $link . '</span> ';
428 $data['timestampLink'] = $link;
430 $currentAndLastLinks = '';
431 if ( !$type == RC_LOG ||
$type == RC_NEW
) {
432 $currentAndLastLinks .= ' ' . $this->msg( 'parentheses' )->rawParams(
434 $this->message
['pipe-separator'] .
438 $data['currentAndLastLinks'] = $currentAndLastLinks;
439 $data['separatorAfterCurrentAndLastLinks'] = $separator;
442 if ( $RCShowChangedSize ) {
443 $cd = $this->formatCharacterDifference( $rcObj );
445 $data['characterDiff'] = $cd;
446 $data['separatorAfterCharacterDiff'] = $separator;
450 if ( $rcObj->mAttribs
['rc_type'] == RC_LOG
) {
451 $data['logEntry'] = $this->insertLogEntry( $rcObj );
452 } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) {
453 $data['comment'] = $this->insertComment( $rcObj );
456 $data['userLink'] = $rcObj->userlink
;
457 $data['userTalkLink'] = $rcObj->usertalklink
;
458 $data['comment'] = $this->insertComment( $rcObj );
462 $data['rollback'] = $this->getRollback( $rcObj );
465 $data['tags'] = $this->getTags( $rcObj, $classes );
467 $attribs = $this->getDataAttributes( $rcObj );
469 // give the hook a chance to modify the data
470 $success = Hooks
::run( 'EnhancedChangesListModifyLineData',
471 [ $this, &$data, $block, $rcObj, &$classes, &$attribs ] );
473 // skip entry if hook aborted it
476 $attribs = array_filter( $attribs,
477 [ Sanitizer
::class, 'isReservedDataAttribute' ],
481 $lineParams['recentChangesFlagsRaw'] = [];
482 if ( isset( $data['recentChangesFlags'] ) ) {
483 $lineParams['recentChangesFlags'] = $this->recentChangesFlags( $data['recentChangesFlags'] );
484 # FIXME: This is used by logic, don't return it in the template params.
485 $lineParams['recentChangesFlagsRaw'] = $data['recentChangesFlags'];
486 unset( $data['recentChangesFlags'] );
489 if ( isset( $data['timestampLink'] ) ) {
490 $lineParams['timestampLink'] = $data['timestampLink'];
491 unset( $data['timestampLink'] );
494 $lineParams['classes'] = array_values( $classes );
495 $lineParams['attribs'] = Html
::expandAttributes( $attribs );
497 // everything else: makes it easier for extensions to add or remove data
498 $lineParams['data'] = array_values( $data );
504 * Generates amount of changes (linking to diff ) & link to history.
506 * @param RCCacheEntry[] $block
507 * @param array $queryParams
508 * @param bool $allLogs
510 * @param bool $namehidden
513 protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
514 if ( empty( $block ) ) {
519 static $nchanges = [];
520 static $sinceLastVisitMsg = [];
522 $n = count( $block );
523 if ( !isset( $nchanges[$n] ) ) {
524 $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
528 $unvisitedOldid = null;
529 /** @var RCCacheEntry $rcObj */
530 foreach ( $block as $rcObj ) {
531 // Same logic as below inside main foreach
532 if ( $rcObj->watched
) {
534 $unvisitedOldid = $rcObj->mAttribs
['rc_last_oldid'];
537 if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
538 $sinceLastVisitMsg[$sinceLast] =
539 $this->msg( 'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
542 $currentRevision = 0;
543 foreach ( $block as $rcObj ) {
544 if ( !$currentRevision ) {
545 $currentRevision = $rcObj->mAttribs
['rc_this_oldid'];
551 /** @var RecentChange $block0 */
553 $last = $block[count( $block ) - 1];
557 $rcObj->mAttribs
['rc_type'] == RC_CATEGORIZE ||
558 !ChangesList
::userCan( $rcObj, RevisionRecord
::DELETED_TEXT
, $this->getUser() )
560 $links['total-changes'] = Html
::rawElement( 'span', [], $nchanges[$n] );
562 $links['total-changes'] = Html
::rawElement( 'span', [],
563 $this->linkRenderer
->makeKnownLink(
565 new HtmlArmor( $nchanges[$n] ),
566 [ 'class' => 'mw-changeslist-groupdiff' ],
568 'diff' => $currentRevision,
569 'oldid' => $last->mAttribs
['rc_last_oldid'],
576 $rcObj->mAttribs
['rc_type'] != RC_CATEGORIZE
&&
580 $links['total-changes-since-last'] = Html
::rawElement( 'span', [],
581 $this->linkRenderer
->makeKnownLink(
583 new HtmlArmor( $sinceLastVisitMsg[$sinceLast] ),
584 [ 'class' => 'mw-changeslist-groupdiff' ],
586 'diff' => $currentRevision,
587 'oldid' => $unvisitedOldid,
595 if ( $allLogs ||
$rcObj->mAttribs
['rc_type'] == RC_CATEGORIZE
) {
596 // don't show history link for logs
597 } elseif ( $namehidden ||
!$block0->getTitle()->exists() ) {
598 $links['history'] = Html
::rawElement( 'span', [], $this->message
['enhancedrc-history'] );
600 $params = $queryParams;
601 $params['action'] = 'history';
603 $links['history'] = Html
::rawElement( 'span', [],
604 $this->linkRenderer
->makeKnownLink(
606 new HtmlArmor( $this->message
['enhancedrc-history'] ),
607 [ 'class' => 'mw-changeslist-history' ],
613 # Allow others to alter, remove or add to these links
614 Hooks
::run( 'EnhancedChangesList::getLogText',
615 [ $this, &$links, $block ] );
621 $logtext = Html
::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ],
622 implode( ' ', $links ) );
623 return ' ' . $logtext;
627 * Enhanced RC ungrouped line.
629 * @param RecentChange|RCCacheEntry $rcObj
630 * @return string A HTML formatted line (generated using $r)
632 protected function recentChangesBlockLine( $rcObj ) {
635 $query['curid'] = $rcObj->mAttribs
['rc_cur_id'];
637 $type = $rcObj->mAttribs
['rc_type'];
638 $logType = $rcObj->mAttribs
['rc_log_type'];
639 $classes = $this->getHTMLClasses( $rcObj, $rcObj->watched
);
640 $classes[] = 'mw-enhanced-rc';
644 $classes[] = 'mw-changeslist-log';
645 $classes[] = Sanitizer
::escapeClass( 'mw-changeslist-log-' . $logType );
647 $classes[] = 'mw-changeslist-edit';
648 $classes[] = Sanitizer
::escapeClass( 'mw-changeslist-ns' .
649 $rcObj->mAttribs
['rc_namespace'] . '-' . $rcObj->mAttribs
['rc_title'] );
653 $data['recentChangesFlags'] = [
654 'newpage' => $type == RC_NEW
,
655 'minor' => $rcObj->mAttribs
['rc_minor'],
656 'unpatrolled' => $rcObj->unpatrolled
,
657 'bot' => $rcObj->mAttribs
['rc_bot'],
659 // timestamp is not really a link here, but is called timestampLink
660 // for consistency with EnhancedChangesListModifyLineData
661 $data['timestampLink'] = htmlspecialchars( $rcObj->timestamp
);
663 # Article or log link
665 $logPage = new LogPage( $logType );
666 $logTitle = SpecialPage
::getTitleFor( 'Log', $logType );
667 $logName = $logPage->getName()->text();
668 $data['logLink'] = Html
::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ],
669 $this->linkRenderer
->makeKnownLink( $logTitle, $logName )
672 $data['articleLink'] = $this->getArticleLink( $rcObj, $rcObj->unpatrolled
, $rcObj->watched
);
675 # Diff and hist links
676 if ( $type != RC_LOG
&& $type != RC_CATEGORIZE
) {
677 $query['action'] = 'history';
678 $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query, false );
680 $data['separatorAfterLinks'] = ' <span class="mw-changeslist-separator"></span> ';
683 if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
684 $cd = $this->formatCharacterDifference( $rcObj );
686 $data['characterDiff'] = $cd;
687 $data['separatorAftercharacterDiff'] = ' <span class="mw-changeslist-separator"></span> ';
691 if ( $type == RC_LOG
) {
692 $data['logEntry'] = $this->insertLogEntry( $rcObj );
693 } elseif ( $this->isCategorizationWithoutRevision( $rcObj ) ) {
694 $data['comment'] = $this->insertComment( $rcObj );
696 $data['userLink'] = $rcObj->userlink
;
697 $data['userTalkLink'] = $rcObj->usertalklink
;
698 $data['comment'] = $this->insertComment( $rcObj );
699 if ( $type == RC_CATEGORIZE
) {
700 $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query, false );
702 $data['rollback'] = $this->getRollback( $rcObj );
706 $data['tags'] = $this->getTags( $rcObj, $classes );
708 # Show how many people are watching this if enabled
709 $data['watchingUsers'] = $this->numberofWatchingusers( $rcObj->numberofWatchingusers
);
711 $data['attribs'] = array_merge( $this->getDataAttributes( $rcObj ), [ 'class' => $classes ] );
713 // give the hook a chance to modify the data
714 $success = Hooks
::run( 'EnhancedChangesListModifyBlockLineData',
715 [ $this, &$data, $rcObj ] );
717 // skip entry if hook aborted it
720 $attribs = $data['attribs'];
721 unset( $data['attribs'] );
722 $attribs = array_filter( $attribs, function ( $key ) {
723 return $key === 'class' || Sanitizer
::isReservedDataAttribute( $key );
724 }, ARRAY_FILTER_USE_KEY
);
727 if ( is_callable( $this->changeLinePrefixer
) ) {
728 $prefix = call_user_func( $this->changeLinePrefixer
, $rcObj, $this, false );
731 $line = Html
::openElement( 'table', $attribs ) . Html
::openElement( 'tr' );
733 $line .= Html
::rawElement( 'td', [],
734 $this->getHighlightsContainerDiv()
737 $line .= Html
::rawElement( 'td', [], '<span class="mw-enhancedchanges-arrow-space"></span>' );
738 $line .= Html
::rawElement( 'td', [ 'class' => 'mw-changeslist-line-prefix' ], $prefix );
739 $line .= '<td class="mw-enhanced-rc" colspan="2">';
741 if ( isset( $data['recentChangesFlags'] ) ) {
742 $line .= $this->recentChangesFlags( $data['recentChangesFlags'] );
743 unset( $data['recentChangesFlags'] );
746 if ( isset( $data['timestampLink'] ) ) {
747 $line .= "\u{00A0}" . $data['timestampLink'];
748 unset( $data['timestampLink'] );
750 $line .= "\u{00A0}</td>";
751 $line .= Html
::openElement( 'td', [
752 'class' => 'mw-changeslist-line-inner',
753 // Used for reliable determination of the affiliated page
754 'data-target-page' => $rcObj->getTitle(),
757 // everything else: makes it easier for extensions to add or remove data
758 foreach ( $data as $key => $dataItem ) {
759 $line .= Html
::rawElement( 'span', [
760 'class' => 'mw-changeslist-line-inner-' . $key,
764 $line .= "</td></tr></table>\n";
770 * Returns value to be used in 'historyLink' element of $data param in
771 * EnhancedChangesListModifyBlockLineData hook.
775 * @param RCCacheEntry $rc
776 * @param array $query array of key/value pairs to append as a query string
777 * @param bool $useParentheses (optional) Wrap comments in parentheses where needed
778 * @return string HTML
780 public function getDiffHistLinks( RCCacheEntry
$rc, array $query, $useParentheses = true ) {
781 $pageTitle = $rc->getTitle();
782 if ( $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE
) {
783 // For categorizations we must swap the category title with the page title!
784 $pageTitle = Title
::newFromID( $rc->getAttribute( 'rc_cur_id' ) );
786 // The page has been deleted, but the RC entry
787 // deletion job has not run yet. Just skip.
792 $histLink = $this->linkRenderer
->makeKnownLink(
794 new HtmlArmor( $this->message
['hist'] ),
795 [ 'class' => 'mw-changeslist-history' ],
798 if ( $useParentheses ) {
799 $retVal = $this->msg( 'parentheses' )
800 ->rawParams( $rc->difflink
. $this->message
['pipe-separator']
801 . $histLink )->escaped();
803 $retVal = Html
::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ],
804 Html
::rawElement( 'span', [], $rc->difflink
) .
805 Html
::rawElement( 'span', [], $histLink )
808 return ' ' . $retVal;
812 * If enhanced RC is in use, this function takes the previously cached
813 * RC lines, arranges them, and outputs the HTML
817 protected function recentChangesBlock() {
818 if ( count( $this->rc_cache
) == 0 ) {
823 foreach ( $this->rc_cache
as $block ) {
824 if ( count( $block ) < 2 ) {
825 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
827 $blockOut .= $this->recentChangesBlockGroup( $block );
831 if ( $blockOut === '' ) {
834 // $this->lastdate is kept up to date by recentChangesLine()
835 return Xml
::element( 'h4', null, $this->lastdate
) . "\n<div>" . $blockOut . '</div>';
839 * Returns text for the end of RC
840 * If enhanced RC is in use, returns pretty much all the text
843 public function endRecentChangesList() {
844 return $this->recentChangesBlock() . '</div>';