Index: trunk/extensions/Translate/specials/SpecialMessageGroupStats.php |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | function getTable() { |
109 | 109 | $table = $this->table; |
110 | 110 | |
111 | | - $this->workflowStatesColumn(); |
| 111 | + $this->addWorkflowStatesColumn(); |
112 | 112 | $out = ''; |
113 | 113 | |
114 | 114 | if ( $this->purge ) { |
— | — | @@ -173,7 +173,7 @@ |
174 | 174 | $out = "\t" . Html::openElement( 'tr' ); |
175 | 175 | $out .= "\n\t\t" . $this->getMainColumnCell( $code, $extra ); |
176 | 176 | $out .= $this->table->makeNumberColumns( $fuzzy, $translated, $total ); |
177 | | - $out .= $this->workflowStateCell( $code ); |
| 177 | + $out .= $this->getWorkflowStateCell( $code ); |
178 | 178 | |
179 | 179 | $out .= "\n\t" . Html::closeElement( 'tr' ) . "\n"; |
180 | 180 | return $out; |
Index: trunk/extensions/Translate/specials/SpecialLanguageStats.php |
— | — | @@ -231,10 +231,10 @@ |
232 | 232 | /** |
233 | 233 | * If workflow states are configured, adds a workflow states column |
234 | 234 | */ |
235 | | - function workflowStatesColumn() { |
| 235 | + function addWorkflowStatesColumn() { |
236 | 236 | global $wgTranslateWorkflowStates; |
237 | 237 | if ( $wgTranslateWorkflowStates ) { |
238 | | - $this->states = self::getWorkflowStates( $this->target ); |
| 238 | + $this->states = self::getWorkflowStates(); |
239 | 239 | $this->statemap = array_flip( $wgTranslateWorkflowStates ); |
240 | 240 | $this->table->addExtraColumn( wfMessage( 'translate-stats-workflow' ) ); |
241 | 241 | } |
— | — | @@ -244,13 +244,13 @@ |
245 | 245 | |
246 | 246 | /** |
247 | 247 | * If workflow states are configured, adds a cell with the workflow state to the row, |
248 | | - * @param $code Language code |
| 248 | + * @param $target Whose workflow state do we want, such as language code or group id. |
249 | 249 | * @return string |
250 | 250 | */ |
251 | | - function workflowStateCell( $code ) { |
| 251 | + function getWorkflowStateCell( $target ) { |
252 | 252 | global $wgTranslateWorkflowStates; |
253 | 253 | if ( $wgTranslateWorkflowStates ) { |
254 | | - $state = isset( $this->states[$code] ) ? $this->states[$code] : ''; |
| 254 | + $state = isset( $this->states[$target] ) ? $this->states[$target] : ''; |
255 | 255 | $sort = isset( $this->statemap[$state] ) ? $this->statemap[$state] + 1 : -1; |
256 | 256 | $stateMessage = wfMessage( "translate-workflow-state-$state" ); |
257 | 257 | $stateText = $stateMessage->isBlank() ? $state : $stateMessage->text(); |
— | — | @@ -271,7 +271,7 @@ |
272 | 272 | function getTable() { |
273 | 273 | $table = $this->table; |
274 | 274 | |
275 | | - $this->workflowStatesColumn(); |
| 275 | + $this->addWorkflowStatesColumn(); |
276 | 276 | $out = ''; |
277 | 277 | |
278 | 278 | if ( $this->purge ) { |
— | — | @@ -333,7 +333,9 @@ |
334 | 334 | * @return string |
335 | 335 | */ |
336 | 336 | protected function makeGroupRow( $group, $cache, $parent = false ) { |
337 | | - if ( $this->table->isBlacklisted( $group->getId(), $this->target ) !== null ) { |
| 337 | + $groupId = $group->getId(); |
| 338 | + |
| 339 | + if ( $this->table->isBlacklisted( $groupId, $this->target ) !== null ) { |
338 | 340 | return ''; |
339 | 341 | } |
340 | 342 | |
— | — | @@ -343,7 +345,7 @@ |
344 | 346 | return ''; |
345 | 347 | } |
346 | 348 | |
347 | | - $stats = $cache[$group->getId()]; |
| 349 | + $stats = $cache[$groupId]; |
348 | 350 | |
349 | 351 | list( $total, $translated, $fuzzy ) = $stats; |
350 | 352 | if ( $total === null ) { |
— | — | @@ -370,7 +372,7 @@ |
371 | 373 | } |
372 | 374 | |
373 | 375 | $rowParams = array(); |
374 | | - $rowParams['data-groupid'] = $group->getId(); |
| 376 | + $rowParams['data-groupid'] = $groupId; |
375 | 377 | if ( is_string( $parent ) ) { |
376 | 378 | $rowParams['data-parentgroups'] = $parent; |
377 | 379 | } elseif ( $parent === true ) { |
— | — | @@ -381,22 +383,35 @@ |
382 | 384 | $out .= "\n\t\t" . Html::rawElement( 'td', array(), |
383 | 385 | $this->table->makeGroupLink( $group, $this->target, $extra ) ); |
384 | 386 | $out .= $this->table->makeNumberColumns( $fuzzy, $translated, $total ); |
| 387 | + $out .= $this->getWorkflowStateCell( $groupId ); |
385 | 388 | |
386 | 389 | $out .= "\n\t" . Html::closeElement( 'tr' ) . "\n"; |
387 | 390 | return $out; |
388 | 391 | } |
389 | 392 | |
390 | | - protected static function getWorkflowStates( $group ) { |
| 393 | + protected function getWorkflowStates() { |
391 | 394 | $db = wfGetDB( DB_SLAVE ); |
| 395 | + |
| 396 | + switch ( $this->targetValueName ) { |
| 397 | + case 'group': |
| 398 | + $targetCol = 'tgr_group'; |
| 399 | + $selectKey = 'tgr_lang'; |
| 400 | + break; |
| 401 | + case 'code': |
| 402 | + $targetCol = 'tgr_lang'; |
| 403 | + $selectKey = 'tgr_group'; |
| 404 | + break; |
| 405 | + } |
| 406 | + |
392 | 407 | $res = $db->select( |
393 | 408 | 'translate_groupreviews', |
394 | | - array( 'tgr_state', 'tgr_lang' ), |
395 | | - array( 'tgr_group' => $group ), |
| 409 | + array( 'tgr_state', $selectKey ), |
| 410 | + array( $targetCol => $this->target ), |
396 | 411 | __METHOD__ |
397 | 412 | ); |
398 | 413 | $states = array(); |
399 | 414 | foreach ( $res as $row ) { |
400 | | - $states[$row->tgr_lang] = $row->tgr_state; |
| 415 | + $states[$row->$selectKey] = $row->tgr_state; |
401 | 416 | } |
402 | 417 | return $states; |
403 | 418 | } |