You are here

adsense_search.results.inc in Google AdSense integration 6

Same filename and directory in other branches
  1. 5.3 old/search/adsense_search.results.inc

Displays the page containing the results of the Adsense for Search box.

File

old/search/adsense_search.results.inc
View source
<?php

/**
 * @file
 * Displays the page containing the results of the Adsense for Search box.
 */

/**
 * Creates the Adsense for Search page for site-embedded search results.
 *
 * @return string
 *   JavaScript that embeds the Google results
 */
function _adsense_search_results() {

  // Log the search keys.
  watchdog('AdSense', 'Search keywords: %keyword', array(
    '%keyword' => urldecode($_GET['as_q']),
  ), WATCHDOG_NOTICE);

  // Output search results.
  $width = variable_get('adsense_search_frame_width', ADSENSE_SEARCH_FRAME_WIDTH_DEFAULT);
  $country = variable_get('adsense_search_country', ADSENSE_SEARCH_COUNTRY_DEFAULT);
  if (variable_get('adsense_test_mode', ADSENSE_TEST_MODE_DEFAULT)) {
    $output = theme('adsense_placeholder', "Results<br />width = {$width}<br />country = {$country}", $width, 100);
  }
  else {
    $output = <<<SEARCH_RESULTS_TXT
<!-- Google Search Result Snippet Begins -->
<div id="googleSearchUnitIframe"></div>
<script type="text/javascript">
  var googleSearchIframeName = 'googleSearchUnitIframe';
  var googleSearchFrameWidth = {<span class="php-variable">$width</span>};
  var googleSearchFrameborder = 0 ;
  var googleSearchDomain = '{<span class="php-variable">$country</span>}';
</script>
<script type="text/javascript"
  src="http://www.google.com/afsonline/show_afs_search.js">
</script>
<!-- Google Search Result Snippet Ends -->
SEARCH_RESULTS_TXT;

    // Remove empty lines.
    $output = str_replace("\n\n", "\n", $output);
  }
  return $output;
}

Functions

Namesort descending Description
_adsense_search_results Creates the Adsense for Search page for site-embedded search results.