function device_geolocation_form_alter in Smart IP 6.2
Same name and namespace in other branches
- 6 modules/device_geolocation/device_geolocation.module \device_geolocation_form_alter()
- 7.2 modules/device_geolocation/device_geolocation.module \device_geolocation_form_alter()
- 7 modules/device_geolocation/device_geolocation.module \device_geolocation_form_alter()
Implements hook_form_alter()
File
- modules/
device_geolocation/ device_geolocation.module, line 146 - Provides visitor's geographical location using client device location source that implements W3C Geolocation API and Google Geocoding service.
Code
function device_geolocation_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'smart_ip_admin_settings') {
// Container for Device Geolocation preference forms
$form['device_geolocation_preferences'] = array(
'#type' => 'fieldset',
'#title' => t('Device Geolocation settings'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'#weight' => 4,
);
$form['device_geolocation_preferences']['device_geolocation_ajax_check'] = array(
'#type' => 'checkbox',
'#title' => t("Use AJAX in user's geolocation checking (useful if the site or pages listed above are cached)"),
'#default_value' => variable_get('device_geolocation_ajax_check', FALSE),
);
$device_geolocation_check_frequency = variable_get('device_geolocation_check_frequency', NULL);
$form['device_geolocation_preferences']['device_geolocation_check_frequency'] = array(
'#title' => t("Frequency of user's geolocation checking"),
'#type' => 'textfield',
'#size' => 10,
'#description' => t('Specify number of hours will prompt the user for geolocation. Leave it empty to disable.'),
'#default_value' => $device_geolocation_check_frequency === NULL ? '' : $device_geolocation_check_frequency / 3600,
'#field_suffix' => t('hours'),
);
$form['device_geolocation_preferences']['device_geolocation_google_map_api'] = array(
'#title' => t('Google map API key'),
'#type' => 'textfield',
'#description' => t('The use of Google map service requires API key. Get your API key !here.', array(
'!here' => l(t('here'), 'https://developers.google.com/maps/documentation/javascript/get-api-key'),
)),
'#default_value' => variable_get('device_geolocation_google_map_api', NULL),
);
$form['device_geolocation_preferences']['device_geolocation_google_map_region'] = array(
'#type' => 'textfield',
'#title' => t('Google map region'),
'#default_value' => variable_get('device_geolocation_google_map_region', NULL),
'#description' => t("Specify a region code, which alters the Google map service's behavior based on a given country or territory. See !google_localization_region", array(
'!google_localization_region' => l(t('Google Maps API - Localizing the Map (Region localization)'), 'https://developers.google.com/maps/documentation/javascript/localization#Region'),
)),
);
$form['device_geolocation_preferences']['device_geolocation_google_map_language'] = array(
'#type' => 'textfield',
'#title' => t('Google map language'),
'#default_value' => variable_get('device_geolocation_google_map_language', NULL),
'#description' => t('Change the Google map service default language settings. See !google_localization_language', array(
'!google_localization_language' => l(t('Google Maps API - Localizing the Map (Language localization)'), 'https://developers.google.com/maps/documentation/javascript/localization#Language'),
)),
);
$form['#validate'][] = '_device_geolocation_check_frequency_validate';
}
}