From bc43f524f76b983ea11b070a49e6924c9b096a66 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Fri, 24 Jul 2009 11:06:27 +0000 Subject: [PATCH] * 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 --- includes/diff/DifferenceEngine.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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] ) ); } -- 2.20.1