Index: location.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/location/location.module,v retrieving revision 1.79.2.12 diff -u -p -r1.79.2.12 location.module --- location.module 23 Aug 2007 01:09:16 -0000 1.79.2.12 +++ location.module 13 Sep 2007 15:06:41 -0000 @@ -1567,3 +1567,48 @@ function location_invoke_locationapi(&$l } return $return; } + +/** + * Implementation of hook_token_list to list out the tokens provided by location + */ +function location_token_list($type = 'all') { + if ($type == 'node' || $type == 'all') { + $tokens['node']['countrycode'] = t("Two Letter Country Code."); + $tokens['node']['countryname'] = t("Complete country name."); + $tokens['node']['city'] = t("City"); + $tokens['node']['province'] = t("Province"); + $tokens['node']['postal_code'] = t("Postal Code"); + $tokens['node']['lat'] = t("Latitude"); + $tokens['node']['lon'] = t("Longitude"); + return $tokens; + } +} + +/* + * Implementation of hook_token_values() + */ +function location_token_values($type, $object = NULL) { + if ($type == 'node') { + if (isset($node->location)) { + $countries = _location_get_iso3166_list(); + $tokens['countrycode'] = check_plain($object->location['country']); + $tokens['countryname'] = check_plain($countries[$object->location['country']]); + $tokens['city'] = check_plain($object->location['city']); + $tokens['province'] = check_plain($object->location['province']); + $tokens['postal_code'] = check_plain($object->location['postal_code']); + $tokens['lat'] = $object->location['lat']; + $tokens['lon'] = $object->location['lon']; + } + else { + $tokens['countrycode'] = ''; + $tokens['countryname'] = ''; + $tokens['city'] = ''; + $tokens['province'] = ''; + $tokens['postal_code'] = ''; + $tokens['lat'] = ''; + $tokens['lon'] = ''; + } + + return $tokens; + } +} \ No newline at end of file