mAttribs = $rc->mAttribs;
$rc2->mExtra = $rc->mExtra;
return $rc2;
}
} ;
/**
* 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 __construct( &$skin ) {
$this->skin =& $skin;
$this->preCacheMessages();
}
/**
* Fetch an appropriate changes list class for the specified user
* Some users might want to use an enhanced list format, for instance
*
* @param $user User to fetch the list class for
* @return ChangesList derivative
*/
public static function newFromUser( &$user ) {
$sk = $user->getSkin();
$list = NULL;
if( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) {
return $user->getOption( 'usenewrc' ) ? new EnhancedChangesList( $sk ) : new OldChangesList( $sk );
} else {
return $list;
}
}
/**
* As we use the same small set of messages in various methods and that
* they are called often, we call them once and save them in $this->message
*/
function preCacheMessages() {
// Precache various messages
if( !isset( $this->message ) ) {
foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last '.
'blocklink history boteditletter semicolon-separator' ) as $msg ) {
$this->message[$msg] = wfMsgExt( $msg, array( 'escape') );
}
}
}
/**
* Returns the appropriate flags for new page, minor change and patrolling
*/
function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ', $bot = false ) {
$f = $new ? '' . $this->message['newpageletter'] . ''
: $nothing;
$f .= $minor ? '' . $this->message['minoreditletter'] . ''
: $nothing;
$f .= $bot ? '' . $this->message['boteditletter'] . '' : $nothing;
$f .= $patrolled ? '!' : $nothing;
return "$f";
}
/**
* Returns text for the start of the tabular part of RC
*/
function beginRecentChangesList() {
$this->rc_cache = array();
$this->rcMoveIndex = 0;
$this->rcCacheIndex = 0;
$this->lastdate = '';
$this->rclistOpen = false;
return '';
}
/**
* Returns text for the end of RC
*/
function endRecentChangesList() {
if( $this->rclistOpen ) {
return "\n";
} else {
return '';
}
}
/**
* int $field one of DELETED_* bitfield constants
* @return bool
*/
function isDeleted( $rc, $field ) {
return ($rc->mAttribs['rc_deleted'] & $field) == $field;
}
/**
* Determine if the current user is allowed to view a particular
* field of this revision, if it's marked as deleted.
* @param int $field
* @return bool
*/
function userCan( $rc, $field ) {
if( ( $rc->mAttribs['rc_deleted'] & $field ) == $field ) {
global $wgUser;
$permission = ( $rc->mAttribs['rc_deleted'] & Revision::DELETED_RESTRICTED ) == Revision::DELETED_RESTRICTED
? 'hiderevision'
: 'deleterevision';
wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" );
return $wgUser->isAllowed( $permission );
} else {
return true;
}
}
function insertMove( &$s, $rc ) {
# Diff
$s .= '(' . $this->message['diff'] . ') (';
# Hist
$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, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
$this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
}
function insertDateHeader(&$s, $rc_timestamp) {
global $wgLang;
# Make date header if necessary
$date = $wgLang->date( $rc_timestamp, true, true );
$s = '';
if( $date != $this->lastdate ) {
if( '' != $this->lastdate ) {
$s .= "\n";
}
$s .= '
'.$date."
\n