(.*)<\/code>/', $http_reply->data, $status_code_match); $status_code = $status_code_match[1]; if ($status_code != 200) { return NULL; } $accuracy_code_match = array(); preg_match('/Accuracy="([0-9])"/', $http_reply->data, $accuracy_code_match); $accuracy_code = $accuracy_code_match[1]; if (!in_array($accuracy_code, $accuracies)) { return NULL; } $latlon_match = array(); preg_match('/(.*)<\/coordinates>/', $http_reply->data, $latlon_match); $latlon_exploded = explode(',', $latlon_match[1]); return array('lat' => $latlon_exploded[1], 'lon' => $latlon_exploded[0]); } function location_geocode_google_settings($cc = NULL) { $form = array(); $api_key_name = $cc ? 'location_geocode_'.$cc.'_google_apikey' : 'location_geocode_google_apikey'; $form[$api_key_name] = array( '#type' => 'textfield', '#title' => t('Google Maps API Key'), '#size' => 64, '#maxlength' => 128, '#default_value' => location_geocode_google_apikey($cc), '#description' => t('In order to use the Google Maps API geocoding web-service, you will need a Google Maps API Key. You can obtain one at the !sign_up_link for the !google_maps_api.', array('!sign_up_link' => 'sign-up page', '!google_maps_api' => 'Google Maps API')) ); return $form; } function location_geocode_google_apikey($cc = NULL) { if ($cc) $keynames[] = 'location_geocode_'.$cc.'_google_apikey'; $keynames[] = 'location_geocode_google_apikey'; if (module_exists('gmap')) $keynames[] = 'googlemap_api_key'; foreach ($keynames as $kname) { $apikey = variable_get($kname, NULL); if ($apikey) return $apikey; } return NULL; }