You are here

function google_cse_searchbox_form_builder in Google Custom Search Engine 6

Form builder for the searchbox forms.

1 string reference to 'google_cse_searchbox_form_builder'
google_cse_forms in ./google_cse.module
Implementation of hook_forms();

File

./google_cse.module, line 90
Display a Google Custom Search Engine on your site.

Code

function google_cse_searchbox_form_builder(&$form_state, $form_id, $self = FALSE) {
  $form = array();

  // The default form.
  if (variable_get('google_cse_results_display', 'here') == 'here') {
    $form['#action'] = url($self ? $_GET['q'] : 'search/google');
    $cof = variable_get('google_cse_cof_here', 'FORID:11');
  }
  else {
    $form['#action'] = 'http://' . variable_get('google_cse_domain', 'www.google.com') . '/cse';
    $cof = variable_get('google_cse_cof_google', 'FORID:0');
  }
  $form['#method'] = 'get';
  $form['cx'] = array(
    '#type' => 'hidden',
    '#value' => variable_get('google_cse_cx', ''),
  );
  $form['cof'] = array(
    '#type' => 'hidden',
    '#value' => $cof,
  );
  $form['query'] = array(
    '#type' => 'textfield',
    '#default_value' => isset($_GET['query']) ? $_GET['query'] : '',
  );
  $form['sa'] = array(
    '#type' => 'submit',
    '#value' => t('Search'),
  );
  foreach (google_cse_advanced_settings() as $parameter => $setting) {
    $form[$parameter] = array(
      '#type' => 'hidden',
      '#value' => $setting,
    );
  }

  // And the small differences between both.
  switch ($form_id) {
    case 'google_cse_searchbox_form':
      $form['query']['#size'] = intval(variable_get('google_cse_searchbox_width', 15));
      $form['query']['#attributes']['title'] = t('Enter the terms you wish to search for.');
      break;
    case 'google_cse_results_searchbox_form':
      $form['query']['#size'] = intval(variable_get('google_cse_results_searchbox_width', 40));
      $form['query']['#title'] = t('Enter your keywords');
      if (variable_get('google_cse_results_gadget', 1)) {
        $form['sa']['#suffix'] = theme('google_cse_results_gadget');
      }
      break;
  }
  google_cse_sitesearch_form($form);
  return $form;
}