function adsense_managed_block_configure in Google AdSense integration 7
Implements hook_block_configure().
File
- managed/
adsense_managed.module, line 103 - Displays Google AdSense ads on Drupal pages.
Code
function adsense_managed_block_configure($delta = '') {
$ad = _adsense_managed_get_block_config($delta);
$ad_list = array();
foreach (adsense_ad_formats() as $format => $data) {
$ad_list[$format] = $format . ' : ' . $data['desc'];
}
$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/structure/block'),
)),
'#required' => TRUE,
'#weight' => -19,
);
$form['ad_format'] = array(
'#type' => 'select',
'#title' => t('Ad format'),
'#default_value' => $ad ? $ad[1] : 'responsive',
'#options' => $ad_list,
'#description' => t('Select the ad dimensions you want for this block.'),
'#required' => TRUE,
);
$form['ad_width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#default_value' => isset($ad[5]) ? $ad[5] : '',
'#description' => t('Custom ad width.'),
'#field_suffix' => ' ' . t('pixels'),
'#size' => 3,
'#maxlength' => 4,
'#states' => array(
'enabled' => array(
':input[name="ad_format"]' => array(
'value' => 'custom',
),
),
'visible' => array(
':input[name="ad_format"]' => array(
'value' => 'custom',
),
),
'required' => array(
':input[name="ad_format"]' => array(
'value' => 'custom',
),
),
),
);
$form['ad_height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#default_value' => isset($ad[6]) ? $ad[6] : '',
'#description' => t('Custom ad height.'),
'#field_suffix' => ' ' . t('pixels'),
'#size' => 3,
'#maxlength' => 4,
'#states' => array(
'enabled' => array(
':input[name="ad_format"]' => array(
'value' => 'custom',
),
),
'visible' => array(
':input[name="ad_format"]' => array(
'value' => 'custom',
),
),
'required' => array(
':input[name="ad_format"]' => array(
'value' => 'custom',
),
),
),
);
$form['ad_slot'] = array(
'#type' => 'textfield',
'#title' => t('Ad Slot ID'),
'#default_value' => $ad ? $ad[2] : '',
'#description' => t('This is the Ad Slot ID from your Google Adsense account, such as 0123456789.'),
'#required' => TRUE,
);
$form['ad_shape'] = array(
'#type' => 'select',
'#title' => t('Responsive ad shape'),
'#default_value' => isset($ad[4]) ? explode(',', $ad[4]) : 'auto',
'#multiple' => TRUE,
'#options' => array(
'auto' => t('Auto-sizing'),
'horizontal' => t('Horizontal'),
'vertical' => t('Vertical'),
'rectangle' => t('Rectangle'),
),
'#description' => t("Shape of the responsive ad unit. Google's default is 'auto' for auto-sizing behaviour, but can also be a combination of one or more of the following: 'rectangle', 'vertical' or 'horizontal'."),
'#states' => array(
'enabled' => array(
':input[name="ad_format"]' => array(
'value' => 'responsive',
),
),
'visible' => array(
':input[name="ad_format"]' => array(
'value' => 'responsive',
),
),
),
);
$form['ad_layout_key'] = array(
'#type' => 'textfield',
'#title' => t('Layout key'),
'#default_value' => isset($ad[7]) ? $ad[7] : '',
'#description' => t("This is the data-ad-layout-key in the ad code from your Google Adsense account, such as '-gw-3+1f-3d+2z'."),
'#states' => array(
'enabled' => array(
':input[name="ad_format"]' => array(
'value' => 'in-feed',
),
),
'visible' => array(
':input[name="ad_format"]' => array(
'value' => 'in-feed',
),
),
'required' => array(
':input[name="ad_format"]' => array(
'value' => 'in-feed',
),
),
),
);
$form['ad_align'] = array(
'#type' => 'select',
'#title' => t('Ad alignment'),
'#default_value' => $ad ? $ad[3] : 'center',
'#options' => array(
'' => t('None'),
'left' => t('Left'),
'center' => t('Centered'),
'right' => t('Right'),
),
'#description' => t('Select the horizontal alignment of the ad within the block.'),
);
return $form;
}