Lewis Cawte has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/152044

Change subject: Push latest copy from ShoutWiki SVN with various updates and 
changes.
......................................................................

Push latest copy from ShoutWiki SVN with various updates and changes.

Change-Id: Ib556e644a33ce643f39dcf689d963157a3a9e126
---
M ShoutWikiAds.class.php
M ShoutWikiAds.php
A css/aurora-leaderboard-ad.css
A css/aurora-skyscraper-ad.css
A css/cologneblue-leaderboard-ad.css
A css/home-leaderboard-bottom-ad.css
A css/home-skyscraper-ad.css
A css/modern-button-ad.css
A css/modern-leaderboard-ad.css
M css/monobook-button-ad.css
M css/monobook-skyscraper-ad.css
A css/quartz-square-ad.css
D css/truglass-ads.css
A css/truglass-leaderboard-ad.css
A css/vector-button-ad.css
A css/vector-skyscraper-ad.css
16 files changed, 580 insertions(+), 104 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ShoutWikiAds 
refs/changes/44/152044/1

diff --git a/ShoutWikiAds.class.php b/ShoutWikiAds.class.php
index aac4ae9..e2ccb33 100644
--- a/ShoutWikiAds.class.php
+++ b/ShoutWikiAds.class.php
@@ -2,6 +2,7 @@
 /**
  * ShoutWikiAds class -- contains the hooked functions and some other crap for
  * displaying the advertisements.
+ *
  * Route all requests through loadAd( $type ) to ensure correct processing.
  *
  * We allow wiki admins to configure some things because our "sane defaults"
@@ -20,9 +21,10 @@
        /**
         * Can we show ads on the current page?
         *
-        * @return bool False if ads aren't enabled or the current page is
-        *   Special:UserLogin (login page) or if the user is autoconfirmed and 
the
-        *   forceads parameter is NOT in the URL, otherwise true.
+        * @return Boolean: false if ads aren't enabled or the current page is
+        *                  Special:UserLogin (login page) or if the user is
+        *                  autoconfirmed and the forceads parameter is NOT in 
the
+        *                  URL, otherwise true
         */
        public static function canShowAds() {
                global $wgAdConfig, $wgTitle, $wgUser, $wgRequest;
@@ -31,9 +33,8 @@
                        return false;
                }
 
-               list( $alias, /*..*/ ) = SpecialPageFactory::resolveAlias( 
$wgTitle->getDBkey() );
                if( $wgTitle instanceof Title &&
-                               $alias === 'Userlogin' ||
+                               $wgTitle->isSpecial( 'Userlogin' ) ||
                        in_array( 'staff', $wgUser->getEffectiveGroups() ) && 
!$wgRequest->getVal( 'forceads' )
                )
                {
@@ -41,7 +42,7 @@
                }
 
                // No configuration for this skin? Bail out!
