You are here

function location_address2singleline in Location 5

Same name and namespace in other branches
  1. 5.3 location.inc \location_address2singleline()
  2. 6.3 location.inc \location_address2singleline()
  3. 7.5 location.inc \location_address2singleline()
  4. 7.3 location.inc \location_address2singleline()
  5. 7.4 location.inc \location_address2singleline()
3 calls to location_address2singleline()
google_geocode_location in geocoding/google.inc
location_geocode_ca_geocoder in supported/location.ca.inc
This needs some more work to cover errors and such. I think showing a proper Drupal error is a good idea. If an incorrect address is given to geocoder.ca it offers a suggestion. If this happens the drupal user should be told.
location_geocode_us_yahoo in supported/location.us.inc

File

./location.inc, line 1314

Code

function location_address2singleline($location = array()) {
  $address = '';
  if (!empty($location['street'])) {
    $address .= $location['street'];
  }
  if (!empty($location['city'])) {
    if (!empty($location['street'])) {
      $address .= ', ';
    }
    $address .= $location['city'];
  }
  if (!empty($location['province'])) {
    if (!empty($location['street']) || !empty($location['city'])) {
      $address .= ', ';
    }
    $address .= $location['province'];
  }
  if (!empty($location['postal_code'])) {
    if (!empty($address)) {
      $address .= ' ';
    }
    $address .= $location['postal_code'];
  }
  if (!empty($location['country'])) {
    $address .= ', ' . $location['country'];
  }
  return $address;
}