if( !isset( $this->message ) ) {
foreach ( explode( ' ', 'cur diff hist last blocklink history ' .
'semicolon-separator pipe-separator' ) as $msg ) {
- $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
+ $this->message[$msg] = $this->msg( $msg )->escaped();
}
}
}
* Show formatted char difference
* @param $old Integer: bytes
* @param $new Integer: bytes
+ * @param $context IContextSource context to use
* @return String
*/
- public static function showCharacterDifference( $old, $new ) {
- global $wgRCChangedSizeThreshold, $wgLang, $wgMiserMode;
+ public static function showCharacterDifference( $old, $new, IContextSource $context = null ) {
+ global $wgRCChangedSizeThreshold, $wgMiserMode;
+
+ if ( !$context ) {
+ $context = RequestContext::getMain();
+ }
+
$szdiff = $new - $old;
- $code = $wgLang->getCode();
+ $lang = $context->getLanguage();
+ $code = $lang->getCode();
static $fastCharDiff = array();
if ( !isset($fastCharDiff[$code]) ) {
- $fastCharDiff[$code] = $wgMiserMode || wfMsgNoTrans( 'rc-change-size' ) === '$1';
+ $fastCharDiff[$code] = $wgMiserMode || $context->msg( 'rc-change-size' )->plain() === '$1';
}
- $formattedSize = $wgLang->formatNum($szdiff);
+ $formattedSize = $lang->formatNum( $szdiff );
if ( !$fastCharDiff[$code] ) {
- $formattedSize = wfMsgExt( 'rc-change-size', array( 'parsemag' ), $formattedSize );
+ $formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text();
}
if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
$formattedSizeClass = 'mw-plusminus-neg';
}
- $formattedTotalSize = wfMsgExt( 'rc-change-size-new', 'parsemag', $wgLang->formatNum( $new ) );
+ $formattedTotalSize = $context->msg( 'rc-change-size-new' )->numParams( $new )->text();
return Html::element( $tag,
array( 'dir' => 'ltr', 'class' => $formattedSizeClass, 'title' => $formattedTotalSize ),
- wfMessage( 'parentheses', $formattedSize )->plain() ) . $wgLang->getDirMark();
+ $context->msg( 'parentheses', $formattedSize )->plain() ) . $lang->getDirMark();
+ }
+
+ /**
+ * Format the character difference of one or several changes.
+ *
+ * @param $old RecentChange
+ * @param $new RecentChange last change to use, if not provided, $old will be used
+ * @return string HTML fragment
+ */
+ public function formatCharacterDifference( RecentChange $old, RecentChange $new = null ) {
+ $oldlen = $old->mAttribs['rc_old_len'];
+
+ if ( $new ) {
+ $newlen = $new->mAttribs['rc_new_len'];
+ } else {
+ $newlen = $old->mAttribs['rc_new_len'];
+ }
+
+ if( $oldlen === null || $newlen === null ) {
+ return '';
+ }
+
+ return self::showCharacterDifference( $oldlen, $newlen, $this->getContext() );
}
/**
public function insertDateHeader( &$s, $rc_timestamp ) {
# Make date header if necessary
- $date = $this->getLanguage()->date( $rc_timestamp, true, true );
+ $date = $this->getLanguage()->userDate( $rc_timestamp, $this->getUser() );
if( $date != $this->lastdate ) {
if( $this->lastdate != '' ) {
$s .= "</ul>\n";
*/
public function insertTimestamp( &$s, $rc ) {
$s .= $this->message['semicolon-separator'] .
- $this->getLanguage()->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
+ $this->getLanguage()->userTime( $rc->mAttribs['rc_timestamp'], $this->getUser() ) . ' . . ';
}
/**
*/
public function insertUserRelatedLinks( &$s, &$rc ) {
if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
- $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
+ $s .= ' <span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
} else {
$s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'],
$rc->mAttribs['rc_user_text'] );
*/
public function insertLogEntry( $rc ) {
$formatter = LogFormatter::newFromRow( $rc->mAttribs );
+ $formatter->setContext( $this->getContext() );
$formatter->setShowUserToolLinks( true );
$mark = $this->getLanguage()->getDirMark();
return $formatter->getActionText() . " $mark" . $formatter->getComment();
}
- /**
+ /**
* Insert a formatted comment
* @param $rc RecentChange
* @return string
public function insertComment( $rc ) {
if( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) {
if( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) {
- return ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
+ return ' <span class="history-deleted">' . $this->msg( 'rev-deleted-comment' )->escaped() . '</span>';
} else {
return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
}
static $cache = array();
if( $count > 0 ) {
if( !isset( $cache[$count] ) ) {
- $cache[$count] = wfMsgExt( 'number_of_watching_users_RCview',
- array('parsemag', 'escape' ), $this->getLanguage()->formatNum( $count ) );
+ $cache[$count] = $this->msg( 'number_of_watching_users_RCview' )->numParams( $count )->escaped();
}
return $cache[$count];
} else {
# Edit/log timestamp
$this->insertTimestamp( $s, $rc );
# Bytes added or removed
- if( $wgRCShowChangedSize ) {
- $cd = $rc->getCharacterDifference();
- if( $cd != '' ) {
+ if ( $wgRCShowChangedSize ) {
+ $cd = $this->formatCharacterDifference( $rc );
+ if ( $cd !== '' ) {
$s .= "$cd . . ";
}
}
# How many users watch this page
if( $rc->numberofWatchingusers > 0 ) {
- $s .= ' ' . wfMsgExt( 'number_of_watching_users_RCview',
- array( 'parsemag', 'escape' ), $this->getLanguage()->formatNum( $rc->numberofWatchingusers ) );
+ $s .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
}
if( $this->watchlist ) {
$curIdEq = array( 'curid' => $rc->mAttribs['rc_cur_id'] );
# If it's a new day, add the headline and flush the cache
- $date = $this->getLanguage()->date( $rc->mAttribs['rc_timestamp'], true );
+ $date = $this->getLanguage()->userDate( $rc->mAttribs['rc_timestamp'], $this->getUser() );
$ret = '';
if( $date != $this->lastdate ) {
# Process current cache
$showdifflinks = false;
}
- $time = $this->getLanguage()->time( $rc->mAttribs['rc_timestamp'], true, true );
+ $time = $this->getLanguage()->userTime( $rc->mAttribs['rc_timestamp'], $this->getUser() );
$rc->watched = $watched;
$rc->link = $clink;
$rc->timestamp = $time;
# Make user links
if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
- $rc->userlink = ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
+ $rc->userlink = ' <span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
} else {
$rc->userlink = Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
$rc->usertalklink = Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
# Article link
if( $namehidden ) {
- $r .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
+ $r .= ' <span class="history-deleted">' . $this->msg( 'rev-deleted-event' )->escaped() . '</span>';
} elseif( $allLogs ) {
$r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
} else {
$n = count($block);
static $nchanges = array();
if ( !isset( $nchanges[$n] ) ) {
- $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $this->getLanguage()->formatNum( $n ) );
+ $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
}
# Total change link
$r .= ' ';
$first--;
}
# Get net change
- $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs['rc_old_len'],
- $block[$last]->mAttribs['rc_new_len'] );
+ $chardiff = $this->formatCharacterDifference( $block[$first], $block[$last] );
if( $chardiff == '' ) {
$r .= ' ';
$r .= ' . . ';
# Character diff
- if( $wgRCShowChangedSize && $rcObj->getCharacterDifference() ) {
- $r .= $rcObj->getCharacterDifference() . ' . . ' ;
+ if ( $wgRCShowChangedSize ) {
+ $cd = $this->formatCharacterDifference( $rcObj );
+ if ( $cd !== '' ) {
+ $r .= "$cd . . ";
+ }
}
if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) {
* @return String: HTML <img> tag
*/
protected function sideArrow() {
- global $wgLang;
- $dir = $wgLang->isRTL() ? 'l' : 'r';
- return $this->arrow( $dir, '+', wfMsg( 'rc-enhanced-expand' ) );
+ $dir = $this->getLanguage()->isRTL() ? 'l' : 'r';
+ return $this->arrow( $dir, '+', $this->msg( 'rc-enhanced-expand' )->text() );
}
/**
* @return String: HTML <img> tag
*/
protected function downArrow() {
- return $this->arrow( 'd', '-', wfMsg( 'rc-enhanced-hide' ) );
+ return $this->arrow( 'd', '-', $this->msg( 'rc-enhanced-hide' )->text() );
}
/**
}
$r .= ' . . ';
# Character diff
- if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) {
- $r .= "$cd . . ";
+ if ( $wgRCShowChangedSize ) {
+ $cd = $this->formatCharacterDifference( $rcObj );
+ if ( $cd !== '' ) {
+ $r .= "$cd . . ";
+ }
}
if ( $type == RC_LOG ) {
$r .= $this->insertLogEntry( $rcObj );
- } else {
+ } else {
$r .= ' '.$rcObj->userlink . $rcObj->usertalklink;
$r .= $this->insertComment( $rcObj );
$this->insertRollback( $r, $rcObj );