function _adsense_format in Google AdSense integration 5
Same name and namespace in other branches
- 5.2 adsense.module \_adsense_format()
1 call to _adsense_format()
File
- ./
adsense.module, line 1149
Code
function _adsense_format($format, $group = 1, $channel = 1) {
$group = _adsense_validate_group($group);
$client = adsense_get_client_id();
$text = variable_get(ADSENSE_COLOR_TEXT . $group, '000000');
$border = variable_get(ADSENSE_COLOR_BORDER . $group, '336699');
$bg = variable_get(ADSENSE_COLOR_BG . $group, 'FFFFFF');
$link = variable_get(ADSENSE_COLOR_LINK . $group, '336699');
$url = variable_get(ADSENSE_COLOR_URL . $group, 'FF8C00');
$alt = variable_get(ADSENSE_ALT . $group, 0);
$alt_info = variable_get(ADSENSE_ALT_INFO . $group, '');
$channel = variable_get(ADSENSE_AD_CHANNEL . _adsense_validate_channel($channel), '');
switch (variable_get(ADSENSE_AD_TYPE . $group, '0')) {
case 2:
$type = 'text_image';
break;
case 1:
$type = 'image';
break;
default:
$type = 'text';
break;
}
$width = _adsense_get_width($format);
$height = _adsense_get_height($format);
$format = $width . 'x' . $height . adsense_get_ad_code($format);
$output .= _adsense_add_nl('');
$output .= _adsense_add_nl('<div class="adsense">');
$output .= _adsense_add_nl('<script type="text/javascript"><!--');
switch ($alt) {
case 0:
// disabled
break;
case 1:
$output .= _adsense_add_nl('google_alternate_ad_url = "' . $alt_info . '";');
break;
case 2:
$output .= _adsense_add_nl('google_alternate_color = "' . $alt_info . '";');
break;
}
$output .= _adsense_add_nl('google_ad_client = "' . $client . '";');
$output .= _adsense_add_nl('google_ad_type = "' . $type . '";');
$output .= _adsense_add_nl('google_ad_channel = "' . $channel . '";');
$output .= _adsense_add_nl('google_ad_width = ' . $width . ';');
$output .= _adsense_add_nl('google_ad_height = ' . $height . ';');
$output .= _adsense_add_nl('google_ad_format = "' . $format . '";');
$output .= _adsense_add_nl('google_color_border = "' . $border . '";');
$output .= _adsense_add_nl('google_color_bg = "' . $bg . '";');
$output .= _adsense_add_nl('google_color_link = "' . $link . '";');
$output .= _adsense_add_nl('google_color_url = "' . $url . '";');
$output .= _adsense_add_nl('google_color_text = "' . $text . '";');
$output .= _adsense_add_nl('//--></script>');
$output .= _adsense_add_nl('<script type="text/javascript"');
$output .= _adsense_add_nl(' src="http://pagead2.googlesyndication.com/pagead/show_ads.js">');
$output .= _adsense_add_nl('</script>');
$output .= _adsense_add_nl('</div>');
if (variable_get(ADSENSE_TEST_MODE, 0)) {
$text = "client={$client} format={$format} group={$group} channel={$channel} type={$type}";
$output = '<div style="';
$output .= ' width:' . $width . 'px;';
$output .= ' height:' . $height . 'px;';
$output .= ' border:solid 1px">' . $text . '</div>';
}
return $output;
}