-               if ( !$wgAdConfig[self::determineSkin()] ) {
+               if ( !isset( $wgAdConfig[self::determineSkin()] ) ) {
                        return false;
                }
 
@@ -92,13 +93,80 @@
         * @return Boolean: true if the namespace is supported, otherwise false
         */
        public static function isEnabledNamespace() {
-               global $wgAdConfig, $wgTitle;
-               $namespace = $wgTitle->getNamespace();
+               global $wgAdConfig;
+               $title = RequestContext::getMain()->getTitle(); // @todo FIXME 
filthy hack
+               $namespace = $title->getNamespace();
                if( in_array( $namespace, $wgAdConfig['namespaces'] ) ) {
                        return true;
                } else {
                        return false;
                }
+       }
+
+       /**
+        * Skin-agnostic way of getting the HTML for a Google AdSense banner ad.
+        *
+        * @return String: HTML code
+        */
+       public static function getBannerHTML() {
+               global $wgAdConfig;
+
+               $skinName = self::determineSkin();
+
+               $adSlot = '';
+               if ( isset( $wgAdConfig[$skinName . '-banner-ad-slot'] ) ) {
+                       $adSlot = $wgAdConfig[$skinName . '-banner-ad-slot'];
+               }
+
+               $borderColorMsg = wfMessage( 'shoutwiki-' . $skinName . 
'-banner-ad-color-border' )->inContentLanguage();
+               $colorBGMsg = wfMessage( 'shoutwiki-' . $skinName . 
'-banner-ad-color-bg' )->inContentLanguage();
+               $colorLinkMsg = wfMessage( 'shoutwiki-' . $skinName . 
'-banner-ad-color-link' )->inContentLanguage();
+               $colorTextMsg = wfMessage( 'shoutwiki-' . $skinName . 
'-banner-ad-color-text' )->inContentLanguage();
+               $colorURLMsg = wfMessage( 'shoutwiki-' . $skinName . 
'-banner-ad-color-url' )->inContentLanguage();
+
+               $colorBorderDefault = 'F6F4C4';
+               $colorBGDefault = 'FFFFE0';
+               $colorLinkDefault = '000000';
+               $colorURLDefault = '002BB8';
+
+               // different defaults for Truglass from old Truglass ad code
+               if ( $skinName == 'truglass' ) {
+                       $colorBorderDefault = 'CDCDCD';
+                       $colorBGDefault = 'FFFFFF';
+                       $colorLinkDefault = '0066FF';
+                       $colorURLDefault = '00A000';
+               }
+
+               if ( $wgAdConfig['debug'] === true ) {
+                       return '<!-- Begin banner ad (ShoutWikiAds) -->
+               <div id="' . $skinName . '-banner-ad" class="' . $skinName . 
'-ad noprint">
+                       <img 
src="http://www.google.com/help/hc/images/adsense/adsense_185665_adformat-text_468x60_en.png";
 alt="" />
+               </div>
+<!-- End banner ad (ShoutWikiAds) -->' . "\n";
+               }
+
+               return '<!-- Begin banner ad (ShoutWikiAds) -->
+               <div id="' . $skinName . '-banner-ad" class="' . $skinName . 
'-ad noprint">
+<script type="text/javascript"><!--
+google_ad_client = "pub-' . $wgAdConfig['adsense-client'] . '";
+google_ad_slot = "' . $adSlot . '";
+google_ad_width = 468;
+google_ad_height = 60;
+google_ad_format = "468x60_as";
+//google_ad_type = "";
+google_ad_channel = "";
+google_color_border = "' . ( $borderColorMsg->isDisabled() ? 
$colorBorderDefault : $borderColorMsg->text() ) . '";
+google_color_bg = "' . ( $colorBGMsg->isDisabled() ? $colorBGDefault : 
$colorBGMsg->text() ) . '";
+google_color_link = "' . ( $colorLinkMsg->isDisabled() ? $colorLinkDefault : 
$colorLinkMsg->text() ) . '";
+google_color_text = "' . ( $colorTextMsg->isDisabled() ? '000000' : 
$colorTextMsg->text() ) . '";
+google_color_url = "' . ( $colorURLMsg->isDisabled() ? $colorURLDefault : 
$colorURLMsg->text() ) . '";
+//--></script>
+<script type="text/javascript"
+  src="http://pagead2.googlesyndication.com/pagead/show_ads.js";>
+</script>
+
+</div>
+<!-- End banner ad (ShoutWikiAds) -->' . "\n";
        }
 
        /**
@@ -172,6 +240,64 @@
 
 </div>
 <!-- End sidebar ad (ShoutWikiAds) -->' . "\n";
+       }
+
+       /**
+        * Skin-agnostic way of getting the HTML for a Google AdSense square ad.
+        *
+        * @return String: HTML code
+        */
+       public static function getSquareHTML() {
+               global $wgAdConfig;
+
+               $skinName = self::determineSkin();
+
+               $adSlot = '';
+               if ( isset( $wgAdConfig[$skinName . '-square-ad-slot'] ) ) {
+                       $adSlot = $wgAdConfig[$skinName . '-square-ad-slot'];
+               }
+
+               $borderColorMsg = wfMessage( 'shoutwiki-' . $skinName . 
'-square-ad-color-border' )->inContentLanguage();
+               $colorBGMsg = wfMessage( 'shoutwiki-' . $skinName . 
'-square-ad-color-bg' )->inContentLanguage();
+               $colorLinkMsg = wfMessage( 'shoutwiki-' . $skinName . 
'-square-ad-color-link' )->inContentLanguage();
+               $colorTextMsg = wfMessage( 'shoutwiki-' . $skinName . 
'-square-ad-color-text' )->inContentLanguage();
+               $colorURLMsg = wfMessage( 'shoutwiki-' . $skinName . 
'-square-ad-color-url' )->inContentLanguage();
+
+               $colorBorderDefault = 'F6F4C4';
+               $colorBGDefault = 'FFFFE0';
+               $colorLinkDefault = '000000';
+               $colorURLDefault = '002BB8';
+
+               if ( $wgAdConfig['debug'] === true ) {
+                       return '<!-- Begin square ad (ShoutWikiAds) -->
+               <div id="' . $skinName . '-square-ad" class="' . $skinName . 
'-ad noprint">
+                       <img 
src="https://storage.googleapis.com/support-kms-prod/SNP_2922347_en_v0"; alt="" 
/>
+               </div>
+<!-- End banner ad (ShoutWikiAds) -->' . "\n";
+               }
+
+               return '<!-- Begin square ad (ShoutWikiAds) -->
+               <div id="' . $skinName . '-square-ad" class="' . $skinName . 
'-ad noprint">
+<script type="text/javascript"><!--
+google_ad_client = "pub-' . $wgAdConfig['adsense-client'] . '";
+google_ad_slot = "' . $adSlot . '";
+google_ad_width = 250;
+google_ad_height = 250;
+google_ad_format = "250x250_as";
+//google_ad_type = "";
+google_ad_channel = "";
+google_color_border = "' . ( $borderColorMsg->isDisabled() ? 
$colorBorderDefault : $borderColorMsg->text() ) . '";
+google_color_bg = "' . ( $colorBGMsg->isDisabled() ? $colorBGDefault : 
$colorBGMsg->text() ) . '";
+google_color_link = "' . ( $colorLinkMsg->isDisabled() ? $colorLinkDefault : 
$colorLinkMsg->text() ) . '";
+google_color_text = "' . ( $colorTextMsg->isDisabled() ? '000000' : 
$colorTextMsg->text() ) . '";
+google_color_url = "' . ( $colorURLMsg->isDisabled() ? $colorURLDefault : 
$colorURLMsg->text() ) . '";
+//--></script>
+<script type="text/javascript"
+  src="http://pagead2.googlesyndication.com/pagead/show_ads.js";>
+</script>
+
+</div>
+<!-- End banner ad (ShoutWikiAds) -->' . "\n";
        }
 
        /**
@@ -413,21 +539,21 @@
         * This just adds the relevant ad CSS file under certain conditions.
         * The actual logic is elsewhere.
         *
-        * @param OutputPage $out
-        * @param Skin $sk
-        * @return bool
+        * @param $out OutputPage
+        * @param $sk Skin or one of its child classes
+        * @return Boolean: true
         */
        public static function setupAdCSS( &$out, &$sk ) {
-               global $wgAdConfig, $wgRequest, $wgUser;
+               global $wgAdConfig, $wgResourceModules, $wgRequest, $wgUser;
 
-               if( !$wgAdConfig['enabled'] ) {
+               if ( !$wgAdConfig['enabled'] ) {
                        return true;
                }
 
                // In order for us to load ad-related CSS, the user must either 
be
                // a mortal (=not staff) or have supplied the forceads 
parameter in
                // the URL
-               if(
+               if (
                        !in_array( 'staff', $wgUser->getEffectiveGroups() ) ||
                        $wgRequest->getVal( 'forceads' )
                )
@@ -436,48 +562,47 @@
                        $namespace = $title->getNamespace();
 
                        // Okay, the variable name sucks but anyway...normal 
page != not login page
-                       list( $alias, /*..*/ )  = 
SpecialPageFactory::resolveAlias( $title->getDBkey() );
                        $isNormalPage = $title instanceof Title &&
-                               $alias !== 'Userlogin';
+                               !$title->isSpecial( 'Userlogin' );
 
                        // Load ad CSS file when ads are enabled
-                       if(
+                       if (
                                $isNormalPage &&
                                in_array( $namespace, $wgAdConfig['namespaces'] 
)
                        )
                        {
-                               if ( get_class( $sk ) == 'SkinMonaco' ) { // 
Monaco
-                                       $out->addModuleStyles( 
'ext.ShoutWikiAds.monaco' );
-                               } elseif( get_class( $sk ) == 'SkinMonoBook' ) 
{ // Monobook
-                                       if ( 
$wgAdConfig['monobook']['skyscraper'] ) {
-                                               $out->addModuleStyles( 
'ext.ShoutWikiAds.monobook.skyscraper' );
+                               $skinClass = str_replace( 'Skin', '', 
get_class( $sk ) );
+                               $skinClass = strtolower( $skinClass );
+
+                               if ( isset( $wgAdConfig[$skinClass] ) ) {
+                                       $modules = array();
+
+                                       // Iterate over the enabled
+                                       foreach ( $wgAdConfig[$skinClass] as 
$enabledAdType => $unused ) {
+                                               $moduleName = 
"ext.ShoutWikiAds.{$skinClass}.{$enabledAdType}";
+
+                                               // Aurora's sitenotice 
leaderboard doesn't need any additional CSS
+                                               if ( $skinClass == 'aurora' && 
$enabledAdType == 'leaderboard-bottom' ) {
+                                                       continue;
+                                               }
+
+                                               if ( $skinClass == 'monaco' ) {
+                                                       $moduleName = 
"ext.ShoutWikiAds.{$skinClass}";
+                                               }
+
+                                               if ( $enabledAdType == 
'toolbox' ) {
+                                                       $moduleName = 
str_replace( 'toolbox', 'button', $moduleName );
+                                               }
+
+                                               // Sanity check -- is there 
such a module?
+                                               if ( isset( 
$wgResourceModules[$moduleName] ) ) {
+                                                       $modules[] = 
$moduleName;
+                                               }
                                        }
-                                       if ( $wgAdConfig['monobook']['toolbox'] 
) {
-                                               $out->addModuleStyles( 
'ext.ShoutWikiAds.monobook.button' );
+
+                                       if ( !empty( $modules ) ) {
+                                               $out->addModuleStyles( $modules 
);
                                        }
-                               } elseif ( get_class( $sk ) == 'SkinVector' ) { 
// Vector
-                                       if ( 
$wgAdConfig['vector']['skyscraper'] ) {
-                                               $out->addModuleStyles( 
'ext.ShoutWikiAds.vector.skyscraper' );
-                                       }
-                                       if ( $wgAdConfig['vector']['toolbox'] ) 
{
-                                               $out->addModuleStyles( 
'ext.ShoutWikiAds.vector.button' );
-                                       }
-                               } elseif ( get_class( $sk ) == 'SkinModern' ) { 
// Modern
-                                       if ( 
$wgAdConfig['modern']['leaderboard'] ) {
-                                               $out->addModuleStyles( 
'ext.ShoutWikiAds.modern.leaderboard' );
-                                       }
-                                       // No, the "monobook" here isn't a 
typo. SkinModern extends
-                                       // Monobook's base class so there's no 
specific toggle to
-                                       // turn off the button ads for Modern...
-                                       if ( $wgAdConfig['monobook']['toolbox'] 
) {
-                                               $out->addModuleStyles( 
'ext.ShoutWikiAds.modern.button' );
-                                       }
-                               } elseif ( get_class( $sk ) == 
'SkinCologneBlue' ) { // Cologne Blue
-                                       if ( 
$wgAdConfig['cologneblue']['leaderboard'] ) {
-                                               $out->addModuleStyles( 
'ext.ShoutWikiAds.cologneblue.leaderboard' );
-                                       }
-                               } elseif ( get_class( $sk ) == 'SkinTruglass' ) 
{ // Truglass
-                                       $out->addModuleStyles( 
'ext.ShoutWikiAds.truglass' );
                                }
                        }
                }
@@ -486,14 +611,25 @@
        }
 
        /**
-        * Load toolbox ad for Monobook skin.
+        * Load toolbox ad for Monobook *and* Modern skins.
         * @return Boolean: true
         */
        public static function onMonoBookAfterToolbox() {
                global $wgAdConfig;
-               if ( $wgAdConfig['monobook']['toolbox'] ) {
+
+               // Modern extends Monobook's base class, and therefore this is 
needed
+               // so that we can, for example, have the toolbox button ad 
*enabled*
+               // for Monobook and disabled for Modern. :-(
+               $skin = self::determineSkin();
+
+               if (
+                       isset( $wgAdConfig[$skin]['toolbox'] ) &&
+                       $wgAdConfig[$skin]['toolbox']
+               )
+               {
                        echo self::loadAd( 'toolbox-button' );
                }
+
                return true;
        }
 
@@ -560,6 +696,82 @@
        }
 
        /**
+        * Load a skyscraper ad in Aurora's left-hand sidebar, below the "page 
history"
+        * link.
+        *
+        * @param $auroraTemplate AuroraTemplate
+        * @return Boolean: true
+        */
+       public static function onAuroraLeftSidebar( $auroraTemplate ) {
+               global $wgAdConfig;
+               if ( isset( $wgAdConfig['aurora']['skyscraper'] ) && 
$wgAdConfig['aurora']['skyscraper'] ) {
+                       // Only show this ad on existing pages as it'd strech 
nonexistent ones
+                       // quite a bit
+                       if ( $auroraTemplate->getSkin()->getTitle()->exists() ) 
{
+                               // My naming conventions suck, I know.
+                               echo self::loadAd( 'right-column' );
+                       }
+               }
+               return true;
+       }
+
+       /**
+        * Load a leaderboard ad in Aurora's footer.
+        *
+        * @param $data String
+        * @param $skin Skin
+        * @return Boolean: true
+        */
+       public static function onSkinAfterContent( &$data, Skin $skin ) {
+               global $wgAdConfig;
+
+               if (
+                       get_class( $skin ) == 'SkinAurora' &&
+                       isset( $wgAdConfig['aurora']['leaderboard-bottom'] ) &&
+                       $wgAdConfig['aurora']['leaderboard-bottom']
+               )
+               {
+                       $adHTML = self::loadAd( 'leaderboard' );
+                       $data = str_replace(
+                               // Quick HTML validation fix
+                               '<div id="aurora-leaderboard-ad"',
+                               '<div id="aurora-leaderboard-ad-2"',
+                               $adHTML
+                       );
+               }
+
+               if (
+                       get_class( $skin ) == 'SkinHome' &&
+                       isset( $wgAdConfig['home']['leaderboard-bottom'] ) &&
+                       $wgAdConfig['home']['leaderboard-bottom']
+               )
+               {
+                       $data = self::loadAd( 'leaderboard' );
+               }
+
+               return true;
+       }
+
+       /**
+        * Load a small button ad in Dusk's toolbox (well, this code runs in the
+        * toolbox() function, but after the #p-tb div has been closed).
+        *
+        * @param $dusk DuskTemplate
+        * @return Boolean: true
+        */
+       public static function onDuskAfterToolbox( $dusk ) {
+               global $wgAdConfig;
+               if (
+                       isset( $wgAdConfig['dusk']['toolbox'] ) &&
+                       $wgAdConfig['dusk']['toolbox']
+               )
+               {
+                       echo self::loadAd( 'toolbox-button' );
+               }
+               return true;
+       }
+
+       /**
         * Load a skyscraper ad in Games skin's "sidebox" (the left-hand box 
which
         * contains social sharing links, recent editors, interlanguage links, 
etc.
         * Look for "$wantSideBox" in /skins/Games/Games.skin.php).
@@ -576,12 +788,44 @@
                        if ( empty( $skyscraperHTML ) ) {
                                return true;
                        }
-                       $leaderboardHTML = str_replace(
+                       $skyscraperHTML = str_replace(
                                '<div id="column-google"',
                                '<div id="sideads"',
-                               $leaderboardHTML
+                               $skyscraperHTML
                        );
                        echo $skyscraperHTML;
+               }
+               return true;
+       }
+
+       /**
+        * Skyscraper ads -- two of 'em -- for the Home skin.
+        *
+        * @param $homeTemplate HomeTemplate
+        * @return bool
+        */
+       public static function onHomeAfterEverything( $homeTemplate ) {
+               global $wgAdConfig;
+               if (
+                       isset( $wgAdConfig['home']['skyscraper'] ) &&
+                       $wgAdConfig['home']['skyscraper']
+               )
+               {
+                       $adHTML = self::loadAd( 'skyscraper' );
+                       if ( $adHTML ) {
+                               // Remove the IDs altogether
+                               $adHTML = str_replace(
+                                       'id="column-google"',
+                                       '',
+                                       $adHTML
+                               );
+                               // And instead hackily inject the appropriate 
classes
+                               $adLeft = str_replace( 'class="', 
'class="column-google-left ', $adHTML );
+                               $adRight = str_replace( 'class="', 
'class="column-google-right ', $adHTML );
+                               $output = $adLeft . $adRight;
+                               // Finally display 'em, too!
+                               echo $output;
+                       }
                }
                return true;
        }
@@ -603,6 +847,48 @@
        }
 
        /**
+        * Load a square ad on the Quartz skin, in the sidebar.
+        *
+        * @param QuartzTemplate $quartz
+        * @param string $adBody
+        * @return Boolean: true
+        */
+       public static function onQuartzSidebarWidgets( $quartz, &$adBody ) {
+               global $wgAdConfig;
+               if (
+                       isset( $wgAdConfig['quartz']['square'] ) &&
+                       $wgAdConfig['quartz']['square']
+               )
+               {
+                       $adBody = self::loadAd( 'square' );
+               }
+               return true;
+       }
+
+       /**
+        * Load a square ad on the Quartz skin, in the sidebar.
+        *
+        * @param QuartzTemplate $quartz
+        * @param string $adBody
+        * @return Boolean: true
+        */
+       public static function onQuartzSidebarWidgetAdvertiser( $quartz, 
&$adBody ) {
+               global $wgAdConfig;
+               if (
+                       isset( $wgAdConfig['quartz']['square'] ) &&
+                       $wgAdConfig['quartz']['square']
+               )
+               {
+                       $adBody = str_replace(
+                               'id="quartz-square-ad',
+                               'id="quartz-square-ad-2',
+                               self::loadAd( 'square' )
+                       );
+               }
+               return true;
+       }
+
+       /**
         * Called *only* by Truglass skin.
         *
         * @return Boolean: true
@@ -610,7 +896,11 @@
        public static function renderTruglassAd() {
                global $wgAdConfig;
 
-               if ( $wgAdConfig['truglass']['leaderboard'] ) {
+               if (
+                       isset( $wgAdConfig['truglass']['leaderboard'] ) &&
+                       $wgAdConfig['truglass']['leaderboard']
+               )
+               {
                        // Use the universal loader method so that ads aren't 
shown to
                        // privileged users or on login pages, etc.
                        $leaderboardHTML = self::loadAd( 'leaderboard' );
@@ -622,21 +912,13 @@
                                return true;
                        }
 
-                       // Hack to replace the ad div ID with the "correct" one 
because
-                       // I'm too lazy to edit Truglass' CSS file(s)
-                       $leaderboardHTML = str_replace(
-                               '<div id="truglass-leaderboard-ad"',
-                               '<div id="topadsleft"',
-                               $leaderboardHTML
-                       );
-
                        echo '<!-- Begin Truglass ad (ShoutWikiAds) -->
-                       <table border="0" cellpadding="0" cellspacing="0" 
width="100%">
+                       <table class="fullwidth truglass-ad-container">
                                <tbody>
                                        <tr>
-                                               <td valign="top" 
id="contentBox">
+                                               <td id="contentBox">
                                                        <div id="contentCont">
-                                                               <table 
id="topsector" width="100%">
+                                                               <table 
id="topsector" class="fullwidth">
                                                                        <tr>
                                                                                
<td>' . $leaderboardHTML . '</td>
                                                                        </tr>
@@ -653,7 +935,8 @@
        }
 
        /**
-        * Render a leaderboard ad in the site notice area for certain skins.
+        * Render a leaderboard ad in the site notice area for certain skins 
(or a
+        * banner ad for Dusk).
         *
         * @param $siteNotice String: existing site notice HTML (etc.), if any
         * @return Boolean: true
@@ -663,7 +946,10 @@
 
                $skinName = self::determineSkin();
 
-               $allowedSkins = array( 'cologneblue', 'modern', 'monobook', 
'nimbus', 'vector' );
+               $allowedSkins = array(
+                       'aurora', 'cologneblue', 'modern', 'monobook', 
'nimbus', 'quartz',
+                       'vector'
+               );
                // Monaco and Truglass have a different leaderboard ad 
implementation
                // and AdSense's terms of use state that one page may have up 
to three
                // ads
@@ -674,6 +960,13 @@
                )
                {
                        $siteNotice .= self::loadAd( 'leaderboard' );
+               } elseif ( // Dusk is a special case, as it's so damn small 
that it can't fit a normal leaderboard
+                       $skinName == 'dusk' &&
+                       isset( $wgAdConfig[$skinName]['banner'] ) &&
+                       $wgAdConfig[$skinName]['banner'] === true
+               )
+               {
+                       $siteNotice .= self::loadAd( 'banner' );
                }
 
                return true;
@@ -685,9 +978,13 @@
         * @return String: skin name in lowercase
         */
        public static function determineSkin() {
-               global $wgOut;
+               global $wgUser;
 
-               return strtolower( $wgOut->getSkin()->getSkinName() );
+               $skinObj = $wgUser->getSkin();
+
+               $skinName = strtolower( str_replace( 'Skin', '', get_class( 
$skinObj ) ) );
+
+               return $skinName;
        }
 
        /**
@@ -695,9 +992,7 @@
         * Ad code (div element + JS) is echoed back and no value is returned
         * except in special cases we return true (early return 
cases/unrecognized slot)
         *
-        * @param $type String: what kind of ads to load? Valid values are:
-        *                      'leaderboard', 'sidebar', 'toolbox-button' and
-        *                      'right-column' (=skyscraper) so far
+        * @param $type String: what kind of ads to load?
         * @return String: HTML to output (if any)
         */
        public static function loadAd( $type ) {
@@ -707,30 +1002,39 @@
                // ** if the wiki's language code isn't supported by Google 
AdSense
                // ** if ads aren't enabled for the current namespace
                if ( !self::canShowAds() ) {
+                       wfDebugLog( 'ShoutWikiAds', 'Early return case #1: 
can\'t show ads' );
                        return '';
                }
 
                if ( !self::isSupportedLanguage() ) {
+                       wfDebugLog( 'ShoutWikiAds', 'Early return case #2: 
language code is not suppored by AdSense' );
                        return '';
                }
 
                if ( !self::isEnabledNamespace() ) {
+                       wfDebugLog( 'ShoutWikiAds', 'Early return case #3: ads 
not enabled for this namespace' );
                        return '';
                }
 
                // Main ad logic starts here
-               if( $type === 'leaderboard' ) {
-                       return self::getLeaderboardHTML();
-               } elseif( $type === 'sidebar' ) {
-                       return self::getSidebarHTML();
-               } elseif ( $type === 'toolbox-button' ) {
-                       return self::getToolboxHTML();
-               } elseif ( $type === 'right-column' ) {
-                       return self::getSkyscraperHTML();
-               } elseif ( $type === 'small-square' ) {
-                       return self::getSmallSquareHTML();
-               } else { // invalid type/these ads not enabled in $wgAdConfig
-                       return '';
+               switch ( $type ) {
+                       case 'banner':
+                               return self::getBannerHTML();
+                       case 'leaderboard':
+                               return self::getLeaderboardHTML();
+                       case 'sidebar':
+                               return self::getSidebarHTML();
+                       case 'toolbox-button':
+                               return self::getToolboxHTML();
+                       case 'right-column': // old and ugly name
+                       case 'skyscraper': // standard name used by AdSense 
documentation, etc.
+                               return self::getSkyscraperHTML();
+                       case 'small-square':
+                               return self::getSmallSquareHTML();
+                       case 'square':
+                               return self::getSquareHTML();
+                       default: // invalid type/these ads not enabled in 
$wgAdConfig
+                               return '';
                }
        }
 
diff --git a/ShoutWikiAds.php b/ShoutWikiAds.php
index ecf1b05..a9742a9 100644
--- a/ShoutWikiAds.php
+++ b/ShoutWikiAds.php
@@ -4,11 +4,11 @@
  *
  * @file
  * @ingroup Extensions
- * @version 0.3.3
- * @date 3 July 2013
+ * @version 0.3.7
+ * @date 20 January 2014
  * @author Jack Phoenix <j...@countervandalism.net>
  * @license http://en.wikipedia.org/wiki/Public_domain Public domain
- * @link http://www.mediawiki.org/wiki/Extension:ShoutWiki_Ads Documentation
+ * @link https://www.mediawiki.org/wiki/Extension:ShoutWiki_Ads Documentation
  */
 
 if ( !defined( 'MEDIAWIKI' ) ) {
@@ -18,7 +18,7 @@
 // Extension credits that will show up on Special:Version
 $wgExtensionCredits['other'][] = array(
        'name' => 'ShoutWiki Ads',
-       'version' => '0.3.3',
+       'version' => '0.3.7',
        'author' => 'Jack Phoenix',
        'description' => 'Delicious advertisements for everyone!',
        'url' => 'https://www.mediawiki.org/wiki/Extension:ShoutWiki_Ads',
@@ -27,9 +27,22 @@
 // Autoload the class so that we can actually use its functions
 $wgAutoloadClasses['ShoutWikiAds'] = dirname( __FILE__ ) . 
'/ShoutWikiAds.class.php';
 
+// CSS module loading for virtually all skins supported by this extension
+$wgHooks['BeforePageDisplay'][] = 'ShoutWikiAds::setupAdCSS';
+
+// Aurora
+$wgHooks['AuroraLeftSidebar'][] = 'ShoutWikiAds::onAuroraLeftSidebar';
+$wgHooks['SkinAfterContent'][] = 'ShoutWikiAds::onSkinAfterContent';
+
 // BlueCloud was designed by StrategyWiki with ads in mind, so removing them
 // from it will mess up the display, which is exactly why we don't handle
 // BlueCloud ads here
+
+// Dusk
+$wgHooks['DuskAfterToolbox'][] = 'ShoutWikiAds::onDuskAfterToolbox';
+
+// Home
+$wgHooks['HomeAfterEverything'][] = 'ShoutWikiAds::onHomeAfterEverything';
 
 // Games
 $wgHooks['GamesSideBox'][] = 'ShoutWikiAds::onGamesSideBox';
@@ -40,12 +53,15 @@
 $wgHooks['MonacoFooter'][] = 'ShoutWikiAds::onMonacoFooter';
 
 // MonoBook
-$wgHooks['BeforePageDisplay'][] = 'ShoutWikiAds::setupAdCSS';
 $wgHooks['MonoBookAfterContent'][] = 'ShoutWikiAds::onMonoBookAfterContent';
 $wgHooks['MonoBookAfterToolbox'][] = 'ShoutWikiAds::onMonoBookAfterToolbox';
 
 // Nimbus
 $wgHooks['NimbusLeftSide'][] = 'ShoutWikiAds::onNimbusLeftSide';
+
+// Quartz
+$wgHooks['QuartzSidebarWidgets'][] = 'ShoutWikiAds::onQuartzSidebarWidgets';
+$wgHooks['QuartzSidebarWidgetAdvertiser'][] = 
'ShoutWikiAds::onQuartzSidebarWidgetAdvertiser';
 
 // Truglass
 $wgHooks['TruglassInContent'][] = 'ShoutWikiAds::renderTruglassAd';
@@ -54,7 +70,7 @@
 $wgHooks['VectorAfterToolbox'][] = 'ShoutWikiAds::onVectorAfterToolbox';
 $wgHooks['VectorBeforeFooter'][] = 'ShoutWikiAds::onVectorBeforeFooter';
 
-// Generic (Cologne Blue, Modern, Monobook, Nimbus & Vector) leaderboard ad
+// Generic leaderboard ad for most core skins and some custom skins
 $wgHooks['SiteNoticeAfter'][] = 'ShoutWikiAds::onSiteNoticeAfter';
 
 // ResourceLoader support for MediaWiki 1.17+
@@ -63,8 +79,24 @@
        'remoteExtPath' => 'ShoutWikiAds'
 );
 
+$wgResourceModules['ext.ShoutWikiAds.aurora.leaderboard'] = $resourceTemplate 
+ array(
+       'styles' => 'css/aurora-leaderboard-ad.css'
+);
+
+$wgResourceModules['ext.ShoutWikiAds.aurora.skyscraper'] = $resourceTemplate + 
array(
+       'styles' => 'css/aurora-skyscraper-ad.css'
+);
+
 $wgResourceModules['ext.ShoutWikiAds.cologneblue.leaderboard'] = 
$resourceTemplate + array(
        'styles' => 'css/cologneblue-leaderboard-ad.css'
+);
+
+$wgResourceModules['ext.ShoutWikiAds.home.leaderboard-bottom'] = 
$resourceTemplate + array(
+       'styles' => 'css/home-leaderboard-bottom-ad.css'
+);
+
+$wgResourceModules['ext.ShoutWikiAds.home.skyscraper'] = $resourceTemplate + 
array(
+       'styles' => 'css/home-skyscraper-ad.css'
 );
 
 $wgResourceModules['ext.ShoutWikiAds.modern.button'] = $resourceTemplate + 
array(
@@ -87,6 +119,10 @@
        'styles' => 'css/monobook-skyscraper-ad.css'
 );
 
+$wgResourceModules['ext.ShoutWikiAds.quartz.square'] = $resourceTemplate + 
array(
+       'styles' => 'css/quartz-square-ad.css'
+);
+
 $wgResourceModules['ext.ShoutWikiAds.vector.button'] = $resourceTemplate + 
array(
        'styles' => 'css/vector-button-ad.css'
 );
@@ -95,8 +131,8 @@
        'styles' => 'css/vector-skyscraper-ad.css'
 );
 
-$wgResourceModules['ext.ShoutWikiAds.truglass'] = $resourceTemplate + array(
-       'styles' => 'css/truglass-ads.css'
+$wgResourceModules['ext.ShoutWikiAds.truglass.leaderboard'] = 
$resourceTemplate + array(
+       'styles' => 'css/truglass-leaderboard-ad.css'
 );
 
 /* Configuration
@@ -121,9 +157,18 @@
        'truglass-leaderboard-ad-slot' => '', [Tabor]
 
        // Skin-specific ad configuration
+       'aurora' => array(
+               'leaderboard' => true, // leaderboard ad in the site notice area
+               'leaderboard-bottom' => true, // leaderboard ad after 
categories, in the bottom of the page
+               'skyscraper' => true, // skyscraper ad in the left column, 
below "Page history" on longer pages
+       ),
        'cologneblue' => array(
                'leaderboard' => true, // leaderboard ad in the site notice area
        ),
+       'dusk' => array(
+               'banner' => true, // banner in the site notice area
+               'toolbox' => true, // small 125x125px ad below the toolbox in 
the right-hand sidebar
+       ),
        'modern' => array(
                'leaderboard' => true, // leaderboard ad in the site notice area
        ),
diff --git a/css/aurora-leaderboard-ad.css b/css/aurora-leaderboard-ad.css
new file mode 100644
index 0000000..f5534fc
--- /dev/null
+++ b/css/aurora-leaderboard-ad.css
@@ -0,0 +1,5 @@
+/** Leaderboard ad styling for the Aurora skin */
+#aurora-leaderboard-ad-2 {
+       margin: 5px;
+       text-align: center;
+}
\ No newline at end of file
diff --git a/css/aurora-skyscraper-ad.css b/css/aurora-skyscraper-ad.css
new file mode 100644
index 0000000..a7f9cde
--- /dev/null
+++ b/css/aurora-skyscraper-ad.css
@@ -0,0 +1,14 @@
+/** Skyscraper ad styling for the Aurora skin */
+#column-google {
+       height: 600px;
+       margin-bottom: 10px;
+       margin-left: -15px;
+       margin-right: 10px;
+       margin-top: 10px;
+       width: 120px;
+}
+
+/* Need to stretch the content area a "bit" to make the skyscraper fit in the 
left-hand sidebar... */
+div#content {
+       min-height: 1000px;
+}
\ No newline at end of file
diff --git a/css/cologneblue-leaderboard-ad.css 
b/css/cologneblue-leaderboard-ad.css
new file mode 100644
index 0000000..0a37425
--- /dev/null
+++ b/css/cologneblue-leaderboard-ad.css
@@ -0,0 +1,7 @@
+/**
+ * Leaderboard ad styling for the Cologne Blue skin
+ */
+#cologneblue-leaderboard-ad {
+       padding-top: 5px;
+       text-align: center;
+}
\ No newline at end of file
diff --git a/css/home-leaderboard-bottom-ad.css 
b/css/home-leaderboard-bottom-ad.css
new file mode 100644
index 0000000..3845992
--- /dev/null
+++ b/css/home-leaderboard-bottom-ad.css
@@ -0,0 +1,6 @@
+/**
+ * Bottom leaderboard ad styling for the Home skin
+ */
+div#home-leaderboard-ad {
+       margin-left: -5px;
+}
\ No newline at end of file
diff --git a/css/home-skyscraper-ad.css b/css/home-skyscraper-ad.css
new file mode 100644
index 0000000..ef014a7
--- /dev/null
+++ b/css/home-skyscraper-ad.css
@@ -0,0 +1,23 @@
+/**
+ * Skyscraper ad styling for the Home skin
+ */
+.column-google-left {
+       float: left;
+       width: 120px;
+       height: 600px;
+       left: 200px;
+       position: absolute;
+       top: 150px;
+       z-index: 1;
+}
+
+.column-google-right {
+       float: right;
+       right: 200px;
+       top: 150px;
+       width: 120px;
+       height: 600px;
+       float: left;
+       position: absolute;
+       z-index: 1;
+}
\ No newline at end of file
diff --git a/css/modern-button-ad.css b/css/modern-button-ad.css
new file mode 100644
index 0000000..71bd040
--- /dev/null
+++ b/css/modern-button-ad.css
@@ -0,0 +1,9 @@
+/**
+ * Button ad styling for the Modern skin
+ */
+#p-ads-left {
+       right: 0px;
+       top: 10px;
+       z-index: 1;
+       text-align: center;
+}
\ No newline at end of file
diff --git a/css/modern-leaderboard-ad.css b/css/modern-leaderboard-ad.css
new file mode 100644
index 0000000..a8ee38d
--- /dev/null
+++ b/css/modern-leaderboard-ad.css
@@ -0,0 +1,7 @@
+/**
+ * Leaderboard ad styling for the Modern skin
+ */
+#modern-leaderboard-ad {
+       padding-top: 5px;
+       text-align: center;
+}
\ No newline at end of file
diff --git a/css/monobook-button-ad.css b/css/monobook-button-ad.css
index 9e466d6..8d17373 100644
--- a/css/monobook-button-ad.css
+++ b/css/monobook-button-ad.css
@@ -6,4 +6,5 @@
        top: 10px;
        width: 150px;
        z-index: 1;
-}
\ No newline at end of file
+       text-align: center;
+}
diff --git a/css/monobook-skyscraper-ad.css b/css/monobook-skyscraper-ad.css
index b179fac..4cb1cfa 100644
--- a/css/monobook-skyscraper-ad.css
+++ b/css/monobook-skyscraper-ad.css
@@ -1,19 +1,17 @@
 /**
  * Skyscraper ad styling for Monobook skin
  */
