r43988 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43987‎ | r43988 | r43989 >
Date:01:13, 27 November 2008
Author:siebrand
Status:ok
Tags:
Comment:
* add option to only show the ads to anonymous users
* (commented out because it needs fixing) add hook to inject CSS, instead if having to add it to common.css
Modified paths:
  • /trunk/extensions/GoogleAdSense/GoogleAdSense.class.php (modified) (history)
  • /trunk/extensions/GoogleAdSense/GoogleAdSense.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GoogleAdSense/GoogleAdSense.php
@@ -33,6 +33,8 @@
3434 $wgGoogleAdSenseWidth = 120; // Width of the AdSense box, specified in your AdSense account
3535 $wgGoogleAdSenseHeight = 240; // Width of the AdSense box, specified in your AdSense account
3636 $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
3739
3840 /**
3941 * The following variables must be set in your LocalSettings.php.
@@ -58,3 +60,6 @@
5961
6062 // Hook to modify the sidebar
6163 $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 @@
99 * @license MIT
1010 */
1111 class GoogleAdSense {
12 -
1312 static function GoogleAdSenseInSidebar( $skin, &$bar ) {
1413 global $wgGoogleAdSenseWidth, $wgGoogleAdSenseID,
1514 $wgGoogleAdSenseHeight, $wgGoogleAdSenseClient,
16 - $wgGoogleAdSenseSlot, $wgGoogleAdSenseSrc;
 15+ $wgGoogleAdSenseSlot, $wgGoogleAdSenseSrc,
 16+ $wgGoogleAdSenseAnonOnly, $wgUser;
1717
1818 // Return $bar unchanged if not all values have been set.
1919 // FIXME: signal incorrect configuration nicely?
2020 if( $wgGoogleAdSenseClient == 'none' || $wgGoogleAdSenseSlot == 'none' || $wgGoogleAdSenseID == 'none' )
2121 return $bar;
2222
 23+ if( $wgUser->isLoggedIn() && $wgGoogleAdSenseAnonOnly ) {
 24+ return $bar;
 25+ }
 26+
2327 wfLoadExtensionMessages( 'GoogleAdSense' );
2428
2529 $bar['googleadsense'] = "<script type=\"text/javascript\">
@@ -36,4 +40,24 @@
3741
3842 return true;
3943 }
 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+*/
4064 }

Status & tagging log