Index: trunk/extensions/googleAnalytics/googleAnalytics.php |
— | — | @@ -32,17 +32,26 @@ |
33 | 33 | return true; |
34 | 34 | } |
35 | 35 | |
36 | | -function efGoogleAnalyticsHookText($skin, &$text='') { |
| 36 | +function efGoogleAnalyticsHookText( $skin, &$text='' ) { |
37 | 37 | $text .= efAddGoogleAnalytics(); |
38 | 38 | return true; |
39 | 39 | } |
40 | 40 | |
41 | 41 | function efAddGoogleAnalytics() { |
42 | 42 | global $wgGoogleAnalyticsAccount, $wgGoogleAnalyticsIgnoreSysops, $wgGoogleAnalyticsIgnoreBots, $wgUser; |
43 | | - if (!$wgUser->isAllowed('bot') || !$wgGoogleAnalyticsIgnoreBots) { |
44 | | - if (!$wgUser->isAllowed('protect') || !$wgGoogleAnalyticsIgnoreSysops) { |
45 | | - if ( !empty($wgGoogleAnalyticsAccount) ) { |
46 | | - $funcOutput = <<<GASCRIPT |
| 43 | + if ( $wgUser->isAllowed( 'bot' ) && $wgGoogleAnalyticsIgnoreBots ) { |
| 44 | + return "\n<!-- Google Analytics tracking is disabled for bots -->"; |
| 45 | + } |
| 46 | + |
| 47 | + if ( $wgUser->isAllowed( 'protect' ) && $wgGoogleAnalyticsIgnoreSysops ) { |
| 48 | + return "\n<!-- Google Analytics tracking is disabled for users with 'protect' rights (I.E. sysops) -->"; |
| 49 | + } |
| 50 | + |
| 51 | + if ( $wgGoogleAnalyticsAccount === '' ) { |
| 52 | + return "\n<!-- Set \$wgGoogleAnalyticsAccount to your account # provided by Google Analytics. -->"; |
| 53 | + } |
| 54 | + |
| 55 | + return <<<HTML |
47 | 56 | <script type="text/javascript"> |
48 | 57 | var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); |
49 | 58 | document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); |
— | — | @@ -51,18 +60,7 @@ |
52 | 61 | var pageTracker = _gat._getTracker("{$wgGoogleAnalyticsAccount}"); |
53 | 62 | pageTracker._trackPageview(); |
54 | 63 | </script> |
55 | | -GASCRIPT; |
56 | | - } else { |
57 | | - $funcOutput = "\n<!-- Set \$wgGoogleAnalyticsAccount to your account # provided by Google Analytics. -->"; |
58 | | - } |
59 | | - } else { |
60 | | - $funcOutput = "\n<!-- Google Analytics tracking is disabled for users with 'protect' rights (I.E. sysops) -->"; |
61 | | - } |
62 | | - } else { |
63 | | - $funcOutput = "\n<!-- Google Analytics tracking is disabled for bots -->"; |
64 | | - } |
65 | | - |
66 | | - return $funcOutput; |
| 64 | +HTML; |
67 | 65 | } |
68 | 66 | |
69 | 67 | ///Alias for efAddGoogleAnalytics - backwards compatibility. |