$f = '';
foreach ( array_keys( $this->getConfig()->get( 'RecentChangesFlags' ) ) as $flag ) {
$f .= isset( $flags[$flag] ) && $flags[$flag]
- ? self::flag( $flag )
+ ? self::flag( $flag, $this->getContext() )
: $nothing;
}
}
/**
- * 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
- * unpatrolled edit. By default in English it will contain "N", "m", "b",
- * "!" respectively, plus it will have an appropriate title and class.
+ * 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;
+ }
+
+ /**
+ * Make an "<abbr>" element for a given change flag. The flag indicating a new page, minor edit,
+ * bot edit, or unpatrolled edit. In English it typically contains "N", "m", "b", or "!".
*
* @param string $flag One key of $wgRecentChangesFlags
- * @return string Raw HTML
+ * @param IContextSource $context
+ * @return string HTML
*/
- public static function flag( $flag ) {
+ public static function flag( $flag, IContextSource $context = null ) {
+ static $map = [ 'minoredit' => 'minor', 'botedit' => 'bot' ];
static $flagInfos = null;
+
if ( is_null( $flagInfos ) ) {
global $wgRecentChangesFlags;
$flagInfos = [];
foreach ( $wgRecentChangesFlags as $key => $value ) {
- $flagInfos[$key]['letter'] = wfMessage( $value['letter'] )->escaped();
- $flagInfos[$key]['title'] = wfMessage( $value['title'] )->escaped();
+ $flagInfos[$key]['letter'] = $value['letter'];
+ $flagInfos[$key]['title'] = $value['title'];
// Allow customized class name, fall back to flag name
- $flagInfos[$key]['class'] = Sanitizer::escapeClass(
- isset( $value['class'] ) ? $value['class'] : $key );
+ $flagInfos[$key]['class'] = isset( $value['class'] ) ? $value['class'] : $key;
}
}
- // Inconsistent naming, bleh, kepted for b/c
- $map = [
- 'minoredit' => 'minor',
- 'botedit' => 'bot',
- ];
+ $context = $context ?: RequestContext::getMain();
+
+ // Inconsistent naming, kepted for b/c
if ( isset( $map[$flag] ) ) {
$flag = $map[$flag];
}
- return "<abbr class='" . $flagInfos[$flag]['class'] . "' title='" .
- $flagInfos[$flag]['title'] . "'>" . $flagInfos[$flag]['letter'] .
- '</abbr>';
+ $info = $flagInfos[$flag];
+ return Html::element( 'abbr', [
+ 'class' => $info['class'],
+ 'title' => wfMessage( $info['title'] )->setContext( $context )->text(),
+ ], wfMessage( $info['letter'] )->setContext( $context )->text() );
}
/**
*/
public function insertLog( &$s, $title, $logtype ) {
$page = new LogPage( $logtype );
- $logname = $page->getName()->escaped();
+ $logname = $page->getName()->setContext( $this->getContext() )->escaped();
$s .= $this->msg( 'parentheses' )->rawParams( Linker::linkKnown( $title, $logname ) )->escaped();
}
/**
* @param string $s HTML to update
* @param RecentChange $rc
- * @param bool $unpatrolled
+ * @param bool|null $unpatrolled Unused variable, since 1.27.
*/
- public function insertDiffHist( &$s, &$rc, $unpatrolled ) {
+ public function insertDiffHist( &$s, &$rc, $unpatrolled = null ) {
# Diff link
if (
$rc->mAttribs['rc_type'] == RC_NEW ||