You are here

function adsense_display in Google AdSense integration 5

Same name and namespace in other branches
  1. 8 adsense.module \adsense_display()
  2. 5.3 adsense.module \adsense_display()
  3. 5.2 adsense.module \adsense_display()
  4. 6 adsense.module \adsense_display()
  5. 7 adsense.module \adsense_display()
2 calls to adsense_display()
adsense_block in ./adsense.module
Implementation of hook_block().
_adsense_process_tags in ./adsense.module

File

./adsense.module, line 992

Code

function adsense_display($format = '160x600', $group = 1, $channel = 1) {
  if (!_adsense_validate_dimensions($format)) {
    $ad = '<!--adsense: invalid format: ' . $format . '-->';
  }
  else {

    // This ad format is not cached, generate it
    // Check first if disabled or if we are at adsense limit or if this page doesn't allow adsense
    if (_adsense_check_if_enabled()) {
      if (_adsense_can_insert_another($format)) {
        if (_adsense_page_match()) {

          // Ad should be displayed
          // Check cache first
          $ad = $format != ADSENSE_SEARCH_BOX ? _adsense_get_ad($format, $group, $channel) : _adsense_get_searchbox($group, $channel);
        }
        else {
          $ad = '<!--adsense: page not in match list-->';
        }
      }
      else {
        $ad = '<!--adsense: ad limit reached for type-->';
      }
    }
    else {

      // Ads are disabled
      if (_adsense_page_match()) {
        if (_adsense_check_placeholder()) {
          $ad = '<!--adsense: placeholder-->' . _adsense_format_placeholder($format);
        }
        else {
          $ad = '<!--adsense: ads disabled -->';
        }
      }
    }
  }
  return $ad;
}