adsense_cse_block

Versions
6
adsense_cse_block($op = 'list', $delta = 0, $edit = array())

Implementation of hook_block().

Code

contributions/adsense/cse/adsense_cse.module, line 55

<?php
function adsense_cse_block($op = 'list', $delta = 0, $edit = array()) {
  $block = NULL;

  switch ($op) {
    case 'list':
      $max = variable_get('adsense_cse_number_blocks', ADSENSE_CSE_NUMBER_BLOCKS_DEFAULT);
      for ($count=0; $count < $max ; $count++) {
        if ($ad = _adsense_cse_get_block_config($count)) {
          $title = $ad[0];
        }
        else {
          $title = t('AdSense CSE: unconfigured ') . $count;
        }
        $block[$count]['info'] = $title;
      }
      break;

    case 'configure':
      $ad = _adsense_cse_get_block_config($delta);

      $form['info'] = array(
        '#type' => 'textfield',
        '#title' => t('Block description'),
        '#default_value' => ($ad) ? $ad[0] : '',
        '#maxlength' => 64,
        '#description' => t('A brief description of your block. Used on the <a href="@overview">block overview page</a>.', array('@overview' => url('admin/build/block'))),
        '#required' => TRUE,
        '#weight' => -19,
      );

      $form['ad_slot'] = array(
        '#type' => 'textfield',
        '#title' => t('Ad Slot ID'),
        '#default_value' => ($ad) ? $ad[1] : '',
        '#description' => t('This is the provided by the AdSense site in the Search Box Code "cx" field. This is usually provided in the form partner-<em>Publisher ID</em>:<em>Slot Id</em>. If the code provided is, for example, partner-pub-0123456789:<strong>abcdef-ghij</strong>, then insert only <strong>abcdef-ghij</strong> here.'),
        '#required' => TRUE,
      );
      return $form;

    case 'save':
      $data = implode(':', array(urlencode($edit['info']), $edit['ad_slot']));
      variable_set('adsense_cse_ad_block_'. $delta, $data);
      return;

    case 'view':
      if (_adsense_page_match()) {
        $ad = _adsense_cse_get_block_config($delta);
        $block['content'] = ($ad) ? adsense_display(array('format' => 'Search Box', 'slot' => $ad[1])) : t('AdSense unconfigured block. <a href=!url>Click to configure.</a>', array('!url' => url('admin/build/block/configure/adsense_cse/'. $delta)));
      }
      break;
    }
  return $block;
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.