Jack Phoenix has uploaded a new change for review. https://gerrit.wikimedia.org/r/168914
Change subject: Version 0.3.0 -- more RequestContext, less legacy i18n ...................................................................... Version 0.3.0 -- more RequestContext, less legacy i18n Change-Id: Iae22af7f3ebce8fd015ff231f50ed78524615521 --- D Quantcast.i18n.php M Quantcast.php 2 files changed, 16 insertions(+), 51 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Quantcast refs/changes/14/168914/1 diff --git a/Quantcast.i18n.php b/Quantcast.i18n.php deleted file mode 100644 index baf8b2b..0000000 --- a/Quantcast.i18n.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php -/** - * This is a backwards-compatibility shim, generated by: - * https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php - * - * Beginning with MediaWiki 1.23, translation strings are stored in json files, - * and the EXTENSION.i18n.php file only exists to provide compatibility with - * older releases of MediaWiki. For more information about this migration, see: - * https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format - * - * This shim maintains compatibility back to MediaWiki 1.17. - */ -$messages = array(); -if ( !function_exists( 'wfJsonI18nShimb23cb4cbb110b6e7' ) ) { - function wfJsonI18nShimb23cb4cbb110b6e7( $cache, $code, &$cachedData ) { - $codeSequence = array_merge( array( $code ), $cachedData['fallbackSequence'] ); - foreach ( $codeSequence as $csCode ) { - $fileName = dirname( __FILE__ ) . "/i18n/$csCode.json"; - if ( is_readable( $fileName ) ) { - $data = FormatJson::decode( file_get_contents( $fileName ), true ); - foreach ( array_keys( $data ) as $key ) { - if ( $key === '' || $key[0] === '@' ) { - unset( $data[$key] ); - } - } - $cachedData['messages'] = array_merge( $data, $cachedData['messages'] ); - } - - $cachedData['deps'][] = new FileDependency( $fileName ); - } - return true; - } - - $GLOBALS['wgHooks']['LocalisationCacheRecache'][] = 'wfJsonI18nShimb23cb4cbb110b6e7'; -} diff --git a/Quantcast.php b/Quantcast.php index 6993293..a4b7138 100644 --- a/Quantcast.php +++ b/Quantcast.php @@ -5,27 +5,27 @@ * @file * @ingroup Extensions * @author Jack Phoenix <j...@shoutwiki.com> (forgive me) - * @license http://en.wikipedia.org/wiki/Public_domain Public domain - * @link http://www.mediawiki.org/wiki/Extension:Quantcast Documentation - * @see http://bugzilla.shoutwiki.com/show_bug.cgi?id=108 + * @license https://en.wikipedia.org/wiki/Public_domain Public domain + * @link https://www.mediawiki.org/wiki/Extension:Quantcast Documentation + * @see https://bugzilla.shoutwiki.com/show_bug.cgi?id=108 */ if ( !defined( 'MEDIAWIKI' ) ) { die( 'This is not a valid entry point to MediaWiki.' ); } -$wgMessagesDirs['QuantCast'] = __DIR__ . '/i18n'; -$wgExtensionMessagesFiles['Quantcast'] = __DIR__ . '/Quantcast.i18n.php'; - // Extension credits that will show up on Special:Version $wgExtensionCredits['other'][] = array( 'path' => __FILE__, 'name' => 'Quantcast Tracking', - 'version' => '0.2.0', + 'version' => '0.3.0', 'author' => 'Jack Phoenix', 'descriptionmsg' => 'quantcast-desc', 'url' => 'https://www.mediawiki.org/wiki/Extension:Quantcast', ); + +// i18n +$wgMessagesDirs['Quantcast'] = __DIR__ . '/i18n'; // Groups that are excluded from Quantcast statistics $wgQuantcastTrackingExcludedGroups = array( 'staff' ); @@ -37,21 +37,21 @@ * Add tracking JS to all pages for all users that are not members of excluded * groups (the group listed in $wgQuantcastTrackingExcludedGroups). * - * @param $skin Object: Skin object - * @param $text String: bottomScripts text - * @return Boolean: true + * @param Skin $skin + * @param string $text bottomScripts text + * @return bool */ function wfAddQuantcastTrackingCode( $skin, &$text ) { - global $wgUser, $wgQuantcastTrackingExcludedGroups; + global $wgQuantcastTrackingExcludedGroups; - $groups = $wgUser->getEffectiveGroups(); + $groups = $skin->getUser()->getEffectiveGroups(); if ( !in_array( $wgQuantcastTrackingExcludedGroups, $groups ) ) { - $message = trim( wfMsgForContent( 'quantcast-tracking-number' ) ); + $message = $skin->msg( 'quantcast-tracking-number' )->inContentLanguage(); // We have a custom tracking code, use it! - if( !wfEmptyMsg( 'quantcast-tracking-number', $message ) ) { - $trackingCode = $message; + if ( !$message->isDisabled() ) { + $trackingCode = trim( $message->text() ); } else { // use ShoutWiki's default code - $trackingCode = wfMsgForContent( 'shoutwiki-quantcast-tracking-number' ); + $trackingCode = $skin->msg( 'shoutwiki-quantcast-tracking-number' )->inContentLanguage()->text(); } $safeCode = htmlspecialchars( $trackingCode, ENT_QUOTES ); $text .= "\t\t" . '<!-- Start Quantcast tag --> -- To view, visit https://gerrit.wikimedia.org/r/168914 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iae22af7f3ebce8fd015ff231f50ed78524615521 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Quantcast Gerrit-Branch: master Gerrit-Owner: Jack Phoenix <j...@countervandalism.net> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits