function name_token_info in Name Field 7
Implements hook_token_info().
File
- ./
name.tokens.inc, line 11 - Builds placeholder replacement tokens for country-related data.
Code
function name_token_info() {
// Start depreciated tokens. These only work if given a name object.
$types['name'] = array(
'name' => t('Name (depreciated)'),
'description' => t('Raw name component tokens. (depreciated)'),
'needs-data' => 'name',
);
$old_tokens['default'] = array(
'name' => t('Name (depreciated)'),
'description' => t('Full default formatted name. Do not use, depreciated!'),
);
foreach (name_get_custom_format_options() as $machine_name => $formatter_title) {
$old_tokens['formatter-' . $machine_name] = array(
'name' => t('Name: %formatter formatted (depreciated)', array(
'%formatter' => $formatter_title,
)),
'description' => t('Name using the %formatter formatter.', array(
'%formatter' => $formatter_title,
)),
);
}
foreach (_name_translations() as $component => $component_label) {
$old_tokens['component-' . $component] = array(
'name' => t('Name component: %component (depreciated)', array(
'%component' => $component_label,
)),
'description' => t('The %component component of the name.', array(
'%component' => $component_label,
)),
);
}
// End depreciated tokens.
//
// The basic generic user real name token.
$user_tokens['realname'] = array(
'name' => t('Real name'),
'description' => t('The real name of the user account, from the RealName or Name modules.'),
);
// New field integration.
$types['name-field'] = array(
'name' => t('Name field values'),
'description' => t('Name field in the default format.'),
'needs-data' => 'name-field',
);
foreach (name_get_custom_format_options() as $machine_name => $formatter_title) {
$tokens['formatter-' . $machine_name] = array(
'name' => t('Formatted name: %formatter', array(
'%formatter' => $formatter_title,
)),
'description' => t('Uses the %formatter format.', array(
'%formatter' => $formatter_title,
)),
);
}
foreach (_name_translations() as $component => $component_label) {
$tokens['component-' . $component] = array(
'name' => t('Component: %component', array(
'%component' => $component_label,
)),
'description' => t('The name component %component.', array(
'%component' => $component_label,
)),
);
}
$token_info = array(
'types' => $types,
'tokens' => array(
'name' => $old_tokens,
'name-field' => $tokens,
'user' => $user_tokens,
),
);
foreach (name_token_types_chained(NULL, TRUE) as $token_type => $tokens) {
$token_info['tokens'][$token_type] = $tokens;
}
return $token_info;
}