From: Rotem Liss Date: Sun, 3 Sep 2006 16:31:28 +0000 (+0000) Subject: Creating the function MessageCache::getExtensionMessagesFor, to get an array of the... X-Git-Tag: 1.31.0-rc.0~55845 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=ad8032b081d07dbfb65ceddee8d8ece8face962d;p=lhc%2Fweb%2Fwiklou.git Creating the function MessageCache::getExtensionMessagesFor, to get an array of the extension messages in a specific language, and avoid the ugly hack in Special:Allmessages, which uses a private variable of wgMessageCache and uses is_array to check the array of messages, which includes both regular strings (as should be) and arrays of the languages. --- diff --git a/includes/MessageCache.php b/includes/MessageCache.php index 3520b3216d..3859e5f3bd 100644 --- a/includes/MessageCache.php +++ b/includes/MessageCache.php @@ -594,6 +594,25 @@ class MessageCache { wfProfileOut( __METHOD__ ); } + /** + * Get the extension messages for a specific language + * + * @param string $lang The messages language, English by default + */ + function getExtensionMessagesFor( $lang = 'en' ) { + wfProfileIn( __METHOD__ ); + $messages = array(); + foreach( $this->mExtensionMessages as $key => $message ) { + if ( isset( $message[$lang] ) ) { + $messages[$key] = $message[$lang]; + } elseif ( isset( $message['en'] ) ) { + $messages[$key] = $message['en']; + } + } + wfProfileOut( __METHOD__ ); + return $messages; + } + /** * Clear all stored messages. Mainly used after a mass rebuild. */ diff --git a/includes/SpecialAllmessages.php b/includes/SpecialAllmessages.php index d88ca51a00..7eada4b981 100644 --- a/includes/SpecialAllmessages.php +++ b/includes/SpecialAllmessages.php @@ -30,13 +30,13 @@ function wfSpecialAllmessages() { MessageCache::loadAllMessages(); $first = true; - $sortedArray = array_merge( Language::getMessagesFor( 'en' ), $wgMessageCache->mExtensionMessages ); + $sortedArray = array_merge( Language::getMessagesFor( 'en' ), $wgMessageCache->getExtensionMessagesFor( 'en' ) ); ksort( $sortedArray ); $messages = array(); $wgMessageCache->disableTransform(); foreach ( $sortedArray as $key => $value ) { - $messages[$key]['enmsg'] = is_array( $value ) ? $value['en'] : $value; + $messages[$key]['enmsg'] = $value; $messages[$key]['statmsg'] = wfMsgNoDb( $key ); $messages[$key]['msg'] = wfMsg ( $key ); }