$this->skin = $obj;
}
$this->preCacheMessages();
- $this->watchMsgCache = new HashBagOStuff( array( 'maxKeys' => 50 ) );
+ $this->watchMsgCache = new HashBagOStuff( [ 'maxKeys' => 50 ] );
}
/**
$user = $context->getUser();
$sk = $context->getSkin();
$list = null;
- if ( Hooks::run( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) {
+ if ( Hooks::run( 'FetchChangesList', [ $user, &$sk, &$list ] ) ) {
$new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
return $new ? new EnhancedChangesList( $context ) : new OldChangesList( $context );
*/
private function preCacheMessages() {
if ( !isset( $this->message ) ) {
- foreach ( array(
+ foreach ( [
'cur', 'diff', 'hist', 'enhancedrc-history', 'last', 'blocklink', 'history',
- 'semicolon-separator', 'pipe-separator' ) as $msg
+ 'semicolon-separator', 'pipe-separator' ] as $msg
) {
$this->message[$msg] = $this->msg( $msg )->escaped();
}
return $f;
}
+ /**
+ * Get an array of default HTML class attributes for the change.
+ *
+ * @param RecentChange|RCCacheEntry $rc
+ * @param string|bool $watched Optionally timestamp for adding watched class
+ *
+ * @return array of classes
+ */
+ protected function getHTMLClasses( $rc, $watched ) {
+ $classes = [];
+ $logType = $rc->mAttribs['rc_log_type'];
+
+ if ( $logType ) {
+ $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' . $logType );
+ } else {
+ $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' .
+ $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
+ }
+
+ // Indicate watched status on the line to allow for more
+ // comprehensive styling.
+ $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched
+ ? 'mw-changeslist-line-watched'
+ : 'mw-changeslist-line-not-watched';
+
+ return $classes;
+ }
+
/**
* Provide the "<abbr>" element appropriate to a given abbreviated flag,
* namely the flag indicating a new page, a minor edit, a bot edit, or an
static $flagInfos = null;
if ( is_null( $flagInfos ) ) {
global $wgRecentChangesFlags;
- $flagInfos = array();
+ $flagInfos = [];
foreach ( $wgRecentChangesFlags as $key => $value ) {
$flagInfos[$key]['letter'] = wfMessage( $value['letter'] )->escaped();
$flagInfos[$key]['title'] = wfMessage( $value['title'] )->escaped();
}
// Inconsistent naming, bleh, kepted for b/c
- $map = array(
+ $map = [
'minoredit' => 'minor',
'botedit' => 'bot',
- );
+ ];
if ( isset( $map[$flag] ) ) {
$flag = $map[$flag];
}
* @return string
*/
public function beginRecentChangesList() {
- $this->rc_cache = array();
+ $this->rc_cache = [];
$this->rcMoveIndex = 0;
$this->rcCacheIndex = 0;
$this->lastdate = '';
* @param ResultWrapper|array $rows
*/
public function initChangesListRows( $rows ) {
- Hooks::run( 'ChangesListInitRows', array( $this, $rows ) );
+ Hooks::run( 'ChangesListInitRows', [ $this, $rows ] );
}
/**
$lang = $context->getLanguage();
$config = $context->getConfig();
$code = $lang->getCode();
- static $fastCharDiff = array();
+ static $fastCharDiff = [];
if ( !isset( $fastCharDiff[$code] ) ) {
$fastCharDiff[$code] = $config->get( 'MiserMode' )
|| $context->msg( 'rc-change-size' )->plain() === '$1';
$formattedTotalSize = $context->msg( 'rc-change-size-new' )->numParams( $new )->text();
return Html::element( $tag,
- array( 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ),
+ [ 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ],
$context->msg( 'parentheses', $formattedSize )->plain() ) . $lang->getDirMark();
}
} elseif ( !self::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
$diffLink = $this->message['diff'];
} else {
- $query = array(
+ $query = [
'curid' => $rc->mAttribs['rc_cur_id'],
'diff' => $rc->mAttribs['rc_this_oldid'],
'oldid' => $rc->mAttribs['rc_last_oldid']
- );
+ ];
$diffLink = Linker::linkKnown(
$rc->getTitle(),
$this->message['diff'],
- array( 'tabindex' => $rc->counter ),
+ [ 'tabindex' => $rc->counter ],
$query
);
}
$diffhist .= Linker::linkKnown(
$rc->getTitle(),
$this->message['hist'],
- array(),
- array(
+ [],
+ [
'curid' => $rc->mAttribs['rc_cur_id'],
'action' => 'history'
- )
+ ]
);
}
* @since 1.26
*/
public function getArticleLink( &$rc, $unpatrolled, $watched ) {
- $params = array();
+ $params = [];
if ( $rc->getTitle()->isRedirect() ) {
- $params = array( 'redirect' => 'no' );
+ $params = [ 'redirect' => 'no' ];
}
- $articlelink = Linker::linkKnown(
+ $articlelink = Linker::link(
$rc->getTitle(),
null,
- array( 'class' => 'mw-changeslist-title' ),
+ [ 'class' => 'mw-changeslist-title' ],
$params
);
if ( $this->isDeleted( $rc, Revision::DELETED_TEXT ) ) {
# TODO: Deprecate the $s argument, it seems happily unused.
$s = '';
Hooks::run( 'ChangesListInsertArticleLink',
- array( &$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched ) );
+ [ &$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched ] );
return "{$s} {$articlelink}";
}
return '';
}
$cache = $this->watchMsgCache;
- $that = $this;
return $cache->getWithSetCallback( $count, $cache::TTL_INDEFINITE,
- function () use ( $that, $count ) {
- return $that->msg( 'number_of_watching_users_RCview' )
+ function () use ( $count ) {
+ return $this->msg( 'number_of_watching_users_RCview' )
->numParams( $count )->escaped();
}
);
if ( $this->getUser()->isAllowed( 'rollback' )
&& $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid']
) {
- $rev = new Revision( array(
+ $rev = new Revision( [
'title' => $page,
'id' => $rc->mAttribs['rc_this_oldid'],
'user' => $rc->mAttribs['rc_user'],
'user_text' => $rc->mAttribs['rc_user_text'],
'deleted' => $rc->mAttribs['rc_deleted']
- ) );
+ ] );
$s .= ' ' . Linker::generateRollback( $rev, $this->getContext() );
}
}
list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
$rc->mAttribs['ts_tags'],
- 'changeslist'
+ 'changeslist',
+ $this->getContext()
);
$classes = array_merge( $classes, $newClasses );
$s .= ' ' . $tagSummary;
if ( $rc instanceof RecentChange ) {
$isPatrolled = $rc->mAttribs['rc_patrolled'];
$rcType = $rc->mAttribs['rc_type'];
+ $rcLogType = $rc->mAttribs['rc_log_type'];
} else {
$isPatrolled = $rc->rc_patrolled;
$rcType = $rc->rc_type;
+ $rcLogType = $rc->rc_log_type;
}
if ( !$isPatrolled ) {
if ( $user->useNPPatrol() && $rcType == RC_NEW ) {
return true;
}
+ if ( $user->useFilePatrol() && $rcLogType == 'upload' ) {
+ return true;
+ }
}
return false;