r60116 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60115‎ | r60116 | r60117 >
Date:10:14, 16 December 2009
Author:overlordq
Status:deferred
Tags:
Comment:
Add option to enable AdSense Analytics Code
Modified paths:
  • /trunk/extensions/googleAnalytics/googleAnalytics.php (modified) (history)

Diff [purge]

Index: trunk/extensions/googleAnalytics/googleAnalytics.php
@@ -6,7 +6,7 @@
77 $wgExtensionCredits['other'][] = array(
88 'path' => __FILE__,
99 'name' => 'Google Analytics Integration',
10 - 'version' => '2.0.1',
 10+ 'version' => '2.0.2',
1111 'author' => 'Tim Laqua',
1212 'description' => 'Inserts Google Analytics script (ga.js) in to MediaWiki pages for tracking.',
1313 'descriptionurl' => 'googleanalytics-desc',
@@ -16,11 +16,21 @@
1717 $wgExtensionMessagesFiles['googleAnalytics'] = dirname(__FILE__) . '/googleAnalytics.i18n.php';
1818
1919 $wgHooks['SkinAfterBottomScripts'][] = 'efGoogleAnalyticsHookText';
 20+$wgHooks['ParserAfterTidy'][] = 'efGoogleAnalyticsASAC';
2021
2122 $wgGoogleAnalyticsAccount = "";
 23+$wgGoogleAnalyticsAddASAC = false;
2224 $wgGoogleAnalyticsIgnoreSysops = true;
2325 $wgGoogleAnalyticsIgnoreBots = true;
2426
 27+function efGoogleAnalyticsASAC( &$parser, &$text ) {
 28+ global $wgOut;
 29+
 30+ if( !empty($wgGoogleAnalyticsAccount) && $wgGoogleAnalyticsAddASAC ) {
 31+ $wgOut->addScript('<script>window.google_analytics_uacct = "' . $wgGoogleAnalyticsAccount . '";</script>');
 32+ }
 33+}
 34+
2535 function efGoogleAnalyticsHookText(&$skin, &$text='') {
2636 $text .= efAddGoogleAnalytics();
2737 return true;

Status & tagging log