Index: trunk/extensions/Translate/specials/SpecialMessageGroupStats.php |
— | — | @@ -107,13 +107,7 @@ |
108 | 108 | function getTable() { |
109 | 109 | $table = $this->table; |
110 | 110 | |
111 | | - global $wgTranslateWorkflowStates; |
112 | | - if ( $wgTranslateWorkflowStates ) { |
113 | | - $this->states = self::getWorkflowStates( $this->target ); |
114 | | - $this->statemap = array_flip( $wgTranslateWorkflowStates ); |
115 | | - $table->addExtraColumn( wfMessage( 'translate-stats-workflow' ) ); |
116 | | - } |
117 | | - |
| 111 | + $this->workflowStatesColumn(); |
118 | 112 | $out = ''; |
119 | 113 | |
120 | 114 | if ( $this->purge ) { |
— | — | @@ -179,19 +173,8 @@ |
180 | 174 | $out = "\t" . Html::openElement( 'tr' ); |
181 | 175 | $out .= "\n\t\t" . $this->getMainColumnCell( $code, $extra ); |
182 | 176 | $out .= $this->table->makeNumberColumns( $fuzzy, $translated, $total ); |
| 177 | + $out .= $this->workflowStateCell( $code ); |
183 | 178 | |
184 | | - global $wgTranslateWorkflowStates; |
185 | | - if ( $wgTranslateWorkflowStates ) { |
186 | | - $state = isset( $this->states[$code] ) ? $this->states[$code] : ''; |
187 | | - $sort = isset( $this->statemap[$state] ) ? $this->statemap[$state] + 1 : -1; |
188 | | - $stateMessage = wfMessage( "translate-workflow-state-$state" ); |
189 | | - $stateText = $stateMessage->isBlank() ? $state : $stateMessage->text(); |
190 | | - $out .= "\n\t\t" . $this->table->element( |
191 | | - $stateText, |
192 | | - isset( $wgTranslateWorkflowStates[$state] ) ? $wgTranslateWorkflowStates[$state] : '', |
193 | | - $sort |
194 | | - ); |
195 | | - } |
196 | 179 | $out .= "\n\t" . Html::closeElement( 'tr' ) . "\n"; |
197 | 180 | return $out; |
198 | 181 | } |
— | — | @@ -218,19 +201,4 @@ |
219 | 202 | $link = $linker->link( $this->translate, $text, array(), $queryParameters ); |
220 | 203 | return Html::rawElement( 'td', array(), $link ); |
221 | 204 | } |
222 | | - |
223 | | - protected static function getWorkflowStates( $group ) { |
224 | | - $db = wfGetDB( DB_SLAVE ); |
225 | | - $res = $db->select( |
226 | | - 'translate_groupreviews', |
227 | | - array( 'tgr_state', 'tgr_lang' ), |
228 | | - array( 'tgr_group' => $group ), |
229 | | - __METHOD__ |
230 | | - ); |
231 | | - $states = array(); |
232 | | - foreach ( $res as $row ) { |
233 | | - $states[$row->tgr_lang] = $row->tgr_state; |
234 | | - } |
235 | | - return $states; |
236 | | - } |
237 | 205 | } |
Index: trunk/extensions/Translate/specials/SpecialLanguageStats.php |
— | — | @@ -229,12 +229,49 @@ |
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
| 233 | + * If workflow states are configured, adds a workflow states column |
| 234 | + */ |
| 235 | + function workflowStatesColumn() { |
| 236 | + global $wgTranslateWorkflowStates; |
| 237 | + if ( $wgTranslateWorkflowStates ) { |
| 238 | + $this->states = self::getWorkflowStates( $this->target ); |
| 239 | + $this->statemap = array_flip( $wgTranslateWorkflowStates ); |
| 240 | + $this->table->addExtraColumn( wfMessage( 'translate-stats-workflow' ) ); |
| 241 | + } |
| 242 | + |
| 243 | + return; |
| 244 | + } |
| 245 | + |
| 246 | + /** |
| 247 | + * If workflow states are configured, adds a cell with the workflow state to the row, |
| 248 | + * @param $code Language code |
| 249 | + * @return string |
| 250 | + */ |
| 251 | + function workflowStateCell( $code ) { |
| 252 | + global $wgTranslateWorkflowStates; |
| 253 | + if ( $wgTranslateWorkflowStates ) { |
| 254 | + $state = isset( $this->states[$code] ) ? $this->states[$code] : ''; |
| 255 | + $sort = isset( $this->statemap[$state] ) ? $this->statemap[$state] + 1 : -1; |
| 256 | + $stateMessage = wfMessage( "translate-workflow-state-$state" ); |
| 257 | + $stateText = $stateMessage->isBlank() ? $state : $stateMessage->text(); |
| 258 | + return "\n\t\t" . $this->table->element( |
| 259 | + $stateText, |
| 260 | + isset( $wgTranslateWorkflowStates[$state] ) ? $wgTranslateWorkflowStates[$state] : '', |
| 261 | + $sort |
| 262 | + ); |
| 263 | + } |
| 264 | + |
| 265 | + return ''; |
| 266 | + } |
| 267 | + |
| 268 | + /** |
233 | 269 | * Returns the table itself. |
234 | 270 | * @return \string HTML |
235 | 271 | */ |
236 | 272 | function getTable() { |
237 | 273 | $table = $this->table; |
238 | 274 | |
| 275 | + $this->workflowStatesColumn(); |
239 | 276 | $out = ''; |
240 | 277 | |
241 | 278 | if ( $this->purge ) { |
— | — | @@ -344,7 +381,23 @@ |
345 | 382 | $out .= "\n\t\t" . Html::rawElement( 'td', array(), |
346 | 383 | $this->table->makeGroupLink( $group, $this->target, $extra ) ); |
347 | 384 | $out .= $this->table->makeNumberColumns( $fuzzy, $translated, $total ); |
| 385 | + |
348 | 386 | $out .= "\n\t" . Html::closeElement( 'tr' ) . "\n"; |
349 | 387 | return $out; |
350 | 388 | } |
| 389 | + |
| 390 | + protected static function getWorkflowStates( $group ) { |
| 391 | + $db = wfGetDB( DB_SLAVE ); |
| 392 | + $res = $db->select( |
| 393 | + 'translate_groupreviews', |
| 394 | + array( 'tgr_state', 'tgr_lang' ), |
| 395 | + array( 'tgr_group' => $group ), |
| 396 | + __METHOD__ |
| 397 | + ); |
| 398 | + $states = array(); |
| 399 | + foreach ( $res as $row ) { |
| 400 | + $states[$row->tgr_lang] = $row->tgr_state; |
| 401 | + } |
| 402 | + return $states; |
| 403 | + } |
351 | 404 | } |