Revert r35178 and normalize User's getID() and setID() methods to prettier getId...
[lhc/web/wiklou.git] / includes / RecentChange.php
1 <?php
2
3 /**
4 * Utility class for creating new RC entries
5 * mAttribs:
6 * rc_id id of the row in the recentchanges table
7 * rc_timestamp time the entry was made
8 * rc_cur_time timestamp on the cur row
9 * rc_namespace namespace #
10 * rc_title non-prefixed db key
11 * rc_type is new entry, used to determine whether updating is necessary
12 * rc_minor is minor
13 * rc_cur_id page_id of associated page entry
14 * rc_user user id who made the entry
15 * rc_user_text user name who made the entry
16 * rc_comment edit summary
17 * rc_this_oldid rev_id associated with this entry (or zero)
18 * rc_last_oldid rev_id associated with the entry before this one (or zero)
19 * rc_bot is bot, hidden
20 * rc_ip IP address of the user in dotted quad notation
21 * rc_new obsolete, use rc_type==RC_NEW
22 * rc_patrolled boolean whether or not someone has marked this edit as patrolled
23 * rc_old_len integer byte length of the text before the edit
24 * rc_new_len the same after the edit
25 * rc_deleted partial deletion
26 * rc_logid the log_id value for this log entry (or zero)
27 * rc_log_type the log type (or null)
28 * rc_log_action the log action (or null)
29 * rc_params log params
30 *
31 * mExtra:
32 * prefixedDBkey prefixed db key, used by external app via msg queue
33 * lastTimestamp timestamp of previous entry, used in WHERE clause during update
34 * lang the interwiki prefix, automatically set in save()
35 * oldSize text size before the change
36 * newSize text size after the change
37 *
38 * temporary: not stored in the database
39 * notificationtimestamp
40 * numberofWatchingusers
41 *
42 * @todo document functions and variables
43 */
44 class RecentChange
45 {
46 var $mAttribs = array(), $mExtra = array();
47 var $mTitle = false, $mMovedToTitle = false;
48 var $numberofWatchingusers = 0 ; # Dummy to prevent error message in SpecialRecentchangeslinked
49
50 # Factory methods
51
52 public static function newFromRow( $row )
53 {
54 $rc = new RecentChange;
55 $rc->loadFromRow( $row );
56 return $rc;
57 }
58
59 public static function newFromCurRow( $row, $rc_this_oldid = 0 )
60 {
61 $rc = new RecentChange;
62 $rc->loadFromCurRow( $row, $rc_this_oldid );
63 $rc->notificationtimestamp = false;
64 $rc->numberofWatchingusers = false;
65 return $rc;
66 }
67
68 /**
69 * Obtain the recent change with a given rc_id value
70 *
71 * @param $rcid rc_id value to retrieve
72 * @return RecentChange
73 */
74 public static function newFromId( $rcid ) {
75 $dbr = wfGetDB( DB_SLAVE );
76 $res = $dbr->select( 'recentchanges', '*', array( 'rc_id' => $rcid ), __METHOD__ );
77 if( $res && $dbr->numRows( $res ) > 0 ) {
78 $row = $dbr->fetchObject( $res );
79 $dbr->freeResult( $res );
80 return self::newFromRow( $row );
81 } else {
82 return NULL;
83 }
84 }
85
86 /**
87 * Find the first recent change matching some specific conditions
88 *
89 * @param array $conds Array of conditions
90 * @param mixed $fname Override the method name in profiling/logs
91 * @return RecentChange
92 */
93 public static function newFromConds( $conds, $fname = false ) {
94 if( $fname === false )
95 $fname = __METHOD__;
96 $dbr = wfGetDB( DB_SLAVE );
97 $res = $dbr->select(
98 'recentchanges',
99 '*',
100 $conds,
101 $fname
102 );
103 if( $res instanceof ResultWrapper && $res->numRows() > 0 ) {
104 $row = $res->fetchObject();
105 $res->free();
106 return self::newFromRow( $row );
107 }
108 return null;
109 }
110
111 # Accessors
112
113 function setAttribs( $attribs )
114 {
115 $this->mAttribs = $attribs;
116 }
117
118 function setExtra( $extra )
119 {
120 $this->mExtra = $extra;
121 }
122
123 function &getTitle()
124 {
125 if ( $this->mTitle === false ) {
126 $this->mTitle = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
127 }
128 return $this->mTitle;
129 }
130
131 function getMovedToTitle()
132 {
133 if ( $this->mMovedToTitle === false ) {
134 $this->mMovedToTitle = Title::makeTitle( $this->mAttribs['rc_moved_to_ns'],
135 $this->mAttribs['rc_moved_to_title'] );
136 }
137 return $this->mMovedToTitle;
138 }
139
140 # Writes the data in this object to the database
141 function save()
142 {
143 global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, $wgRC2UDPPort, $wgRC2UDPPrefix;
144 $fname = 'RecentChange::save';
145
146 $dbw = wfGetDB( DB_MASTER );
147 if ( !is_array($this->mExtra) ) {
148 $this->mExtra = array();
149 }
150 $this->mExtra['lang'] = $wgLocalInterwiki;
151
152 if ( !$wgPutIPinRC ) {
153 $this->mAttribs['rc_ip'] = '';
154 }
155
156 ## If our database is strict about IP addresses, use NULL instead of an empty string
157 if ( $dbw->strictIPs() and $this->mAttribs['rc_ip'] == '' ) {
158 unset( $this->mAttribs['rc_ip'] );
159 }
160
161 # Fixup database timestamps
162 $this->mAttribs['rc_timestamp'] = $dbw->timestamp($this->mAttribs['rc_timestamp']);
163 $this->mAttribs['rc_cur_time'] = $dbw->timestamp($this->mAttribs['rc_cur_time']);
164 $this->mAttribs['rc_id'] = $dbw->nextSequenceValue( 'rc_rc_id_seq' );
165
166 ## If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL
167 if ( $dbw->cascadingDeletes() and $this->mAttribs['rc_cur_id']==0 ) {
168 unset ( $this->mAttribs['rc_cur_id'] );
169 }
170
171 # Insert new row
172 $dbw->insert( 'recentchanges', $this->mAttribs, $fname );
173
174 # Set the ID
175 $this->mAttribs['rc_id'] = $dbw->insertId();
176
177 # Update old rows, if necessary
178 if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
179 $lastTime = $this->mExtra['lastTimestamp'];
180 #$now = $this->mAttribs['rc_timestamp'];
181 #$curId = $this->mAttribs['rc_cur_id'];
182
183 # Don't bother looking for entries that have probably
184 # been purged, it just locks up the indexes needlessly.
185 global $wgRCMaxAge;
186 $age = time() - wfTimestamp( TS_UNIX, $lastTime );
187 if( $age < $wgRCMaxAge ) {
188 # live hack, will commit once tested - kate
189 # Update rc_this_oldid for the entries which were current
190 #
191 #$oldid = $this->mAttribs['rc_last_oldid'];
192 #$ns = $this->mAttribs['rc_namespace'];
193 #$title = $this->mAttribs['rc_title'];
194 #
195 #$dbw->update( 'recentchanges',
196 # array( /* SET */
197 # 'rc_this_oldid' => $oldid
198 # ), array( /* WHERE */
199 # 'rc_namespace' => $ns,
200 # 'rc_title' => $title,
201 # 'rc_timestamp' => $dbw->timestamp( $lastTime )
202 # ), $fname
203 #);
204 }
205
206 # Update rc_cur_time
207 #$dbw->update( 'recentchanges', array( 'rc_cur_time' => $now ),
208 # array( 'rc_cur_id' => $curId ), $fname );
209 }
210
211 # Notify external application via UDP
212 if ( $wgRC2UDPAddress ) {
213 $conn = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
214 if ( $conn ) {
215 $line = $wgRC2UDPPrefix . $this->getIRCLine();
216 socket_sendto( $conn, $line, strlen($line), 0, $wgRC2UDPAddress, $wgRC2UDPPort );
217 socket_close( $conn );
218 }
219 }
220
221 # E-mail notifications
222 global $wgUseEnotif, $wgShowUpdatedMarker, $wgUser;
223 if( $wgUseEnotif || $wgShowUpdatedMarker ) {
224 // Users
225 if( $this->mAttribs['rc_user'] ) {
226 $editor = ($wgUser->getId() == $this->mAttribs['rc_user']) ?
227 $wgUser : User::newFromID( $this->mAttribs['rc_user'] );
228 // Anons
229 } else {
230 $editor = ($wgUser->getName() == $this->mAttribs['rc_user_text']) ?
231 $wgUser : User::newFromName( $this->mAttribs['rc_user_text'], false );
232 }
233 # FIXME: this would be better as an extension hook
234 $enotif = new EmailNotification();
235 $title = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
236 $enotif->notifyOnPageChange( $editor, $title,
237 $this->mAttribs['rc_timestamp'],
238 $this->mAttribs['rc_comment'],
239 $this->mAttribs['rc_minor'],
240 $this->mAttribs['rc_last_oldid'] );
241 }
242
243 # Notify extensions
244 wfRunHooks( 'RecentChange_save', array( &$this ) );
245 }
246
247 /**
248 * Mark a given change as patrolled
249 *
250 * @param mixed $change RecentChange or corresponding rc_id
251 * @returns integer number of affected rows
252 */
253 public static function markPatrolled( $change ) {
254 $rcid = $change instanceof RecentChange
255 ? $change->mAttribs['rc_id']
256 : $change;
257 $dbw = wfGetDB( DB_MASTER );
258 $dbw->update(
259 'recentchanges',
260 array(
261 'rc_patrolled' => 1
262 ),
263 array(
264 'rc_id' => $rcid
265 ),
266 __METHOD__
267 );
268 return $dbw->affectedRows();
269 }
270
271 # Makes an entry in the database corresponding to an edit
272 public static function notifyEdit( $timestamp, &$title, $minor, &$user, $comment,
273 $oldId, $lastTimestamp, $bot, $ip = '', $oldSize = 0, $newSize = 0,
274 $newId = 0)
275 {
276 if ( !$ip ) {
277 $ip = wfGetIP();
278 if ( !$ip ) {
279 $ip = '';
280 }
281 }
282
283 $rc = new RecentChange;
284 $rc->mAttribs = array(
285 'rc_timestamp' => $timestamp,
286 'rc_cur_time' => $timestamp,
287 'rc_namespace' => $title->getNamespace(),
288 'rc_title' => $title->getDBkey(),
289 'rc_type' => RC_EDIT,
290 'rc_minor' => $minor ? 1 : 0,
291 'rc_cur_id' => $title->getArticleID(),
292 'rc_user' => $user->getId(),
293 'rc_user_text' => $user->getName(),
294 'rc_comment' => $comment,
295 'rc_this_oldid' => $newId,
296 'rc_last_oldid' => $oldId,
297 'rc_bot' => $bot ? 1 : 0,
298 'rc_moved_to_ns' => 0,
299 'rc_moved_to_title' => '',
300 'rc_ip' => $ip,
301 'rc_patrolled' => 0,
302 'rc_new' => 0, # obsolete
303 'rc_old_len' => $oldSize,
304 'rc_new_len' => $newSize,
305 'rc_deleted' => 0,
306 'rc_logid' => 0,
307 'rc_log_type' => null,
308 'rc_log_action' => '',
309 'rc_params' => ''
310 );
311
312 $rc->mExtra = array(
313 'prefixedDBkey' => $title->getPrefixedDBkey(),
314 'lastTimestamp' => $lastTimestamp,
315 'oldSize' => $oldSize,
316 'newSize' => $newSize,
317 );
318 $rc->save();
319 return( $rc->mAttribs['rc_id'] );
320 }
321
322 /**
323 * Makes an entry in the database corresponding to page creation
324 * Note: the title object must be loaded with the new id using resetArticleID()
325 * @todo Document parameters and return
326 */
327 public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot,
328 $ip='', $size = 0, $newId = 0 )
329 {
330 if ( !$ip ) {
331 $ip = wfGetIP();
332 if ( !$ip ) {
333 $ip = '';
334 }
335 }
336
337 $rc = new RecentChange;
338 $rc->mAttribs = array(
339 'rc_timestamp' => $timestamp,
340 'rc_cur_time' => $timestamp,
341 'rc_namespace' => $title->getNamespace(),
342 'rc_title' => $title->getDBkey(),
343 'rc_type' => RC_NEW,
344 'rc_minor' => $minor ? 1 : 0,
345 'rc_cur_id' => $title->getArticleID(),
346 'rc_user' => $user->getId(),
347 'rc_user_text' => $user->getName(),
348 'rc_comment' => $comment,
349 'rc_this_oldid' => $newId,
350 'rc_last_oldid' => 0,
351 'rc_bot' => $bot ? 1 : 0,
352 'rc_moved_to_ns' => 0,
353 'rc_moved_to_title' => '',
354 'rc_ip' => $ip,
355 'rc_patrolled' => 0,
356 'rc_new' => 1, # obsolete
357 'rc_old_len' => 0,
358 'rc_new_len' => $size,
359 'rc_deleted' => 0,
360 'rc_logid' => 0,
361 'rc_log_type' => null,
362 'rc_log_action' => '',
363 'rc_params' => ''
364 );
365
366 $rc->mExtra = array(
367 'prefixedDBkey' => $title->getPrefixedDBkey(),
368 'lastTimestamp' => 0,
369 'oldSize' => 0,
370 'newSize' => $size
371 );
372 $rc->save();
373 return( $rc->mAttribs['rc_id'] );
374 }
375
376 # Makes an entry in the database corresponding to a rename
377 public static function notifyMove( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='', $overRedir = false )
378 {
379 global $wgRequest;
380
381 if ( !$ip ) {
382 $ip = wfGetIP();
383 if ( !$ip ) {
384 $ip = '';
385 }
386 }
387
388 $rc = new RecentChange;
389 $rc->mAttribs = array(
390 'rc_timestamp' => $timestamp,
391 'rc_cur_time' => $timestamp,
392 'rc_namespace' => $oldTitle->getNamespace(),
393 'rc_title' => $oldTitle->getDBkey(),
394 'rc_type' => $overRedir ? RC_MOVE_OVER_REDIRECT : RC_MOVE,
395 'rc_minor' => 0,
396 'rc_cur_id' => $oldTitle->getArticleID(),
397 'rc_user' => $user->getId(),
398 'rc_user_text' => $user->getName(),
399 'rc_comment' => $comment,
400 'rc_this_oldid' => 0,
401 'rc_last_oldid' => 0,
402 'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot' , true ) : 0,
403 'rc_moved_to_ns' => $newTitle->getNamespace(),
404 'rc_moved_to_title' => $newTitle->getDBkey(),
405 'rc_ip' => $ip,
406 'rc_new' => 0, # obsolete
407 'rc_patrolled' => 1,
408 'rc_old_len' => NULL,
409 'rc_new_len' => NULL,
410 'rc_deleted' => 0,
411 'rc_logid' => 0, # notifyMove not used anymore
412 'rc_log_type' => null,
413 'rc_log_action' => '',
414 'rc_params' => ''
415 );
416
417 $rc->mExtra = array(
418 'prefixedDBkey' => $oldTitle->getPrefixedDBkey(),
419 'lastTimestamp' => 0,
420 'prefixedMoveTo' => $newTitle->getPrefixedDBkey()
421 );
422 $rc->save();
423 }
424
425 public static function notifyMoveToNew( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='' ) {
426 RecentChange::notifyMove( $timestamp, $oldTitle, $newTitle, $user, $comment, $ip, false );
427 }
428
429 public static function notifyMoveOverRedirect( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='' ) {
430 RecentChange::notifyMove( $timestamp, $oldTitle, $newTitle, $user, $comment, $ip, true );
431 }
432
433 # A log entry is different to an edit in that previous revisions are not kept
434 public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip='',
435 $type, $action, $target, $logComment, $params, $newId=0 )
436 {
437 global $wgRequest;
438
439 if ( !$ip ) {
440 $ip = wfGetIP();
441 if ( !$ip ) {
442 $ip = '';
443 }
444 }
445
446 $rc = new RecentChange;
447 $rc->mAttribs = array(
448 'rc_timestamp' => $timestamp,
449 'rc_cur_time' => $timestamp,
450 'rc_namespace' => $target->getNamespace(),
451 'rc_title' => $target->getDBkey(),
452 'rc_type' => RC_LOG,
453 'rc_minor' => 0,
454 'rc_cur_id' => $target->getArticleID(),
455 'rc_user' => $user->getId(),
456 'rc_user_text' => $user->getName(),
457 'rc_comment' => $logComment,
458 'rc_this_oldid' => 0,
459 'rc_last_oldid' => 0,
460 'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot' , true ) : 0,
461 'rc_moved_to_ns' => 0,
462 'rc_moved_to_title' => '',
463 'rc_ip' => $ip,
464 'rc_patrolled' => 1,
465 'rc_new' => 0, # obsolete
466 'rc_old_len' => NULL,
467 'rc_new_len' => NULL,
468 'rc_deleted' => 0,
469 'rc_logid' => $newId,
470 'rc_log_type' => $type,
471 'rc_log_action' => $action,
472 'rc_params' => $params
473 );
474 $rc->mExtra = array(
475 'prefixedDBkey' => $title->getPrefixedDBkey(),
476 'lastTimestamp' => 0,
477 'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage
478 );
479 $rc->save();
480 }
481
482 # Initialises the members of this object from a mysql row object
483 function loadFromRow( $row )
484 {
485 $this->mAttribs = get_object_vars( $row );
486 $this->mAttribs["rc_timestamp"] = wfTimestamp(TS_MW, $this->mAttribs["rc_timestamp"]);
487 $this->mExtra = array();
488 }
489
490 # Makes a pseudo-RC entry from a cur row
491 function loadFromCurRow( $row )
492 {
493 $this->mAttribs = array(
494 'rc_timestamp' => wfTimestamp(TS_MW, $row->rev_timestamp),
495 'rc_cur_time' => $row->rev_timestamp,
496 'rc_user' => $row->rev_user,
497 'rc_user_text' => $row->rev_user_text,
498 'rc_namespace' => $row->page_namespace,
499 'rc_title' => $row->page_title,
500 'rc_comment' => $row->rev_comment,
501 'rc_minor' => $row->rev_minor_edit ? 1 : 0,
502 'rc_type' => $row->page_is_new ? RC_NEW : RC_EDIT,
503 'rc_cur_id' => $row->page_id,
504 'rc_this_oldid' => $row->rev_id,
505 'rc_last_oldid' => isset($row->rc_last_oldid) ? $row->rc_last_oldid : 0,
506 'rc_bot' => 0,
507 'rc_moved_to_ns' => 0,
508 'rc_moved_to_title' => '',
509 'rc_ip' => '',
510 'rc_id' => $row->rc_id,
511 'rc_patrolled' => $row->rc_patrolled,
512 'rc_new' => $row->page_is_new, # obsolete
513 'rc_old_len' => $row->rc_old_len,
514 'rc_new_len' => $row->rc_new_len,
515 'rc_params' => isset($row->rc_params) ? $row->rc_params : '',
516 'rc_log_type' => isset($row->rc_log_type) ? $row->rc_log_type : null,
517 'rc_log_action' => isset($row->rc_log_action) ? $row->rc_log_action : null,
518 'rc_log_id' => isset($row->rc_log_id) ? $row->rc_log_id: 0,
519 // this one REALLY should be set...
520 'rc_deleted' => isset($row->rc_deleted) ? $row->rc_deleted: 0,
521 );
522
523 $this->mExtra = array();
524 }
525
526 /**
527 * Get an attribute value
528 *
529 * @param $name Attribute name
530 * @return mixed
531 */
532 public function getAttribute( $name ) {
533 return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : NULL;
534 }
535
536 /**
537 * Gets the end part of the diff URL associated with this object
538 * Blank if no diff link should be displayed
539 */
540 function diffLinkTrail( $forceCur )
541 {
542 if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
543 $trail = "curid=" . (int)($this->mAttribs['rc_cur_id']) .
544 "&oldid=" . (int)($this->mAttribs['rc_last_oldid']);
545 if ( $forceCur ) {
546 $trail .= '&diff=0' ;
547 } else {
548 $trail .= '&diff=' . (int)($this->mAttribs['rc_this_oldid']);
549 }
550 } else {
551 $trail = '';
552 }
553 return $trail;
554 }
555
556 function cleanupForIRC( $text ) {
557 return str_replace(array("\n", "\r"), array("", ""), $text);
558 }
559
560 function getIRCLine() {
561 global $wgUseRCPatrol;
562
563 // FIXME: Would be good to replace these 2 extract() calls with something more explicit
564 // e.g. list ($rc_type, $rc_id) = array_values ($this->mAttribs); [or something like that]
565 extract($this->mAttribs);
566 extract($this->mExtra);
567
568 if ( $rc_type == RC_LOG ) {
569 $titleObj = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL );
570 } else {
571 $titleObj =& $this->getTitle();
572 }
573 $title = $titleObj->getPrefixedText();
574 $title = $this->cleanupForIRC( $title );
575
576 // FIXME: *HACK* these should be getFullURL(), hacked for SSL madness --brion 2005-12-26
577 if ( $rc_type == RC_LOG ) {
578 $url = '';
579 } elseif ( $rc_new && $wgUseRCPatrol ) {
580 $url = $titleObj->getInternalURL("rcid=$rc_id");
581 } else if ( $rc_new ) {
582 $url = $titleObj->getInternalURL();
583 } else if ( $wgUseRCPatrol ) {
584 $url = $titleObj->getInternalURL("diff=$rc_this_oldid&oldid=$rc_last_oldid&rcid=$rc_id");
585 } else {
586 $url = $titleObj->getInternalURL("diff=$rc_this_oldid&oldid=$rc_last_oldid");
587 }
588
589 if ( isset( $oldSize ) && isset( $newSize ) ) {
590 $szdiff = $newSize - $oldSize;
591 if ($szdiff < -500) {
592 $szdiff = "\002$szdiff\002";
593 } elseif ($szdiff >= 0) {
594 $szdiff = '+' . $szdiff ;
595 }
596 $szdiff = '(' . $szdiff . ')' ;
597 } else {
598 $szdiff = '';
599 }
600
601 $user = $this->cleanupForIRC( $rc_user_text );
602
603 if ( $rc_type == RC_LOG ) {
604 $logTargetText = $this->getTitle()->getPrefixedText();
605 $comment = $this->cleanupForIRC( str_replace($logTargetText,"\00302$logTargetText\00310",$actionComment) );
606 $flag = $rc_log_action;
607 } else {
608 $comment = $this->cleanupForIRC( $rc_comment );
609 $flag = ($rc_minor ? "M" : "") . ($rc_new ? "N" : "");
610 }
611 # see http://www.irssi.org/documentation/formats for some colour codes. prefix is \003,
612 # no colour (\003) switches back to the term default
613 $fullString = "\00314[[\00307$title\00314]]\0034 $flag\00310 " .
614 "\00302$url\003 \0035*\003 \00303$user\003 \0035*\003 $szdiff \00310$comment\003\n";
615 return $fullString;
616 }
617
618 /**
619 * Returns the change size (HTML).
620 * The lengths can be given optionally.
621 */
622 function getCharacterDifference( $old = 0, $new = 0 ) {
623 global $wgRCChangedSizeThreshold, $wgLang;
624
625 if( $old === 0 ) {
626 $old = $this->mAttribs['rc_old_len'];
627 }
628 if( $new === 0 ) {
629 $new = $this->mAttribs['rc_new_len'];
630 }
631
632 if( $old === NULL || $new === NULL ) {
633 return '';
634 }
635
636 $szdiff = $new - $old;
637 $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape'),
638 $wgLang->formatNum($szdiff) );
639
640 if( $szdiff < $wgRCChangedSizeThreshold ) {
641 return '<strong class=\'mw-plusminus-neg\'>(' . $formatedSize . ')</strong>';
642 } elseif( $szdiff === 0 ) {
643 return '<span class=\'mw-plusminus-null\'>(' . $formatedSize . ')</span>';
644 } elseif( $szdiff > 0 ) {
645 return '<span class=\'mw-plusminus-pos\'>(+' . $formatedSize . ')</span>';
646 } else {
647 return '<span class=\'mw-plusminus-neg\'>(' . $formatedSize . ')</span>';
648 }
649 }
650 }