http://www.mediawiki.org/wiki/Special:Code/MediaWiki/68616
Revision: 68616 Author: dantman Date: 2010-06-27 04:47:17 +0000 (Sun, 27 Jun 2010) Log Message: ----------- Make this extension a little closer to the extension coding standard. Modified Paths: -------------- trunk/extensions/mw-editcount/EditCount.i18n.php trunk/extensions/mw-editcount/EditCount.php trunk/extensions/mw-editcount/EditCountPage.php Modified: trunk/extensions/mw-editcount/EditCount.i18n.php =================================================================== --- trunk/extensions/mw-editcount/EditCount.i18n.php 2010-06-27 04:31:26 UTC (rev 68615) +++ trunk/extensions/mw-editcount/EditCount.i18n.php 2010-06-27 04:47:17 UTC (rev 68616) @@ -1,13 +1,14 @@ <?php /** - * Messages for the EditCount extension - * - * Feel free to translate these - * @package MediaWiki - * @subpackage EditCount + * Internationalisation file for extension mw-editcount/EditCount. + * + * @file + * @ingroup Extensions */ -$weECMessages['en'] = array( +$messages = array(); + +$messages['en'] = array( "editcount" => "Edit Count", "editcount-des" => "Enter an username or IP to view that user's edit count.", "editcount-edits" => "Edits", @@ -23,7 +24,7 @@ ); //German -$weECMessages['de'] = array( +$messages['de'] = array( "editcount" => "Anzahl der Bearbeitungen", "editcount-des" => "Geben Sie einen Benutzernamen oder eine IP ein, um sich die Anzahl der Bearbeitungen eines Benutzers anzeigen zu lassen.", @@ -40,7 +41,7 @@ ); //Finish -$weECMessages['fi'] = array( +$messages['fi'] = array( "editcount" => "K�ytt�jien muokkausm��r�t", "editcount-des" => "Voit tarkastella k�ytt�j�n tekemien tai IP-osoitteesta tehtyjen muokkausten lukum��r�� sy�tt�m�ll� tunnuksen tai IP:n alla olevaan kentt��n.", "editcount-edits" => "muokkauksia", @@ -55,7 +56,7 @@ "editcount-username" => "K�ytt�j�:" ); //Polish -$weECMessages['pl'] = array( +$messages['pl'] = array( "editcount" => "Liczba edycji", "editcount-des" => "Wpisz nazwe uzytkownika lub adres IP, aby zobaczyc liczbe jego edycji.", "editcount-edits" => "Edycji", @@ -71,7 +72,7 @@ ); //French -$weECMessages['fr'] = array( +$messages['fr'] = array( "editcount" => "Compteur d'éditions", "editcount-des" => "Saisir un nom d'utilisateur ou une IP pour voir le nombre d'édition de l'utilisateur.", "editcount-edits" => "Editions", @@ -87,7 +88,7 @@ ); //brazilian portuguese -$weECMessages['pt-br'] = array( +$messages['pt-br'] = array( "editcount" => "Contador de Edições", "editcount-des" => "Incira um nome de usuário ou IP para ver a contagem de edições do usuário.", "editcount-edits" => "Edições", @@ -103,7 +104,7 @@ ); //Dutch -$weECMessages['nl'] = array( +$messages['nl'] = array( "editcount" => "Bewerkingsteller", "editcount-des" => "Geef een gebruikersnaam of een IP-adres om .", "editcount-edits" => "Bewerkingen", Modified: trunk/extensions/mw-editcount/EditCount.php =================================================================== --- trunk/extensions/mw-editcount/EditCount.php 2010-06-27 04:31:26 UTC (rev 68615) +++ trunk/extensions/mw-editcount/EditCount.php 2010-06-27 04:47:17 UTC (rev 68616) @@ -49,15 +49,9 @@ $wgExtensionCredits["specialpage"][] = $egEditCountCredits; $wgExtensionFunctions[] = "efEditCount"; -if ($egECParserFunction) { - $wgHooks["LanguageGetMagic"][] = "efEditCountMagic"; -} + +$wgExtensionMessagesFiles['mw-editcount'] = dirname(__FILE__) . '/EditCount.i18n.php'; -if ($egECEnableSpecialPage) { - $wgHooks["SkinTemplateBuildNavUrlsNav_urlsAfterPermalink"][] = "efEditCountNavUrls"; - $wgHooks["MonoBookTemplateToolboxEnd"][] = "efEditCountToolbox"; -} - /** * The extension function that's called to set up EditCount. */ @@ -68,20 +62,18 @@ //Autoload $wgAutoloadClasses["EditCountPage"] = dirname(__FILE__) . "/EditCountPage.php"; $wgAutoloadClasses["EditCount"] = dirname(__FILE__) . "/EditCountPage.php"; - if ($before17) { - //autoloading not supported - require_once "EditCountPage.php"; - } if ($egECEnableSpecialPage) { $wgSpecialPages["EditCount"] = "EditCountPage"; + $wgHooks["SkinTemplateBuildNavUrlsNav_urlsAfterPermalink"][] = "efEditCountNavUrls"; + $wgHooks["MonoBookTemplateToolboxEnd"][] = "efEditCountToolbox"; } if ($egECParserFunction) { - $wgParser->setFunctionHook("editcount", "efEditCountParserFunction"); + $wgHooks["LanguageGetMagic"][] = "efEditCountMagic"; + $wgHooks['ParserFirstCallInit'][] = "efEditCountRegisterParser"; } - efEditCountMsgs(); } /** @@ -102,30 +94,6 @@ } /** - * Injects EditCount's messages into the message system - */ -function efEditCountMsgs() { - global $wgMessageCache, $wgContLang, $wgVersion; - static $msgsLoaded = false; - - wfProfileIn(__FUNCTION__); - - $before17 = version_compare($wgVersion, "1.7", "<"); - - if (!$msgsLoaded) { - $weECMessages = array(); - require_once "EditCount.i18n.php"; - //add all the message to fill in language gaps - foreach ($weECMessages as $code => $msgs) { - $wgMessageCache->addMessages($weECMessages[$code], $code); - } - $msgsLoaded = true; - } - - wfProfileOut(__FUNCTION__); -} - -/** * Adds the path of the EditCount special page to toolboxes on user pages * * @param SkinTemplate $skinTemplate @@ -140,7 +108,7 @@ if (!$egECEnableSpecialPage) { return; } - + wfLoadExtensionMessages( 'mw-editcount' ); $title = $skinTemplate->mTitle; if ($title->getNamespace() == NS_USER && $revisionid !== 0) { $navUrls["editcount"] = array( @@ -149,6 +117,15 @@ } return true; } + +/** + * Registers the parser function with parsers + */ +function efEditCountRegisterParser(&$parser) { + $wgParser->setFunctionHook("editcount", "efEditCountParserFunction"); + + return true; +} /** * Preforms the parser function action (getting the edit count of a user) @@ -202,6 +179,7 @@ * @return bool always true */ function efEditcountToolbox(&$monobook) { + wfLoadExtensionMessages( 'mw-editcount' ); if (array_key_exists("editcount", $monobook->data["nav_urls"])) { ?><li id="t-editcount"> <a href="<?php echo htmlspecialchars($monobook->data["nav_urls"]["editcount"]["href"]) ?>"><?php Modified: trunk/extensions/mw-editcount/EditCountPage.php =================================================================== --- trunk/extensions/mw-editcount/EditCountPage.php 2010-06-27 04:31:26 UTC (rev 68615) +++ trunk/extensions/mw-editcount/EditCountPage.php 2010-06-27 04:47:17 UTC (rev 68616) @@ -37,6 +37,7 @@ function EditCountPage() { parent::SpecialPage("EditCount", "", true); + wfLoadExtensionMessages( 'mw-editcount' ); } /** _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs