Token list display is broken.
Attached is a patch to display the tokens in a table.
Patch also removes extra white space on line endings.

Comments

jose reyero’s picture

Status: Needs review » Needs work

I don't see how it's broken, though I agree it may look nicer in a table.

Also the patch has a lot of not needed lines that make it difficult to review.

andremolnar’s picture

My apologies - that was not the most detailed bug report.

Specific problem: message_tokens_get_list includes HTML with no call to a theme function.

The patch removes the offending HTML and adds code to use a table instead of a simple item list.

The code currently in CVS is riddled with extra 'junk'/spaces at the end of many lines - my IDE automatically strips those out to 'clean' the code - hence the extra parts in the patch.

The Important parts:

@@ -159,6 +159,14 @@
   }
   // Tokens for text replacement
   if ($tokens = messaging_tokens_get_list($group)) {
+    $headers = array(t('Token'), t('Replacement value'));
+    $rows = array();
+    foreach ($tokens as $token => $token_description) {
+        $row = array();
+        $row[] = '[' . $token . ']';
+        $row[] = $token_description;
+        $rows[] = $row;
+    }
     $form['tokens'] = array(
       '#title' => t('Available tokens'),
       '#type' => 'fieldset',
@@ -167,7 +175,7 @@
       '#collapsed' => TRUE,
     );
     $form['tokens']['list'] = array(
-      '#value' => theme('item_list', $tokens),    
+      '#value' => theme('table', $headers, $rows, array('class' => 'description'))
     );
   }

and

@@ -179,25 +187,25 @@
 
 /**
  * Get list of tokens for text replacement
- * 
+ *
  * @param $group
  *   Message group to get tokens for
  * @param $tokens
- *   
+ *
  */
 function messaging_tokens_get_list($group) {
   // First compile token types for this message group
   $type_list = module_invoke_all('messaging', 'tokens', $group);
-  
+
   // Now get token list from token module for each type
   $return = array();
   foreach ($type_list as $type) {
     if ($list = token_get_list($type)) {
       foreach ($list as $category => $tokens) {
         foreach ($tokens as $token => $description) {
-          $return[$token] = "<em>[$token]</em> $description";
+          $return[$token] = $description;

I will be glad to re-roll the patch if you can clean up the line endings.

andre

andremolnar’s picture

Status: Needs work » Needs review

status change

andremolnar’s picture

StatusFileSize
new7.01 KB

Updated patch against latest set of changes in 5.x branch.

jose reyero’s picture

Status: Needs review » Fixed

Yeah, looks much better now!

Thank you (And thanks too for the extra space clean-up)

PS: If someone could tell me how to set up Eclipse for removing that extra spaces automatically... :-)

andremolnar’s picture

I don't use eclipse, but I saw this http://drupal.org/node/75242 and I would assume there is some place that has settings like 'remove extra white space'

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.