Index: token.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/token/token.module,v retrieving revision 1.7 diff -u -r1.7 token.module --- token.module 31 Jul 2007 23:54:02 -0000 1.7 +++ token.module 1 Aug 2007 15:04:11 -0000 @@ -58,6 +58,44 @@ } /** + * For a given node, builds a formatted list of tokens and descriptions + * of its replacement values. + * + * @param node + * The node to display documentation for. + * @param prefix + * The prefix your module will use when parsing tokens. Defaults to '[' + * @param suffix + * The suffix your module will use when parsing tokens. Defaults to ']' + * @return + * An HTML table containing the formatting docs. + **/ +function theme_token_node_help($node, $prefix = '[', $suffix = ']') { + token_include(); + $full_list = token_get_list('node', $node); + // Build an array with keys of defined tokens. + $used_list = array_flip(token_get_values('node', $node)->tokens); + + $headers = array(t('Token'), t('Replacement value')); + $rows = array(); + + foreach ($full_list as $key => $category) { + $rows[] = array(array('data' => drupal_ucfirst($key) . ' ' . t('tokens'), 'class' => 'region', 'colspan' => 2)); + foreach ($category as $token => $description) { + if (isset($used_list[$token])) { + $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