*/
use MediaWiki\Linker\LinkRenderer;
use MediaWiki\MediaWikiServices;
+use MediaWiki\Revision\RevisionRecord;
use Wikimedia\Rdbms\IResultWrapper;
class ChangesList extends ContextSource {
$user = $context->getUser();
$sk = $context->getSkin();
$list = null;
- if ( Hooks::run( 'FetchChangesList', [ $user, &$sk, &$list ] ) ) {
+ if ( Hooks::run( 'FetchChangesList', [ $user, &$sk, &$list, $groups ] ) ) {
$new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
return $new ?
*/
private function preCacheMessages() {
if ( !isset( $this->message ) ) {
+ $this->message = [];
foreach ( [
'cur', 'diff', 'hist', 'enhancedrc-history', 'last', 'blocklink', 'history',
'semicolon-separator', 'pipe-separator' ] as $msg
$classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' .
$rc->mAttribs['rc_namespace'] );
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+ $classes[] = Sanitizer::escapeClass(
+ self::CSS_CLASS_PREFIX .
+ 'ns-' .
+ ( $nsInfo->isTalk( $rc->mAttribs['rc_namespace'] ) ? 'talk' : 'subject' )
+ );
+
if ( $this->filterGroups !== null ) {
foreach ( $this->filterGroups as $filterGroup ) {
foreach ( $filterGroup->getFilters() as $filter ) {
public static function revDateLink( Revision $rev, User $user, Language $lang, $title = null ) {
$ts = $rev->getTimestamp();
$date = $lang->userTimeAndDate( $ts, $user );
- if ( $rev->userCan( Revision::DELETED_TEXT, $user ) ) {
+ if ( $rev->userCan( RevisionRecord::DELETED_TEXT, $user ) ) {
$link = MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
$title ?? $rev->getTitle(),
$date,
} else {
$link = htmlspecialchars( $date );
}
- if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
+ if ( $rev->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
$link = "<span class=\"history-deleted mw-changeslist-date\">$link</span>";
}
return $link;
* @param string &$s HTML to update
* @param Title $title
* @param string $logtype
+ * @param bool $useParentheses (optional) Wrap log entry in parentheses where needed
*/
- public function insertLog( &$s, $title, $logtype ) {
+ public function insertLog( &$s, $title, $logtype, $useParentheses = true ) {
$page = new LogPage( $logtype );
$logname = $page->getName()->setContext( $this->getContext() )->text();
- $s .= $this->msg( 'parentheses' )->rawParams(
- $this->linkRenderer->makeKnownLink( $title, $logname )
- )->escaped();
+ $link = $this->linkRenderer->makeKnownLink( $title, $logname, [
+ 'class' => $useParentheses ? '' : 'mw-changeslist-links'
+ ] );
+ if ( $useParentheses ) {
+ $s .= $this->msg( 'parentheses' )->rawParams(
+ $link
+ )->escaped();
+ } else {
+ $s .= $link;
+ }
}
/**
$rc->mAttribs['rc_type'] == RC_CATEGORIZE
) {
$diffLink = $this->message['diff'];
- } elseif ( !self::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
+ } elseif ( !self::userCan( $rc, RevisionRecord::DELETED_TEXT, $this->getUser() ) ) {
$diffLink = $this->message['diff'];
} else {
$query = [
[ 'class' => 'mw-changeslist-title' ],
$params
);
- if ( $this->isDeleted( $rc, Revision::DELETED_TEXT ) ) {
+ if ( $this->isDeleted( $rc, RevisionRecord::DELETED_TEXT ) ) {
$articlelink = '<span class="history-deleted">' . $articlelink . '</span>';
}
# To allow for boldening pages watched by this user
* @param RecentChange &$rc
*/
public function insertUserRelatedLinks( &$s, &$rc ) {
- if ( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
+ if ( $this->isDeleted( $rc, RevisionRecord::DELETED_USER ) ) {
$s .= ' <span class="history-deleted">' .
$this->msg( 'rev-deleted-user' )->escaped() . '</span>';
} else {
$formatter->setShowUserToolLinks( true );
$mark = $this->getLanguage()->getDirMark();
- return $formatter->getActionText() . " $mark" . $formatter->getComment();
+ return Html::openElement( 'span', [ 'class' => 'mw-changeslist-log-entry' ] )
+ . $formatter->getActionText() . " $mark" . $formatter->getComment()
+ . Html::closeElement( 'span' );
}
/**
* @return string
*/
public function insertComment( $rc ) {
- if ( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) {
- return ' <span class="history-deleted">' .
+ if ( $this->isDeleted( $rc, RevisionRecord::DELETED_COMMENT ) ) {
+ return ' <span class="history-deleted comment">' .
$this->msg( 'rev-deleted-comment' )->escaped() . '</span>';
} else {
return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle(),
* field of this revision, if it's marked as deleted.
* @param RCCacheEntry|RecentChange $rc
* @param int $field
- * @param User|null $user User object to check, or null to use $wgUser
+ * @param User|null $user User object to check against. If null, the global RequestContext's
+ * User is assumed instead.
* @return bool
*/
public static function userCan( $rc, $field, User $user = null ) {
+ if ( $user === null ) {
+ $user = RequestContext::getMain()->getUser();
+ }
+
if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
- } else {
- return Revision::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
}
+
+ return RevisionRecord::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
}
/**
) {
$title = $rc->getTitle();
/** Check for rollback permissions, disallow special pages, and only
- * show a link on the top-most revision */
- if ( $title->quickUserCan( 'rollback', $this->getUser() ) ) {
+ * show a link on the top-most revision
+ */
+ if ( MediaWikiServices::getInstance()->getPermissionManager()
+ ->quickUserCan( 'rollback', $this->getUser(), $title )
+ ) {
$rev = new Revision( [
'title' => $title,
'id' => $rc->mAttribs['rc_this_oldid'],
'actor' => $rc->mAttribs['rc_actor'] ?? null,
'deleted' => $rc->mAttribs['rc_deleted']
] );
- $s .= ' ' . Linker::generateRollback( $rev, $this->getContext() );
+ $s .= ' ' . Linker::generateRollback( $rev, $this->getContext(),
+ [ 'noBrackets' ] );
}
}
}