function getlocations_fields_handler_field_distance::query in Get Locations 7
Same name and namespace in other branches
- 7.2 modules/getlocations_fields/handlers/getlocations_fields_handler_field_distance.inc \getlocations_fields_handler_field_distance::query()
Called to add the field to a query.
Overrides views_handler_field::query
File
- modules/
getlocations_fields/ handlers/ getlocations_fields_handler_field_distance.inc, line 94 - getlocations_fields_handler_field_distance.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Class
- getlocations_fields_handler_field_distance
- @file getlocations_fields_handler_field_distance.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function query() {
// Google Autocomplete data needs to be transferred to options
if ($this->options['origin'] == 'search' && isset($this->view->exposed_data['distance']) && $this->view->exposed_data['distance']['latitude'] && $this->view->exposed_data['distance']['longitude']) {
$this->options['latitude'] = $this->view->exposed_data['distance']['latitude'];
$this->options['longitude'] = $this->view->exposed_data['distance']['longitude'];
// not sure about this, it attempts to sync distance units, seems to work.
$this->options['units'] = $this->view->exposed_data['distance']['search_units'];
}
$coordinates = getlocations_fields_views_proximity_get_reference_location($this->view, $this->options);
$this
->ensure_my_table();
if (!empty($coordinates) && $coordinates['latitude'] && $coordinates['longitude']) {
$this->field_alias = $this->query
->add_field(NULL, getlocations_earth_distance_sql($coordinates['latitude'], $coordinates['longitude'], $this->table_alias), $this->table_alias . '_' . $this->field);
}
#else {
# $this->field_alias = $this->query->add_field(NULL, "'Unknown'", $this->table_alias . '_' . $this->field);
#}
}