From: Niklas Laxström Date: Fri, 24 Jul 2009 11:06:27 +0000 (+0000) Subject: * Don't add 200 extra css/js requests when showing 100 diffs X-Git-Tag: 1.31.0-rc.0~40748 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=bc43f524f76b983ea11b070a49e6924c9b096a66;p=lhc%2Fweb%2Fwiklou.git * Don't add 200 extra css/js requests when showing 100 diffs * Allow suppressing "line 1" from the diffs, which can get quite annoying with many diffs --- diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index 001d9bba9e..d1c2888ab6 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -30,6 +30,10 @@ class DifferenceEngine { var $mCacheHit = false; // Was the diff fetched from cache? var $htmldiff; + // If true, line X is not displayed when X is 1, for example to increase + // readability and conserve space with many small diffs. + protected $mReducedLineNumbers = false; + protected $unhide = false; /**#@-*/ @@ -80,6 +84,10 @@ class DifferenceEngine { $this->unhide = $unhide; } + function setReducedLineNumbers( $value = true ) { + $this->mReducedLineNumbers = $value; + } + function getTitle() { return $this->mTitle; } @@ -637,10 +645,16 @@ CONTROL; */ function showDiffStyle() { global $wgStylePath, $wgStyleVersion, $wgOut; + + static $styleDone = false; + if ( $styleDone === $wgOut ) return; + $wgOut->addStyle( 'common/diff.css' ); // JS is needed to detect old versions of Mozilla to work around an annoyance bug. $wgOut->addScript( "" ); + + $styleDone = $wgOut; } /** @@ -842,6 +856,7 @@ CONTROL; function localiseLineNumbersCb( $matches ) { global $wgLang; + if ( $matches[1] === '1' && $this->mReducedLineNumbers ) return ''; return wfMsgExt( 'lineno', 'escape', $wgLang->formatNum( $matches[1] ) ); }