You are here

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

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

Implementation of hook_block().

File

./google_admanager.module, line 10

Code

function google_admanager_block($op = 'list', $delta = 0, $edit = array()) {
  if ($op == 'view') {
    $ad_slots = _google_admanager_get_ad_slots();
    $block = array(
      'subject' => '',
      'content' => '',
    );
    if ($id = variable_get('google_admanager_account', '')) {
      if (isset($ad_slots[$delta])) {

        // ad slot
        $block['content'] = theme('google_admanager_block', $id, $ad_slots[$delta]);
      }
      elseif (substr($delta, 0, 10) == 'superslot:') {

        // superslot
        $superslots = variable_get('google_admanager_superslots', array());
        if ($superslot = $superslots[substr($delta, 10)]) {
          foreach ($superslot as $ad_slot => $php) {
            if (eval($php)) {
              $block['content'] .= theme('google_admanager_block', $id, $ad_slot);
            }
          }
        }
      }
    }
    return $block;
  }
  else {
    require_once drupal_get_path('module', 'google_admanager') . '/google_admanager.admin.inc';
    return _google_admanager_block($op, $delta, $edit);
  }
}