Index: trunk/extensions/ProofreadPage/ProofreadPage_body.php |
— | — | @@ -440,28 +440,27 @@ |
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
| 444 | + // Get the names of the quality categories. Replaces earlier |
| 445 | + // code which called wfMsgForContent() 5 times for each page. |
| 446 | + // ISSUE: Should the number of quality levels be adjustable? |
| 447 | + // ISSUE 2: Should this array be saved as a member variable? |
| 448 | + // How often is this code called anyway? |
| 449 | + $qualityCategories = array(); |
| 450 | + for ( $i = 0; $i < 5; $i++ ) { |
| 451 | + $cat = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( "proofreadpage_quality{$i}_category" ) ); |
| 452 | + if ( $cat ) { |
| 453 | + $qualityCategories[$cat->getDBkey()] = "quality$i"; |
| 454 | + } |
| 455 | + } |
| 456 | + |
444 | 457 | if ( count( $values ) ) { |
445 | 458 | $query .= "SELECT cl_from, cl_to FROM $catlinks WHERE cl_from IN(" . implode( ",", $values ) . ")"; |
446 | 459 | $res = $dbr->query( $query, __METHOD__ ); |
447 | 460 | |
448 | 461 | foreach ( $res as $x ) { |
449 | 462 | $pdbk = $page_ids[$x->cl_from]; |
450 | | - switch( $x->cl_to ) { |
451 | | - case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality0_category' ) ): |
452 | | - $colours[$pdbk] = 'quality0'; |
453 | | - break; |
454 | | - case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality1_category' ) ): |
455 | | - $colours[$pdbk] = 'quality1'; |
456 | | - break; |
457 | | - case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality2_category' ) ): |
458 | | - $colours[$pdbk] = 'quality2'; |
459 | | - break; |
460 | | - case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality3_category' ) ): |
461 | | - $colours[$pdbk] = 'quality3'; |
462 | | - break; |
463 | | - case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality4_category' ) ): |
464 | | - $colours[$pdbk] = 'quality4'; |
465 | | - break; |
| 463 | + if ( array_key_exists( $x->cl_to, $qualityCategories ) ) { |
| 464 | + $colours[$pdbk] = $qualityCategories[$x->cl_to]; |
466 | 465 | } |
467 | 466 | } |
468 | 467 | } |