You are here

function theme_google_admanager_block in DFP Small Business (Google Ad Manager) 6.2

Same name and namespace in other branches
  1. 5 google_admanager.module \theme_google_admanager_block()
  2. 6 google_admanager.module \theme_google_admanager_block()
  3. 7.2 google_admanager.module \theme_google_admanager_block()

Theme function the Ad Slot code

Parameters

$id google admanager account id:

$id google admanager slot name:

Return value

google admanager slot script

1 call to theme_google_admanager_block()
_google_admanager_substitute_tags in ./google_admanager.module
Replace all Admanager tags with their corresponding files or images.
1 theme call to theme_google_admanager_block()
google_admanager_block in ./google_admanager.module
Implementation of hook_block().

File

./google_admanager.module, line 148

Code

function theme_google_admanager_block($id, $ad_slot, $cache = FALSE) {
  $script = '<script type="text/javascript">GA_googleFillSlot("' . $ad_slot . '");</script>';
  if ($cache) {
    $script = '<script type="text/javascript">GA_googleAddSlot("' . $id . '", "' . $ad_slot . '");</script>' . $script;
  }
  else {
    google_admanager_add_js('GA_googleAddSlot("' . $id . '", "' . $ad_slot . '");');
  }
  $style = '';
  if (variable_get('google_admanager_lazy', FALSE)) {

    // if ad slot name has the format some-name_widthxheight_something,
    // set the div dimension
    if (variable_get('google_admanager_autodetect', FALSE)) {
      if (preg_match('/(\\d+)x(\\d+)(_.*|)$/', $ad_slot, $match)) {
        $style = ' style="width:' . $match[1] . 'px;height:' . $match[2] . 'px;"';
      }
    }
    google_admanager_add_block('<div id="gam-content-' . $ad_slot . '" class="gam-banner">' . $script . '</div>');
    $script = '';
  }
  return '<div id="gam-holder-' . $ad_slot . '" class="gam-holder"' . $style . '>' . $script . '</div>';
}