A string representing the street location * 'additional' => A string for any additional portion of the street location * 'city' => A string for the city name * 'province' => The standard postal abbreviation for the province * 'country' => The two-letter ISO code for the country of the location (REQUIRED) * 'postal_code' => The international postal code for the location * * @return * A link to a map provided by a third-party. The idea is to encode the appropriate * parameters as HTTP GET variables to the URL. */ function location_map_link($location = array(), $link_text = 'See map: ') { if (!isset($location['country']) && $location['country'] != 'xx') { return ''; } $default_func = 'location_map_link_'. $location['country'] .'_default_providers'; $providers_func = 'location_map_link_'. $location['country'] .'_providers'; $providers = function_exists($providers_func) ? $providers_func() : array(); $selected_providers = variable_get('location_map_link_'. $location['country'], function_exists($default_func) ? $default_func() : array()); $links = array(); foreach ($selected_providers as $mapper) { $link_func = 'location_map_link_'. $location['country'] .'_'. $mapper; if (function_exists($link_func)) { if ($link = $link_func($location)) { $links[] = ''. $providers[$mapper]['name'] .''; } } } if (count($links)) { return t($link_text) . implode($links, ", "); } else { return NULL; } } function location_get_postalcode_data($location = array()) { $location['country'] = isset($location['country']) ? trim($location['country']) : NULL; $location['postal_code'] = isset($location['postal_code']) ? trim($location['postal_code']) : NULL; if (is_null($location['postal_code']) || is_null($location['country']) || empty($location['country']) || empty($location['postal_code']) || $location['postal_code'] == 'xx') { return NULL; } $country_specific_function = 'location_get_postalcode_data_'. $location['country']; if (function_exists($country_specific_function)) { return $country_specific_function($location); } else { return NULL; } } function _location_is_empty($location = array()) { $fields = array('street', 'additional', 'city', 'province', 'postal_code', 'country'); foreach ($fields as $field) { if (isset($location[$field]) && strlen(trim($location[$field]))) { return FALSE; } } return TRUE; } function theme_locations($locations = array(), $hide = array()) { $output = ''; foreach ($locations as $location) { $output .= theme('location', $location, $hide); } return $output; } /** * Generates HTML for the passed location. * * @param $location * An associative array where * 'street' => A string representing the street location * 'additional' => A string for any additional portion of the street location * 'city' => A string for the city name * 'province' => The standard postal abbreviation for the province * 'country' => The two-letter ISO code for the country of the location (REQUIRED) * 'postal_code' => The international postal code for the location * * @param $hide * An linear array where the values are the location fields to suppress in the themed display. * * @return * An HTML string with special tags for locations. */ function theme_location($location = array(), $hide = array()) { if (_location_nothing_to_show($location, $hide)) { return ''; } $output = ''; if (isset($location['country']) && ($f = theme_get_function('location_'. $location['country']))) { $output .= call_user_func($f, $location, $hide); } elseif (count($location)) { $output .= "\n"; $output .= '