You are here

function geofield_handler_argument_proximity::parseArg in Geofield 7.2

1 call to geofield_handler_argument_proximity::parseArg()
geofield_handler_argument_proximity::query in views/handlers/geofield_handler_argument_proximity.inc
Set up the where clause for the contextual filter argument.

File

views/handlers/geofield_handler_argument_proximity.inc, line 97
Geofield contextual filter argument handler for Views.

Class

geofield_handler_argument_proximity
The proximity argument may be appended to URL in the following format: /lat,lon_dist where dist is a positive number representing a circular proximity in either kilometers or miles, as configured through the contextual filter UI.

Code

function parseArg($argument) {

  // Get and process args. Expect and parse this format: "lat,lon dist".
  if (!empty($this->view->args) && ($lat_lon_dist = $this
    ->parseLatLonDistArg($this->view->args[$argument->position]))) {

    // Found lat, lon and dist. Can proceed with haversine formula.
    return $lat_lon_dist;
  }

  // The filter argument cannot be parsed as a lat,lon_dist string.
  // Reinterpret this and all trailing arguments as an address of sorts.
  // Examples:
  // "/Sydney/Opera House" or "/sydney opera house"
  // "/Portland" (defaults to "/Portland, Oregon")
  // "/Indiana/Portland" or "/IN/Portland"  or "/Portland IN"
  // Ignore all args up to the one that belongs to this contextual filter.
  $args = array_slice(arg(), $argument->position + 1);
  return $this
    ->parseAddress($args);

  // may return FALSE
}