function template_preprocess_location in Location 6.3
Same name and namespace in other branches
- 5.3 location.module \template_preprocess_location()
- 7.5 location.module \template_preprocess_location()
- 7.3 location.module \template_preprocess_location()
- 7.4 location.module \template_preprocess_location()
Theme preprocess function for a location.
1 call to template_preprocess_location()
- location_cck_token_values in contrib/
location_cck/ location_cck.module - Implementation of hook_token_values().
File
- ./
location.module, line 1569 - Location module main routines. An implementation of a universal API for location manipulation. Provides functions for postal_code proximity searching, deep-linking into online mapping services. Currently, some options are configured through an…
Code
function template_preprocess_location(&$variables) {
$location = $variables['location'];
// This will get taken back out if map links are hidden.
$location['map_link'] = TRUE;
if (is_array($variables['hide'])) {
foreach ($variables['hide'] as $key) {
unset($location[$key]);
// Special case for coords.
if ($key == 'coords') {
unset($location['latitude']);
unset($location['longitude']);
}
}
}
$fields = location_field_names(TRUE);
if (is_array($fields)) {
foreach ($fields as $key => $value) {
$variables[$key] = '';
// Arrays can't be converted, ignore them.
if (!empty($location[$key]) && !is_array($location[$key])) {
$variables[$key] = check_plain($location[$key]);
}
}
}
// Map link.
$variables['map_link'] = '';
if (!empty($location['map_link'])) {
// Do not use $location for generating the map link, since it will
// not contain the country if that field is hidden.
$variables['map_link'] = location_map_link($variables['location']);
}
// Theme latitude and longitude as d/m/s.
$variables['latitude'] = '';
$variables['latitude_dms'] = '';
if (!empty($location['latitude'])) {
$variables['latitude'] = check_plain($location['latitude']);
$variables['latitude_dms'] = theme('location_latitude_dms', $location['latitude']);
}
$variables['longitude'] = '';
$variables['longitude_dms'] = '';
if (!empty($location['longitude'])) {
$variables['longitude'] = check_plain($location['longitude']);
$variables['longitude_dms'] = theme('location_longitude_dms', $location['longitude']);
}
// Add a country-specific template suggestion.
if (!empty($location['country']) && location_standardize_country_code($location['country'])) {
// $location['country'] is normalized in the previous line.
$variables['template_files'][] = 'location-' . $location['country'];
}
// Display either the code or the full name for the province.
if (!isset($location['province'])) {
$location['province'] = '';
}
if (!isset($location['province_name'])) {
$location['province_name'] = '';
}
$variables['province_print'] = variable_get('location_use_province_abbreviation', 1) ? isset($location['province']) ? $location['province'] : '' : (isset($location['province_name']) ? $location['province_name'] : '');
}