You are here

function adsense_search in Google AdSense integration 5

Same name and namespace in other branches
  1. 5.2 adsense.module \adsense_search()
1 string reference to 'adsense_search'
adsense_menu in ./adsense.module
Implementation of hook_menu().

File

./adsense.module, line 1881

Code

function adsense_search($op = 'search', $keys = NULL) {
  global $base_url;
  if (!user_access('access adsense search result page')) {
    return;
  }
  switch ($op) {
    case 'name':
      return t('Google AdSense for Search');
    case 'search':

      // Log the search keys:
      watchdog('AdSense', t('Keyword') . ': <em>' . urldecode($_GET['as_q']) . '</em>', WATCHDOG_NOTICE, 'AdSense for Search');

      // Output search results
      $width = variable_get(ADSENSE_SEARCH_FRAME_WIDTH, '500');
      $domain = variable_get(ADSENSE_SEARCH_DOMAIN . '_0', $base_url);
      $country = variable_get(ADSENSE_SEARCH_COUNTRY, 'www.google.com');
      $output .= _adsense_add_nl(ADSENSE_SEARCH_RESULT_START);
      $output .= _adsense_add_nl('<div id="googleSearchUnitIframe"></div>');
      $output .= _adsense_add_nl('<script type="text/javascript">');
      $output .= _adsense_add_nl('  var googleSearchIframeName = \'googleSearchUnitIframe\';');
      $output .= _adsense_add_nl('  var googleSearchFrameWidth = ' . $width . ';');
      $output .= _adsense_add_nl('  var googleSearchFrameborder = 0 ;');
      $output .= _adsense_add_nl('  var googleSearchDomain = \'' . $country . '\';');
      $output .= _adsense_add_nl('</script>');
      $output .= _adsense_add_nl('<script type="text/javascript"');
      $output .= _adsense_add_nl('  src="http://www.google.com/afsonline/show_afs_search.js">');
      $output .= _adsense_add_nl('</script>');
      $output .= _adsense_add_nl(ADSENSE_SEARCH_RESULT_END);
      return $output;
  }
}