Skip to content
Snippets Groups Projects
Commit b5a52828 authored by Brandon Bergren's avatar Brandon Bergren
Browse files

Fix #676108. Original patch by greenSkin, heavily modified by me to hopefully...

Fix #676108. Original patch by greenSkin, heavily modified by me to hopefully maximize compatibility.

In theory, this should work in both keys_api and keys now.
(cherry picked from commit 2831abcbe55a2b60dbeaeb52e895d0877ef20615)
parent 12c2c5af
No related branches found
No related tags found
No related merge requests found
...@@ -1164,12 +1164,37 @@ function gmap_simple_map($latitude, $longitude, $markername = '', $info = '', $z ...@@ -1164,12 +1164,37 @@ function gmap_simple_map($latitude, $longitude, $markername = '', $info = '', $z
* Implementation of hook_keys_service(). (from the keys api) * Implementation of hook_keys_service(). (from the keys api)
*/ */
function gmap_keys_service() { function gmap_keys_service() {
return array( // @@@ Remove after everyone has upgraded.
'gmap' => array( if (module_exists('keys_api')) {
'name' => t('Gmap'), return array(
'description' => t('Google Maps API Key'), 'gmap' => array(
), 'name' => t('Gmap'),
); 'description' => t('Google Maps API Key'),
),
);
}
elseif (module_exists('keys')) {
// @greenSkin:
// What is your reasoning behind predefining this?
// I'll avoid overriding you for now, but this seems rather arbitrary.
// Reference: http://drupal.org/cvs?commit=310498
// Probe keys to determine if it is defining our key for us.
$test = array();
if (function_exists('keys_keys_service')) {
$test = keys_keys_service();
}
if (!isset($test['google_maps'])) {
// Be forward compatible with future versions of keys api
// that no longer define it.
return array(
'google_maps' => array(
'name' => t('Google Maps'),
'description' => t('Google Maps API Key'),
),
);
}
}
} }
/** /**
...@@ -1180,6 +1205,9 @@ function gmap_get_key() { ...@@ -1180,6 +1205,9 @@ function gmap_get_key() {
if (module_exists('keys_api')) { if (module_exists('keys_api')) {
$key = keys_api_get_key('gmap', $_SERVER['HTTP_HOST']); $key = keys_api_get_key('gmap', $_SERVER['HTTP_HOST']);
} }
elseif (module_exists('keys')) {
$key = keys_get_key('google_maps');
}
return $key; return $key;
} }
......
...@@ -17,25 +17,26 @@ function gmap_admin_settings(&$form_state) { ...@@ -17,25 +17,26 @@ function gmap_admin_settings(&$form_state) {
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => t('Google Map Initialize'), '#title' => t('Google Map Initialize'),
); );
if (!module_exists('keys_api')) {
if (!module_exists('keys_api') && !module_exists('keys')) {
$form['initialization']['googlemap_api_key'] = array( $form['initialization']['googlemap_api_key'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Google Maps API Key'),
'#default_value' => variable_get('googlemap_api_key', ''), '#default_value' => variable_get('googlemap_api_key', ''),
'#size' => 50, '#size' => 50,
'#maxlength' => 255, '#maxlength' => 255,
'#description' => t('Your personal Googlemaps API key. You must get this for each separate website at <a href="http://www.google.com/apis/maps/">Google Map API website</a>.'),
); );
} }
else { else {
$form['initialization']['googlemap_api_key'] = array( $form['initialization']['googlemap_api_key'] = array(
'#type' => 'item', '#type' => 'item',
'#title' => t('Google Maps API Key'), '#title' => t('Google Maps API Key'),
'#description' => t('Your personal Googlemaps API key. You must get this for each separate website at <a href="http://www.google.com/apis/maps/">Google Map API website</a>.'), '#value' => t('Managed by <a href="@url">Keys</a>.', array('@url' => url('admin/settings/keys'))),
'#value' => t("Managed by <a href='@url'>keys api</a>.", array('@url' => url('admin/settings/keys'))),
); );
} }
$form['initialization']['googlemap_api_key']['#title'] = t('Google Maps API Key');
$form['initialization']['googlemap_api_key']['#description'] = t('Your personal Googlemaps API key. You must get this for each separate website at <a href="http://www.google.com/apis/maps/">Google Map API website</a>.');
if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) != FILE_DOWNLOADS_PUBLIC) { if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) != FILE_DOWNLOADS_PUBLIC) {
$form['initialization']['gmap_private_markerfile'] = array( $form['initialization']['gmap_private_markerfile'] = array(
'#type' => 'textfield', '#type' => 'textfield',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment