Index: trunk/extensions/GoogleAdSense/GoogleAdSense.php |
— | — | @@ -33,6 +33,8 @@ |
34 | 34 | $wgGoogleAdSenseWidth = 120; // Width of the AdSense box, specified in your AdSense account |
35 | 35 | $wgGoogleAdSenseHeight = 240; // Width of the AdSense box, specified in your AdSense account |
36 | 36 | $wgGoogleAdSenseSrc = "http://pagead2.googlesyndication.com/pagead/show_ads.js"; // Source URL of the AdSense script |
| 37 | +$wgGoogleAdSenseAnonOnly = false; // Show the AdSense box only for anonymous users |
| 38 | +//$wgGoogleAdSenseCssLocation = $wgScriptPath . '/extensions/GoogleAdSense'; // Path to GoogleAdSense.css if non-default |
37 | 39 | |
38 | 40 | /** |
39 | 41 | * The following variables must be set in your LocalSettings.php. |
— | — | @@ -58,3 +60,6 @@ |
59 | 61 | |
60 | 62 | // Hook to modify the sidebar |
61 | 63 | $wgHooks['SkinBuildSidebar'][] = 'GoogleAdSense::GoogleAdSenseInSidebar'; |
| 64 | + |
| 65 | +// Hook to inject CSS - currently disabled, because it does not add the CSS somehow |
| 66 | +//$wgHooks['OutputPageBeforeHTML'][] = 'GoogleAdSense::injectCSS'; |
Index: trunk/extensions/GoogleAdSense/GoogleAdSense.class.php |
— | — | @@ -8,17 +8,21 @@ |
9 | 9 | * @license MIT |
10 | 10 | */ |
11 | 11 | class GoogleAdSense { |
12 | | - |
13 | 12 | static function GoogleAdSenseInSidebar( $skin, &$bar ) { |
14 | 13 | global $wgGoogleAdSenseWidth, $wgGoogleAdSenseID, |
15 | 14 | $wgGoogleAdSenseHeight, $wgGoogleAdSenseClient, |
16 | | - $wgGoogleAdSenseSlot, $wgGoogleAdSenseSrc; |
| 15 | + $wgGoogleAdSenseSlot, $wgGoogleAdSenseSrc, |
| 16 | + $wgGoogleAdSenseAnonOnly, $wgUser; |
17 | 17 | |
18 | 18 | // Return $bar unchanged if not all values have been set. |
19 | 19 | // FIXME: signal incorrect configuration nicely? |
20 | 20 | if( $wgGoogleAdSenseClient == 'none' || $wgGoogleAdSenseSlot == 'none' || $wgGoogleAdSenseID == 'none' ) |
21 | 21 | return $bar; |
22 | 22 | |
| 23 | + if( $wgUser->isLoggedIn() && $wgGoogleAdSenseAnonOnly ) { |
| 24 | + return $bar; |
| 25 | + } |
| 26 | + |
23 | 27 | wfLoadExtensionMessages( 'GoogleAdSense' ); |
24 | 28 | |
25 | 29 | $bar['googleadsense'] = "<script type=\"text/javascript\"> |
— | — | @@ -36,4 +40,24 @@ |
37 | 41 | |
38 | 42 | return true; |
39 | 43 | } |
| 44 | + |
| 45 | +/* Not working yet. Need to find out why... |
| 46 | + static function injectCSS( $out ) { |
| 47 | + |
| 48 | + global $wgUser, $wgGoogleAdSenseAnonOnly, $wgGoogleAdSenseCssLocation; |
| 49 | + |
| 50 | + if( $wgUser->isLoggedIn() && $wgGoogleAdSenseAnonOnly ) { |
| 51 | + return true; |
| 52 | + } |
| 53 | + |
| 54 | + $out->addLink( |
| 55 | + array( |
| 56 | + 'rel' => 'stylesheet', |
| 57 | + 'type' => 'text/css', |
| 58 | + 'href' => $wgGoogleAdSenseCssLocation . '/GoogleAdSense.css', |
| 59 | + ) |
| 60 | + ); |
| 61 | + return true; |
| 62 | + } |
| 63 | +*/ |
40 | 64 | } |