$category) { $rows[] = array(array('data' => drupal_ucfirst($key) . ' ' . t('tokens'), 'class' => 'region', 'colspan' => 2)); foreach ($category as $token => $description) { $row = array(); $row[] = $prefix . $token . $suffix; $row[] = $description; $rows[] = $row; } } $output = theme('table', $headers, $rows, array('class' => 'description')); return $output; } /** * Sample implementation of hook_token_values(). * * @param type * A flag indicating the class of substitution tokens to use. If an * object is passed in the second param, 'type' should contain the * object's type. For example, 'node', 'comment', or 'user'. If your * implemention of the hook inserts globally applicable tokens that * do not depend on a particular object, it should only return values * when $type is 'global'. * @param object * Optionally, the object to use for building substitution values. * A node, comment, user, etc. * @return * A keyed array containing the substitution tokens and the substition * values for the passed-in type and object. */ function token_token_values($type, $object = NULL) { global $user; global $base_url; switch ($type) { case 'global': $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 : ''; $values['site-url'] = $base_url; $values['site-name'] = variable_get('site_name', t('Drupal')); $values['site-slogan'] = variable_get('site_slogan', ''); $values['site-mail'] = variable_get('site_mail', ''); $values['site-date'] = format_date(time(), 'short', '', variable_get('date_default_timezone', 0)); break; } return $values; } /** * Sample implementation of hook_token_list(). Documents the individual * tokens handled by your module. * * @param type * A flag indicating the class of substitution tokens to return * information on. If this is set to 'all', a complete list is being * built and your module should return its full list, regardless of * type. Global tokens should always be returned, regardless of the * $type passed in. * @return * A keyed array listing the substitution tokens. Elements should be * in the form of: $list[$type][$token] = $description */ function token_token_list($type = 'all') { $tokens['global']['user-name'] = t('The name of the currently logged in user.'); $tokens['global']['user-id'] = t('The user ID of the currently logged in user.'); $tokens['global']['user-mail'] = t('The email address of the currently logged in user.'); $tokens['global']['site-url'] = t('The url of the current Drupal website.'); $tokens['global']['site-name'] = t('The name of the current Drupal website.'); $tokens['global']['site-slogan'] = t('The slogan of the current Drupal website.'); $tokens['global']['site-mail'] = t('The contact email address for the current Drupal website.'); $tokens['global']['site-date'] = t("The current date on the site's server."); return $tokens; }