-#content {
+div#content {
+       border-right: solid 1px #aaaaaa !important; /* yes, the important is 
needed...lame */
        margin-top: 2.8em !important;
        margin-right: 125px !important;
        margin-bottom: 0 !important;
        margin-left: 12.2em !important;
 }
 
-#content {
-       border-right: solid 1px rgb(170,170,170);
-}
-
 #column-google {
        width: 120px;
+       height: 600px;
        clear: left;
        position: absolute;
        padding-top: 35px;
@@ -27,5 +25,5 @@
 }
 
 #footer {
-       width: 91%;
-}
\ No newline at end of file
+       width: 90%;
+}
diff --git a/css/quartz-square-ad.css b/css/quartz-square-ad.css
new file mode 100644
index 0000000..c1f307a
--- /dev/null
+++ b/css/quartz-square-ad.css
@@ -0,0 +1,4 @@
+/** Styling for Quartz's ads -- the selector also matches the sitenotice 
leaderboard, but that's perfectly fine */
+.quartz-ad {
+       text-align: center;
+}
\ No newline at end of file
diff --git a/css/truglass-ads.css b/css/truglass-ads.css
deleted file mode 100644
index db46934..0000000
--- a/css/truglass-ads.css
+++ /dev/null
@@ -1,6 +0,0 @@
-/**
- * Ad CSS for Truglass skin
- */
-#topadsleft {
-       text-align: center;
-}
\ No newline at end of file
diff --git a/css/truglass-leaderboard-ad.css b/css/truglass-leaderboard-ad.css
new file mode 100644
index 0000000..ccdddc9
--- /dev/null
+++ b/css/truglass-leaderboard-ad.css
@@ -0,0 +1,22 @@
+#truglass-leaderboard-ad {
+       text-align: center;
+       padding-top: 3px;
+       padding-bottom: 5px;
+}
+
+table.truglass-ad-container {
+       border-collapse: collapse; /* cellspacing=0 equivalent */
+}
+
+table.truglass-ad-container td {
+       border: none;
+       outline: none;
+}
+
+table.truglass-ad-container td, table.truglass-ad-container th {
+       padding: 0; /* cellpadding=0 equivalent */
+}
+
+td#contentBox {
+       vertical-align: top;
+}
\ No newline at end of file
diff --git a/css/vector-button-ad.css b/css/vector-button-ad.css
new file mode 100644
index 0000000..03cbc8b
--- /dev/null
+++ b/css/vector-button-ad.css
@@ -0,0 +1,10 @@
+/**
+ * Button ad styling for the Vector skin
+ */
+#p-ads-left {
+       margin-bottom: 20px;
+       right: 0px;
+       text-align: center;
+       width: 150px;
+       z-index: 1;
+}
diff --git a/css/vector-skyscraper-ad.css b/css/vector-skyscraper-ad.css
new file mode 100644
index 0000000..05b0a59
--- /dev/null
+++ b/css/vector-skyscraper-ad.css
@@ -0,0 +1,27 @@
+/**
+ * Skyscraper ad styling for the Vector skin
+ */
+div#content {
+       border-right: solid 1px #a7d7f9 !important; /* the color is from 
skins/vector/images/border.png */
+       margin-right: 125px !important;
+}
+
+#column-google {
+       width: 120px;
+       height: 600px;
+       clear: left;
+       position: absolute;
+       padding-top: 0px;
+       padding-right: 0px;
+       padding-bottom: 0px;
+       padding-left: 3px;
+       float: right;
+       right: 0px;
+       top: 85px;
+       z-index: 1;
+}
+
+#footer {
+       /* 75% is not enough, 76% is too much... */
+       width: 75.5%;
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/152044
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib556e644a33ce643f39dcf689d963157a3a9e126
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ShoutWikiAds
Gerrit-Branch: master
Gerrit-Owner: Lewis Cawte <le...@lewiscawte.me>
Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to