? nh_token.patch
Index: nodehierarchy.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodehierarchy/nodehierarchy.module,v
retrieving revision 1.4.2.17
diff -u -p -r1.4.2.17 nodehierarchy.module
--- nodehierarchy.module	3 Nov 2009 15:57:05 -0000	1.4.2.17
+++ nodehierarchy.module	3 Feb 2010 17:44:30 -0000
@@ -318,6 +318,33 @@ function nodehierarchy_nodehierarchyapi(
         ),
         '#description' => t("Users must have the 'administer menu' permission to create menu items. If you want to allow users to use this feature without that permission you can enable that on !settings", array('!settings' => l(t('the node hierarchy settings page'), 'admin/settings/nodehierarchy'))),
       );
+
+      if (module_exists('token')) {
+        $form['nh_menutitle'] = array(
+          '#type' => 'textfield',
+          '#title' => t('Pattern for menu item title generation'),
+          '#default_value' => variable_get('nh_menutitle_'. $key, '[title-raw]'),
+          '#description' => t("Users may enter a pattern here for the menu item that will be generated for this content type"),
+          );
+        $form['nh_menulink'] = array(
+          '#type' => 'textfield',
+          '#title' => t('Pattern for menu item link generation'),
+          '#default_value' => variable_get('nh_menulink_'. $key, 'node/[nid]'),
+          '#description' => t("Users may enter a pattern here for the menu item link that will be generated for this content type"),
+          );
+        $form['view']['token_help'] = array(
+          '#title' => t('Replacement patterns'),
+          '#type' => 'fieldset',
+          '#collapsible' => TRUE,
+          '#collapsed' => TRUE,
+          '#description' => t('Prefer raw-text replacements for text'),
+        );
+
+        $form['view']['token_help']['help'] = array(
+          '#value' => theme('token_help', 'node'),
+        );
+      }
+          
       return $form;
     break;
 
@@ -979,9 +1006,16 @@ function _nodehierarchy_create_menu(&$no
       $item['parent'] = variable_get('nodehierarchy_menus_default', 'primary-links:0');
       list($item['menu_name'], $item['plid']) = explode(":", $item['parent']);
     }
+    if (module_exists('token')) {
+      $item['link_title'] = trim(token_replace(variable_get('nh_menutitle_' . $node->type , '[title-raw]'), 
+        $type = 'node', $object = $node, $leading = '[', $trailing = ']'));
+      $item['link_path'] =  token_replace(variable_get('nh_menulink_' . $node->type , 'node/[nid]'),
+        $type = 'node', $object = $node, $leading = '[', $trailing = ']');
+    } else {
+      $item['link_title'] = trim($node->title);
+      $item['link_path'] = "node/$node->nid";
+    }
 
-    $item['link_title'] = trim($node->title);
-    $item['link_path'] = "node/$node->nid";
     // Editable menu weight range used to start at -10.
     $item['weight'] = $node->order_by - 11;
     if (!menu_link_save($item)) {
@@ -1021,7 +1055,15 @@ function _nodehierarchy_set_menu_order($
  * Find the menu ID for the given node.
  */
 function _nodehierarchy_get_menu($nid) {
-  return db_fetch_array(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = '%s'", "node/$nid", 0, 1));
+
+  if (module_exists('token')) {
+    $node=node_load($nid);
+    $link_path =  token_replace(variable_get('nh_menulink_' . $node->type , 'node/[nid]'),
+      $type = 'node', $object = $node, $leading = '[', $trailing = ']');
+   } else {
+     $link_path = "node/$nid";
+   }  
+  return db_fetch_array(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = '%s'", $link_path, 0, 1));
 }
 
 /**
@@ -1034,7 +1076,14 @@ function _nodehierarchy_get_parent_menu(
   }
   // Otherwise get the parent menu of the item (if any).
   else {
-    return db_fetch_array(db_query_range("SELECT plid FROM {menu_links} WHERE link_path = '%s'", "node/$nid", 0, 1));
+    if (module_exists('token')) {
+      $node=node_load($nid);
+      $link_path =  token_replace(variable_get('nh_menulink_' . $node->type , 'node/[nid]'),
+        $type = 'node', $object = $node, $leading = '[', $trailing = ']');
+     } else {
+       $link_path = "node/$nid";
+     }  
+    return db_fetch_array(db_query_range("SELECT plid FROM {menu_links} WHERE link_path = '%s'", $link_path, 0, 1));
   }
 }
 
@@ -1042,7 +1091,14 @@ function _nodehierarchy_get_parent_menu(
  * Find the menu ID for the given node with the given parent menu ID.
  */
 function _nodehierarchy_get_child_menu($nid, $plid = NULL) {
-  return db_fetch_array(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND plid = '%d'", "node/$nid", $plid, 0, 1));
+  if (module_exists('token')) {
+    $node=node_load($nid);
+    $link_path =  token_replace(variable_get('nh_menulink_' . $node->type , 'node/[nid]'),
+      $type = 'node', $object = $node, $leading = '[', $trailing = ']');
+   } else {
+     $link_path = "node/$nid";
+   }  
+  return db_fetch_array(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND plid = '%d'", $link_path, $plid, 0, 1));
 }
 
 /**
