function token_token_values in Token 6
Same name and namespace in other branches
- 5 token.module \token_token_values()
Implements hook_token_values().
File
- ./
token.module, line 94 - The Token API module.
Code
function token_token_values($type, $object = NULL) {
global $user;
$values = array();
switch ($type) {
case 'global':
// Current user tokens.
$values['user-name'] = $user->uid ? $user->name : variable_get('anonymous', t('Anonymous'));
$values['user-id'] = $user->uid ? $user->uid : 0;
$values['user-mail'] = $user->uid ? $user->mail : '';
// Site information tokens.
$values['site-url'] = url('<front>', array(
'absolute' => TRUE,
));
$values['site-name'] = check_plain(variable_get('site_name', t('Drupal')));
$values['site-slogan'] = check_plain(variable_get('site_slogan', ''));
$values['site-mission'] = filter_xss_admin(variable_get('site_mission', ''));
$values['site-mail'] = variable_get('site_mail', '');
$values += token_get_date_token_values(NULL, 'site-date-');
// Current page tokens.
$values['current-page-title'] = drupal_get_title();
$alias = drupal_get_path_alias($_GET['q']);
$values['current-page-path-raw'] = $alias;
$values['current-page-path'] = check_plain($alias);
$values['current-page-url'] = url($_GET['q'], array(
'absolute' => TRUE,
));
$page = isset($_GET['page']) ? $_GET['page'] : '';
$pager_page_array = explode(',', $page);
$page = $pager_page_array[0];
$values['current-page-number'] = (int) $page + 1;
// Backwards compatability for renamed tokens.
$values['site-date'] = $values['site-date-small'];
$values['page-number'] = $values['current-page-number'];
break;
}
return $values;
}