You are here

public function ip_geoloc_plugin_argument_default_ip_geoloc::get_argument in IP Geolocation Views & Maps 7

Return the default argument.

This needs to be overridden by every default argument handler to properly do what is needed.

Overrides views_plugin_argument_default::get_argument

File

views/ip_geoloc_plugin_argument_default_ip_geoloc.inc, line 34
views/ip_geoloc_plugin_argument_default_ip_geoloc.inc

Class

ip_geoloc_plugin_argument_default_ip_geoloc
Default argument plugin to inject attributes from the visitor's location.

Code

public function get_argument() {
  $location = ip_geoloc_get_visitor_location();
  if (!empty($location)) {
    switch ($this->options['type']) {
      case 'postal_code':
        return isset($location['postal_code']) ? $location['postal_code'] : '';
      case 'city_state':
        return isset($location['city']) && isset($location['region']) ? $location['city'] . ', ' . $location['region'] : '';
      case 'country':
        return isset($location['country']) ? $location['country'] : '';
      case 'lat_long':
        return isset($location['latitude']) && isset($location['longitude']) ? $location['latitude'] . ',' . $location['longitude'] : '';
      case 'formatted_address':
        return isset($location['formatted_address']) ? $location['formatted_address'] : '';
    }
  }
  return NULL;
}