r48527 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48526‎ | r48527 | r48528 >
Date:20:09, 18 March 2009
Author:tparscal
Status:deferred
Tags:
Comment:
Fixed message loading bug.
Modified paths:
  • /trunk/extensions/CommunityVoice/CommunityVoice.php (modified) (history)
  • /trunk/extensions/CommunityVoice/Modules/Ratings.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CommunityVoice/CommunityVoice.php
@@ -59,13 +59,24 @@
6060
6161 abstract class CommunityVoice {
6262
63 - /* Static Members */
 63+ /* Private Static Members */
6464
65 - static private $modules = array(
 65+ private static $modules = array(
6666 'Ratings' => array( 'class' => 'CommunityVoiceRatings' )
6767 );
68 - static private $messagesLoaded = false;
 68+ private static $messagesLoaded = false;
6969
 70+ /* Private Static Functions */
 71+
 72+ private static function autoLoadMessages() {
 73+ // Checks if extension messages have been loaded already
 74+ if ( !self::$messagesLoaded ) {
 75+ // Loads extension messages
 76+ wfLoadExtensionMessages( 'CommunityVoice' );
 77+ self::$messagesLoaded = true;
 78+ }
 79+ }
 80+
7081 /* Static Functions */
7182
7283 public static function getModules() {
@@ -124,16 +135,31 @@
125136 $message,
126137 $parameter = null
127138 ) {
128 - // Checks if extension messages have been loaded already
129 - if ( !self::$messagesLoaded ) {
130 - // Loads extension messages
131 - wfLoadExtensionMessages( 'CommunityVoice' );
132 - self::$messagesLoaded = true;
133 - }
 139+ // Makes sure messages are laoded
 140+ self::autoLoadMessages();
134141 // Returns message
135142 return wfMsg( 'communityvoice-' . $module . '-' . $message, $parameter );
136143 }
137144
 145+ public static function getMessageParse(
 146+ $module,
 147+ $message
 148+ ) {
 149+ // Makes sure messages are laoded
 150+ self::autoLoadMessages();
 151+ // Gets variadic parameters
 152+ $parameters = func_get_args();
 153+ // Less the first two
 154+ array_shift( $parameters );
 155+ array_shift( $parameters );
 156+ // Returns message
 157+ return wfMsgExt(
 158+ 'communityvoice-' . $module . '-' . $message,
 159+ array( 'parsemag' ),
 160+ $parameters
 161+ );
 162+ }
 163+
138164 /**
139165 * Adds scripts to document
140166 */
Index: trunk/extensions/CommunityVoice/Modules/Ratings.php
@@ -177,7 +177,12 @@
178178 'cv_ratings_scale_' . $args['category'] . '_' . $args['title']
179179 );
180180 // Gets stats message
181 - $stats = wfMsgExt( 'communityvoice-ratings-scale-stats', array( 'parsemag' ), $wgLang->formatNum( round( $rating, 1 ) ), $wgLang->formatnum( $totalVotes ) );
 181+ $stats = CommunityVoice::getMessageParse(
 182+ 'ratings',
 183+ 'scale-stats',
 184+ $wgLang->formatNum( round( $rating, 1 ) ),
 185+ $wgLang->formatnum( $totalVotes )
 186+ );
182187
183188 // Begins rating scale
184189 $htmlOut = Html::open(

Status & tagging log