You are here

function adsense_ad_formats in Google AdSense integration 5.3

Same name and namespace in other branches
  1. 5 adsense.module \adsense_ad_formats()
  2. 5.2 adsense.module \adsense_ad_formats()
  3. 6 adsense.module \adsense_ad_formats()
  4. 7 adsense.module \adsense_ad_formats()

This is the array that holds all ad formats.

All it has is a multi-dimensional array indexed by a key, containing the ad type, the description, Google's javascript ad code and the dimensions.

To add a new code:

  • Make sure the key is not in use by a different format
  • Go to Google AdSense . Get the dimensions . Get the code
  • Add it below

Parameters

$key: (optional) ad key for which the format is needed

Return value

if no key is provided: array of supported ad formats as an array (type, desc(ription), code, width and height) if a key is provided, the array containing the ad format for that key, or NULL if there is no ad with that key

6 calls to adsense_ad_formats()
adsense_display in ./adsense.module
Generates the Google AdSense Ad
adsense_help_text in help/adsense.help.inc
Creates the help text for the settings tab
adsense_managed_block in managed/adsense_managed.module
Implementation of hook_block().
adsense_oldcode_block in old/oldcode/adsense_oldcode.module
Implementation of hook_block().
_adsense_managed_get_ad in managed/adsense_managed.module
Generates the AdSense ad

... See full list

File

./adsense.module, line 53
Displays Google AdSense ads on Drupal pages

Code

function adsense_ad_formats($key = NULL) {
  $ads = array(
    '120x240' => array(
      'type' => ADSENSE_TYPE_AD,
      'desc' => t('Vertical banner'),
      'code' => '120x240_as',
      'width' => 120,
      'height' => 240,
    ),
    '120x600' => array(
      'type' => ADSENSE_TYPE_AD,
      'desc' => t('Skyscraper'),
      'code' => '120x600_as',
      'width' => 120,
      'height' => 600,
    ),
    '125x125' => array(
      'type' => ADSENSE_TYPE_AD,
      'desc' => t('Button'),
      'code' => '125x125_as',
      'width' => 125,
      'height' => 125,
    ),
    '160x600' => array(
      'type' => ADSENSE_TYPE_AD,
      'desc' => t('Wide Skyscraper'),
      'code' => '160x600_as',
      'width' => 160,
      'height' => 600,
    ),
    '180x150' => array(
      'type' => ADSENSE_TYPE_AD,
      'desc' => t('Small Rectangle'),
      'code' => '180x150_as',
      'width' => 180,
      'height' => 150,
    ),
    '200x200' => array(
      'type' => ADSENSE_TYPE_AD,
      'desc' => t('Small Square'),
      'code' => '200x200_as',
      'width' => 200,
      'height' => 200,
    ),
    '234x60' => array(
      'type' => ADSENSE_TYPE_AD,
      'desc' => t('Half Banner'),
      'code' => '234x60_as',
      'width' => 234,
      'height' => 60,
    ),
    '250x250' => array(
      'type' => ADSENSE_TYPE_AD,
      'desc' => t('Square'),
      'code' => '250x250_as',
      'width' => 250,
      'height' => 250,
    ),
    '300x250' => array(
      'type' => ADSENSE_TYPE_AD,
      'desc' => t('Medium Rectangle'),
      'code' => '300x250_as',
      'width' => 300,
      'height' => 250,
    ),
    '320x50' => array(
      'type' => ADSENSE_TYPE_AD,
      'desc' => t('Mobile Banner'),
      'code' => '320x50_as',
      'width' => 320,
      'height' => 50,
    ),
    '336x280' => array(
      'type' => ADSENSE_TYPE_AD,
      'desc' => t('Large Rectangle'),
      'code' => '336x280_as',
      'width' => 336,
      'height' => 280,
    ),
    '468x60' => array(
      'type' => ADSENSE_TYPE_AD,
      'desc' => t('Banner'),
      'code' => '468x60_as',
      'width' => 468,
      'height' => 60,
    ),
    '728x90' => array(
      'type' => ADSENSE_TYPE_AD,
      'desc' => t('Leaderboard'),
      'code' => '728x90_as',
      'width' => 728,
      'height' => 90,
    ),
    '120x90' => array(
      'type' => ADSENSE_TYPE_LINK,
      'desc' => t('4-links Vertical Smal'),
      'code' => '120x90_0ads_al',
      'width' => 120,
      'height' => 90,
    ),
    '160x90' => array(
      'type' => ADSENSE_TYPE_LINK,
      'desc' => t('4-links Vertical Medium'),
      'code' => '160x90_0ads_al',
      'width' => 160,
      'height' => 90,
    ),
    '180x90' => array(
      'type' => ADSENSE_TYPE_LINK,
      'desc' => t('4-links Vertical Large'),
      'code' => '180x90_0ads_al',
      'width' => 180,
      'height' => 90,
    ),
    '200x90' => array(
      'type' => ADSENSE_TYPE_LINK,
      'desc' => t('4-links Vertical X-Large'),
      'code' => '200x90_0ads_al',
      'width' => 200,
      'height' => 90,
    ),
    '468x15' => array(
      'type' => ADSENSE_TYPE_LINK,
      'desc' => t('4-links Horizontal Medium'),
      'code' => '468x15_0ads_al',
      'width' => 468,
      'height' => 15,
    ),
    '728x15' => array(
      'type' => ADSENSE_TYPE_LINK,
      'desc' => t('4-links Horizontal Large'),
      'code' => '728x15_0ads_al',
      'width' => 728,
      'height' => 15,
    ),
    '120x90_5' => array(
      'type' => ADSENSE_TYPE_LINK,
      'desc' => t('5-links Vertical Smal'),
      'code' => '120x90_0ads_al_s',
      'width' => 120,
      'height' => 90,
    ),
    '160x90_5' => array(
      'type' => ADSENSE_TYPE_LINK,
      'desc' => t('5-links Vertical Medium'),
      'code' => '160x90_0ads_al_s',
      'width' => 160,
      'height' => 90,
    ),
    '180x90_5' => array(
      'type' => ADSENSE_TYPE_LINK,
      'desc' => t('5-links Vertical Large'),
      'code' => '180x90_0ads_al_s',
      'width' => 180,
      'height' => 90,
    ),
    '200x90_5' => array(
      'type' => ADSENSE_TYPE_LINK,
      'desc' => t('5-links Vertical X-Large'),
      'code' => '200x90_0ads_al_s',
      'width' => 200,
      'height' => 90,
    ),
    '468x15_5' => array(
      'type' => ADSENSE_TYPE_LINK,
      'desc' => t('5-links Horizontal Medium'),
      'code' => '468x15_0ads_al_s',
      'width' => 468,
      'height' => 15,
    ),
    '728x15_5' => array(
      'type' => ADSENSE_TYPE_LINK,
      'desc' => t('5-links Horizontal Large'),
      'code' => '728x15_0ads_al_s',
      'width' => 728,
      'height' => 15,
    ),
  );
  if (!empty($key)) {
    if (array_key_exists($key, $ads)) {
      return $ads[$key];
    }
    elseif ($key == 'Search Box') {
      return array(
        'type' => ADSENSE_TYPE_SEARCH,
        'desc' => t('AdSense for Search'),
      );
    }
    else {
      return NULL;
    }
  }
  return $ads;
}