You are here

function _adsense_search_get_searchbox in Google AdSense integration 6

Same name and namespace in other branches
  1. 5.3 old/search/adsense_search.module \_adsense_search_get_searchbox()
  2. 7 old/search/adsense_search.module \_adsense_search_get_searchbox()

Generates the search box.

Parameters

int $channel: (optional) Channel ID of the configured Ad Channel.

Return value

string HTML with the search input form

1 call to _adsense_search_get_searchbox()
adsense_display in ./adsense.module
Generates the Google AdSense Ad.

File

old/search/adsense_search.module, line 159
Displays Google AdSense ads on Drupal pages.

Code

function _adsense_search_get_searchbox($client, $channel = NULL) {
  global $base_url;
  $border = variable_get('adsense_search_color_border', ADSENSE_SEARCH_COLOR_BORDER_DEFAULT);
  $title = variable_get('adsense_search_color_title', ADSENSE_SEARCH_COLOR_TITLE_DEFAULT);
  $bg = variable_get('adsense_search_color_bg', ADSENSE_SEARCH_COLOR_BG_DEFAULT);
  $text = variable_get('adsense_search_color_text', ADSENSE_SEARCH_COLOR_TEXT_DEFAULT);
  $url = variable_get('adsense_search_color_url', ADSENSE_SEARCH_COLOR_URL_DEFAULT);
  $visited = variable_get('adsense_search_color_visited_url', ADSENSE_SEARCH_COLOR_VISITED_URL_DEFAULT);
  $light = variable_get('adsense_search_color_light_url', ADSENSE_SEARCH_COLOR_LIGHT_URL_DEFAULT);
  $logobg = variable_get('adsense_search_color_logo_bg', ADSENSE_SEARCH_COLOR_LOGO_BG_DEFAULT);
  $logo = variable_get('adsense_search_logo', ADSENSE_SEARCH_LOGO_DEFAULT);
  $search_button = variable_get('adsense_search_button', ADSENSE_SEARCH_BUTTON_DEFAULT);
  $box_text_color = variable_get('adsense_search_color_box_text', ADSENSE_SEARCH_COLOR_BOX_TEXT_DEFAULT);
  $box_background_color = variable_get('adsense_search_color_box_background', ADSENSE_SEARCH_COLOR_BOX_BACKGROUND_DEFAULT);
  $encoding = variable_get('adsense_search_encoding', ADSENSE_SEARCH_ENCODING_DEFAULT);
  $domain_0 = variable_get('adsense_search_domain_0', str_replace('http://', '', $base_url));
  $domain_1 = variable_get('adsense_search_domain_1', ADSENSE_SEARCH_DOMAIN_DEFAULT);
  $domain_2 = variable_get('adsense_search_domain_2', ADSENSE_SEARCH_DOMAIN_DEFAULT);
  $domain = $domain_1 ? "{$domain_0};{$domain_1}" : $domain_0;
  $domain = $domain_2 ? "{$domain};{$domain_2}" : $domain;
  $language = variable_get('adsense_search_language', ADSENSE_SEARCH_LANGUAGE_DEFAULT);
  $textbox_length = variable_get('adsense_search_textbox_length', ADSENSE_SEARCH_TEXTBOX_LENGTH_DEFAULT);
  if (variable_get('clean_url', 0)) {
    $results_path = url(ADSENSE_SEARCH_RESULTS_PATH, array(
      'absolute' => TRUE,
    ));
    $hidden_q_field = "";
  }
  else {
    $results_path = $base_url;
    $hidden_q_field = '<input type="hidden" name="q" value="." />';
  }
  if ($logo != 'adsense_search_logo_on_button') {
    $btn = t('Search');
    if ($box_background_color == '#000000') {
      $logo_color = 'blk';
    }
    elseif ($box_background_color == '#CCCCCC') {
      $logo_color = 'gry';
    }
    else {
      $logo_color = 'wht';
    }
    $part1 = "<a href=\"http://www.google.com/\">\n" . "<img src=\"http://www.google.com/logos/Logo_25{$logo_color}.gif\" border=\"0\" alt=\"Google\" align=\"middle\"></img></a>";
    if ($logo == 'adsense_search_logo_google') {
      $part1 .= "\n</td>\n<td nowrap=\"nowrap\">";
      $part3 = "<td>&nbsp;</td>";
    }
    elseif ($logo == 'adsense_search_logo_above_textbox') {
      $part1 .= "\n<br/>";
      $part3 = "";
    }
  }
  else {
    $btn = t('Google Search');
    $part1 = "</td>\n<td nowrap=\"nowrap\">";
    $part3 = "<td>&nbsp;</td>";
  }
  $button_html = "<label for=\"sbb\" style=\"display: none\">Submit search form</label>\n" . "<input type=\"submit\" name=\"sa\" value=\"{$btn}\" id=\"sbb\"></input>";
  if (!$search_button) {
    $part2 = $button_html;
    $part5 = "";
  }
  else {
    $part5 = $button_html;
    $part2 = "";
  }

  // Searched domains >=1 (2 or 3)
  if ($domain_1) {
    $part4 = "<tr>\n<td>\n<input type=\"radio\" name=\"sitesearch\" value=\"{$domain_1}\" id=\"ss2\"></input>\n" . "<label for=\"ss2\" title=\"Search {$domain_1}\"><font size=\"-1\" color=\"{$box_text_color}\">{$domain_1}</font></label></td>\n";
    if ($domain_2) {
      $part4 .= "<td>\n<input type=\"radio\" name=\"sitesearch\" value=\"{$domain_2}\" id=\"ss3\"></input>\n" . "<label for=\"ss3\" title=\"Search {$domain_2}\"><font size=\"-1\" color=\"{$box_text_color}\">{$domain_2}</font></label></td>";
    }
    else {
      $part4 .= "<td></td>";
    }
    $part4 .= "\n</tr>";
  }
  else {
    $part4 = "";
  }

  // AdSense for Search channel.
  $channel = variable_get('adsense_ad_channel_' . $channel, ADSENSE_AD_CHANNEL_DEFAULT);
  if (!empty($channel)) {
    $part6 = "<input type=\"hidden\" name=\"channel\" value=\"{$channel}\"></input>";
  }
  else {
    $part6 = "";
  }

  // Is SafeSearch active?
  $part7 = variable_get('adsense_search_safe_mode', ADSENSE_SEARCH_SAFE_MODE_DEFAULT) ? '<input type="hidden" name="safe" value="active"></input>' : '';
  $output = <<<SEARCH_TXT
<!-- SiteSearch Google -->
<form method="get" action="{<span class="php-variable">$results_path</span>}" target="_top">
<table border="0" bgcolor="{<span class="php-variable">$box_background_color</span>}">
<tr><td nowrap="nowrap" valign="top" align="left" height="32">
{<span class="php-variable">$part1</span>}
{<span class="php-variable">$hidden_q_field</span>}
<input type="hidden" name="domains" value="{<span class="php-variable">$domain</span>}"></input>
<label for="sbi" style="display: none">Enter your search terms</label>
<input type="text" name="as_q" size="{<span class="php-variable">$textbox_length</span>}" maxlength="255" value="" id="sbi"></input>
{<span class="php-variable">$part2</span>}
</td></tr>
<tr>
{<span class="php-variable">$part3</span>}
<td nowrap="nowrap">
<table>
<tr>
<td>
<input type="radio" name="sitesearch" value="" checked id="ss0"></input>
<label for="ss0" title="Search the Web"><font size="-1" color="{<span class="php-variable">$box_text_color</span>}">Web</font></label></td>
<td>
<input type="radio" name="sitesearch" value="{<span class="php-variable">$domain_0</span>}" id="ss1"></input>
<label for="ss1" title="Search {<span class="php-variable">$domain_0</span>}"><font size="-1" color="{<span class="php-variable">$box_text_color</span>}">{<span class="php-variable">$domain_0</span>}</font></label></td>
</tr>
{<span class="php-variable">$part4</span>}
</table>
{<span class="php-variable">$part5</span>}
<input type="hidden" name="client" value="{<span class="php-variable">$client</span>}"></input>
<input type="hidden" name="forid" value="1"></input>
{<span class="php-variable">$part6</span>}
<input type="hidden" name="ie" value="{<span class="php-variable">$encoding</span>}"></input>
<input type="hidden" name="oe" value="{<span class="php-variable">$encoding</span>}"></input>
{<span class="php-variable">$part7</span>}
<input type="hidden" name="cof" value="GALT:{<span class="php-variable">$url</span>};GL:1;DIV:{<span class="php-variable">$border</span>};VLC:{<span class="php-variable">$visited</span>};AH:center;BGC:{<span class="php-variable">$bg</span>};LBGC:{<span class="php-variable">$logobg</span>};ALC:{<span class="php-variable">$title</span>};LC:{<span class="php-variable">$title</span>};T:{<span class="php-variable">$text</span>};GFNT:{<span class="php-variable">$light</span>};GIMP:{<span class="php-variable">$light</span>};FORID:11"></input>
<input type="hidden" name="hl" value="{<span class="php-variable">$language</span>}"></input>
</td></tr></table>
</form>
<!-- SiteSearch Google -->
SEARCH_TXT;
  return $output;
}