From 2ce29213c2437f0014e52b08e8625c555910e27d Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sun, 10 Aug 2008 19:29:02 +0000 Subject: [PATCH] Add localisation of special pages for Asksql, BadImage, CategoryIntersection, ContributionScores, Contributors --- ContributionScores.alias.php | 14 ++++++++++++++ ContributionScores.php | 25 ++++++++++++++----------- 2 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 ContributionScores.alias.php diff --git a/ContributionScores.alias.php b/ContributionScores.alias.php new file mode 100644 index 0000000..f988dc6 --- /dev/null +++ b/ContributionScores.alias.php @@ -0,0 +1,14 @@ + array( 'ContributionScores' ), +); diff --git a/ContributionScores.php b/ContributionScores.php index 7dd7b39..f4d62fd 100644 --- a/ContributionScores.php +++ b/ContributionScores.php @@ -1,6 +1,6 @@ =' ) ) { +if( version_compare( $wgVersion, '1.13', '>=' ) ) { + $wgExtensionMessagesFiles['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores.i18n.php'; + $wgExtensionAliasesFiles['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores.alias.php'; +} else if( version_compare( $wgVersion, '1.11', '>=' ) ) { $wgExtensionMessagesFiles['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores.i18n.php'; } else { $wgExtensionFunctions[] = 'efContributionScores_AddMessages'; @@ -47,7 +50,7 @@ if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { ///Message Cache population for versions that did not support $wgExtensionFunctions function efContributionScores_AddMessages() { global $wgMessageCache; - + #Add Messages require( CONTRIBUTIONSCORES_PATH . '/ContributionScores.i18n.php' ); foreach( $messages as $key => $value ) { @@ -58,7 +61,7 @@ function efContributionScores_AddMessages() { function efContributionScores_Setup() { global $wgParser; - + $wgParser->setFunctionHook( 'cscore', 'efContributionScores_Render' ); return true; } @@ -73,16 +76,16 @@ function efContributionScores_Render(&$parser, $usertext, $metric='score') { if( version_compare( $wgVersion, '1.11', '>=' ) ) wfLoadExtensionMessages( 'ContributionScores' ); - + $output = ""; - + if ($wgContribScoreDisableCache) { $parser->disableCache(); } - + $user = User::newFromName($usertext); $dbr = wfGetDB( DB_SLAVE ); - + if ( $user instanceof User && $user->isLoggedIn() ) { if ($metric=='score') { $res = $dbr->select('revision', @@ -96,7 +99,7 @@ function efContributionScores_Render(&$parser, $usertext, $metric='score') { array('rev_user' => $user->getID())); $row = $dbr->fetchObject($res); $output = $row->rev_count; - + } elseif ($metric=='pages') { $res = $dbr->select('revision', 'COUNT(DISTINCT rev_page) AS page_count', @@ -109,6 +112,6 @@ function efContributionScores_Render(&$parser, $usertext, $metric='score') { } else { $output = wfMsg('contributionscores-invalidusername'); } - + return $parser->insertStripItem($output, $parser->mStripState); -} \ No newline at end of file +}