Refactor getCharacterDifference()

This commit is contained in:
Aaron Schulz 2008-11-16 23:18:43 +00:00
parent 8df706c465
commit 371a23a35f
2 changed files with 25 additions and 23 deletions

View file

@ -99,6 +99,30 @@ class ChangesList {
$this->rclistOpen = false;
return '';
}
/**
* Show formatted char difference
* @param int $old bytes
* @param int $new bytes
* @returns string
*/
public static function showCharacterDifference( $old, $new ) {
global $wgRCChangedSizeThreshold, $wgLang;
$szdiff = $new - $old;
$formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape'), $wgLang->formatNum($szdiff) );
if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
$tag = 'strong';
} else {
$tag = 'span';
}
if( $szdiff === 0 ) {
return "<$tag class='mw-plusminus-null'>($formatedSize)</$tag>";
} elseif( $szdiff > 0 ) {
return "<$tag class='mw-plusminus-pos'>(+$formatedSize)</$tag>";
} else {
return "<$tag class='mw-plusminus-neg'>($formatedSize)</$tag>";
}
}
/**
* Returns text for the end of RC

View file

@ -668,37 +668,15 @@ class RecentChange
* The lengths can be given optionally.
*/
public 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( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
$tag = 'strong';
}
else{
$tag = 'span';
}
if( $szdiff === 0 ) {
return "<$tag class='mw-plusminus-null'>($formatedSize)</$tag>";
} elseif( $szdiff > 0 ) {
return "<$tag class='mw-plusminus-pos'>(+$formatedSize)</$tag>";
} else {
return "<$tag class='mw-plusminus-neg'>($formatedSize)</$tag>";
}
return ChangesList::showCharacterDifference( $old, $new );
}
}