summaryrefslogtreecommitdiff
path: root/includes/RecentChange.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2007-01-11 19:06:07 +0000
committerPierre Schmitz <pierre@archlinux.de>2007-01-11 19:06:07 +0000
commita58285fd06c8113c45377c655dd43cef6337e815 (patch)
treedfe31d3d12652352fe44890b4811eda0728faefb /includes/RecentChange.php
parent20194986f6638233732ba1fc3e838f117d3cc9ea (diff)
Aktualisierung auf MediaWiki 1.9.0
Diffstat (limited to 'includes/RecentChange.php')
-rw-r--r--includes/RecentChange.php92
1 files changed, 82 insertions, 10 deletions
diff --git a/includes/RecentChange.php b/includes/RecentChange.php
index ebd4b335..1c7791c2 100644
--- a/includes/RecentChange.php
+++ b/includes/RecentChange.php
@@ -24,6 +24,8 @@
* 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
+ * rc_old_len integer byte length of the text before the edit
+ * rc_new_len the same after the edit
*
* mExtra:
* prefixedDBkey prefixed db key, used by external app via msg queue
@@ -54,7 +56,7 @@ class RecentChange
return $rc;
}
- /* static */ function newFromCurRow( $row, $rc_this_oldid = 0 )
+ public static function newFromCurRow( $row, $rc_this_oldid = 0 )
{
$rc = new RecentChange;
$rc->loadFromCurRow( $row, $rc_this_oldid );
@@ -62,6 +64,24 @@ class RecentChange
$rc->numberofWatchingusers = false;
return $rc;
}
+
+ /**
+ * Obtain the recent change with a given rc_id value
+ *
+ * @param $rcid rc_id value to retrieve
+ * @return RecentChange
+ */
+ public static function newFromId( $rcid ) {
+ $dbr =& wfGetDB( DB_SLAVE );
+ $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;
+ }
+ }
# Accessors
@@ -95,7 +115,7 @@ class RecentChange
# Writes the data in this object to the database
function save()
{
- global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, $wgRC2UDPPort, $wgRC2UDPPrefix, $wgUseRCPatrol;
+ global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, $wgRC2UDPPort, $wgRC2UDPPrefix;
$fname = 'RecentChange::save';
$dbw =& wfGetDB( DB_MASTER );
@@ -212,6 +232,7 @@ class RecentChange
$oldId, $lastTimestamp, $bot = "default", $ip = '', $oldSize = 0, $newSize = 0,
$newId = 0)
{
+
if ( $bot === 'default' ) {
$bot = $user->isAllowed( 'bot' );
}
@@ -240,9 +261,11 @@ class RecentChange
'rc_bot' => $bot ? 1 : 0,
'rc_moved_to_ns' => 0,
'rc_moved_to_title' => '',
- 'rc_ip' => $ip,
- 'rc_patrolled' => 0,
- 'rc_new' => 0 # obsolete
+ 'rc_ip' => $ip,
+ 'rc_patrolled' => 0,
+ 'rc_new' => 0, # obsolete
+ 'rc_old_len' => $oldSize,
+ 'rc_new_len' => $newSize
);
$rc->mExtra = array(
@@ -294,7 +317,9 @@ class RecentChange
'rc_moved_to_title' => '',
'rc_ip' => $ip,
'rc_patrolled' => 0,
- 'rc_new' => 1 # obsolete
+ 'rc_new' => 1, # obsolete
+ 'rc_old_len' => 0,
+ 'rc_new_len' => $size
);
$rc->mExtra = array(
@@ -336,7 +361,9 @@ class RecentChange
'rc_moved_to_title' => $newTitle->getDBkey(),
'rc_ip' => $ip,
'rc_new' => 0, # obsolete
- 'rc_patrolled' => 1
+ 'rc_patrolled' => 1,
+ 'rc_old_len' => NULL,
+ 'rc_new_len' => NULL,
);
$rc->mExtra = array(
@@ -386,7 +413,9 @@ class RecentChange
'rc_moved_to_title' => '',
'rc_ip' => $ip,
'rc_patrolled' => 1,
- 'rc_new' => 0 # obsolete
+ 'rc_new' => 0, # obsolete
+ 'rc_old_len' => NULL,
+ 'rc_new_len' => NULL,
);
$rc->mExtra = array(
'prefixedDBkey' => $title->getPrefixedDBkey(),
@@ -408,7 +437,7 @@ class RecentChange
$this->mExtra = array();
}
- # Makes a pseudo-RC entry from a cur row, for watchlists and things
+ # Makes a pseudo-RC entry from a cur row
function loadFromCurRow( $row )
{
$this->mAttribs = array(
@@ -430,12 +459,23 @@ class RecentChange
'rc_ip' => '',
'rc_id' => $row->rc_id,
'rc_patrolled' => $row->rc_patrolled,
- 'rc_new' => $row->page_is_new # obsolete
+ 'rc_new' => $row->page_is_new, # obsolete
+ 'rc_old_len' => $row->rc_old_len,
+ 'rc_new_len' => $row->rc_new_len,
);
$this->mExtra = array();
}
+ /**
+ * Get an attribute value
+ *
+ * @param $name Attribute name
+ * @return mixed
+ */
+ public function getAttribute( $name ) {
+ return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : NULL;
+ }
/**
* Gets the end part of the diff URL associated with this object
@@ -522,5 +562,37 @@ class RecentChange
return $fullString;
}
+ /**
+ * 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;
+ $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape'),
+ $wgLang->formatNum($szdiff) );
+
+ if( $szdiff < $wgRCChangedSizeThreshold ) {
+ return '<strong class=\'mw-plusminus-neg\'>(' . $formatedSize . ')</strong>';
+ } elseif( $szdiff === 0 ) {
+ return '<span class=\'mw-plusminus-null\'>(' . $formatedSize . ')</span>';
+ } elseif( $szdiff > 0 ) {
+ return '<span class=\'mw-plusminus-pos\'>(+' . $formatedSize . ')</span>';
+ } else {
+ return '<span class=\'mw-plusminus-neg\'>(' . $formatedSize . ')</span>';
+ }
+ }
}
?>