Index: token_filter.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token_filter/token_filter.module,v
retrieving revision 1.1
diff -u -r1.1 token_filter.module
--- token_filter.module	23 Dec 2008 09:54:45 -0000	1.1
+++ token_filter.module	8 Jan 2009 22:03:06 -0000
@@ -1,9 +1,15 @@
 <?php
+/**
+ * @file This is a module that gives you token values from an input filter.
+ */
 
-// implementation of hook_filter to create the checkbox filter
+/**
+ * Implementation of hook_filter().
+ *
+ * Adds the Token filter to the input format options.
+ */
 function token_filter_filter($op, $delta = 0, $format = -1, $text = '' ) {
-
-  switch($op) {
+  switch ($op) {
     case 'list':
       return array (0 => t('Token filter'));
     case 'description':
@@ -17,11 +23,11 @@
     case 'process':
       // generate some header code, form tag and we save the node id so that the 
       // javascript has a convenient place to get it from
-      if (strpos($text,"[token") === false) {
+      if (strpos($text, "[token") === false) {
         return $text;
       }
       else {
-        $output .= preg_replace_callback("|\[token ([^ ]*)([^]]*)\]|i",'token_filter_replacetoken',$text);
+        $output .= preg_replace_callback("|\[token ([^ ]*)([^]]*)\]|i", 'token_filter_replacetoken',$text);
         return $output;
       }
       break;
@@ -43,7 +49,7 @@
       $object = $user;
       break;
     default :
-      drupal_set_message("Filter Error: token_filter doesn't yet handle objects of type $type",'error');
+      drupal_set_message("Filter Error: token_filter doesn't yet handle objects of type $type", 'error');
       // Return the provided token so at least you can see which one is giving the error in the text
       return "%$token";
     } 
@@ -51,3 +57,53 @@
   return $output;
 }
 
+/**
+ * Implementation of hook_filter_tips().
+ *
+ * Let the user know they may use tokens and provide them a list of available tokens.
+ */
+function token_filter_filter_tips($delta, $format, $long = FALSE) {
+	$output = t('Utilize tokens as variables in your content.');
+	
+	if (! $long) {
+		$output .= ' '.l('View full list of available tokens.', 'filter/tips', array('fragment' => 'token_filter_help'));
+	}
+	else {
+	  $output .= '<a name="token_filter_help"></a>';
+		$output .= theme('token_filter_help');
+	}
+	return $output;
+}
+
+/**
+ * Implementation of hook_theme().
+ */
+function token_filter_theme() {
+  return array(
+    'token_filter_help' => array(
+      'arguments' => array('type' => 'all', 'prefix' => '[token ', 'suffix' => ']'),
+    ),
+  );
+}
+
+/**
+ * Based on theme_filter_help(). Modifies filter_help to display token_filter syntax.
+ */
+function theme_token_filter_help($type = 'all', $prefix = '[token ', $suffix = ']') {
+  $full_list = token_get_list($type);
+
+  $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) {
+      $row = array();
+      $row[] = $prefix .' '. $key .' '. $token . $suffix;
+      $row[] = $description;
+      $rows[] = $row;
+    }
+  }
+
+  $output = theme('table', $headers, $rows, array('class' => 'description'));
+  return $output;
+}
\ No newline at end of file

