function token_token_info in Token 7
Same name and namespace in other branches
- 8 token.tokens.inc \token_token_info()
Implements hook_token_info().
File
- ./
token.tokens.inc, line 94 - Token callbacks for the token module.
Code
function token_token_info() {
// Node tokens.
$info['tokens']['node']['source'] = array(
'name' => t('Translation source node'),
'description' => t("The source node for this current node's translation set."),
'type' => 'node',
);
$info['tokens']['node']['log'] = array(
'name' => t('Revision log message'),
'description' => t('The explanation of the most recent changes made to the node.'),
);
$info['tokens']['node']['content-type'] = array(
'name' => t('Content type'),
'description' => t('The content type of the node.'),
'type' => 'content-type',
);
// Content type tokens.
$info['types']['content-type'] = array(
'name' => t('Content types'),
'description' => t('Tokens related to content types.'),
'needs-data' => 'node_type',
);
$info['tokens']['content-type']['name'] = array(
'name' => t('Name'),
'description' => t('The name of the content type.'),
);
$info['tokens']['content-type']['machine-name'] = array(
'name' => t('Machine-readable name'),
'description' => t('The unique machine-readable name of the content type.'),
);
$info['tokens']['content-type']['description'] = array(
'name' => t('Description'),
'description' => t('The optional description of the content type.'),
);
$info['tokens']['content-type']['node-count'] = array(
'name' => t('Node count'),
'description' => t('The number of nodes belonging to the content type.'),
);
$info['tokens']['content-type']['edit-url'] = array(
'name' => t('Edit URL'),
'description' => t("The URL of the content type's edit page."),
);
// Taxonomy term and vocabulary tokens.
if (module_exists('taxonomy')) {
$info['tokens']['term']['edit-url'] = array(
'name' => t('Edit URL'),
'description' => t("The URL of the taxonomy term's edit page."),
);
$info['tokens']['term']['parents'] = array(
'name' => t('Parents'),
'description' => t("An array of all the term's parents, starting with the root."),
'type' => 'array',
);
$info['tokens']['term']['root'] = array(
'name' => t('Root term'),
'description' => t("The root term of the taxonomy term."),
'type' => 'term',
);
$info['tokens']['vocabulary']['machine-name'] = array(
'name' => t('Machine-readable name'),
'description' => t('The unique machine-readable name of the vocabulary.'),
);
$info['tokens']['vocabulary']['edit-url'] = array(
'name' => t('Edit URL'),
'description' => t("The URL of the vocabulary's edit page."),
);
}
// File tokens.
$info['tokens']['file']['basename'] = array(
'name' => t('Base name'),
'description' => t('The base name of the file.'),
);
$info['tokens']['file']['extension'] = array(
'name' => t('Extension'),
'description' => t('The extension of the file.'),
);
$info['tokens']['file']['size-raw'] = array(
'name' => t('File byte size'),
'description' => t('The size of the file, in bytes.'),
);
// User tokens.
// Add information on the restricted user tokens.
$info['tokens']['user']['cancel-url'] = array(
'name' => t('Account cancellation URL'),
'description' => t('The URL of the confirm delete page for the user account.'),
'restricted' => TRUE,
);
$info['tokens']['user']['one-time-login-url'] = array(
'name' => t('One-time login URL'),
'description' => t('The URL of the one-time login page for the user account.'),
'restricted' => TRUE,
);
if (variable_get('user_pictures', 0)) {
$info['tokens']['user']['picture'] = array(
'name' => t('Picture'),
'description' => t('The picture of the user.'),
'type' => 'file',
);
}
$info['tokens']['user']['roles'] = array(
'name' => t('Roles'),
'description' => t('The user roles associated with the user account.'),
'type' => 'array',
);
// Current user tokens.
$info['tokens']['current-user']['ip-address'] = array(
'name' => t('IP address'),
'description' => 'The IP address of the current user.',
);
// Menu link tokens (work regardless if menu module is enabled or not).
$info['types']['menu-link'] = array(
'name' => t('Menu links'),
'description' => t('Tokens related to menu links.'),
'needs-data' => 'menu-link',
);
$info['tokens']['menu-link']['mlid'] = array(
'name' => t('Link ID'),
'description' => t('The unique ID of the menu link.'),
);
$info['tokens']['menu-link']['title'] = array(
'name' => t('Title'),
'description' => t('The title of the menu link.'),
);
$info['tokens']['menu-link']['url'] = array(
'name' => t('URL'),
'description' => t('The URL of the menu link.'),
'type' => 'url',
);
$info['tokens']['menu-link']['parent'] = array(
'name' => t('Parent'),
'description' => t("The menu link's parent."),
'type' => 'menu-link',
);
$info['tokens']['menu-link']['parents'] = array(
'name' => t('Parents'),
'description' => t("An array of all the menu link's parents, starting with the root."),
'type' => 'array',
);
$info['tokens']['menu-link']['root'] = array(
'name' => t('Root'),
'description' => t("The menu link's root."),
'type' => 'menu-link',
);
// Current page tokens.
$info['types']['current-page'] = array(
'name' => t('Current page'),
'description' => t('Tokens related to the current page request.'),
);
$info['tokens']['current-page']['title'] = array(
'name' => t('Title'),
'description' => t('The title of the current page.'),
);
$info['tokens']['current-page']['url'] = array(
'name' => t('URL'),
'description' => t('The URL of the current page.'),
'type' => 'url',
);
$info['tokens']['current-page']['page-number'] = array(
'name' => t('Page number'),
'description' => t('The page number of the current page when viewing paged lists.'),
);
$info['tokens']['current-page']['query'] = array(
'name' => t('Query string value'),
'description' => t('The value of a specific query string field of the current page.'),
'dynamic' => TRUE,
);
// URL tokens.
$info['types']['url'] = array(
'name' => t('URL'),
'description' => t('Tokens related to URLs.'),
'needs-data' => 'path',
);
$info['tokens']['url']['path'] = array(
'name' => t('Path'),
'description' => t('The path component of the URL.'),
);
$info['tokens']['url']['relative'] = array(
'name' => t('Relative URL'),
'description' => t('The relative URL.'),
);
$info['tokens']['url']['absolute'] = array(
'name' => t('Absolute URL'),
'description' => t('The absolute URL.'),
);
$info['tokens']['url']['brief'] = array(
'name' => t('Brief URL'),
'description' => t('The URL without the protocol and trailing backslash.'),
);
$info['tokens']['url']['unaliased'] = array(
'name' => t('Unaliased URL'),
'description' => t('The unaliased URL.'),
'type' => 'url',
);
$info['tokens']['url']['args'] = array(
'name' => t('Arguments'),
'description' => t("The specific argument of the current page (e.g. 'arg:1' on the page 'node/1' returns '1')."),
'type' => 'array',
);
// Array tokens.
$info['types']['array'] = array(
'name' => t('Array'),
'description' => t('Tokens related to arrays of strings.'),
'needs-data' => 'array',
);
$info['tokens']['array']['first'] = array(
'name' => t('First'),
'description' => t('The first element of the array.'),
);
$info['tokens']['array']['last'] = array(
'name' => t('Last'),
'description' => t('The last element of the array.'),
);
$info['tokens']['array']['count'] = array(
'name' => t('Count'),
'description' => t('The number of elements in the array.'),
);
$info['tokens']['array']['reversed'] = array(
'name' => t('Reversed'),
'description' => t('The array reversed.'),
'type' => 'array',
);
$info['tokens']['array']['keys'] = array(
'name' => t('Keys'),
'description' => t('The array of keys of the array.'),
'type' => 'array',
);
$info['tokens']['array']['join'] = array(
'name' => t('Imploded'),
'description' => t('The values of the array joined together with a custom string in-between each value.'),
'dynamic' => TRUE,
);
$info['tokens']['array']['value'] = array(
'name' => t('Value'),
'description' => t('The specific value of the array.'),
'dynamic' => TRUE,
);
// Random tokens.
$info['types']['random'] = array(
'name' => t('Random'),
'description' => 'Tokens related to random data.',
);
$info['tokens']['random']['number'] = array(
'name' => t('Number'),
'description' => t('A random number from 0 to @max.', array(
'@max' => mt_getrandmax(),
)),
);
$info['tokens']['random']['hash'] = array(
'name' => t('Hash'),
'description' => t('A random hash. The possible hashing algorithms are: @hash-algos.', array(
'@hash-algos' => implode(', ', hash_algos()),
)),
'dynamic' => TRUE,
);
return $info;
}