function location_cck_token_values in Location 6.3
Same name and namespace in other branches
- 7.5 contrib/location_cck/location_cck.module \location_cck_token_values()
- 7.4 contrib/location_cck/location_cck.module \location_cck_token_values()
Implementation of hook_token_values().
File
- contrib/
location_cck/ location_cck.module, line 492 - Defines location field type.
Code
function location_cck_token_values($type, $object = NULL) {
if ($type == 'field') {
$tokens = array();
$item = $object[0];
if ($item['lid']) {
// If the location exists, we need to set up the tokens.
$location = array(
// There is no way to find out which elements to hide because $item does not contain
// the 'location_settings' element, so for now, just set it to be an empty array.
// See http://drupal.org/node/463618 for more infomation.
'hide' => array(),
'location' => location_load_location($item['lid']),
);
// @@@ This is rather silly, but I can't think of anything better at the moment.
template_preprocess_location($location);
$fields = location_field_names(TRUE);
// @@@ We really need to rethink fields in location..
unset($fields['locpick']);
foreach ($fields as $k => $v) {
if (isset($location[$k])) {
$tokens[$k] = $location[$k];
}
else {
$tokens[$k] = '';
}
}
}
return $tokens;
}
}