Index: trunk/extensions/Translate/utils/StatsTable.php |
— | — | @@ -27,6 +27,8 @@ |
28 | 28 | protected $translate; |
29 | 29 | /// @var string |
30 | 30 | protected $mainColumnHeader; |
| 31 | + /// @var array |
| 32 | + protected $extraColumns = array(); |
31 | 33 | |
32 | 34 | public function __construct() { |
33 | 35 | global $wgLang; |
— | — | @@ -45,7 +47,10 @@ |
46 | 48 | public function element( $in, $bgcolor = '', $sort = '' ) { |
47 | 49 | $attributes = array(); |
48 | 50 | if ( $sort ) $attributes['data-sort-value'] = $sort; |
49 | | - if ( $bgcolor ) $attributes['style'] = "background-color: #" . $bgcolor; |
| 51 | + if ( $bgcolor ) { |
| 52 | + $attributes['style'] = "background-color: #" . $bgcolor; |
| 53 | + $attributes['class'] = 'hover-color'; |
| 54 | + } |
50 | 55 | |
51 | 56 | $element = Html::element( 'td', $attributes, $in ); |
52 | 57 | return $element; |
— | — | @@ -87,6 +92,19 @@ |
88 | 93 | return Html::element( 'th', array(), $msg->text() ); |
89 | 94 | } |
90 | 95 | |
| 96 | + public function addExtraColumn( Message $column ) { |
| 97 | + $this->extraColumns[] = $column; |
| 98 | + } |
| 99 | + |
| 100 | + public function getOtherColumnHeaders() { |
| 101 | + return array_merge( array( |
| 102 | + wfMessage( 'translate-total' ), |
| 103 | + wfMessage( 'translate-untranslated' ), |
| 104 | + wfMessage( 'translate-percentage-complete' ), |
| 105 | + wfMessage( 'translate-percentage-fuzzy' ), |
| 106 | + ), $this->extraColumns ); |
| 107 | + } |
| 108 | + |
91 | 109 | public function createHeader() { |
92 | 110 | // Create table header |
93 | 111 | $out = Html::openElement( |
— | — | @@ -98,14 +116,9 @@ |
99 | 117 | $out .= "\n\t" . Html::openElement( 'tr' ); |
100 | 118 | |
101 | 119 | $out .= "\n\t\t" . $this->getMainColumnHeader(); |
102 | | - $out .= "\n\t\t" . $this->createColumnHeader( |
103 | | - wfMessage( 'translate-total' ) ); |
104 | | - $out .= "\n\t\t" . $this->createColumnHeader( |
105 | | - wfMessage( 'translate-untranslated' ) ); |
106 | | - $out .= "\n\t\t" . $this->createColumnHeader( |
107 | | - wfMessage( 'translate-percentage-complete' ) ); |
108 | | - $out .= "\n\t\t" . $this->createColumnHeader( |
109 | | - wfMessage( 'translate-percentage-fuzzy' ) ); |
| 120 | + foreach ( $this->getOtherColumnHeaders() as $label ) { |
| 121 | + $out .= "\n\t\t" . $this->createColumnHeader( $label ); |
| 122 | + } |
110 | 123 | $out .= "\n\t" . Html::closeElement( 'tr' ); |
111 | 124 | $out .= "\n\t" . Html::closeElement( 'thead' ); |
112 | 125 | $out .= "\n\t" . Html::openElement( 'tbody' ); |
— | — | @@ -124,6 +137,7 @@ |
125 | 138 | $out = "\t" . Html::openElement( 'tr' ); |
126 | 139 | $out .= "\n\t\t" . Html::element( 'td', array(), $message->text() ); |
127 | 140 | $out .= $this->makeNumberColumns( $fuzzy, $translated, $total ); |
| 141 | + $out .= "\n\t" . Xml::closeElement( 'tr' ) . "\n"; |
128 | 142 | return $out; |
129 | 143 | } |
130 | 144 | |
— | — | @@ -139,7 +153,6 @@ |
140 | 154 | $na = "\n\t\t" . Html::element( 'td', array( 'data-sort-value' => -1 ), '...' ); |
141 | 155 | $nap = "\n\t\t" . $this->element( '...', 'AFAFAF', -1 ); |
142 | 156 | $out = $na . $na . $nap . $nap; |
143 | | - $out .= "\n\t" . Xml::closeElement( 'tr' ) . "\n"; |
144 | 157 | return $out; |
145 | 158 | } |
146 | 159 | |
— | — | @@ -158,8 +171,6 @@ |
159 | 172 | $out .= "\n\t\t" . $this->element( $this->formatPercentage( $fuzzy / $total ), |
160 | 173 | $this->getBackgroundColour( $fuzzy, $total, true ), |
161 | 174 | sprintf( '%1.5f', $fuzzy / $total ) ); |
162 | | - |
163 | | - $out .= "\n\t" . Xml::closeElement( 'tr' ) . "\n"; |
164 | 175 | return $out; |
165 | 176 | } |
166 | 177 | |
Index: trunk/extensions/Translate/Translate.i18n.php |
— | — | @@ -402,7 +402,7 @@ |
403 | 403 | 'translate-workflow-set-do' => 'Set', |
404 | 404 | 'translate-workflow-set-doing' => 'Setting...', |
405 | 405 | 'translate-workflow-set-done' => 'Set!', |
406 | | - |
| 406 | + 'translate-stats-workflow' => 'Status', |
407 | 407 | ); |
408 | 408 | |
409 | 409 | /** Message documentation (Message documentation) |
— | — | @@ -631,6 +631,7 @@ |
632 | 632 | 'translate-workflow-set-do' => 'Submit button text when active', |
633 | 633 | 'translate-workflow-set-doing' => 'Submit button text when waiting for reply from server', |
634 | 634 | 'translate-workflow-set-done' => 'Submit button text when submission completed succesfully', |
| 635 | + 'translate-stats-workflow' => 'Column header on Special:LanguageStats and Special:MessageGroupStats', |
635 | 636 | ); |
636 | 637 | |
637 | 638 | /** Faeag Rotuma (Faeag Rotuma) |
Index: trunk/extensions/Translate/specials/SpecialMessageGroupStats.php |
— | — | @@ -106,6 +106,13 @@ |
107 | 107 | */ |
108 | 108 | function getTable() { |
109 | 109 | $table = $this->table; |
| 110 | + |
| 111 | + global $wgTranslateWorkflowStates; |
| 112 | + if ( $wgTranslateWorkflowStates !== false ) { |
| 113 | + $this->states = self::getWorkflowStates( $this->target ); |
| 114 | + $this->statemap = array_flip( $wgTranslateWorkflowStates ); |
| 115 | + $table->addExtraColumn( wfMessage( 'translate-stats-workflow' ) ); |
| 116 | + } |
110 | 117 | $out = ''; |
111 | 118 | |
112 | 119 | if ( $this->purge ) { |
— | — | @@ -171,6 +178,13 @@ |
172 | 179 | $out = "\t" . Html::openElement( 'tr' ); |
173 | 180 | $out .= "\n\t\t" . $this->getMainColumnCell( $code, $extra ); |
174 | 181 | $out .= $this->table->makeNumberColumns( $fuzzy, $translated, $total ); |
| 182 | + global $wgTranslateWorkflowStates; |
| 183 | + if ( $wgTranslateWorkflowStates !== false ) { |
| 184 | + $state = isset( $this->states[$code] ) ? $this->states[$code] : ''; |
| 185 | + $sort = isset( $this->statemap[$state] ) ? $this->statemap[$state] + 1 : -1; |
| 186 | + $out .= "\n\t\t" . $this->table->element( $state, false, $sort ); |
| 187 | + } |
| 188 | + $out .= "\n\t" . Xml::closeElement( 'tr' ) . "\n"; |
175 | 189 | return $out; |
176 | 190 | } |
177 | 191 | |
— | — | @@ -197,4 +211,14 @@ |
198 | 212 | return Html::rawElement( 'td', array(), $link ); |
199 | 213 | } |
200 | 214 | |
201 | | -} |
\ No newline at end of file |
| 215 | + protected static function getWorkflowStates( $group ) { |
| 216 | + $db = wfGetDB( DB_SLAVE ); |
| 217 | + $res = $db->select( 'translate_groupreviews', array( 'tgr_state', 'tgr_lang' ), array( 'tgr_group' => $group ), __METHOD__ ); |
| 218 | + $states = array(); |
| 219 | + foreach ( $res as $row ) { |
| 220 | + $states[$row->tgr_lang] = $row->tgr_state; |
| 221 | + } |
| 222 | + return $states; |
| 223 | + } |
| 224 | + |
| 225 | +} |
Index: trunk/extensions/Translate/specials/SpecialLanguageStats.php |
— | — | @@ -337,6 +337,7 @@ |
338 | 338 | $out .= "\n\t\t" . Html::rawElement( 'td', array(), |
339 | 339 | $this->table->makeGroupLink( $group, $this->target, $extra ) ); |
340 | 340 | $out .= $this->table->makeNumberColumns( $fuzzy, $translated, $total ); |
| 341 | + $out .= "\n\t" . Xml::closeElement( 'tr' ) . "\n"; |
341 | 342 | return $out; |
342 | 343 | } |
343 | 344 | } |
Index: trunk/extensions/Translate/resources/ext.translate.special.languagestats.js |
— | — | @@ -73,24 +73,17 @@ |
74 | 74 | // When hovering a row, adjust brightness of the last two custom-colored cells as well |
75 | 75 | // See also translate.langstats.css for the highlighting for the other normal rows |
76 | 76 | mw.loader.using( 'jquery.colorUtil' , function() { |
77 | | - |
78 | 77 | $( '.mw-sp-translate-table.wikitable tr' ).hover( function() { |
79 | | - |
80 | | - $( '> td:last', this ) |
81 | | - // Get last two cells |
82 | | - .prev( 'td' ).andSelf() |
83 | | - // 30% more brightness |
84 | | - .css( 'background-color', function( i, val ) { |
85 | | - return $.colorUtil.getColorBrightness( val, +0.3 ); |
86 | | - } ); |
| 78 | + $( '> td.hover-color', this ) |
| 79 | + // 30% more brightness |
| 80 | + .css( 'background-color', function( i, val ) { |
| 81 | + return $.colorUtil.getColorBrightness( val, +0.3 ); |
| 82 | + } ); |
87 | 83 | }, function() { |
88 | | - $( '> td:last', this ) |
89 | | - // Get last two cells |
90 | | - .prev( 'td' ).andSelf() |
91 | | - // 30% less brightness |
92 | | - .css( 'background-color', function( i, val ) { |
93 | | - return $.colorUtil.getColorBrightness( val, -0.3 ); |
94 | | - } ); |
| 84 | + $( '> td.hover-color', this ) |
| 85 | + // 30% less brightness |
| 86 | + .css( 'background-color', function( i, val ) { |
| 87 | + return $.colorUtil.getColorBrightness( val, -0.3 ); |
| 88 | + } ); |
95 | 89 | } ); |
96 | | - |
97 | | -} ); |
\ No newline at end of file |
| 90 | +} ); |