From a070873551ba51f87807d27b1fe04845393504f2 Mon Sep 17 00:00:00 2001 From: Ryan Schmidt Date: Mon, 7 Jul 2008 22:37:42 +0000 Subject: [PATCH] * Add new hook NormalizeMessageKey to allow extensions to change what system message is being shown before any queries are made --- RELEASE-NOTES | 5 +++-- docs/hooks.txt | 8 ++++++++ includes/GlobalFunctions.php | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 1a2c5f0a58..54908fe209 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -182,8 +182,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Allow the search box, toolbox and languages box in the Monobook sidebar to be moved around arbitrarily using special sections in [[MediaWiki:Sidebar]]: SEARCH, TOOLBOX and LANGUAGES - - +* Add a new hook NormalizeMessageKey to allow extensions to replace messages before + the database is potentially queried + === Bug fixes in 1.13 === * (bug 10677) Add link to the file description page on the shared repository diff --git a/docs/hooks.txt b/docs/hooks.txt index 68c529ca10..d289efb906 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -862,6 +862,14 @@ $article: the article edited $rev: the new revision $baseID: the revision ID this was based off, if any +'NormalizeMessageKey': Called before the software gets the text of a message + (stuff in the MediaWiki: namespace), useful for changing WHAT message gets displayed +&$key: the message being looked up. Change this to something else to change what message gets displayed (string) +&$useDB: whether or not to look up the message in the database (bool) +&$langCode: the language code to get the message for (string) - or - + whether to use the content language (true) or site language (false) (bool) +&$transform: whether or not to expand variables and templates in the message (bool) + 'OpenSearchUrls': Called when constructing the OpenSearch description XML. Hooks can alter or append to the array of URLs for search & suggestion formats. &$urls: array of associative arrays with Url element attributes diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 4e60bd493b..ae17222487 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -460,6 +460,8 @@ function wfMsgWeirdKey ( $key ) { function wfMsgGetKey( $key, $useDB, $langCode = false, $transform = true ) { global $wgParser, $wgContLang, $wgMessageCache, $wgLang; + wfRunHooks('NormalizeMessageKey', array(&$key, &$useDB, &$langCode, &$transform)); + # If $wgMessageCache isn't initialised yet, try to return something sensible. if( is_object( $wgMessageCache ) ) { $message = $wgMessageCache->get( $key, $useDB, $langCode ); -- 2.20.1