From: Ævar Arnfjörð Bjarmason Date: Sat, 26 Nov 2005 01:13:37 +0000 (+0000) Subject: * Support named arguments to wfMsg* like wfMsg( 'msg', array( 'foo' => 'bar' ) ) X-Git-Tag: 1.6.0~1131 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/?a=commitdiff_plain;h=0fec84c81cb2e996198ab11697c1b124445eb50f;p=lhc%2Fweb%2Fwiklou.git * Support named arguments to wfMsg* like wfMsg( 'msg', array( 'foo' => 'bar' ) ) --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 3d0ac194a8..5666072054 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -408,13 +408,17 @@ function wfMsgReplaceArgs( $message, $args ) { # Some messages are split with explode("\n", $msg) $message = str_replace( "\r", '', $message ); - # Replace arguments - if( count( $args ) ) { - foreach( $args as $n => $param ) { + // Replace arguments + if ( count( $args ) ) + if ( is_array( $args[0] ) ) + foreach ( $args[0] as $key => $val ) + $message = str_replace( '$' . $key, $val, $message ); + else { + foreach( $args as $n => $param ) $replacementKeys['$' . ($n + 1)] = $param; - } $message = strtr( $message, $replacementKeys ); } + return $message; }