* Fix WebRequest.php
[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 )
60 {
61 $rc = new RecentChange;
62 $rc->loadFromCurRow( $row );
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,
144 $wgRC2UDPPort, $wgRC2UDPPrefix, $wgRC2UDPOmitBots;
145 $fname = 'RecentChange::save';
146
147 $dbw = wfGetDB( DB_MASTER );
148 if ( !is_array($this->mExtra) ) {
149 $this->mExtra = array();
150 }
151 $this->mExtra['lang'] = $wgLocalInterwiki;
152
153 if ( !$wgPutIPinRC ) {
154 $this->mAttribs['rc_ip'] = '';
155 }
156
157 ## If our database is strict about IP addresses, use NULL instead of an empty string
158 if ( $dbw->strictIPs() and $this->mAttribs['rc_ip'] == '' ) {
159 unset( $this->mAttribs['rc_ip'] );
160 }
161
162 # Fixup database timestamps
163 $this->mAttribs['rc_timestamp'] = $dbw->timestamp($this->mAttribs['rc_timestamp']);
164 $this->mAttribs['rc_cur_time'] = $dbw->timestamp($this->mAttribs['rc_cur_time']);
165 $this->mAttribs['rc_id'] = $dbw->nextSequenceValue( 'rc_rc_id_seq' );
166
167 ## If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL
168 if ( $dbw->cascadingDeletes() and $this->mAttribs['rc_cur_id']==0 ) {
169 unset ( $this->mAttribs['rc_cur_id'] );
170 }
171
172 # Insert new row
173 $dbw->insert( 'recentchanges', $this->mAttribs, $fname );
174
175 # Set the ID
176 $this->mAttribs['rc_id'] = $dbw->insertId();
177
178 # Update old rows, if necessary
179 if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
180 $lastTime = $this->mExtra['lastTimestamp'];
181 #$now = $this->mAttribs['rc_timestamp'];
182 #$curId = $this->mAttribs['rc_cur_id'];
183
184 # Don't bother looking for entries that have probably
185 # been purged, it just locks up the indexes needlessly.
186 global $wgRCMaxAge;
187 $age = time() - wfTimestamp( TS_UNIX, $lastTime );
188 if( $age < $wgRCMaxAge ) {
189 # live hack, will commit once tested - kate
190 # Update rc_this_oldid for the entries which were current
191 #
192 #$oldid = $this->mAttribs['rc_last_oldid'];
193 #$ns = $this->mAttribs['rc_namespace'];
194 #$title = $this->mAttribs['rc_title'];
195 #
196 #$dbw->update( 'recentchanges',
197 # array( /* SET */
198 # 'rc_this_oldid' => $oldid
199 # ), array( /* WHERE */
200 # 'rc_namespace' => $ns,
201 # 'rc_title' => $title,
202 # 'rc_timestamp' => $dbw->timestamp( $lastTime )
203 # ), $fname
204 #);
205 }
206
207 # Update rc_cur_time
208 #$dbw->update( 'recentchanges', array( 'rc_cur_time' => $now ),
209 # array( 'rc_cur_id' => $curId ), $fname );
210 }
211
212 # Notify external application via UDP
213 if ( $wgRC2UDPAddress && ( !$this->mAttribs['rc_bot'] || !$wgRC2UDPOmitBots ) ) {
214 $conn = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
215 if ( $conn ) {
216 $line = $wgRC2UDPPrefix . $this->getIRCLine();
217 socket_sendto( $conn, $line, strlen($line), 0, $wgRC2UDPAddress, $wgRC2UDPPort );
218 socket_close( $conn );
219 }
220 }
221
222 # E-mail notifications
223 global $wgUseEnotif, $wgShowUpdatedMarker, $wgUser;
224 if( $wgUseEnotif || $wgShowUpdatedMarker ) {
225 // Users
226 if( $this->mAttribs['rc_user'] ) {
227 $editor = ($wgUser->getId() == $this->mAttribs['rc_user']) ?
228 $wgUser : User::newFromID( $this->mAttribs['rc_user'] );
229 // Anons
230 } else {
231 $editor = ($wgUser->getName() == $this->mAttribs['rc_user_text']) ?
232 $wgUser : User::newFromName( $this->mAttribs['rc_user_text'], false );
233 }
234 # FIXME: this would be better as an extension hook
235 $enotif = new EmailNotification();
236 $title = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
237 $enotif->notifyOnPageChange( $editor, $title,
238 $this->mAttribs['rc_timestamp'],
239 $this->mAttribs['rc_comment'],
240 $this->mAttribs['rc_minor'],
241 $this->mAttribs['rc_last_oldid'] );
242 }
243
244 # Notify extensions
245 wfRunHooks( 'RecentChange_save', array( &$this ) );
246 }
247
248 /**
249 * Mark a given change as patrolled
250 *
251 * @param mixed $change RecentChange or corresponding rc_id
252 * @returns integer number of affected rows
253 */
254 public static function markPatrolled( $change ) {
255 $rcid = $change instanceof RecentChange
256 ? $change->mAttribs['rc_id']
257 : $change;
258 $dbw = wfGetDB( DB_MASTER );
259 $dbw->update(
260 'recentchanges',
261 array(
262 'rc_patrolled' => 1
263 ),
264 array(
265 'rc_id' => $rcid
266 ),
267 __METHOD__
268 );
269 return $dbw->affectedRows();
270 }
271
272 # Makes an entry in the database corresponding to an edit
273 public static function notifyEdit( $timestamp, &$title, $minor, &$user, $comment,
274 $oldId, $lastTimestamp, $bot, $ip = '', $oldSize = 0, $newSize = 0,
275 $newId = 0)
276 {
277 if ( !$ip ) {
278 $ip = wfGetIP();
279 if ( !$ip ) {
280 $ip = '';
281 }
282 }
283
284 $rc = new RecentChange;
285 $rc->mAttribs = array(
286 'rc_timestamp' => $timestamp,
287 'rc_cur_time' => $timestamp,
288 'rc_namespace' => $title->getNamespace(),
289 'rc_title' => $title->getDBkey(),
290 'rc_type' => RC_EDIT,
291 'rc_minor' => $minor ? 1 : 0,
292 'rc_cur_id' => $title->getArticleID(),
293 'rc_user' => $user->getId(),
294 'rc_user_text' => $user->getName(),
295 'rc_comment' => $comment,
296 'rc_this_oldid' => $newId,
297 'rc_last_oldid' => $oldId,
298 'rc_bot' => $bot ? 1 : 0,
299 'rc_moved_to_ns' => 0,
300 'rc_moved_to_title' => '',
301 'rc_ip' => $ip,
302 'rc_patrolled' => 0,
303 'rc_new' => 0, # obsolete
304 'rc_old_len' => $oldSize,
305 'rc_new_len' => $newSize,
306 'rc_deleted' => 0,
307 'rc_logid' => 0,
308 'rc_log_type' => null,
309 'rc_log_action' => '',
310 'rc_params' => ''
311 );
312
313 $rc->mExtra = array(
314 'prefixedDBkey' => $title->getPrefixedDBkey(),
315 'lastTimestamp' => $lastTimestamp,
316 'oldSize' => $oldSize,
317 'newSize' => $newSize,
318 );
319 $rc->save();
320 return( $rc->mAttribs['rc_id'] );
321 }
322
323 /**
324 * Makes an entry in the database corresponding to page creation
325 * Note: the title object must be loaded with the new id using resetArticleID()
326 * @todo Document parameters and return
327 */
328 public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot,
329 $ip='', $size = 0, $newId = 0 )
330 {
331 if ( !$ip ) {
332 $ip = wfGetIP();
333 if ( !$ip ) {
334 $ip = '';
335 }
336 }
337
338 $rc = new RecentChange;
339 $rc->mAttribs = array(
340 'rc_timestamp' => $timestamp,
341 'rc_cur_time' => $timestamp,
342 'rc_namespace' => $title->getNamespace(),
343 'rc_title' => $title->getDBkey(),
344 'rc_type' => RC_NEW,
345 'rc_minor' => $minor ? 1 : 0,
346 'rc_cur_id' => $title->getArticleID(),
347 'rc_user' => $user->getId(),
348 'rc_user_text' => $user->getName(),
349 'rc_comment' => $comment,
350 'rc_this_oldid' => $newId,
351 'rc_last_oldid' => 0,
352 'rc_bot' => $bot ? 1 : 0,
353 'rc_moved_to_ns' => 0,
354 'rc_moved_to_title' => '',
355 'rc_ip' => $ip,
356 'rc_patrolled' => 0,
357 'rc_new' => 1, # obsolete
358 'rc_old_len' => 0,
359 'rc_new_len' => $size,
360 'rc_deleted' => 0,
361 'rc_logid' => 0,
362 'rc_log_type' => null,
363 'rc_log_action' => '',
364 'rc_params' => ''
365 );
366
367 $rc->mExtra = array(
368 'prefixedDBkey' => $title->getPrefixedDBkey(),
369 'lastTimestamp' => 0,
370 'oldSize' => 0,
371 'newSize' => $size
372 );
373 $rc->save();
374 return( $rc->mAttribs['rc_id'] );
375 }
376
377 # Makes an entry in the database corresponding to a rename
378 public static function notifyMove( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='', $overRedir = false )
379 {
380 global $wgRequest;
381
382 if ( !$ip ) {
383 $ip = wfGetIP();
384 if ( !$ip ) {
385 $ip = '';
386 }
387 }
388
389 $rc = new RecentChange;
390 $rc->mAttribs = array(
391 'rc_timestamp' => $timestamp,
392 'rc_cur_time' => $timestamp,
393 'rc_namespace' => $oldTitle->getNamespace(),
394 'rc_title' => $oldTitle->getDBkey(),
395 'rc_type' => $overRedir ? RC_MOVE_OVER_REDIRECT : RC_MOVE,
396 'rc_minor' => 0,
397 'rc_cur_id' => $oldTitle->getArticleID(),
398 'rc_user' => $user->getId(),
399 'rc_user_text' => $user->getName(),
400 'rc_comment' => $comment,
401 'rc_this_oldid' => 0,
402 'rc_last_oldid' => 0,
403 'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot' , true ) : 0,
404 'rc_moved_to_ns' => $newTitle->getNamespace(),
405 'rc_moved_to_title' => $newTitle->getDBkey(),
406 'rc_ip' => $ip,
407 'rc_new' => 0, # obsolete
408 'rc_patrolled' => 1,
409 'rc_old_len' => NULL,
410 'rc_new_len' => NULL,
411 'rc_deleted' => 0,
412 'rc_logid' => 0, # notifyMove not used anymore
413 'rc_log_type' => null,
414 'rc_log_action' => '',
415 'rc_params' => ''
416 );
417
418 $rc->mExtra = array(
419 'prefixedDBkey' => $oldTitle->getPrefixedDBkey(),
420 'lastTimestamp' => 0,
421 'prefixedMoveTo' => $newTitle->getPrefixedDBkey()
422 );
423 $rc->save();
424 }
425
426 public static function notifyMoveToNew( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='' ) {
427 RecentChange::notifyMove( $timestamp, $oldTitle, $newTitle, $user, $comment, $ip, false );
428 }
429
430 public static function notifyMoveOverRedirect( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='' ) {
431 RecentChange::notifyMove( $timestamp, $oldTitle, $newTitle, $user, $comment, $ip, true );
432 }
433
434 # A log entry is different to an edit in that previous revisions are not kept
435 public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip='',
436 $type, $action, $target, $logComment, $params, $newId=0 )
437 {
438 global $wgRequest;
439
440 if ( !$ip ) {
441 $ip = wfGetIP();
442 if ( !$ip ) {
443 $ip = '';
444 }
445 }
446
447 $rc = new RecentChange;
448 $rc->mAttribs = array(
449 'rc_timestamp' => $timestamp,
450 'rc_cur_time' => $timestamp,
451 'rc_namespace' => $target->getNamespace(),
452 'rc_title' => $target->getDBkey(),
453 'rc_type' => RC_LOG,
454 'rc_minor' => 0,
455 'rc_cur_id' => $target->getArticleID(),
456 'rc_user' => $user->getId(),
457 'rc_user_text' => $user->getName(),
458 'rc_comment' => $logComment,
459 'rc_this_oldid' => 0,
460 'rc_last_oldid' => 0,
461 'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot' , true ) : 0,
462 'rc_moved_to_ns' => 0,
463 'rc_moved_to_title' => '',
464 'rc_ip' => $ip,
465 'rc_patrolled' => 1,
466 'rc_new' => 0, # obsolete
467 'rc_old_len' => NULL,
468 'rc_new_len' => NULL,
469 'rc_deleted' => 0,
470 'rc_logid' => $newId,
471 'rc_log_type' => $type,
472 'rc_log_action' => $action,
473 'rc_params' => $params
474 );
475 $rc->mExtra = array(
476 'prefixedDBkey' => $title->getPrefixedDBkey(),
477 'lastTimestamp' => 0,
478 'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage
479 );
480 $rc->save();
481 }
482
483 # Initialises the members of this object from a mysql row object
484 function loadFromRow( $row )
485 {
486 $this->mAttribs = get_object_vars( $row );
487 $this->mAttribs["rc_timestamp"] = wfTimestamp(TS_MW, $this->mAttribs["rc_timestamp"]);
488 $this->mExtra = array();
489 }
490
491 # Makes a pseudo-RC entry from a cur row
492 function loadFromCurRow( $row )
493 {
494 $this->mAttribs = array(
495 'rc_timestamp' => wfTimestamp(TS_MW, $row->rev_timestamp),
496 'rc_cur_time' => $row->rev_timestamp,
497 'rc_user' => $row->rev_user,
498 'rc_user_text' => $row->rev_user_text,
499 'rc_namespace' => $row->page_namespace,
500 'rc_title' => $row->page_title,
501 'rc_comment' => $row->rev_comment,
502 'rc_minor' => $row->rev_minor_edit ? 1 : 0,
503 'rc_type' => $row->page_is_new ? RC_NEW : RC_EDIT,
504 'rc_cur_id' => $row->page_id,
505 'rc_this_oldid' => $row->rev_id,
506 'rc_last_oldid' => isset($row->rc_last_oldid) ? $row->rc_last_oldid : 0,
507 'rc_bot' => 0,
508 'rc_moved_to_ns' => 0,
509 'rc_moved_to_title' => '',
510 'rc_ip' => '',
511 'rc_id' => $row->rc_id,
512 'rc_patrolled' => $row->rc_patrolled,
513 'rc_new' => $row->page_is_new, # obsolete
514 'rc_old_len' => $row->rc_old_len,
515 'rc_new_len' => $row->rc_new_len,
516 'rc_params' => isset($row->rc_params) ? $row->rc_params : '',
517 'rc_log_type' => isset($row->rc_log_type) ? $row->rc_log_type : null,
518 'rc_log_action' => isset($row->rc_log_action) ? $row->rc_log_action : null,
519 'rc_log_id' => isset($row->rc_log_id) ? $row->rc_log_id: 0,
520 // this one REALLY should be set...
521 'rc_deleted' => isset($row->rc_deleted) ? $row->rc_deleted: 0,
522 );
523
524 $this->mExtra = array();
525 }
526
527 /**
528 * Get an attribute value
529 *
530 * @param $name Attribute name
531 * @return mixed
532 */
533 public function getAttribute( $name ) {
534 return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : NULL;
535 }
536
537 /**
538 * Gets the end part of the diff URL associated with this object
539 * Blank if no diff link should be displayed
540 */
541 function diffLinkTrail( $forceCur )
542 {
543 if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
544 $trail = "curid=" . (int)($this->mAttribs['rc_cur_id']) .
545 "&oldid=" . (int)($this->mAttribs['rc_last_oldid']);
546 if ( $forceCur ) {
547 $trail .= '&diff=0' ;
548 } else {
549 $trail .= '&diff=' . (int)($this->mAttribs['rc_this_oldid']);
550 }
551 } else {
552 $trail = '';
553 }
554 return $trail;
555 }
556
557 function cleanupForIRC( $text ) {
558 return str_replace(array("\n", "\r"), array("", ""), $text);
559 }
560
561 function getIRCLine() {
562 global $wgUseRCPatrol;
563
564 // FIXME: Would be good to replace these 2 extract() calls with something more explicit
565 // e.g. list ($rc_type, $rc_id) = array_values ($this->mAttribs); [or something like that]
566 extract($this->mAttribs);
567 extract($this->mExtra);
568
569 if ( $rc_type == RC_LOG ) {
570 $titleObj = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL );
571 } else {
572 $titleObj =& $this->getTitle();
573 }
574 $title = $titleObj->getPrefixedText();
575 $title = $this->cleanupForIRC( $title );
576
577 // FIXME: *HACK* these should be getFullURL(), hacked for SSL madness --brion 2005-12-26
578 if ( $rc_type == RC_LOG ) {
579 $url = '';
580 } elseif ( $rc_new && $wgUseRCPatrol ) {
581 $url = $titleObj->getInternalURL("rcid=$rc_id");
582 } else if ( $rc_new ) {
583 $url = $titleObj->getInternalURL();
584 } else if ( $wgUseRCPatrol ) {
585 $url = $titleObj->getInternalURL("diff=$rc_this_oldid&oldid=$rc_last_oldid&rcid=$rc_id");
586 } else {
587 $url = $titleObj->getInternalURL("diff=$rc_this_oldid&oldid=$rc_last_oldid");
588 }
589
590 if ( isset( $oldSize ) && isset( $newSize ) ) {
591 $szdiff = $newSize - $oldSize;
592 if ($szdiff < -500) {
593 $szdiff = "\002$szdiff\002";
594 } elseif ($szdiff >= 0) {
595 $szdiff = '+' . $szdiff ;
596 }
597 $szdiff = '(' . $szdiff . ')' ;
598 } else {
599 $szdiff = '';
600 }
601
602 $user = $this->cleanupForIRC( $rc_user_text );
603
604 if ( $rc_type == RC_LOG ) {
605 $logTargetText = $this->getTitle()->getPrefixedText();
606 $comment = $this->cleanupForIRC( str_replace($logTargetText,"\00302$logTargetText\00310",$actionComment) );
607 $flag = $rc_log_action;
608 } else {
609 $comment = $this->cleanupForIRC( $rc_comment );
610 $flag = ($rc_new ? "N" : "") . ($rc_minor ? "M" : "") . ($rc_bot ? "B" : "");
611 }
612 # see http://www.irssi.org/documentation/formats for some colour codes. prefix is \003,
613 # no colour (\003) switches back to the term default
614 $fullString = "\00314[[\00307$title\00314]]\0034 $flag\00310 " .
615 "\00302$url\003 \0035*\003 \00303$user\003 \0035*\003 $szdiff \00310$comment\003\n";
616 return $fullString;
617 }
618
619 /**
620 * Returns the change size (HTML).
621 * The lengths can be given optionally.
622 */
623 function getCharacterDifference( $old = 0, $new = 0 ) {
624 global $wgRCChangedSizeThreshold, $wgLang;
625
626 if( $old === 0 ) {
627 $old = $this->mAttribs['rc_old_len'];
628 }
629 if( $new === 0 ) {
630 $new = $this->mAttribs['rc_new_len'];
631 }
632
633 if( $old === NULL || $new === NULL ) {
634 return '';
635 }
636
637 $szdiff = $new - $old;
638 $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape'),
639 $wgLang->formatNum($szdiff) );
640
641 if( $szdiff < $wgRCChangedSizeThreshold ) {
642 return '<strong class=\'mw-plusminus-neg\'>(' . $formatedSize . ')</strong>';
643 } elseif( $szdiff === 0 ) {
644 return '<span class=\'mw-plusminus-null\'>(' . $formatedSize . ')</span>';
645 } elseif( $szdiff > 0 ) {
646 return '<span class=\'mw-plusminus-pos\'>(+' . $formatedSize . ')</span>';
647 } else {
648 return '<span class=\'mw-plusminus-neg\'>(' . $formatedSize . ')</span>';
649 }
650 }
651 }