You are here

function google_appliance_search_form in Google Search Appliance 7

Same name and namespace in other branches
  1. 6.2 google_appliance.module \google_appliance_search_form()

Form builder outputs the search form for results pages

See also

google_appliance_search_form_submit()

google_appliance-search-form.tpl.php

google_appliance-results.tpl.php

2 string references to 'google_appliance_search_form'
google_appliance_search_view in ./google_appliance.module
Top level search execution (menu callback)
template_preprocess_google_appliance_results in theme/google_appliance.theme.inc
Preprocess google-search-appliance-results.tpl.php (results page).

File

./google_appliance.module, line 419
Google Appliance module enables searching via a dedicated Google Search Appliance hardware device. See README.txt and the help page at admin/help/google_appliance.

Code

function google_appliance_search_form($form, &$form_state, $query = '', $prompt = '') {
  $settings = _google_appliance_get_settings();
  $prompt = $prompt == '' ? t('Enter the terms you wish to search for.') : $prompt;

  // basic search
  $form['basic'] = array(
    '#type' => 'container',
  );
  $form['basic']['search_keys'] = array(
    '#type' => 'textfield',
    '#default_value' => $query,
    '#attributes' => array(
      'title' => $prompt,
    ),
    '#title' => check_plain($prompt),
    '#title_display' => 'invisible',
  );

  // only prompt if we haven't searched yet
  if ($query == '') {
    $form['basic']['prompt'] = array(
      '#type' => 'item',
      '#markup' => '<p><b>' . $prompt . '</b></p>',
    );
  }
  $form['basic']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Search'),
  );

  // submit points to search page without any keys (pre-search state)
  // the redirect happens in _submit handler
  $form_state['action'] = $settings['drupal_path'] . '/';

  // use core search CSS in addition to this module's css
  // (keep it general in case core search is enabled)
  $form['#attributes']['class'][] = 'search-form';
  $form['#attributes']['class'][] = 'search-google-appliance-search-form';
  return $form;
}