Index: nodewords.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodewords/nodewords.module,v
retrieving revision 1.57.2.364
diff -u -p -r1.57.2.364 nodewords.module
--- nodewords.module	1 Nov 2010 01:10:38 -0000	1.57.2.364
+++ nodewords.module	1 Nov 2010 05:48:58 -0000
@@ -243,66 +243,40 @@ function nodewords_user($op, &$edit, &$a
 function nodewords_add_tokens_help(&$form, $type) {
   switch ($type['type']) {
     case NODEWORDS_TYPE_PAGE:
-      $tokens_type[] = 'global';
-      $tokens_type[] = 'global meta tags';
-      $tokens_type[] = 'node';
-      $tokens_type[] = 'node meta tags';
-      $tokens_type[] = 'taxonomy';
-      $tokens_type[] = 'user';
-    break;
-
-    case NODEWORDS_TYPE_ERRORPAGE:
-      $tokens_type[] = 'global';
-      $tokens_type[] = 'global meta tags';
-      break;
-
     case NODEWORDS_TYPE_DEFAULT:
-      $tokens_type[] = 'global';
-      $tokens_type[] = 'global meta tags';
       $tokens_type[] = 'node';
-      $tokens_type[] = 'node meta tags';
       $tokens_type[] = 'taxonomy';
       $tokens_type[] = 'user';
       break;
 
     case NODEWORDS_TYPE_CONTENT_TYPE:
     case NODEWORDS_TYPE_NODE:
-      $tokens_type[] = 'global';
-      $tokens_type[] = 'global meta tags';
       $tokens_type[] = 'node';
-      $tokens_type[] = 'node meta tags';
       break;
 
     case NODEWORDS_TYPE_TERM:
     case NODEWORDS_TYPE_VOCABULARY:
-      $tokens_type[] = 'global';
-      $tokens_type[] = 'global meta tags';
       $tokens_type[] = 'taxonomy';
       break;
 
     case NODEWORDS_TYPE_USER:
-      $tokens_type[] = 'global';
-      $tokens_type[] = 'global meta tags';
       $tokens_type[] = 'user';
       break;
-
-    default:
-      $tokens_type = '';
   }
 
-  if ($tokens_type) {
-    $form['token_help'] = array(
-      '#title' => t('Replacement patterns'),
-      '#type' => 'fieldset',
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
-      '#description' => t('Prefer raw-text replacements for text to avoid problems with HTML entities.'),
-    );
+  $tokens_type[] = 'global';
 
-    $form['token_help']['help'] = array(
-      '#value' => theme('token_help', $tokens_type),
-    );
-  }
+  $form['token_help'] = array(
+    '#title' => t('Replacement patterns'),
+    '#type' => 'fieldset',
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#description' => t('Prefer raw-text replacements for text to avoid problems with HTML entities.'),
+  );
+
+  $form['token_help']['help'] = array(
+    '#value' => theme('token_tree', $token_types),
+  );
 }
 
 /**
@@ -554,7 +528,7 @@ function nodewords_replace_tokens($conte
 
   $options += _nodewords_get_default_metatags_type();
 
-  if (empty($content) || !module_exists('token')) {
+  if (empty($content) || !variable_get('nodewords_enable_tokens', TRUE) || !module_exists('token')) {
     return $content;
   }
 
@@ -572,7 +546,6 @@ function nodewords_replace_tokens($conte
             node_nodewords_type_id($node_options, $arg);
             if (!empty($node_options)) {
               $token_objects['node'] = _nodewords_node_load($node_options);
-              $token_objects['node meta tags'] = $token_objects['node'];
             }
             break;
           // Core user.module.
@@ -629,7 +602,6 @@ function nodewords_replace_tokens($conte
 
     case NODEWORDS_TYPE_NODE:
       $token_objects['node'] = _nodewords_node_load($options);
-      $token_objects['node meta tags'] = $token_objects['node'];
       break;
 
     case NODEWORDS_TYPE_TERM:
@@ -640,34 +612,14 @@ function nodewords_replace_tokens($conte
     case NODEWORDS_TYPE_USER:
       $token_objects['user'] = user_load($options['id']);
       break;
-
-    default:
-      return $content;
   }
 
+  // Always include the global context.
   $token_objects['global'] = NULL;
-  $token_objects['global meta tags'] = NULL;
-
-  // Remove the not replaced tokens.
-  $content = token_replace_multiple($content, $token_objects);
-  $replacements = array();
-  token_include();
-
-  foreach (module_implements('token_list') as $module) {
-    $function = $module .'_token_list';
-    $result = $function('all');
-    if (is_array($result)) {
-      foreach ($result as $category => $tokens) {
-       foreach ($tokens as $token => $title) {
-          $replacements['[' . $token . ']'] = '';
-        }
-      }
-    }
-  }
 
-  if (!empty($replacements)) {
-    $content = strtr($content, $replacements);
-  }
+  // Perform token replacement, making sure all tokens are replaced even if
+  // there is no replacement value for a token.
+  $content = token_replace_multiple($content, $token_objects, TOKEN_PREFIX, TOKEN_SUFFIX, array('clear' => TRUE));
 
   return $content;
 }
Index: nodewords_admin/nodewords_admin.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodewords/nodewords_admin/Attic/nodewords_admin.admin.inc,v
retrieving revision 1.1.2.9
diff -u -p -r1.1.2.9 nodewords_admin.admin.inc
--- nodewords_admin/nodewords_admin.admin.inc	15 Jun 2010 17:16:22 -0000	1.1.2.9
+++ nodewords_admin/nodewords_admin.admin.inc	1 Nov 2010 05:48:58 -0000
@@ -151,27 +151,19 @@ function nodewords_admin_settings_form()
     '#type' => 'checkbox',
     '#title' => t('Repeat meta tags for lists'),
     '#description' => t('Some search engines punish sites that use the same meta tags on different pages. Uncheck this option if you want to suppress the repetition of the same meta tags on pages that use the pager - if unchecked, Drupal will only display the meta tags for the first page and not for subsequent pages. If unsure, select this option.'),
-     '#default_value' => variable_get('nodewords_list_repeat', FALSE),
+    '#default_value' => variable_get('nodewords_list_repeat', FALSE),
   );
 
   $form['metatags_creation']['nodewords_enable_tokens'] = array(
     '#type' => 'checkbox',
     '#title' => t('Enable tokens'),
-    '#description' => t(
-      'This setting allows to use the tokens implemented in <a href="@token">token.module</a> in meta tags content.',
-      array('@token' => 'http://drupal.org/project/token')
-    ),
-    '#default_value' => variable_get('nodewords_enable_tokens', TRUE),
+    '#description' => t('This setting allows to use the tokens implemented in <a href="@token">token.module</a> in meta tags content.', array(
+      '@token' => 'http://drupal.org/project/token',
+    )),
+    '#default_value' => variable_get('nodewords_enable_tokens', TRUE) && module_exists('token'),
+    '#disabled' => !module_exists('token'),
   );
 
-  if (!module_exists('token')) {
-    $form['metatags_creation']['nodewords_enable_tokens']['#description'] .=  ' ' . t('The module token.module is not enabled, or installed.');
-
-    if (!variable_get('nodewords_enable_tokens', TRUE)) {
-      $form['metatags_creation']['nodewords_enable_tokens']['#disabled'] = TRUE;
-    }
-  }
-
   $form['metatags_creation']['nodewords_max_size'] = array(
     '#type' => 'textfield',
     '#title' => t('Maximum meta tags length'),
Index: nodewords_tokens/nodewords_tokens.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodewords/nodewords_tokens/Attic/nodewords_tokens.module,v
retrieving revision 1.1.2.21
diff -u -p -r1.1.2.21 nodewords_tokens.module
--- nodewords_tokens/nodewords_tokens.module	21 Oct 2010 12:58:48 -0000	1.1.2.21
+++ nodewords_tokens/nodewords_tokens.module	1 Nov 2010 05:48:58 -0000
@@ -158,20 +158,18 @@ function nodewords_tokens_filter_regex_v
 function nodewords_tokens_token_list($type = 'all') {
   $tokens = array();
 
-  if ($type == 'all' || $type == 'global meta tags') {
-    $tokens['global meta tags']['metatags-global-keywords-1'] = t('The global keywords.');
-    $tokens['global meta tags']['metatags-global-keywords-2'] = t('The global keywords.');
-    $tokens['global meta tags']['metatags-global-keywords-1-raw'] = t('The raw global keywords.');
-    $tokens['global meta tags']['metatags-global-keywords-2-raw'] = t('The raw global keywords.');
-    $tokens['global meta tags']['metatags-normal-url'] = t('The internal URL of the current page.');
-    $tokens['global meta tags']['metatags-url-alias'] = t('The alias of the current page URL.');
+  if ($type == 'all' || $type == 'global') {
+    $tokens['global']['metatags-global-keywords-1'] = t('The global keywords.');
+    $tokens['global']['metatags-global-keywords-2'] = t('The global keywords.');
+    $tokens['global']['metatags-global-keywords-1-raw'] = t('The raw global keywords.');
+    $tokens['global']['metatags-global-keywords-2-raw'] = t('The raw global keywords.');
   }
 
-  if ($type == 'all' || $type == 'node meta tags') {
-    $tokens['node meta tags']['metatags-description'] = t('The node description generated from the node body, or the node teaser.');
-    $tokens['node meta tags']['metatags-description-raw'] = t('The node description generated from the node body, or the node teaser. WARNING - raw user input.');
-    $tokens['node meta tags']['metatags-taxonomy-keywords'] = t('The node keywords generated from the taxonomy terms associated with the node.');
-    $tokens['node meta tags']['metatags-taxonomy-keywords-raw'] = t('The node keywords generated from the taxonomy terms associated with the node. WARNING - raw user input.');
+  if ($type == 'all' || $type == 'node') {
+    $tokens['node']['metatags-description'] = t('The node description generated from the node body, or the node teaser.');
+    $tokens['node']['metatags-description-raw'] = t('The node description generated from the node body, or the node teaser. WARNING - raw user input.');
+    $tokens['node']['metatags-taxonomy-keywords'] = t('The node keywords generated from the taxonomy terms associated with the node.');
+    $tokens['node']['metatags-taxonomy-keywords-raw'] = t('The node keywords generated from the taxonomy terms associated with the node. WARNING - raw user input.');
   }
 
   return $tokens;
@@ -186,43 +184,31 @@ function nodewords_tokens_token_list($ty
 function nodewords_tokens_token_values($type, $object = NULL, $options = array()) {
   $values = array();
 
-  switch ($type) {
-    case 'global meta tags':
-      $value = nodewords_unique_values(variable_get('nodewords_global_keywords_1', ''));
-      $values['metatags-global-keywords-1-raw'] = $value;
-      $values['metatags-global-keywords-1'] = check_plain($value);
-
-      $value = nodewords_unique_values(variable_get('nodewords_global_keywords_2', ''));
-      $values['metatags-global-keywords-2-raw'] = $value;
-      $values['metatags-global-keywords-2'] = check_plain($value);
-
-      if (drupal_is_front_page()) {
-        $path = '<front>';
-      }
-      else {
-        $path = $_GET['q'];
-      }
-
-      $values['metatags-normal-url'] = nodewords_url($path);
-      $values['metatags-url-alias'] = nodewords_url($path, array('alias' => FALSE));
-      break;
-
-    case 'node meta tags':
-      $value = '';
-      $values['metatags-description-raw'] = _nodewords_tokens_metatag_from_node_content($object);
-      $values['metatags-description'] = check_plain($values['metatags-description-raw']);
-
-      if (module_exists('taxonomy')) {
-        foreach (taxonomy_node_get_terms($object) as $term) {
-          if (in_array($term->vid, variable_get('nodewords_keyword_vids', array()))) {
-            $value .= ',' . $term->name;
-          }
+  if ($type == 'global') {
+    $value = nodewords_unique_values(variable_get('nodewords_global_keywords_1', ''));
+    $values['metatags-global-keywords-1-raw'] = $value;
+    $values['metatags-global-keywords-1'] = check_plain($value);
+
+    $value = nodewords_unique_values(variable_get('nodewords_global_keywords_2', ''));
+    $values['metatags-global-keywords-2-raw'] = $value;
+    $values['metatags-global-keywords-2'] = check_plain($value);
+  }
+
+  if ($type == 'node' && !empty($object)) {
+    $values['metatags-description-raw'] = _nodewords_tokens_metatag_from_node_content($object);
+    $values['metatags-description'] = check_plain($values['metatags-description-raw']);
+
+    $value = '';
+    if (module_exists('taxonomy')) {
+      foreach (taxonomy_node_get_terms($object) as $term) {
+        if (in_array($term->vid, variable_get('nodewords_keyword_vids', array()))) {
+          $value .= ',' . $term->name;
         }
       }
-      $value = nodewords_unique_values($value);
-      $values['metatags-taxonomy-keywords-raw'] = $value;
-      $values['metatags-taxonomy-keywords'] = check_plain($value);
-      break;
+    }
+    $value = nodewords_unique_values($value);
+    $values['metatags-taxonomy-keywords-raw'] = $value;
+    $values['metatags-taxonomy-keywords'] = check_plain($value);
   }
 
   return $values;
