? 534330-token.patch
? 5x-hook.patch
? 5x-menu.patch
? text.patch
Index: menu_node_edit.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/menu_node_edit/menu_node_edit.module,v
retrieving revision 1.9
diff -u -p -r1.9 menu_node_edit.module
--- menu_node_edit.module	15 Jul 2009 14:06:59 -0000	1.9
+++ menu_node_edit.module	17 Aug 2009 18:57:47 -0000
@@ -867,3 +867,61 @@ function menu_node_edit_content_extra_fi
     );
   }
 }
+
+/**
+ * Implement hook_token_list().
+ *
+ * Provides tokens for the path alias of a menu parent.
+ */
+function menu_node_edit_token_list($type = 'all') {
+  if (!menu_node_edit_tokens() || $type != 'all' || $type != 'node') {
+    return;
+  }
+  $tokens = array();
+  $tokens['node']['menu-parent-path-alias'] = t('Path alias of parent menu item.');
+  $tokens['node']['menu-parent-path-alias-raw'] = t('Path alias of parent menu item. WARNING - raw user input.');
+  return $tokens;
+}
+
+/**
+ * Implement hook_token_values().
+ *
+ * Provides tokens for the path alias of a menu parent.
+ */
+function menu_node_edit_token_values($type, $object = NULL, $options = array()) {
+  if (!menu_node_edit_tokens() || $type != 'node') {
+    return;
+  }
+  // Set a default value.
+  $value = t('content');
+  if (!empty($object->nid)) {
+    $path = "node/$object->nid";
+    $plid = db_result(db_query("SELECT ml.plid FROM {menu_links} ml INNER JOIN {menu_custom} mc ON ml.menu_name = mc.menu_name WHERE ml.link_path = '%s'", $path));
+    if (empty($plid)) {
+      continue;
+    }
+    $parent = db_result(db_query("SELECT link_path FROM {menu_links} WHERE mlid = %d", $plid));
+    if (empty($parent)) {
+      continue;
+    }
+    $result = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $parent));
+    if (empty($result)) {
+      continue;
+    }
+    $value = $result;
+  }
+  $tokens = array();
+  $tokens['menu-parent-path-alias'] = check_plain($value);
+  $tokens['menu-parent-path-alias-raw'] = $value;
+  return $tokens;
+}
+
+/**
+ * Helper function to determine token support.
+ */
+function menu_node_edit_tokens() {
+  if (module_exists('path')) {
+    return TRUE;
+  }
+  return FALSE;
+}
