2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-01-17 05:49:39 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Utility class for creating new RC entries
|
2005-06-29 07:01:24 +00:00
|
|
|
* mAttribs:
|
2004-09-02 23:28:24 +00:00
|
|
|
* rc_id id of the row in the recentchanges table
|
|
|
|
|
* rc_timestamp time the entry was made
|
|
|
|
|
* rc_cur_time timestamp on the cur row
|
|
|
|
|
* rc_namespace namespace #
|
|
|
|
|
* rc_title non-prefixed db key
|
|
|
|
|
* rc_type is new entry, used to determine whether updating is necessary
|
|
|
|
|
* rc_minor is minor
|
2005-03-13 07:19:13 +00:00
|
|
|
* rc_cur_id page_id of associated page entry
|
2004-09-02 23:28:24 +00:00
|
|
|
* rc_user user id who made the entry
|
|
|
|
|
* rc_user_text user name who made the entry
|
|
|
|
|
* rc_comment edit summary
|
2005-03-13 07:19:13 +00:00
|
|
|
* rc_this_oldid rev_id associated with this entry (or zero)
|
|
|
|
|
* rc_last_oldid rev_id associated with the entry before this one (or zero)
|
2004-09-02 23:28:24 +00:00
|
|
|
* rc_bot is bot, hidden
|
|
|
|
|
* rc_ip IP address of the user in dotted quad notation
|
|
|
|
|
* rc_new obsolete, use rc_type==RC_NEW
|
|
|
|
|
* rc_patrolled boolean whether or not someone has marked this edit as patrolled
|
2006-12-25 15:17:33 +00:00
|
|
|
* rc_old_len integer byte length of the text before the edit
|
2006-12-09 11:36:35 +00:00
|
|
|
* rc_new_len the same after the edit
|
2008-03-16 21:02:10 +00:00
|
|
|
* rc_deleted partial deletion
|
2008-03-16 20:59:59 +00:00
|
|
|
* rc_logid the log_id value for this log entry (or zero)
|
|
|
|
|
* rc_log_type the log type (or null)
|
|
|
|
|
* rc_log_action the log action (or null)
|
|
|
|
|
* rc_params log params
|
2005-07-01 10:44:48 +00:00
|
|
|
*
|
2004-09-02 23:28:24 +00:00
|
|
|
* mExtra:
|
|
|
|
|
* prefixedDBkey prefixed db key, used by external app via msg queue
|
|
|
|
|
* lastTimestamp timestamp of previous entry, used in WHERE clause during update
|
|
|
|
|
* lang the interwiki prefix, automatically set in save()
|
2005-06-29 07:01:24 +00:00
|
|
|
* oldSize text size before the change
|
|
|
|
|
* newSize text size after the change
|
2005-07-01 10:44:48 +00:00
|
|
|
*
|
2004-12-18 03:47:11 +00:00
|
|
|
* temporary: not stored in the database
|
|
|
|
|
* notificationtimestamp
|
|
|
|
|
* numberofWatchingusers
|
|
|
|
|
*
|
2004-09-02 23:28:24 +00:00
|
|
|
* @todo document functions and variables
|
|
|
|
|
*/
|
2006-05-11 22:40:38 +00:00
|
|
|
class RecentChange
|
|
|
|
|
{
|
|
|
|
|
var $mAttribs = array(), $mExtra = array();
|
|
|
|
|
var $mTitle = false, $mMovedToTitle = false;
|
|
|
|
|
var $numberofWatchingusers = 0 ; # Dummy to prevent error message in SpecialRecentchangeslinked
|
2004-01-17 05:49:39 +00:00
|
|
|
|
|
|
|
|
# Factory methods
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2008-09-16 05:56:43 +00:00
|
|
|
public static function newFromRow( $row )
|
|
|
|
|
{
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc = new RecentChange;
|
|
|
|
|
$rc->loadFromRow( $row );
|
|
|
|
|
return $rc;
|
|
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2008-09-16 05:56:43 +00:00
|
|
|
public static function newFromCurRow( $row )
|
|
|
|
|
{
|
2004-01-17 09:49:43 +00:00
|
|
|
$rc = new RecentChange;
|
2008-06-16 02:39:43 +00:00
|
|
|
$rc->loadFromCurRow( $row );
|
2004-12-18 03:47:11 +00:00
|
|
|
$rc->notificationtimestamp = false;
|
|
|
|
|
$rc->numberofWatchingusers = false;
|
2004-01-17 09:49:43 +00:00
|
|
|
return $rc;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-12-22 19:43:20 +00:00
|
|
|
/**
|
|
|
|
|
* Obtain the recent change with a given rc_id value
|
|
|
|
|
*
|
|
|
|
|
* @param $rcid rc_id value to retrieve
|
|
|
|
|
* @return RecentChange
|
|
|
|
|
*/
|
|
|
|
|
public static function newFromId( $rcid ) {
|
2007-01-22 23:50:42 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
2006-12-22 19:43:20 +00:00
|
|
|
$res = $dbr->select( 'recentchanges', '*', array( 'rc_id' => $rcid ), __METHOD__ );
|
|
|
|
|
if( $res && $dbr->numRows( $res ) > 0 ) {
|
|
|
|
|
$row = $dbr->fetchObject( $res );
|
|
|
|
|
$dbr->freeResult( $res );
|
|
|
|
|
return self::newFromRow( $row );
|
|
|
|
|
} else {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-08-06 03:29:40 +00:00
|
|
|
/**
|
|
|
|
|
* Find the first recent change matching some specific conditions
|
|
|
|
|
*
|
|
|
|
|
* @param array $conds Array of conditions
|
|
|
|
|
* @param mixed $fname Override the method name in profiling/logs
|
|
|
|
|
* @return RecentChange
|
|
|
|
|
*/
|
|
|
|
|
public static function newFromConds( $conds, $fname = false ) {
|
|
|
|
|
if( $fname === false )
|
|
|
|
|
$fname = __METHOD__;
|
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
$res = $dbr->select(
|
|
|
|
|
'recentchanges',
|
|
|
|
|
'*',
|
|
|
|
|
$conds,
|
|
|
|
|
$fname
|
|
|
|
|
);
|
|
|
|
|
if( $res instanceof ResultWrapper && $res->numRows() > 0 ) {
|
|
|
|
|
$row = $res->fetchObject();
|
|
|
|
|
$res->free();
|
|
|
|
|
return self::newFromRow( $row );
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2004-01-17 09:49:43 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
# Accessors
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2008-09-16 05:56:43 +00:00
|
|
|
function setAttribs( $attribs )
|
|
|
|
|
{
|
2004-01-17 05:49:39 +00:00
|
|
|
$this->mAttribs = $attribs;
|
|
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2008-09-16 05:56:43 +00:00
|
|
|
function setExtra( $extra )
|
|
|
|
|
{
|
2004-01-17 05:49:39 +00:00
|
|
|
$this->mExtra = $extra;
|
|
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2008-09-16 05:56:43 +00:00
|
|
|
function &getTitle()
|
|
|
|
|
{
|
2004-01-17 05:49:39 +00:00
|
|
|
if ( $this->mTitle === false ) {
|
|
|
|
|
$this->mTitle = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
|
|
|
|
|
}
|
|
|
|
|
return $this->mTitle;
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-16 05:56:43 +00:00
|
|
|
function getMovedToTitle()
|
|
|
|
|
{
|
2004-01-17 05:49:39 +00:00
|
|
|
if ( $this->mMovedToTitle === false ) {
|
2004-08-09 05:38:11 +00:00
|
|
|
$this->mMovedToTitle = Title::makeTitle( $this->mAttribs['rc_moved_to_ns'],
|
2004-01-17 05:49:39 +00:00
|
|
|
$this->mAttribs['rc_moved_to_title'] );
|
|
|
|
|
}
|
|
|
|
|
return $this->mMovedToTitle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Writes the data in this object to the database
|
2008-09-16 05:56:43 +00:00
|
|
|
function save()
|
|
|
|
|
{
|
2008-10-13 06:17:42 +00:00
|
|
|
global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, $wgRC2UDPOmitBots;
|
2004-08-22 17:24:50 +00:00
|
|
|
$fname = 'RecentChange::save';
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2007-01-22 23:50:42 +00:00
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
2004-01-17 05:49:39 +00:00
|
|
|
if ( !is_array($this->mExtra) ) {
|
|
|
|
|
$this->mExtra = array();
|
|
|
|
|
}
|
|
|
|
|
$this->mExtra['lang'] = $wgLocalInterwiki;
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2004-06-14 10:40:24 +00:00
|
|
|
if ( !$wgPutIPinRC ) {
|
|
|
|
|
$this->mAttribs['rc_ip'] = '';
|
|
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2008-09-22 12:22:18 +00:00
|
|
|
# If our database is strict about IP addresses, use NULL instead of an empty string
|
2006-08-16 00:59:34 +00:00
|
|
|
if ( $dbw->strictIPs() and $this->mAttribs['rc_ip'] == '' ) {
|
|
|
|
|
unset( $this->mAttribs['rc_ip'] );
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-19 12:59:57 +00:00
|
|
|
# Fixup database timestamps
|
2005-08-02 13:35:19 +00:00
|
|
|
$this->mAttribs['rc_timestamp'] = $dbw->timestamp($this->mAttribs['rc_timestamp']);
|
|
|
|
|
$this->mAttribs['rc_cur_time'] = $dbw->timestamp($this->mAttribs['rc_cur_time']);
|
|
|
|
|
$this->mAttribs['rc_id'] = $dbw->nextSequenceValue( 'rc_rc_id_seq' );
|
2004-08-19 12:59:57 +00:00
|
|
|
|
2006-07-23 01:13:56 +00:00
|
|
|
## If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL
|
|
|
|
|
if ( $dbw->cascadingDeletes() and $this->mAttribs['rc_cur_id']==0 ) {
|
|
|
|
|
unset ( $this->mAttribs['rc_cur_id'] );
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
# Insert new row
|
2004-10-24 07:10:33 +00:00
|
|
|
$dbw->insert( 'recentchanges', $this->mAttribs, $fname );
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2006-03-18 22:47:40 +00:00
|
|
|
# Set the ID
|
|
|
|
|
$this->mAttribs['rc_id'] = $dbw->insertId();
|
2005-11-03 11:27:10 +00:00
|
|
|
|
2005-06-29 07:01:24 +00:00
|
|
|
# Notify external application via UDP
|
2008-06-10 13:56:35 +00:00
|
|
|
if ( $wgRC2UDPAddress && ( !$this->mAttribs['rc_bot'] || !$wgRC2UDPOmitBots ) ) {
|
2008-10-17 23:46:21 +00:00
|
|
|
UDP::sendToUDP( $this->getIRCLine() );
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-09-30 12:34:53 +00:00
|
|
|
# E-mail notifications
|
2008-05-17 23:34:28 +00:00
|
|
|
global $wgUseEnotif, $wgShowUpdatedMarker, $wgUser;
|
|
|
|
|
if( $wgUseEnotif || $wgShowUpdatedMarker ) {
|
2008-05-17 22:57:46 +00:00
|
|
|
// Users
|
|
|
|
|
if( $this->mAttribs['rc_user'] ) {
|
2008-05-22 16:39:43 +00:00
|
|
|
$editor = ($wgUser->getId() == $this->mAttribs['rc_user']) ?
|
2008-05-17 22:57:46 +00:00
|
|
|
$wgUser : User::newFromID( $this->mAttribs['rc_user'] );
|
|
|
|
|
// Anons
|
|
|
|
|
} else {
|
|
|
|
|
$editor = ($wgUser->getName() == $this->mAttribs['rc_user_text']) ?
|
|
|
|
|
$wgUser : User::newFromName( $this->mAttribs['rc_user_text'], false );
|
|
|
|
|
}
|
2008-05-17 22:23:56 +00:00
|
|
|
# FIXME: this would be better as an extension hook
|
2008-05-17 22:32:39 +00:00
|
|
|
$enotif = new EmailNotification();
|
2005-12-08 01:36:33 +00:00
|
|
|
$title = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
|
2008-05-17 22:37:06 +00:00
|
|
|
$enotif->notifyOnPageChange( $editor, $title,
|
2005-12-08 01:36:33 +00:00
|
|
|
$this->mAttribs['rc_timestamp'],
|
|
|
|
|
$this->mAttribs['rc_comment'],
|
|
|
|
|
$this->mAttribs['rc_minor'],
|
|
|
|
|
$this->mAttribs['rc_last_oldid'] );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-09-30 12:34:53 +00:00
|
|
|
# Notify extensions
|
|
|
|
|
wfRunHooks( 'RecentChange_save', array( &$this ) );
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2007-08-06 03:29:40 +00:00
|
|
|
/**
|
|
|
|
|
* Mark a given change as patrolled
|
|
|
|
|
*
|
|
|
|
|
* @param mixed $change RecentChange or corresponding rc_id
|
2008-09-19 00:11:41 +00:00
|
|
|
* @param bool $auto for automatic patrol
|
2008-09-04 15:17:51 +00:00
|
|
|
* @return See doMarkPatrolled(), or null if $change is not an existing rc_id
|
2007-08-06 03:29:40 +00:00
|
|
|
*/
|
2008-09-19 00:11:41 +00:00
|
|
|
public static function markPatrolled( $change, $auto = false ) {
|
2008-09-04 15:17:51 +00:00
|
|
|
$change = $change instanceof RecentChange
|
|
|
|
|
? $change
|
|
|
|
|
: RecentChange::newFromId($change);
|
2008-09-20 07:55:14 +00:00
|
|
|
if( !$change instanceof RecentChange ) {
|
2008-09-04 15:17:51 +00:00
|
|
|
return null;
|
2008-09-20 07:55:14 +00:00
|
|
|
}
|
2008-09-19 00:11:41 +00:00
|
|
|
return $change->doMarkPatrolled( $auto );
|
2008-09-04 15:17:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Mark this RecentChange as patrolled
|
|
|
|
|
*
|
|
|
|
|
* NOTE: Can also return 'rcpatroldisabled', 'hookaborted' and 'markedaspatrollederror-noautopatrol' as errors
|
2008-09-19 00:11:41 +00:00
|
|
|
* @param bool $auto for automatic patrol
|
2008-09-04 15:17:51 +00:00
|
|
|
* @return array of permissions errors, see Title::getUserPermissionsErrors()
|
|
|
|
|
*/
|
2008-09-19 00:11:41 +00:00
|
|
|
public function doMarkPatrolled( $auto = false ) {
|
2008-09-04 15:17:51 +00:00
|
|
|
global $wgUser, $wgUseRCPatrol, $wgUseNPPatrol;
|
|
|
|
|
$errors = array();
|
|
|
|
|
// If recentchanges patrol is disabled, only new pages
|
|
|
|
|
// can be patrolled
|
2008-09-20 07:55:14 +00:00
|
|
|
if ( !$wgUseRCPatrol
|
|
|
|
|
&& ( !$wgUseNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) )
|
|
|
|
|
{
|
2008-09-04 15:17:51 +00:00
|
|
|
$errors[] = array('rcpatroldisabled');
|
2008-09-20 07:55:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Automatic patrol needs "autopatrol", ordinary patrol needs "patrol"
|
|
|
|
|
$right = $auto ? 'autopatrol' : 'patrol';
|
|
|
|
|
$errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $wgUser ) );
|
2008-09-19 00:11:41 +00:00
|
|
|
if( !wfRunHooks('MarkPatrolled', array($this->getAttribute('rc_id'), &$wgUser, false)) )
|
2008-09-20 07:55:14 +00:00
|
|
|
$errors[] = array('hookaborted');
|
|
|
|
|
|
2008-09-04 15:17:51 +00:00
|
|
|
// Users without the 'autopatrol' right can't patrol their
|
|
|
|
|
// own revisions
|
2008-09-19 00:11:41 +00:00
|
|
|
if( $wgUser->getName() == $this->getAttribute('rc_user_text') && !$wgUser->isAllowed('autopatrol') )
|
2008-09-04 15:17:51 +00:00
|
|
|
$errors[] = array('markedaspatrollederror-noautopatrol');
|
2008-09-20 07:55:14 +00:00
|
|
|
|
|
|
|
|
if( $errors ) {
|
2008-09-04 15:17:51 +00:00
|
|
|
return $errors;
|
2008-09-20 07:55:14 +00:00
|
|
|
}
|
|
|
|
|
|
2008-09-04 15:17:51 +00:00
|
|
|
// If the change was patrolled already, do nothing
|
2008-09-19 00:11:41 +00:00
|
|
|
if( $this->getAttribute('rc_patrolled') )
|
2008-09-04 15:17:51 +00:00
|
|
|
return array();
|
2008-09-20 07:55:14 +00:00
|
|
|
|
2008-09-19 00:11:41 +00:00
|
|
|
// Actually set the 'patrolled' flag in RC
|
2008-09-04 15:17:51 +00:00
|
|
|
$this->reallyMarkPatrolled();
|
2008-09-20 07:55:14 +00:00
|
|
|
|
2008-09-19 00:11:41 +00:00
|
|
|
// Log this patrol event
|
|
|
|
|
PatrolLog::record( $this, $auto );
|
|
|
|
|
wfRunHooks( 'MarkPatrolledComplete', array($this->getAttribute('rc_id'), &$wgUser, false) );
|
2008-09-04 15:17:51 +00:00
|
|
|
return array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Mark this RecentChange patrolled, without error checking
|
|
|
|
|
* @return int Number of affected rows
|
|
|
|
|
*/
|
|
|
|
|
public function reallyMarkPatrolled() {
|
2007-01-22 23:50:42 +00:00
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
2007-08-06 03:29:40 +00:00
|
|
|
$dbw->update(
|
|
|
|
|
'recentchanges',
|
|
|
|
|
array(
|
2004-08-09 05:38:11 +00:00
|
|
|
'rc_patrolled' => 1
|
2007-08-06 03:29:40 +00:00
|
|
|
),
|
|
|
|
|
array(
|
2008-09-04 15:17:51 +00:00
|
|
|
'rc_id' => $this->getAttribute('rc_id')
|
2007-08-06 03:29:40 +00:00
|
|
|
),
|
|
|
|
|
__METHOD__
|
2004-08-09 05:38:11 +00:00
|
|
|
);
|
2008-02-25 05:58:10 +00:00
|
|
|
return $dbw->affectedRows();
|
2004-08-09 05:38:11 +00:00
|
|
|
}
|
|
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
# Makes an entry in the database corresponding to an edit
|
2007-08-15 15:37:28 +00:00
|
|
|
public static function notifyEdit( $timestamp, &$title, $minor, &$user, $comment,
|
2008-09-19 00:11:41 +00:00
|
|
|
$oldId, $lastTimestamp, $bot, $ip = '', $oldSize = 0, $newSize = 0, $newId = 0)
|
2004-01-17 05:49:39 +00:00
|
|
|
{
|
2004-06-14 10:40:24 +00:00
|
|
|
if ( !$ip ) {
|
2006-06-01 08:19:02 +00:00
|
|
|
$ip = wfGetIP();
|
2005-09-05 02:22:20 +00:00
|
|
|
if ( !$ip ) {
|
|
|
|
|
$ip = '';
|
|
|
|
|
}
|
2004-06-14 10:40:24 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc = new RecentChange;
|
|
|
|
|
$rc->mAttribs = array(
|
|
|
|
|
'rc_timestamp' => $timestamp,
|
|
|
|
|
'rc_cur_time' => $timestamp,
|
|
|
|
|
'rc_namespace' => $title->getNamespace(),
|
|
|
|
|
'rc_title' => $title->getDBkey(),
|
|
|
|
|
'rc_type' => RC_EDIT,
|
|
|
|
|
'rc_minor' => $minor ? 1 : 0,
|
2008-05-14 21:56:30 +00:00
|
|
|
'rc_cur_id' => $title->getArticleID(),
|
2008-05-22 16:39:43 +00:00
|
|
|
'rc_user' => $user->getId(),
|
2004-01-17 05:49:39 +00:00
|
|
|
'rc_user_text' => $user->getName(),
|
|
|
|
|
'rc_comment' => $comment,
|
2005-07-01 20:36:04 +00:00
|
|
|
'rc_this_oldid' => $newId,
|
2004-01-17 05:49:39 +00:00
|
|
|
'rc_last_oldid' => $oldId,
|
2004-01-31 02:22:15 +00:00
|
|
|
'rc_bot' => $bot ? 1 : 0,
|
2004-01-17 05:49:39 +00:00
|
|
|
'rc_moved_to_ns' => 0,
|
2004-01-18 02:24:12 +00:00
|
|
|
'rc_moved_to_title' => '',
|
2006-12-09 11:36:35 +00:00
|
|
|
'rc_ip' => $ip,
|
|
|
|
|
'rc_patrolled' => 0,
|
|
|
|
|
'rc_new' => 0, # obsolete
|
|
|
|
|
'rc_old_len' => $oldSize,
|
2008-04-02 05:07:46 +00:00
|
|
|
'rc_new_len' => $newSize,
|
|
|
|
|
'rc_deleted' => 0,
|
|
|
|
|
'rc_logid' => 0,
|
|
|
|
|
'rc_log_type' => null,
|
|
|
|
|
'rc_log_action' => '',
|
|
|
|
|
'rc_params' => ''
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc->mExtra = array(
|
|
|
|
|
'prefixedDBkey' => $title->getPrefixedDBkey(),
|
2005-06-29 07:01:24 +00:00
|
|
|
'lastTimestamp' => $lastTimestamp,
|
|
|
|
|
'oldSize' => $oldSize,
|
|
|
|
|
'newSize' => $newSize,
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
|
|
|
|
$rc->save();
|
2008-09-19 00:11:41 +00:00
|
|
|
return $rc;
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2006-07-10 15:41:30 +00:00
|
|
|
/**
|
|
|
|
|
* Makes an entry in the database corresponding to page creation
|
|
|
|
|
* Note: the title object must be loaded with the new id using resetArticleID()
|
|
|
|
|
* @todo Document parameters and return
|
|
|
|
|
*/
|
2008-01-10 13:33:23 +00:00
|
|
|
public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot,
|
2007-03-16 16:01:07 +00:00
|
|
|
$ip='', $size = 0, $newId = 0 )
|
2004-01-17 05:49:39 +00:00
|
|
|
{
|
2007-10-01 19:50:25 +00:00
|
|
|
if ( !$ip ) {
|
2006-06-01 08:19:02 +00:00
|
|
|
$ip = wfGetIP();
|
2007-10-01 19:50:25 +00:00
|
|
|
if ( !$ip ) {
|
|
|
|
|
$ip = '';
|
|
|
|
|
}
|
2004-06-14 10:40:24 +00:00
|
|
|
}
|
|
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc = new RecentChange;
|
|
|
|
|
$rc->mAttribs = array(
|
2004-06-14 10:40:24 +00:00
|
|
|
'rc_timestamp' => $timestamp,
|
|
|
|
|
'rc_cur_time' => $timestamp,
|
|
|
|
|
'rc_namespace' => $title->getNamespace(),
|
|
|
|
|
'rc_title' => $title->getDBkey(),
|
|
|
|
|
'rc_type' => RC_NEW,
|
|
|
|
|
'rc_minor' => $minor ? 1 : 0,
|
|
|
|
|
'rc_cur_id' => $title->getArticleID(),
|
2008-05-22 16:39:43 +00:00
|
|
|
'rc_user' => $user->getId(),
|
2004-06-14 10:40:24 +00:00
|
|
|
'rc_user_text' => $user->getName(),
|
|
|
|
|
'rc_comment' => $comment,
|
2005-07-01 20:36:04 +00:00
|
|
|
'rc_this_oldid' => $newId,
|
2004-06-14 10:40:24 +00:00
|
|
|
'rc_last_oldid' => 0,
|
|
|
|
|
'rc_bot' => $bot ? 1 : 0,
|
|
|
|
|
'rc_moved_to_ns' => 0,
|
|
|
|
|
'rc_moved_to_title' => '',
|
|
|
|
|
'rc_ip' => $ip,
|
2004-09-11 08:32:58 +00:00
|
|
|
'rc_patrolled' => 0,
|
2008-04-02 05:07:46 +00:00
|
|
|
'rc_new' => 1, # obsolete
|
2006-12-13 20:08:02 +00:00
|
|
|
'rc_old_len' => 0,
|
2008-04-02 05:07:46 +00:00
|
|
|
'rc_new_len' => $size,
|
|
|
|
|
'rc_deleted' => 0,
|
|
|
|
|
'rc_logid' => 0,
|
|
|
|
|
'rc_log_type' => null,
|
|
|
|
|
'rc_log_action' => '',
|
|
|
|
|
'rc_params' => ''
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc->mExtra = array(
|
|
|
|
|
'prefixedDBkey' => $title->getPrefixedDBkey(),
|
2005-06-29 07:01:24 +00:00
|
|
|
'lastTimestamp' => 0,
|
|
|
|
|
'oldSize' => 0,
|
|
|
|
|
'newSize' => $size
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
|
|
|
|
$rc->save();
|
2008-09-20 07:55:14 +00:00
|
|
|
return $rc;
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
# Makes an entry in the database corresponding to a rename
|
2007-08-15 15:37:28 +00:00
|
|
|
public static function notifyMove( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='', $overRedir = false )
|
2004-01-17 05:49:39 +00:00
|
|
|
{
|
2008-01-10 09:54:35 +00:00
|
|
|
global $wgRequest;
|
|
|
|
|
|
2007-10-01 19:50:25 +00:00
|
|
|
if ( !$ip ) {
|
2006-06-01 08:19:02 +00:00
|
|
|
$ip = wfGetIP();
|
2007-10-01 19:50:25 +00:00
|
|
|
if ( !$ip ) {
|
|
|
|
|
$ip = '';
|
|
|
|
|
}
|
2004-06-14 10:40:24 +00:00
|
|
|
}
|
2007-03-16 16:01:07 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc = new RecentChange;
|
|
|
|
|
$rc->mAttribs = array(
|
|
|
|
|
'rc_timestamp' => $timestamp,
|
|
|
|
|
'rc_cur_time' => $timestamp,
|
|
|
|
|
'rc_namespace' => $oldTitle->getNamespace(),
|
|
|
|
|
'rc_title' => $oldTitle->getDBkey(),
|
2004-06-20 11:55:24 +00:00
|
|
|
'rc_type' => $overRedir ? RC_MOVE_OVER_REDIRECT : RC_MOVE,
|
2004-01-17 05:49:39 +00:00
|
|
|
'rc_minor' => 0,
|
|
|
|
|
'rc_cur_id' => $oldTitle->getArticleID(),
|
2008-05-22 16:39:43 +00:00
|
|
|
'rc_user' => $user->getId(),
|
2004-01-17 05:49:39 +00:00
|
|
|
'rc_user_text' => $user->getName(),
|
|
|
|
|
'rc_comment' => $comment,
|
|
|
|
|
'rc_this_oldid' => 0,
|
|
|
|
|
'rc_last_oldid' => 0,
|
2008-01-10 09:54:35 +00:00
|
|
|
'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot' , true ) : 0,
|
2004-01-17 05:49:39 +00:00
|
|
|
'rc_moved_to_ns' => $newTitle->getNamespace(),
|
2004-01-18 02:24:12 +00:00
|
|
|
'rc_moved_to_title' => $newTitle->getDBkey(),
|
2004-06-14 10:40:24 +00:00
|
|
|
'rc_ip' => $ip,
|
2004-08-09 05:38:11 +00:00
|
|
|
'rc_new' => 0, # obsolete
|
2006-12-09 12:28:02 +00:00
|
|
|
'rc_patrolled' => 1,
|
2006-12-13 20:08:02 +00:00
|
|
|
'rc_old_len' => NULL,
|
|
|
|
|
'rc_new_len' => NULL,
|
2008-04-02 05:07:46 +00:00
|
|
|
'rc_deleted' => 0,
|
|
|
|
|
'rc_logid' => 0, # notifyMove not used anymore
|
|
|
|
|
'rc_log_type' => null,
|
|
|
|
|
'rc_log_action' => '',
|
|
|
|
|
'rc_params' => ''
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc->mExtra = array(
|
|
|
|
|
'prefixedDBkey' => $oldTitle->getPrefixedDBkey(),
|
|
|
|
|
'lastTimestamp' => 0,
|
|
|
|
|
'prefixedMoveTo' => $newTitle->getPrefixedDBkey()
|
|
|
|
|
);
|
|
|
|
|
$rc->save();
|
|
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2007-08-15 15:37:28 +00:00
|
|
|
public static function notifyMoveToNew( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='' ) {
|
2004-06-20 23:47:57 +00:00
|
|
|
RecentChange::notifyMove( $timestamp, $oldTitle, $newTitle, $user, $comment, $ip, false );
|
2004-06-20 11:55:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-08-15 15:37:28 +00:00
|
|
|
public static function notifyMoveOverRedirect( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='' ) {
|
2005-12-04 20:51:02 +00:00
|
|
|
RecentChange::notifyMove( $timestamp, $oldTitle, $newTitle, $user, $comment, $ip, true );
|
2004-06-20 11:55:24 +00:00
|
|
|
}
|
|
|
|
|
|
2008-04-20 14:24:10 +00:00
|
|
|
public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip='',
|
2008-04-02 05:07:46 +00:00
|
|
|
$type, $action, $target, $logComment, $params, $newId=0 )
|
2004-01-17 05:49:39 +00:00
|
|
|
{
|
2008-01-10 09:54:35 +00:00
|
|
|
global $wgRequest;
|
|
|
|
|
|
2007-10-01 19:50:25 +00:00
|
|
|
if ( !$ip ) {
|
2006-06-01 08:19:02 +00:00
|
|
|
$ip = wfGetIP();
|
2007-10-01 19:50:25 +00:00
|
|
|
if ( !$ip ) {
|
|
|
|
|
$ip = '';
|
|
|
|
|
}
|
2004-06-14 10:40:24 +00:00
|
|
|
}
|
2007-03-16 16:01:07 +00:00
|
|
|
|
2004-01-17 05:49:39 +00:00
|
|
|
$rc = new RecentChange;
|
|
|
|
|
$rc->mAttribs = array(
|
|
|
|
|
'rc_timestamp' => $timestamp,
|
|
|
|
|
'rc_cur_time' => $timestamp,
|
2008-04-02 05:07:46 +00:00
|
|
|
'rc_namespace' => $target->getNamespace(),
|
|
|
|
|
'rc_title' => $target->getDBkey(),
|
2004-01-17 05:49:39 +00:00
|
|
|
'rc_type' => RC_LOG,
|
|
|
|
|
'rc_minor' => 0,
|
2008-04-02 05:07:46 +00:00
|
|
|
'rc_cur_id' => $target->getArticleID(),
|
2008-05-22 16:39:43 +00:00
|
|
|
'rc_user' => $user->getId(),
|
2004-01-17 05:49:39 +00:00
|
|
|
'rc_user_text' => $user->getName(),
|
2008-04-02 05:07:46 +00:00
|
|
|
'rc_comment' => $logComment,
|
2004-01-17 05:49:39 +00:00
|
|
|
'rc_this_oldid' => 0,
|
|
|
|
|
'rc_last_oldid' => 0,
|
2008-09-30 13:36:40 +00:00
|
|
|
'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot', true ) : 0,
|
2004-01-17 05:49:39 +00:00
|
|
|
'rc_moved_to_ns' => 0,
|
2004-01-18 02:24:12 +00:00
|
|
|
'rc_moved_to_title' => '',
|
2004-06-14 10:40:24 +00:00
|
|
|
'rc_ip' => $ip,
|
2004-08-09 05:38:11 +00:00
|
|
|
'rc_patrolled' => 1,
|
2006-12-09 12:28:02 +00:00
|
|
|
'rc_new' => 0, # obsolete
|
2006-12-13 20:08:02 +00:00
|
|
|
'rc_old_len' => NULL,
|
|
|
|
|
'rc_new_len' => NULL,
|
2008-04-02 05:07:46 +00:00
|
|
|
'rc_deleted' => 0,
|
|
|
|
|
'rc_logid' => $newId,
|
|
|
|
|
'rc_log_type' => $type,
|
|
|
|
|
'rc_log_action' => $action,
|
|
|
|
|
'rc_params' => $params
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
|
|
|
|
$rc->mExtra = array(
|
|
|
|
|
'prefixedDBkey' => $title->getPrefixedDBkey(),
|
2006-03-06 13:51:58 +00:00
|
|
|
'lastTimestamp' => 0,
|
2008-04-20 14:24:10 +00:00
|
|
|
'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage
|
2004-01-17 05:49:39 +00:00
|
|
|
);
|
|
|
|
|
$rc->save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Initialises the members of this object from a mysql row object
|
|
|
|
|
function loadFromRow( $row )
|
|
|
|
|
{
|
|
|
|
|
$this->mAttribs = get_object_vars( $row );
|
2005-08-02 13:35:19 +00:00
|
|
|
$this->mAttribs["rc_timestamp"] = wfTimestamp(TS_MW, $this->mAttribs["rc_timestamp"]);
|
2004-01-17 05:49:39 +00:00
|
|
|
$this->mExtra = array();
|
|
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2006-12-23 23:08:41 +00:00
|
|
|
# Makes a pseudo-RC entry from a cur row
|
2005-07-01 23:50:11 +00:00
|
|
|
function loadFromCurRow( $row )
|
2004-01-17 09:49:43 +00:00
|
|
|
{
|
|
|
|
|
$this->mAttribs = array(
|
2005-08-02 13:35:19 +00:00
|
|
|
'rc_timestamp' => wfTimestamp(TS_MW, $row->rev_timestamp),
|
2004-12-19 08:00:50 +00:00
|
|
|
'rc_cur_time' => $row->rev_timestamp,
|
|
|
|
|
'rc_user' => $row->rev_user,
|
|
|
|
|
'rc_user_text' => $row->rev_user_text,
|
|
|
|
|
'rc_namespace' => $row->page_namespace,
|
|
|
|
|
'rc_title' => $row->page_title,
|
|
|
|
|
'rc_comment' => $row->rev_comment,
|
2005-07-01 05:28:07 +00:00
|
|
|
'rc_minor' => $row->rev_minor_edit ? 1 : 0,
|
2004-12-19 08:00:50 +00:00
|
|
|
'rc_type' => $row->page_is_new ? RC_NEW : RC_EDIT,
|
|
|
|
|
'rc_cur_id' => $row->page_id,
|
2005-07-01 23:50:11 +00:00
|
|
|
'rc_this_oldid' => $row->rev_id,
|
|
|
|
|
'rc_last_oldid' => isset($row->rc_last_oldid) ? $row->rc_last_oldid : 0,
|
2004-01-17 09:49:43 +00:00
|
|
|
'rc_bot' => 0,
|
|
|
|
|
'rc_moved_to_ns' => 0,
|
2004-01-18 02:24:12 +00:00
|
|
|
'rc_moved_to_title' => '',
|
2004-06-14 10:40:24 +00:00
|
|
|
'rc_ip' => '',
|
2006-05-23 18:23:29 +00:00
|
|
|
'rc_id' => $row->rc_id,
|
|
|
|
|
'rc_patrolled' => $row->rc_patrolled,
|
2006-12-09 12:28:02 +00:00
|
|
|
'rc_new' => $row->page_is_new, # obsolete
|
2006-12-23 23:08:41 +00:00
|
|
|
'rc_old_len' => $row->rc_old_len,
|
|
|
|
|
'rc_new_len' => $row->rc_new_len,
|
2008-03-16 21:02:10 +00:00
|
|
|
'rc_params' => isset($row->rc_params) ? $row->rc_params : '',
|
|
|
|
|
'rc_log_type' => isset($row->rc_log_type) ? $row->rc_log_type : null,
|
|
|
|
|
'rc_log_action' => isset($row->rc_log_action) ? $row->rc_log_action : null,
|
|
|
|
|
'rc_log_id' => isset($row->rc_log_id) ? $row->rc_log_id: 0,
|
|
|
|
|
// this one REALLY should be set...
|
|
|
|
|
'rc_deleted' => isset($row->rc_deleted) ? $row->rc_deleted: 0,
|
2004-01-17 09:49:43 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->mExtra = array();
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-22 19:43:20 +00:00
|
|
|
/**
|
|
|
|
|
* Get an attribute value
|
|
|
|
|
*
|
|
|
|
|
* @param $name Attribute name
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function getAttribute( $name ) {
|
|
|
|
|
return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : NULL;
|
|
|
|
|
}
|
2004-01-17 09:49:43 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2005-07-01 10:44:48 +00:00
|
|
|
* Gets the end part of the diff URL associated with this object
|
2004-09-02 23:28:24 +00:00
|
|
|
* Blank if no diff link should be displayed
|
|
|
|
|
*/
|
2008-09-16 05:56:43 +00:00
|
|
|
function diffLinkTrail( $forceCur )
|
|
|
|
|
{
|
2004-01-17 05:49:39 +00:00
|
|
|
if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
|
|
|
|
|
$trail = "curid=" . (int)($this->mAttribs['rc_cur_id']) .
|
|
|
|
|
"&oldid=" . (int)($this->mAttribs['rc_last_oldid']);
|
|
|
|
|
if ( $forceCur ) {
|
2004-08-22 17:24:50 +00:00
|
|
|
$trail .= '&diff=0' ;
|
2004-01-17 05:49:39 +00:00
|
|
|
} else {
|
2004-08-22 17:24:50 +00:00
|
|
|
$trail .= '&diff=' . (int)($this->mAttribs['rc_this_oldid']);
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2004-08-22 17:24:50 +00:00
|
|
|
$trail = '';
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|
|
|
|
|
return $trail;
|
|
|
|
|
}
|
2005-06-29 07:01:24 +00:00
|
|
|
|
|
|
|
|
function getIRCLine() {
|
2005-11-03 11:27:10 +00:00
|
|
|
global $wgUseRCPatrol;
|
|
|
|
|
|
2007-01-12 10:03:51 +00:00
|
|
|
// FIXME: Would be good to replace these 2 extract() calls with something more explicit
|
|
|
|
|
// e.g. list ($rc_type, $rc_id) = array_values ($this->mAttribs); [or something like that]
|
2005-06-29 07:01:24 +00:00
|
|
|
extract($this->mAttribs);
|
|
|
|
|
extract($this->mExtra);
|
|
|
|
|
|
2006-03-06 13:51:58 +00:00
|
|
|
if ( $rc_type == RC_LOG ) {
|
2008-04-20 14:31:02 +00:00
|
|
|
$titleObj = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL );
|
2006-03-06 13:51:58 +00:00
|
|
|
} else {
|
2008-04-20 14:31:02 +00:00
|
|
|
$titleObj =& $this->getTitle();
|
2006-03-06 13:51:58 +00:00
|
|
|
}
|
2006-04-02 04:09:00 +00:00
|
|
|
$title = $titleObj->getPrefixedText();
|
2008-10-17 23:46:21 +00:00
|
|
|
$title = UDP::cleanupForIRC( $title );
|
2006-04-02 04:09:00 +00:00
|
|
|
|
|
|
|
|
// FIXME: *HACK* these should be getFullURL(), hacked for SSL madness --brion 2005-12-26
|
2006-03-06 13:51:58 +00:00
|
|
|
if ( $rc_type == RC_LOG ) {
|
|
|
|
|
$url = '';
|
|
|
|
|
} elseif ( $rc_new && $wgUseRCPatrol ) {
|
2006-04-02 04:09:00 +00:00
|
|
|
$url = $titleObj->getInternalURL("rcid=$rc_id");
|
2005-11-04 12:07:32 +00:00
|
|
|
} else if ( $rc_new ) {
|
2006-04-02 04:09:00 +00:00
|
|
|
$url = $titleObj->getInternalURL();
|
2005-11-03 11:27:10 +00:00
|
|
|
} else if ( $wgUseRCPatrol ) {
|
2006-04-02 04:09:00 +00:00
|
|
|
$url = $titleObj->getInternalURL("diff=$rc_this_oldid&oldid=$rc_last_oldid&rcid=$rc_id");
|
2005-06-29 07:01:24 +00:00
|
|
|
} else {
|
2006-04-02 04:09:00 +00:00
|
|
|
$url = $titleObj->getInternalURL("diff=$rc_this_oldid&oldid=$rc_last_oldid");
|
2005-06-29 07:01:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( isset( $oldSize ) && isset( $newSize ) ) {
|
|
|
|
|
$szdiff = $newSize - $oldSize;
|
2005-12-04 20:51:02 +00:00
|
|
|
if ($szdiff < -500) {
|
2005-06-29 07:01:24 +00:00
|
|
|
$szdiff = "\002$szdiff\002";
|
2005-12-04 20:51:02 +00:00
|
|
|
} elseif ($szdiff >= 0) {
|
|
|
|
|
$szdiff = '+' . $szdiff ;
|
|
|
|
|
}
|
|
|
|
|
$szdiff = '(' . $szdiff . ')' ;
|
2005-06-29 07:01:24 +00:00
|
|
|
} else {
|
|
|
|
|
$szdiff = '';
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-17 23:46:21 +00:00
|
|
|
$user = UDP::cleanupForIRC( $rc_user_text );
|
2006-03-06 13:51:58 +00:00
|
|
|
|
|
|
|
|
if ( $rc_type == RC_LOG ) {
|
2008-10-11 23:30:38 +00:00
|
|
|
$targetText = $this->getTitle()->getPrefixedText();
|
2008-10-17 23:46:21 +00:00
|
|
|
$comment = UDP::cleanupForIRC( str_replace("[[$targetText]]","[[\00302$targetText\00310]]",$actionComment) );
|
2008-04-20 14:24:10 +00:00
|
|
|
$flag = $rc_log_action;
|
2006-03-06 13:51:58 +00:00
|
|
|
} else {
|
2008-10-17 23:46:21 +00:00
|
|
|
$comment = UDP::cleanupForIRC( $rc_comment );
|
2008-05-24 01:04:32 +00:00
|
|
|
$flag = ($rc_new ? "N" : "") . ($rc_minor ? "M" : "") . ($rc_bot ? "B" : "");
|
2006-03-06 13:51:58 +00:00
|
|
|
}
|
|
|
|
|
# see http://www.irssi.org/documentation/formats for some colour codes. prefix is \003,
|
2005-06-29 07:01:24 +00:00
|
|
|
# no colour (\003) switches back to the term default
|
|
|
|
|
$fullString = "\00314[[\00307$title\00314]]\0034 $flag\00310 " .
|
|
|
|
|
"\00302$url\003 \0035*\003 \00303$user\003 \0035*\003 $szdiff \00310$comment\003\n";
|
|
|
|
|
return $fullString;
|
|
|
|
|
}
|
2006-03-06 13:51:58 +00:00
|
|
|
|
2006-12-13 20:08:02 +00:00
|
|
|
/**
|
|
|
|
|
* Returns the change size (HTML).
|
|
|
|
|
* The lengths can be given optionally.
|
|
|
|
|
*/
|
|
|
|
|
function getCharacterDifference( $old = 0, $new = 0 ) {
|
|
|
|
|
global $wgRCChangedSizeThreshold, $wgLang;
|
|
|
|
|
|
|
|
|
|
if( $old === 0 ) {
|
|
|
|
|
$old = $this->mAttribs['rc_old_len'];
|
|
|
|
|
}
|
|
|
|
|
if( $new === 0 ) {
|
|
|
|
|
$new = $this->mAttribs['rc_new_len'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( $old === NULL || $new === NULL ) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$szdiff = $new - $old;
|
2007-01-07 10:54:02 +00:00
|
|
|
$formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape'),
|
2007-01-05 23:18:37 +00:00
|
|
|
$wgLang->formatNum($szdiff) );
|
2006-12-09 11:36:35 +00:00
|
|
|
|
2008-10-15 20:38:50 +00:00
|
|
|
|
|
|
|
|
if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
|
|
|
|
|
$tag = 'strong';
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
$tag = 'span';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( $szdiff === 0 ) {
|
|
|
|
|
return "<$tag class='mw-plusminus-null'>($formatedSize)</$tag>";
|
2008-10-15 00:06:51 +00:00
|
|
|
} elseif( $szdiff > 0 ) {
|
2008-10-15 20:38:50 +00:00
|
|
|
return "<$tag class='mw-plusminus-pos'>(+$formatedSize)</$tag>";
|
|
|
|
|
} else {
|
|
|
|
|
return "<$tag class='mw-plusminus-neg'>($formatedSize)</$tag>";
|
2008-10-15 00:06:51 +00:00
|
|
|
}
|
2006-12-09 11:36:35 +00:00
|
|
|
}
|
2004-01-17 05:49:39 +00:00
|
|
|
}
|