You are here

function getlocations_search_form in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_search/getlocations_search.module \getlocations_search_form()

The search form

1 string reference to 'getlocations_search_form'
theme_getlocations_search in modules/getlocations_search/getlocations_search.module
Themes the search page.

File

modules/getlocations_search/getlocations_search.module, line 101
getlocations_search.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_search_form($form, &$form_state, $which, $mapid) {
  $mapid2 = preg_replace("/_/", "-", $mapid);
  $getlocations_search_defaults = getlocations_search_defaults();
  if ($which == 'block') {
    $getlocations_search_defaults = getlocations_search_block_get_var();
  }
  $form['#attached']['css'] = array(
    GETLOCATIONS_SEARCH_PATH . '/getlocations_search.css',
  );

  // pass this on to the theme
  $form['which'] = array(
    '#type' => 'value',
    '#value' => $which,
  );
  $form['mapid'] = array(
    '#type' => 'value',
    '#value' => $mapid,
  );
  $form['display_latlon'] = array(
    '#type' => 'value',
    '#value' => $getlocations_search_defaults['display_latlon'],
  );
  $form['display_geo_microformat'] = array(
    '#type' => 'value',
    '#value' => $getlocations_search_defaults['display_geo_microformat'],
  );
  $form['display_accuracy'] = array(
    '#type' => 'value',
    '#value' => $getlocations_search_defaults['display_accuracy'],
  );
  if ($getlocations_search_defaults['method'] == 'vocab' && $getlocations_search_defaults['vocab_element'] == 'dropdown') {

    //
    $form['getlocations_search_' . $mapid] = array(
      '#type' => 'select',
      '#title' => t('Search'),
      '#options' => getlocations_search_term_get(),
    );
  }
  else {
    $form['getlocations_search_' . $mapid] = array(
      '#type' => 'textfield',
      '#title' => t('Search'),
      '#maxlength' => 255,
      '#size' => $getlocations_search_defaults['searchbox_size'],
    );
    if ($getlocations_search_defaults['method'] == 'vocab' && $getlocations_search_defaults['vocab_element'] == 'autocomplete') {
      $form['getlocations_search_' . $mapid]['#autocomplete_path'] = 'getlocations_search/term_autocomplete';
    }
  }
  if ($getlocations_search_defaults['use_geolocation_button']) {
    $form['getlocations_search_geolocation_button_' . $mapid] = array(
      '#markup' => '',
    );
  }
  if ($getlocations_search_defaults['display_search_distance']) {
    $form['getlocations_search_distance_' . $mapid] = getlocations_element_search_distance($getlocations_search_defaults['search_distance'], t('Search distance'), t('The distance away from the center to search for locations.'));
  }
  else {
    $form['getlocations_search_distance_' . $mapid] = array(
      '#type' => 'hidden',
      '#value' => $getlocations_search_defaults['search_distance'],
      '#attributes' => array(
        'id' => 'edit-getlocations-search-distance-' . $mapid2,
      ),
    );
  }
  if ($getlocations_search_defaults['display_search_units']) {
    $form['getlocations_search_units_' . $mapid] = getlocations_element_distance_unit($getlocations_search_defaults['search_units'], t('Distance units'));
  }
  else {
    $form['getlocations_search_units_' . $mapid] = array(
      '#type' => 'hidden',
      '#value' => $getlocations_search_defaults['search_units'],
      '#attributes' => array(
        'id' => 'edit-getlocations-search-units-' . $mapid2,
      ),
    );
  }
  if ($getlocations_search_defaults['display_search_limits']) {
    $form['getlocations_search_limits_' . $mapid] = getlocations_element_map_limits($getlocations_search_defaults['search_limits']);
  }
  else {
    $form['getlocations_search_limits_' . $mapid] = array(
      '#type' => 'hidden',
      '#value' => $getlocations_search_defaults['search_limits'],
      '#attributes' => array(
        'id' => 'edit-getlocations-search-limits-' . $mapid2,
      ),
    );
  }
  $opts = getlocations_search_type_options();
  if ($getlocations_search_defaults['display_search_type'] && count($opts)) {
    $form['getlocations_search_type_' . $mapid] = array(
      '#type' => 'select',
      '#title' => t('Restrict the search'),
      '#options' => $opts,
      '#default_value' => $getlocations_search_defaults['search_type'],
      '#description' => t('Restrict the search to a content type'),
    );
  }
  else {
    $form['getlocations_search_type_' . $mapid] = array(
      '#type' => 'hidden',
      '#value' => $getlocations_search_defaults['search_type'],
      '#attributes' => array(
        'id' => 'edit-getlocations-search-type-' . $mapid2,
      ),
    );
  }
  if ($getlocations_search_defaults['restrict_by_country'] && $getlocations_search_defaults['country']) {
    $form['getlocations_search_country_' . $mapid] = array(
      '#markup' => $getlocations_search_defaults['country'],
    );
  }
  if ($getlocations_search_defaults['method'] != 'google_ac') {
    $form['getlocations_search_submit_' . $mapid] = array(
      '#type' => 'submit',
      '#value' => t('Go'),
    );
  }
  else {
    if ($getlocations_search_defaults['geocode_button_enable']) {

      // geocode button
      $form['getlocations_search_geocode_button_' . $mapid] = array(
        '#markup' => '',
      );
    }
  }
  if ($getlocations_search_defaults['reset_button_enable']) {

    // Reset button
    $form['getlocations_search_reset_button_' . $mapid] = array(
      '#markup' => '',
    );
  }
  return $form;
}