You are here

function getlocations_fields_handler_filter_distance::exposed_form in Get Locations 7.2

Same name and namespace in other branches
  1. 7 modules/getlocations_fields/handlers/getlocations_fields_handler_filter_distance.inc \getlocations_fields_handler_filter_distance::exposed_form()

Render our chunk of the exposed filter form when selecting.

You can override this if it doesn't do what you expect.

Overrides views_handler_filter::exposed_form

File

modules/getlocations_fields/handlers/getlocations_fields_handler_filter_distance.inc, line 234
getlocations_fields_handler_filter_distance.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Class

getlocations_fields_handler_filter_distance
General proximity filter for location latitude/longitude.

Code

function exposed_form(&$form, &$form_state) {
  parent::exposed_form($form, $form_state);
  $key = $this->options['expose']['identifier'];
  $origin = $this->options['origin'];

  // Strip dependencies off on exposed form.
  foreach (element_children($form[$key]) as $el) {
    if (!empty($form[$key][$el]['#dependency'])) {
      $form[$key][$el]['#dependency'] = array();
    }
  }

  // unset anything not needed on exposed form
  if ($origin != 'search') {
    unset($form[$key]['latitude']);
    unset($form[$key]['longitude']);
  }
  unset($form[$key]['php_code']);
  unset($form[$key]['nid_arg']);
  unset($form[$key]['nid_loc_field']);
  unset($form[$key]['uid_arg']);
  unset($form[$key]['uid_loc_field']);
  unset($form[$key]['tid_arg']);
  unset($form[$key]['tid_loc_field']);
  unset($form[$key]['cid_arg']);
  unset($form[$key]['cid_loc_field']);
  unset($form['origin']);
  if (isset($this->options['settings']['display_search_distance'])) {
    if (!$this->options['settings']['display_search_distance']) {
      $def = $form[$key]['search_distance']['#default_value'];
      unset($form[$key]['search_distance']);
      $form[$key]['search_distance'] = array(
        '#type' => 'value',
        '#value' => $def,
      );
    }
    else {
      if (!$this->options['settings']['display_search_units']) {
        $def = $form[$key]['search_units']['#default_value'];
        $form[$key]['search_distance']['#field_suffix'] = getlocations_get_unit_names($def, 'plurals');
      }
    }
  }
  if (isset($this->options['settings']['display_search_units'])) {
    if (!$this->options['settings']['display_search_units']) {
      $def = $form[$key]['search_units']['#default_value'];
      unset($form[$key]['search_units']);
      $form[$key]['search_units'] = array(
        '#type' => 'value',
        '#value' => $def,
      );
    }
  }
  unset($form['settings']);
}