ip_geoloc.inc in IP Geolocation Views & Maps 8
File
plugins/contexts/ip_geoloc.inc
View source
<?php
$plugin = [
'title' => t('IP geolocation'),
'description' => t('The geolocation information for the current user'),
'context' => 'ip_geoloc_ip_geoloc_context',
'keyword' => 'ip_geoloc',
'context name' => 'ip_geoloc',
'convert list' => 'ip_geoloc_ip_geoloc_context_convert_list',
'convert' => 'ip_geoloc_ip_geoloc_context_convert',
];
function ip_geoloc_ip_geoloc_context($empty, $data = NULL, $conf = FALSE) {
$context = new ctools_context('ip_geoloc');
$context->plugin = 'ip_geoloc';
if ($empty) {
return $context;
}
$context->data = _ip_geoloc_get_session_value();
return $context;
}
function ip_geoloc_ip_geoloc_context_convert_list() {
return [
'provider' => t('Provider'),
'ip_address' => t('IP Address'),
'latitude' => t('Latitude'),
'longitude' => t('Longitude'),
'accuracy' => t('Accuracy'),
'formatted_address' => t('Formatted Address'),
'street_number' => t('Street Number'),
'route' => t('Route'),
'locality' => t('Locality'),
'administrative_area_level_1' => t('Administrative Area Level 1'),
'administrative_area_level_2' => t('Administrative Area Level 2'),
'country' => t('Country'),
'country_code' => t('Country Code'),
'postal_code' => t('Postal Code'),
];
}
function ip_geoloc_ip_geoloc_context_convert($context, $type) {
if ($context->data) {
return $context->data['location'][$type];
}
return NULL;
}