<?php
+
+use MediaWiki\Storage\RevisionRecord;
+
/**
* Generates a list of changes using an Enhanced system (uses javascript).
*
$this->lastdate = '';
$this->rclistOpen = false;
$this->getOutput()->addModuleStyles( [
+ 'mediawiki.icon',
+ 'mediawiki.interface.helpers.styles',
'mediawiki.special.changeslist',
'mediawiki.special.changeslist.enhanced',
] );
$this->getOutput()->addModules( [
'jquery.makeCollapsible',
- 'mediawiki.icon',
] );
return '<div class="mw-changeslist">';
$tableClasses[] = Sanitizer::escapeClass( 'mw-changeslist-ns'
. $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
}
- if ( $block[0]->watched
- && $block[0]->mAttribs['rc_timestamp'] >= $block[0]->watched
- ) {
+ if ( $block[0]->watched ) {
$tableClasses[] = 'mw-changeslist-line-watched';
} else {
$tableClasses[] = 'mw-changeslist-line-not-watched';
foreach ( $block as $rcObj ) {
// If all log actions to this page were hidden, then don't
// give the name of the affected page for this block!
- if ( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
+ if ( !static::isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
$namehidden = false;
}
$u = $rcObj->userlink;
} elseif ( $allLogs ) {
$articleLink = $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
} else {
- $articleLink = $this->getArticleLink( $block[0], $block[0]->unpatrolled, $block[0]->watched );
+ $articleLink = $this->getArticleLink(
+ $block[0], $block[0]->unpatrolled, $block[0]->watched );
}
$queryParams['curid'] = $curId;
$lineParams = [ 'targetTitle' => $rcObj->getTitle() ];
$classes = [ 'mw-enhanced-rc' ];
- if ( $rcObj->watched
- && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
- ) {
+ if ( $rcObj->watched ) {
$classes[] = 'mw-enhanced-watched';
}
$classes = array_merge( $classes, $this->getHTMLClasses( $rcObj, $rcObj->watched ) );
- $separator = ' <span class="mw-changeslist-separator">. .</span> ';
+ $separator = ' <span class="mw-changeslist-separator"></span> ';
$data['recentChangesFlags'] = [
'newpage' => $type == RC_NEW,
if ( $type == RC_LOG ) {
$link = htmlspecialchars( $rcObj->timestamp );
# Revision link
- } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
+ } elseif ( !ChangesList::userCan( $rcObj, RevisionRecord::DELETED_TEXT, $this->getUser() ) ) {
$link = Html::element( 'span', [ 'class' => 'history-deleted' ], $rcObj->timestamp );
} else {
$link = $this->linkRenderer->makeKnownLink(
[],
$params
);
- if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) {
+ if ( static::isDeleted( $rcObj, RevisionRecord::DELETED_TEXT ) ) {
$link = '<span class="history-deleted">' . $link . '</span> ';
}
}
/**
* Generates amount of changes (linking to diff ) & link to history.
*
- * @param array $block
+ * @param RCCacheEntry[] $block
* @param array $queryParams
* @param bool $allLogs
* @param bool $isnew
/** @var RCCacheEntry $rcObj */
foreach ( $block as $rcObj ) {
// Same logic as below inside main foreach
- if ( $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ) {
+ if ( $rcObj->watched ) {
$sinceLast++;
$unvisitedOldid = $rcObj->mAttribs['rc_last_oldid'];
}
$block0 = $block[0];
$last = $block[count( $block ) - 1];
if ( !$allLogs ) {
- if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ||
+ if (
$isnew ||
- $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE
+ $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE ||
+ !ChangesList::userCan( $rcObj, RevisionRecord::DELETED_TEXT, $this->getUser() )
) {
- $links['total-changes'] = $nchanges[$n];
+ $links['total-changes'] = Html::rawElement( 'span', [], $nchanges[$n] );
} else {
- $links['total-changes'] = $this->linkRenderer->makeKnownLink(
- $block0->getTitle(),
- new HtmlArmor( $nchanges[$n] ),
- [ 'class' => 'mw-changeslist-groupdiff' ],
- $queryParams + [
- 'diff' => $currentRevision,
- 'oldid' => $last->mAttribs['rc_last_oldid'],
- ]
+ $links['total-changes'] = Html::rawElement( 'span', [],
+ $this->linkRenderer->makeKnownLink(
+ $block0->getTitle(),
+ new HtmlArmor( $nchanges[$n] ),
+ [ 'class' => 'mw-changeslist-groupdiff' ],
+ $queryParams + [
+ 'diff' => $currentRevision,
+ 'oldid' => $last->mAttribs['rc_last_oldid'],
+ ]
+ )
+ );
+ }
+
+ if (
+ $rcObj->mAttribs['rc_type'] != RC_CATEGORIZE &&
+ $sinceLast > 0 &&
+ $sinceLast < $n
+ ) {
+ $links['total-changes-since-last'] = Html::rawElement( 'span', [],
+ $this->linkRenderer->makeKnownLink(
+ $block0->getTitle(),
+ new HtmlArmor( $sinceLastVisitMsg[$sinceLast] ),
+ [ 'class' => 'mw-changeslist-groupdiff' ],
+ $queryParams + [
+ 'diff' => $currentRevision,
+ 'oldid' => $unvisitedOldid,
+ ]
+ )
);
- if ( $sinceLast > 0 && $sinceLast < $n ) {
- $links['total-changes-since-last'] = $this->linkRenderer->makeKnownLink(
- $block0->getTitle(),
- new HtmlArmor( $sinceLastVisitMsg[$sinceLast] ),
- [ 'class' => 'mw-changeslist-groupdiff' ],
- $queryParams + [
- 'diff' => $currentRevision,
- 'oldid' => $unvisitedOldid,
- ]
- );
- }
}
}
if ( $allLogs || $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE ) {
// don't show history link for logs
} elseif ( $namehidden || !$block0->getTitle()->exists() ) {
- $links['history'] = $this->message['enhancedrc-history'];
+ $links['history'] = Html::rawElement( 'span', [], $this->message['enhancedrc-history'] );
} else {
$params = $queryParams;
$params['action'] = 'history';
- $links['history'] = $this->linkRenderer->makeKnownLink(
+ $links['history'] = Html::rawElement( 'span', [],
+ $this->linkRenderer->makeKnownLink(
$block0->getTitle(),
new HtmlArmor( $this->message['enhancedrc-history'] ),
[ 'class' => 'mw-changeslist-history' ],
$params
- );
+ )
+ );
}
# Allow others to alter, remove or add to these links
return '';
}
- $logtext = implode( $this->message['pipe-separator'], $links );
- $logtext = $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
+ $logtext = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ],
+ implode( ' ', $links ) );
return ' ' . $logtext;
}
$logPage = new LogPage( $logType );
$logTitle = SpecialPage::getTitleFor( 'Log', $logType );
$logName = $logPage->getName()->text();
- $data['logLink'] = $this->msg( 'parentheses' )
- ->rawParams(
- $this->linkRenderer->makeKnownLink( $logTitle, $logName )
- )->escaped();
+ $data['logLink'] = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ],
+ $this->linkRenderer->makeKnownLink( $logTitle, $logName )
+ );
} else {
$data['articleLink'] = $this->getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched );
}
# Diff and hist links
if ( $type != RC_LOG && $type != RC_CATEGORIZE ) {
$query['action'] = 'history';
- $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query );
+ $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query, false );
}
- $data['separatorAfterLinks'] = ' <span class="mw-changeslist-separator">. .</span> ';
+ $data['separatorAfterLinks'] = ' <span class="mw-changeslist-separator"></span> ';
# Character diff
if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
$cd = $this->formatCharacterDifference( $rcObj );
if ( $cd !== '' ) {
$data['characterDiff'] = $cd;
- $data['separatorAftercharacterDiff'] = ' <span class="mw-changeslist-separator">. .</span> ';
+ $data['separatorAftercharacterDiff'] = ' <span class="mw-changeslist-separator"></span> ';
}
}
$data['userTalkLink'] = $rcObj->usertalklink;
$data['comment'] = $this->insertComment( $rcObj );
if ( $type == RC_CATEGORIZE ) {
- $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query );
+ $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query, false );
}
$data['rollback'] = $this->getRollback( $rcObj );
}
] );
// everything else: makes it easier for extensions to add or remove data
- $line .= implode( '', $data );
+ foreach ( $data as $key => $dataItem ) {
+ $line .= Html::rawElement( 'span', [
+ 'class' => 'mw-changeslist-line-inner-' . $key,
+ ], $dataItem );
+ }
$line .= "</td></tr></table>\n";
*
* @param RCCacheEntry $rc
* @param array $query array of key/value pairs to append as a query string
+ * @param bool $useParentheses (optional) Wrap comments in parentheses where needed
* @return string HTML
*/
- public function getDiffHistLinks( RCCacheEntry $rc, array $query ) {
+ public function getDiffHistLinks( RCCacheEntry $rc, array $query, $useParentheses = true ) {
$pageTitle = $rc->getTitle();
if ( $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE ) {
// For categorizations we must swap the category title with the page title!
}
}
- $retVal = ' ' . $this->msg( 'parentheses' )
- ->rawParams( $rc->difflink . $this->message['pipe-separator']
- . $this->linkRenderer->makeKnownLink(
- $pageTitle,
- new HtmlArmor( $this->message['hist'] ),
- [ 'class' => 'mw-changeslist-history' ],
- $query
- ) )->escaped();
- return $retVal;
+ $histLink = $this->linkRenderer->makeKnownLink(
+ $pageTitle,
+ new HtmlArmor( $this->message['hist'] ),
+ [ 'class' => 'mw-changeslist-history' ],
+ $query
+ );
+ if ( $useParentheses ) {
+ $retVal = $this->msg( 'parentheses' )
+ ->rawParams( $rc->difflink . $this->message['pipe-separator']
+ . $histLink )->escaped();
+ } else {
+ $retVal = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ],
+ Html::rawElement( 'span', [], $rc->difflink ) .
+ Html::rawElement( 'span', [], $histLink )
+ );
+ }
+ return ' ' . $retVal;
}
/**