Siebrand has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/77093


Change subject: Replace getActivityColor by StatsTable::getBackgroundColor
......................................................................

Replace getActivityColor by StatsTable::getBackgroundColor

Change-Id: I9b30724a344048c85c2be311e242c1917f1b74f9
---
M specials/SpecialSupportedLanguages.php
1 file changed, 4 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate 
refs/changes/93/77093/1

diff --git a/specials/SpecialSupportedLanguages.php 
b/specials/SpecialSupportedLanguages.php
index 1675bb9..3550cf0 100644
--- a/specials/SpecialSupportedLanguages.php
+++ b/specials/SpecialSupportedLanguages.php
@@ -310,6 +310,7 @@
                $period = $this->period;
 
                $links = array();
+               $statsTable = new StatsTable();
 
                foreach ( $users as $username => $count ) {
                        $title = Title::makeTitleSafe( NS_USER, $username );
@@ -330,7 +331,7 @@
                                        ->numParams( $count, $last )->text();
                                $last = max( 1, min( $period, $last ) );
                                $styles['border-bottom'] = '3px solid #' .
-                                       $this->getActivityColor( $period - 
$last, $period );
+                                       $statsTable->getBackgroundColor( 
$period - $last, $period );
                        } else {
                                $enc = "<del>$enc</del>";
                        }
@@ -390,24 +391,6 @@
                return $stylestr;
        }
 
-       /// FIXME: copied from Special:LanguageStats
-       protected function getActivityColor( $subset, $total ) {
-               $v = @round( 255 * $subset / $total );
-
-               if ( $v < 128 ) {
-                       // Red to Yellow
-                       $red = 'FF';
-                       $green = sprintf( '%02X', 2 * $v );
-               } else {
-                       // Yellow to Green
-                       $red = sprintf( '%02X', 2 * ( 255 - $v ) );
-                       $green = 'FF';
-               }
-               $blue = '00';
-
-               return $red . $green . $blue;
-       }
-
        function shuffle_assoc( $list ) {
                if ( !is_array( $list ) ) {
                        return $list;
@@ -437,11 +420,12 @@
        protected function getColorLegend() {
                $legend = '';
                $period = $this->period;
+               $statsTable = new StatsTable();
 
                for ( $i = 0; $i <= $period; $i += 30 ) {
                        $iFormatted = htmlspecialchars( 
$this->getLanguage()->formatNum( $i ) );
                        $legend .= '<span style="background-color:#' .
-                               $this->getActivityColor( $period - $i, $period 
) .
+                               $statsTable->getBackgroundColor( $period - $i, 
$period ) .
                                "\"> $iFormatted</span>";
                }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/77093
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b30724a344048c85c2be311e242c1917f1b74f9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to