<?php
-/**
- * @package MediaWiki
- * Contain class to show various lists of change:
- * - what's link here
- * - related changes
- * - recent changes
- */
/**
* @todo document
- * @package MediaWiki
*/
class RCCacheEntry extends RecentChange
{
var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
var $userlink, $timestamp, $watched;
- function newFromParent( $rc )
- {
+ static function newFromParent( $rc ) {
$rc2 = new RCCacheEntry;
$rc2->mAttribs = $rc->mAttribs;
$rc2->mExtra = $rc->mExtra;
} ;
/**
- * @package MediaWiki
+ * Class to show various lists of changes:
+ * - what links here
+ * - related changes
+ * - recent changes
*/
class ChangesList {
# Called by history lists and recent changes
#
/** @todo document */
- function ChangesList() {
+ function __construct( &$skin ) {
+ $this->skin =& $skin;
$this->preCacheMessages();
}
* @param $user User to fetch the list class for
* @return ChangesList derivative
*/
- function newFromUser( &$user ) {
+ public static function newFromUser( &$user ) {
+ $sk = $user->getSkin();
$list = NULL;
- if( wfRunHooks( 'FetchChangesList', array( &$user, &$list ) ) ) {
- return $user->getOption( 'usenewrc' ) ? new EnhancedChangesList() : new OldChangesList();
+ if( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) {
+ return $user->getOption( 'usenewrc' ) ? new EnhancedChangesList( $sk ) : new OldChangesList( $sk );
} else {
return $list;
}
// Precache various messages
if( !isset( $this->message ) ) {
foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last '.
- 'blocklink changes history boteditletter' ) as $msg ) {
+ 'blocklink history boteditletter' ) as $msg ) {
$this->message[$msg] = wfMsgExt( $msg, array( 'escape') );
}
}
# Diff
$s .= '(' . $this->message['diff'] . ') (';
# Hist
- $s .= Linker::makeKnownLinkObj( $rc->getMovedToTitle(), $this->message['hist'], 'action=history' ) .
+ $s .= $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message['hist'], 'action=history' ) .
') . . ';
# "[[x]] moved to [[y]]"
$msg = ( $rc->mAttribs['rc_type'] == RC_MOVE ) ? '1movedto2' : '1movedto2_redir';
- $s .= wfMsg( $msg, Linker::makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
- Linker::makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
+ $s .= wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
+ $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
}
function insertDateHeader(&$s, $rc_timestamp) {
function insertLog(&$s, $title, $logtype) {
$logname = LogPage::logName( $logtype );
- $s .= '(' . Linker::makeKnownLinkObj($title, $logname ) . ')';
+ $s .= '(' . $this->skin->makeKnownLinkObj($title, $logname ) . ')';
}
$rcidparam = $unpatrolled
? array( 'rcid' => $rc->mAttribs['rc_id'] )
: array();
- $diffLink = Linker::makeKnownLinkObj( $rc->getTitle(), $this->message['diff'],
+ $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'],
wfArrayToCGI( array(
'curid' => $rc->mAttribs['rc_cur_id'],
'diff' => $rc->mAttribs['rc_this_oldid'],
$s .= '('.$diffLink.') (';
# History link
- $s .= Linker::makeKnownLinkObj( $rc->getTitle(), $this->message['hist'],
+ $s .= $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['hist'],
wfArrayToCGI( array(
'curid' => $rc->mAttribs['rc_cur_id'],
'action' => 'history' ) ) );
$params = ( $unpatrolled && $rc->mAttribs['rc_type'] == RC_NEW )
? 'rcid='.$rc->mAttribs['rc_id']
: '';
- $articlelink = ' '. Linker::makeKnownLinkObj( $rc->getTitle(), '', $params );
- if($watched) $articlelink = '<strong>'.$articlelink.'</strong>';
+ $articlelink = ' '. $this->skin->makeKnownLinkObj( $rc->getTitle(), '', $params );
+ if( $watched )
+ $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
global $wgContLang;
$articlelink .= $wgContLang->getDirMark();
$s .= ' '.$articlelink;
}
- function insertTimestamp(&$s, &$rc) {
+ function insertTimestamp(&$s, $rc) {
global $wgLang;
# Timestamp
$s .= '; ' . $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
/** Insert links to user page, user talk page and eventually a blocking link */
function insertUserRelatedLinks(&$s, &$rc) {
- $s .= Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
- $s .= Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
+ $s .= $this->skin->userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
+ $s .= $this->skin->userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
}
/** insert a formatted comment */
function insertComment(&$s, &$rc) {
# Add comment
if( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) {
- $s .= Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
+ $s .= $this->skin->commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
}
}
*/
function usePatrol() {
global $wgUseRCPatrol, $wgUser;
- return( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) );
+ return( $wgUseRCPatrol && ($wgUser->isAllowed('patrol') || $wgUser->isAllowed('patrolmarks')) );
}
-
+ /**
+ * Returns the string which indicates the number of watching users
+ */
+ function numberofWatchingusers( $count ) {
+ global $wgLang;
+ static $cache = array();
+ if ( $count > 0 ) {
+ if ( !isset( $cache[$count] ) ) {
+ $cache[$count] = wfMsgExt('number_of_watching_users_RCview',
+ array('parsemag', 'escape'), $wgLang->formatNum($count));
+ }
+ return $cache[$count];
+ } else {
+ return '';
+ }
+ }
}
* Format a line using the old system (aka without any javascript).
*/
function recentChangesLine( &$rc, $watched = false ) {
- global $wgContLang;
+ global $wgContLang, $wgRCShowChangedSize;
$fname = 'ChangesList::recentChangesLineOld';
wfProfileIn( $fname );
-
# Extract DB fields into local scope
+ // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
extract( $rc->mAttribs );
- $curIdEq = 'curid=' . $rc_cur_id;
# Should patrol-related stuff be shown?
$unpatrolled = $this->usePatrol() && $rc_patrolled == 0;
wfProfileIn( $fname.'-rest' );
$this->insertTimestamp($s,$rc);
+
+ if( $wgRCShowChangedSize ) {
+ $s .= ( $rc->getCharacterDifference() == '' ? '' : $rc->getCharacterDifference() . ' . . ' );
+ }
+
$this->insertUserRelatedLinks($s,$rc);
$this->insertComment($s, $rc);
- if($rc->numberofWatchingusers > 0) {
- $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers));
- }
+ $s .= rtrim(' ' . $this->numberofWatchingusers($rc->numberofWatchingusers));
$s .= "</li>\n";
$rc = RCCacheEntry::newFromParent( $baseRC );
# Extract fields from DB into the function scope (rc_xxxx variables)
+ // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
extract( $rc->mAttribs );
$curIdEq = 'curid=' . $rc_cur_id;
# Make article link
if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
$msg = ( $rc_type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir";
- $clink = wfMsg( $msg, Linker::makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
- Linker::makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
+ $clink = wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
+ $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
} elseif( $rc_namespace == NS_SPECIAL ) {
list( $specialName, $logtype ) = SpecialPage::resolveAliasWithSubpage( $rc_title );
if ( $specialName == 'Log' ) {
# Log updates, etc
$logname = LogPage::logName( $logtype );
- $clink = '(' . Linker::makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
+ $clink = '(' . $this->skin->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
} else {
wfDebug( "Unexpected special page in recentchanges\n" );
$clink = '';
}
} elseif( $rc->unpatrolled && $rc_type == RC_NEW ) {
# Unpatrolled new page, give rc_id in query
- $clink = Linker::makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
+ $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
} else {
- $clink = Linker::makeKnownLinkObj( $rc->getTitle(), '' );
+ $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '' );
}
$time = $wgContLang->time( $rc_timestamp, true, true );
$querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
$querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
$aprops = ' tabindex="'.$baseRC->counter.'"';
- $curLink = Linker::makeKnownLinkObj( $rc->getTitle(), $this->message['cur'], $querycur, '' ,'', $aprops );
+ $curLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['cur'], $querycur, '' ,'', $aprops );
if( $rc_type == RC_NEW || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
if( $rc_type != RC_NEW ) {
$curLink = $this->message['cur'];
}
$diffLink = $this->message['diff'];
} else {
- $diffLink = Linker::makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], $querydiff, '' ,'', $aprops );
+ $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], $querydiff, '' ,'', $aprops );
}
# Make "last" link
if( $rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
$lastLink = $this->message['last'];
} else {
- $lastLink = Linker::makeKnownLinkObj( $rc->getTitle(), $this->message['last'],
+ $lastLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['last'],
$curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
}
- $rc->userlink = Linker::userLink( $rc_user, $rc_user_text );
+ $rc->userlink = $this->skin->userLink( $rc_user, $rc_user_text );
$rc->lastlink = $lastLink;
$rc->curlink = $curLink;
$rc->difflink = $diffLink;
- $rc->usertalklink = Linker::userToolLinks( $rc_user, $rc_user_text );
+ $rc->usertalklink = $this->skin->userToolLinks( $rc_user, $rc_user_text );
# Put accumulated information into the cache, for later display
# Page moves go on their own line
* Enhanced RC group
*/
function recentChangesBlockGroup( $block ) {
- global $wgContLang;
+ global $wgLang, $wgContLang, $wgRCShowChangedSize;
$r = '';
# Collate list of users
$userlinks = array();
foreach( $block as $rcObj ) {
$oldid = $rcObj->mAttribs['rc_last_oldid'];
- $newid = $rcObj->mAttribs['rc_this_oldid'];
if( $rcObj->mAttribs['rc_new'] ) {
$isnew = true;
}
$r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
# Timestamp
- $r .= ' '.$block[0]->timestamp.' ';
- $r .= '</tt>';
+ $r .= ' '.$block[0]->timestamp.' </tt>';
# Article link
$r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
$currentRevision = $block[0]->mAttribs['rc_this_oldid'];
if( $block[0]->mAttribs['rc_type'] != RC_LOG ) {
# Changes
- $r .= ' ('.count($block).' ';
+
+ $n = count($block);
+ static $nchanges = array();
+ if ( !isset( $nchanges[$n] ) ) {
+ $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape'),
+ $wgLang->formatNum( $n ) );
+ }
+
+ $r .= ' (';
+
if( $isnew ) {
- $r .= $this->message['changes'];
+ $r .= $nchanges[$n];
} else {
- $r .= Linker::makeKnownLinkObj( $block[0]->getTitle(),
- $this->message['changes'], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
+ $r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
+ $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
}
- $r .= '; ';
+
+ $r .= ') . . ';
+
+ if( $wgRCShowChangedSize ) {
+ # Character difference
+ $chardiff = $rcObj->getCharacterDifference( $block[ count( $block ) - 1 ]->mAttribs['rc_old_len'],
+ $block[0]->mAttribs['rc_new_len'] );
+ if( $chardiff == '' ) {
+ $r .= ' (';
+ } else {
+ $r .= ' ' . $chardiff. ' . . ';
+ }
+ }
# History
- $r .= Linker::makeKnownLinkObj( $block[0]->getTitle(),
+ $r .= '(' . $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
$this->message['history'], $curIdEq.'&action=history' );
$r .= ')';
}
$r .= $users;
- if($block[0]->numberofWatchingusers > 0) {
- global $wgContLang;
- $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($block[0]->numberofWatchingusers));
- }
+ $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers);
$r .= "<br />\n";
# Sub-entries
$r .= '<div id="'.$rci.'" style="display:none">';
foreach( $block as $rcObj ) {
# Get rc_xxxx variables
+ // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
extract( $rcObj->mAttribs );
$r .= $this->spacerArrow();
if( $rc_type == RC_LOG ) {
$link = $rcObj->timestamp;
} else {
- $link = Linker::makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp, $curIdEq.'&'.$o );
+ $link = $this->skin->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp, $curIdEq.'&'.$o );
}
$link = '<tt>'.$link.'</tt>';
$r .= $rcObj->curlink;
$r .= '; ';
$r .= $rcObj->lastlink;
- $r .= ') . . '.$rcObj->userlink;
+ $r .= ') . . ';
+
+ # Character diff
+ if( $wgRCShowChangedSize ) {
+ $r .= ( $rcObj->getCharacterDifference() == '' ? '' : $rcObj->getCharacterDifference() . ' . . ' ) ;
+ }
+
+ $r .= $rcObj->userlink;
$r .= $rcObj->usertalklink;
- $r .= Linker::commentBlock( $rc_comment, $rcObj->getTitle() );
+ $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() );
$r .= "<br />\n";
}
$r .= "</div>\n";
function maybeWatchedLink( $link, $watched=false ) {
if( $watched ) {
// FIXME: css style might be more appropriate
- return '<strong>' . $link . '</strong>';
+ return '<strong class="mw-watched">' . $link . '</strong>';
} else {
return $link;
}
* @return string a HTML formated line (generated using $r)
*/
function recentChangesBlockLine( $rcObj ) {
- global $wgContLang;
+ global $wgContLang, $wgRCShowChangedSize;
# Get rc_xxxx variables
+ // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
extract( $rcObj->mAttribs );
$curIdEq = 'curid='.$rc_cur_id;
$r .= ' ('. $rcObj->difflink .'; ';
# Hist
- $r .= Linker::makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
+ $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ') . . ';
+
+ # Character diff
+ if( $wgRCShowChangedSize ) {
+ $r .= ( $rcObj->getCharacterDifference() == '' ? '' : ' ' . $rcObj->getCharacterDifference() . ' . . ' ) ;
+ }
# User/talk
- $r .= ') . . '.$rcObj->userlink . $rcObj->usertalklink;
+ $r .= $rcObj->userlink . $rcObj->usertalklink;
# Comment
if( $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) {
- $r .= Linker::commentBlock( $rc_comment, $rcObj->getTitle() );
+ $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() );
}
- if( $rcObj->numberofWatchingusers > 0 ) {
- $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rcObj->numberofWatchingusers));
- }
+ $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers);
$r .= "<br />\n";
return $r;
return '';
}
$blockOut = '';
- foreach( $this->rc_cache as $secureName => $block ) {
+ foreach( $this->rc_cache as $block ) {
if( count( $block ) < 2 ) {
$blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
} else {
}
}
-?>
+