You are here

function ip_geoloc_set_location_form in IP Geolocation Views & Maps 7

Form for finding the visitor or going to a region or street address.

1 string reference to 'ip_geoloc_set_location_form'
ip_geoloc_block_view in ./ip_geoloc_blocks.inc
Implements hook_block_view().

File

./ip_geoloc_blocks.inc, line 466
Blocks available in IP Geolocation Views & Maps.

Code

function ip_geoloc_set_location_form($form, &$form_state) {
  $has_find_visitor = variable_get('ip_geoloc_visitor_find', TRUE);
  $is_address_editable = variable_get('ip_geoloc_visitor_address_editable', TRUE);
  $geo_vocabulary_id = variable_get('ip_geoloc_geo_vocabulary_id', 0);
  if (!$has_find_visitor && !$is_address_editable && !$geo_vocabulary_id) {
    drupal_set_message(t('You should select at least one of the three widgets available for the "Set my location" block.'), 'error');
    return $form;
  }
  $location = ip_geoloc_get_visitor_location();
  $form['#attributes']['id'] = $ajax_wrapper_id = drupal_html_id('set-location-form');
  if ($has_find_visitor) {
    _ip_geoloc_set_my_location_add_find_me($form, $ajax_wrapper_id);
  }
  $options = _ip_geoloc_set_my_location_add_selector($form, $location, $is_address_editable, $geo_vocabulary_id);
  $is_reverse_geocode = $has_find_visitor && variable_get('ip_geoloc_visitor_reverse_geocode', TRUE);
  if ($is_reverse_geocode || $is_address_editable) {
    _ip_geoloc_set_my_location_add_address($form, $location);
  }
  if ($geo_vocabulary_id) {
    _ip_geoloc_set_my_location_add_region($form, $location, $geo_vocabulary_id);
  }
  _ip_geoloc_set_my_location_add_logic($form, $location, $options, $is_address_editable, $geo_vocabulary_id);
  if ($is_address_editable || $geo_vocabulary_id) {
    $form['submit_address'] = array(
      '#type' => 'submit',
      '#value' => t('Go'),
      '#submit' => array(
        '_ip_geoloc_process_go_to_submit',
      ),
      '#weight' => 15,
    );
  }
  $form['#attributes']['class'][] = 'ip-geoloc-address';
  $form['#attached']['css'][] = drupal_get_path('module', 'ip_geoloc') . '/css/ip_geoloc_all.css';
  return $form;
}