r5292 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r5291‎ | r5292 | r5293 >
Date:16:38, 18 September 2004
Author:jeluf
Status:old
Tags:
Comment:
Cleaner handling of NoConvert, for variable number of arguments
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/SpecialAllmessages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialAllmessages.php
@@ -27,8 +27,8 @@
2828
2929 foreach ( $sortedArray as $key => $enMsg ) {
3030 $messages[$key]['enmsg'] = $enMsg;
31 - $messages[$key]['statmsg'] = wfMsgNoDb( $key, false );
32 - $messages[$key]['msg'] = wfMsg ( $key, false );
 31+ $messages[$key]['statmsg'] = wfMsgNoDbNoConvert( $key );
 32+ $messages[$key]['msg'] = wfMsgNoConvert ( $key );
3333 }
3434
3535 $wgMessageCache->enableTransform();
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -355,7 +355,7 @@
356356 /**
357357 * Get a message from anywhere
358358 */
359 -function wfMsg( $key, $convert=true ) {
 359+function wfMsg( $key ) {
360360 global $wgRequest;
361361 if ( $wgRequest->getVal( 'debugmsg' ) ) {
362362 if ( $key == 'linktrail' /* a special case where we want to return something specific */ )
@@ -367,21 +367,50 @@
368368 if ( count( $args ) ) {
369369 array_shift( $args );
370370 }
371 - return wfMsgReal( $key, $args, true, $convert );
 371+ return wfMsgReal( $key, $args, true );
372372 }
373373
374374 /**
 375+ * Get a message from anywhere, but don't call Language::convert
 376+ */
 377+function wfMsgNoConvert( $key ) {
 378+ global $wgRequest;
 379+ if ( $wgRequest->getVal( 'debugmsg' ) ) {
 380+ if ( $key == 'linktrail' /* a special case where we want to return something specific */ )
 381+ return "/^()(.*)$/sD";
 382+ else
 383+ return $key;
 384+ }
 385+ $args = func_get_args();
 386+ if ( count( $args ) ) {
 387+ array_shift( $args );
 388+ }
 389+ return wfMsgReal( $key, $args, true, false );
 390+}
 391+
 392+/**
375393 * Get a message from the language file
376394 */
377 -function wfMsgNoDB( $key, $convert=true ) {
 395+function wfMsgNoDB( $key ) {
378396 $args = func_get_args();
379397 if ( count( $args ) ) {
380398 array_shift( $args );
381399 }
382 - return wfMsgReal( $key, $args, false, $convert );
 400+ return wfMsgReal( $key, $args, false );
383401 }
384402
385403 /**
 404+ * Get a message from the language file, but don't call Language::convert
 405+ */
 406+function wfMsgNoDBNoConvert( $key ) {
 407+ $args = func_get_args();
 408+ if ( count( $args ) ) {
 409+ array_shift( $args );
 410+ }
 411+ return wfMsgReal( $key, $args, false, false );
 412+}
 413+
 414+/**
386415 * Really get a message
387416 */
388417 function wfMsgReal( $key, $args, $useDB, $convert=true ) {

Status & tagging log