? patches
Index: nodewords.api.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodewords/Attic/nodewords.api.php,v
retrieving revision 1.1.2.23
diff -u -p -r1.1.2.23 nodewords.api.php
--- nodewords.api.php	11 Jun 2010 11:41:40 -0000	1.1.2.23
+++ nodewords.api.php	1 Nov 2010 08:19:09 -0000
@@ -76,7 +76,7 @@ function hook_nodewords_tags_permission_
     return;
   }
 
-  if ($object['type'] == 'node' && ($node = _nodewords_node_load($object))) {
+  if ($object['type'] == 'node' && ($node = node_load($options['id']))) {
     if ($user->uid == $node->uid && user_access("edit one's own node meta tags")) {
       $permission = TRUE;
       return;
@@ -231,4 +231,3 @@ function hook_nodewords_type_id(&$result
     }
   }
 }
-
Index: nodewords.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodewords/nodewords.module,v
retrieving revision 1.57.2.366
diff -u -p -r1.57.2.366 nodewords.module
--- nodewords.module	1 Nov 2010 07:29:21 -0000	1.57.2.366
+++ nodewords.module	1 Nov 2010 08:19:10 -0000
@@ -248,6 +248,7 @@ function nodewords_add_tokens_help(&$for
     case NODEWORDS_TYPE_PAGE:
       $token_types[] = 'node';
       $token_types[] = 'taxonomy';
+      $token_types[] = 'vocabulary';
       $token_types[] = 'user';
       break;
 
@@ -257,10 +258,13 @@ function nodewords_add_tokens_help(&$for
       break;
 
     case NODEWORDS_TYPE_TERM:
-    case NODEWORDS_TYPE_VOCABULARY:
       $token_types[] = 'taxonomy';
       break;
 
+    case NODEWORDS_TYPE_VOCABULARY:
+      $token_types[] = 'vocabulary';
+      break;
+
     case NODEWORDS_TYPE_USER:
       $token_types[] = 'user';
       break;
@@ -534,82 +538,34 @@ function nodewords_replace_tokens($conte
 
   $options += _nodewords_get_default_metatags_type();
 
+  // Allow other modules to alter the context used for tokens below if the
+  // current context is not yet specific.
   switch ($options['type']) {
+    case NODEWORDS_TYPE_DEFAULT:
     case NODEWORDS_TYPE_PAGE:
-      // Since a custom page can be virtually anything, we need to load global
-      // tokens and check arg(0) to see if there are additional tokens that we
-      // need to bring into scope.
+    case NODEWORDS_TYPE_PAGER:
       $arg = arg() + array_fill(0, MENU_MAX_PARTS, NULL);
-      if (!empty($arg[0])) {
-        switch ($arg[0]) {
-          // Core node.module.
-          case 'node':
-            $node_options = array();
-            node_nodewords_type_id($node_options, $arg);
-            if (!empty($node_options)) {
-              $token_objects['node'] = _nodewords_node_load($node_options);
-            }
-            break;
-          // Core user.module.
-          case 'user':
-            $user_options = array();
-            user_metatags_type($user_options, $arg);
-            if (!empty($user_options)) {
-              $token_objects['user'] = user_load($user_options['id']);
-            }
-            break;
-          // Core taxonomy.module.
-          case 'taxonomy':
-            $taxonomy_options = array();
-            taxonomy_nodewords_type_id($taxonomy_options, $arg);
-            if (!empty($taxonomy_options)) {
-              $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($taxonomy_options);
-            }
-            break;
-          // Core forum.module.
-          case 'forum':
-            $forum_options = array();
-            forum_nodewords_type_id($forum_options, $arg);
-            if (!empty($forum_options)) {
-              $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($forum_options);
-            }
-            break;
-          // Contrib image.module.
-          case 'image':
-            $image_options = array();
-            image_nodewords_type_id($image_options, $arg);
-            if (!empty($image_options)) {
-              $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($image_options);
-            }
-            break;
-          // Contrib ubercart.module.
-          case 'catalog':
-            $uc_catalog_options = array();
-            forum_nodewords_type_id($uc_catalog_options, $arg);
-            if (!empty($uc_catalog_options)) {
-              $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($uc_catalog_options);
-            }
-            break;
-          // Contrib taxonomy_menu.module.
-          case 'taxonomy_menu':
-            $taxonomy_menu_options = array();
-            taxonomy_menu_nodewords_type_id($taxonomy_menu_options, $arg);
-            if (!empty($taxonomy_menu_options)) {
-              $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($taxonomy_menu_options);
-            }
-            break;
+      foreach (module_implements('nodewords_type_id') as $module) {
+        $function = $module . '_nodewords_type_id';
+        $function($options, $arg);
+        if ($options['type'] != NODEWORDS_TYPE_PAGE) {
+          break;
         }
       }
       break;
+  }
 
+  switch ($options['type']) {
     case NODEWORDS_TYPE_NODE:
-    case NODEWORDS_TYPE_CONTENT_TYPE:
-      $token_objects['node'] = _nodewords_node_load($options);
+      $token_objects['node'] = node_load($options['id']);
       break;
 
     case NODEWORDS_TYPE_TERM:
+      $token_objects['taxonomy'] = taxonomy_get_term($options['id']);
+      break;
+
     case NODEWORDS_TYPE_VOCABULARY:
-      $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($options);
+      $token_objects['vocabulary'] = taxonomy_vocabulary_load($options['id']);
       break;
 
     case NODEWORDS_TYPE_USER:
@@ -628,7 +584,6 @@ function nodewords_replace_tokens($conte
  * Update or insert tags in the table.
  */
 function nodewords_save_tags($tags, $options = array()) {
-  global $user;
   $done = FALSE;
 
   $options += (_nodewords_get_default_metatags_type() + array('log_message' => TRUE));
@@ -652,10 +607,9 @@ function nodewords_save_tags($tags, $opt
       $ret = drupal_write_record('nodewords', $row, isset($row->mtid) ? 'mtid' : array());
 
       if (!$done && $options['log_message'] && $ret) {
-        watchdog('meta tags', 'User %name changed the meta tags for type %type (%id).', array(
-          '%name' => $user->name,
-          '%type' => isset($types_str[$options['type']]) ? $types_str[$options['type']] : t('unknown'),
-          '%id' => $options['id'],
+        watchdog('meta tags', 'Meta tags changed for type @type @id.', array(
+          '@type' => isset($types_str[$options['type']]) ? $types_str[$options['type']] : t('unknown'),
+          '@id' => $options['id'],
         ));
         $done = TRUE;
       }
@@ -905,12 +859,6 @@ function _nodewords_load_hook_files() {
   nodewords_load_all_includes('nodewords.hooks.inc');
 }
 
-function _nodewords_node_load($options) {
-  return node_load(
-    array('nid' => $options['id'])
-  );
-}
-
 /**
  * Render the meta tag values as HTML.
  *
@@ -1045,16 +993,3 @@ function _nodewords_tag_value($tag, $val
 
   return $value;
 }
-
-function _nodewords_taxonomy_object_load($options) {
-  $value = NULL;
-
-  if ($options['type'] == NODEWORDS_TYPE_TERM) {
-    $value = taxonomy_get_term($options['id']);
-  }
-  elseif ($options['type'] == NODEWORDS_TYPE_VOCABULARY) {
-    $value = taxonomy_vocabulary_load($options['id']);
-  }
-
-  return $value;
-}
Index: includes/blog.inc
===================================================================
RCS file: includes/blog.inc
diff -N includes/blog.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ includes/blog.inc	1 Nov 2010 08:19:10 -0000
@@ -0,0 +1,17 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Integration file for blog.module.
+ */
+
+/**
+ * Implements hook_nodewords_type_id().
+ */
+function blog_nodewords_type_id(&$result, $arg) {
+  if ($arg[0] == 'blog' && is_numeric($arg[1])) {
+    $result['type'] = NODEWORDS_TYPE_USER;
+    $result['id'] = $arg[1];
+  }
+}
Index: includes/node.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodewords/includes/node.inc,v
retrieving revision 1.1.4.12
diff -u -p -r1.1.4.12 node.inc
--- includes/node.inc	1 Nov 2010 01:10:38 -0000	1.1.4.12
+++ includes/node.inc	1 Nov 2010 08:19:10 -0000
@@ -10,10 +10,8 @@
  * Implements hook_nodewords_type_id().
  */
 function node_nodewords_type_id(&$result, $arg) {
-  if ($arg[0] == 'node' && is_numeric($arg[1]) && $node = node_load($arg[1])) {
-    if (!isset($arg[2]) || ($node->type == 'poll' && in_array($arg[2], array('edit', 'results')))) {
-      $result['type'] = NODEWORDS_TYPE_NODE;
-      $result['id'] = $node->nid;
-    }
+  if ($arg[0] == 'node' && is_numeric($arg[1])) {
+    $result['type'] = NODEWORDS_TYPE_NODE;
+    $result['id'] = $arg[1];
   }
 }
Index: includes/tracker.inc
===================================================================
RCS file: includes/tracker.inc
diff -N includes/tracker.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ includes/tracker.inc	1 Nov 2010 08:19:10 -0000
@@ -0,0 +1,17 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Integration file for tracker.module.
+ */
+
+/**
+ * Implements hook_nodewords_type_id().
+ */
+function tracker_nodewords_type_id(&$result, $arg) {
+  if ($arg[0] == 'tracker') {
+    $result['type'] = NDOEWORDS_TYPE_USER;
+    $result['id'] = is_numeric($arg[1]) ? $arg[1] : $GLOBALS['user']->uid;
+  }
+}
Index: includes/user.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodewords/includes/user.inc,v
retrieving revision 1.1.4.11
diff -u -p -r1.1.4.11 user.inc
--- includes/user.inc	1 Nov 2010 01:10:38 -0000	1.1.4.11
+++ includes/user.inc	1 Nov 2010 08:19:10 -0000
@@ -9,9 +9,15 @@
 /**
  * Implements hook_nodewords_type_id().
  */
-function user_metatags_type(&$result, $arg) {
-  if ($arg[0] == 'user' && is_numeric($arg[1]) && $account = user_load($arg[1])) {
-    $result['type'] = NODEWORDS_TYPE_USER;
-    $result['id'] = $account->uid;
+function user_nodewords_type_id(&$result, $arg) {
+  if ($arg[0] == 'user') {
+    if (!isset($arg[1])) {
+      $result['type'] = NODEWORDS_TYPE_USER;
+      $result['id'] = $GLOBALS['user']->uid;
+    }
+    elseif (is_numeric($arg[1])) {
+      $result['type'] = NODEWORDS_TYPE_USER;
+      $result['id'] = $arg[1];
+    }
   }
 }
