function ip_geoloc_block_view in IP Geolocation Views & Maps 7
Implements hook_block_view().
File
- ./
ip_geoloc_blocks.inc, line 357 - Blocks available in IP Geolocation Views & Maps.
Code
function ip_geoloc_block_view($delta = '') {
$block = array();
$map_style = variable_get('ip_geoloc_' . $delta . '_div_style', IP_GEOLOC_MAP_DIV_DEFAULT_STYLE);
switch ($delta) {
case 'geocode_address':
$block['subject'] = t('Set my location');
$block['content'] = drupal_get_form('ip_geoloc_set_location_form');
break;
case 'current_visitor_map':
$block['subject'] = t('Your location');
$map_options = variable_get('ip_geoloc_current_visitor_map_options', IP_GEOLOC_CURRENT_VISITOR_MAP_OPTIONS);
$location = ip_geoloc_get_visitor_location();
$block['content'] = theme(array(
'ip_geoloc_map_current_visitor',
), array(
'div_id' => 'ip-geoloc-block-current-visitor-map',
'map_options' => $map_options,
'map_style' => $map_style,
// Lat,Lon NULL values will instigate HTML5 position retrieval. The
// user will be prompted by the browser to give permission.
'latitude' => isset($location['latitude']) ? (double) $location['latitude'] : (empty($location['fixed_address']) ? NULL : 0.0),
'longitude' => isset($location['longitude']) ? (double) $location['longitude'] : (empty($location['fixed_address']) ? NULL : 0.0),
'info_text' => isset($location['formatted_address']) ? $location['formatted_address'] : NULL,
));
break;
case 'recent_visitors_map':
$block['subject'] = t('Recent visitors');
$how_many = variable_get('ip_geoloc_recent_visitors_map_number_of_visitors', 20);
if ($how_many > 0) {
$locations = ip_geoloc_get_recent_visitor_locations($how_many);
$map_options = variable_get('ip_geoloc_recent_visitors_map_options', IP_GEOLOC_RECENT_VISITORS_MAP_OPTIONS);
$block['content'] = theme(array(
'ip_geoloc_visitor_map',
), array(
'locations' => $locations,
'div_id' => 'ip-geoloc-block-recent-visitors-map',
'map_options' => $map_options,
'map_style' => $map_style,
));
}
break;
case 'address_lookup':
$block['subject'] = t('Global IP address lookup');
$block['content'] = drupal_get_form('ip_geoloc_ip_lookup_form');
break;
}
return $block;
}