Kun i .: pathauto_5x_6x_sync.patch
diff -u ./pathauto.inc ../pathauto6x/pathauto.inc
--- ./pathauto.inc	2008-05-30 03:41:32.000000000 +0200
+++ ../pathauto6x/pathauto.inc	2008-05-30 02:47:59.000000000 +0200
@@ -67,7 +67,7 @@
   if (db_table_exists('path_redirect')) {
     $redirect_rid = db_result(db_query_range("SELECT rid FROM {path_redirect} WHERE path = '%s'", $alias, 0, 1));
   }
-  if ($alias_pid || $redirect_rid) {
+  if ($alias_pid || (isset($redirect_rid) && $redirect_rid)) {
     return TRUE;
   }
   else {
@@ -186,7 +186,7 @@
   $output = preg_replace("/\s+/", $separator, $output);
 
   // In preparation for pattern matching,
-  // escape the separator if and only if it is not alphanumeric)
+  // escape the separator if and only if it is not alphanumeric.
   if (isset($separator)) {
     if (preg_match('/^[^'. PREG_CLASS_ALNUM .']+$/uD', $separator)) {
       $seppattern = $separator;
@@ -240,15 +240,15 @@
 
   // Retrieve and apply the pattern for this content type
   $pattern = '';
-  if ($type) {
-    $pattern = variable_get('pathauto_'. $module .'_'. $type .'_pattern', '');
+  if (!empty($type)) {
+    $pattern = trim(variable_get('pathauto_'. $module .'_'. $type .'_pattern', ''));
   }
-  if (!trim($pattern)) {
-    $pattern = variable_get('pathauto_'. $module .'_pattern', '');
+  if (!$pattern) {
+    $pattern = trim(variable_get('pathauto_'. $module .'_pattern', ''));
   }
-
   // No pattern? Do nothing (otherwise we may blow away existing aliases...)
-  if (!trim($pattern)) {
+  if (!$pattern) {
     return '';
   }
 
@@ -344,13 +344,11 @@
  *   TRUE if the path already exists.
  */
 function _pathauto_path_is_callback($path) {
-  static $menu = NULL;
-  if (is_null($menu)) {
-    $menu = menu_get_menu();
+  $menu = menu_get_item($path);
+  if (isset($menu['path']) && $menu['path'] == $path) {
+    return TRUE;
   }
-
-  // Determine the menu item containing the callback.
-  return isset($menu["callbacks"][$path]);
+  return FALSE;
 }
 
 /**
@@ -363,7 +361,7 @@
  * @param $pid
  *   If the item is currently aliased, the pid for that item.
  * @param $verbose
- *   If the admin has enabled verbose, should be TRUE.  Else FALSE or NULL.
+ *   If the admin has enabled verbose, should be TRUE. Else FALSE or NULL.
  * @param $old_alias
  *   If the item is currently aliased, the existing alias for that item.
  */
@@ -376,7 +374,7 @@
     return;
   }
   // Alert users if they are trying to create an alias that is the same as the internal path
-  else if ($src == $dst) {
+  if ($src == $dst) {
     if ($verbose and user_access('notify of path changes')) {
       drupal_set_message(t('Ignoring alias %dst because it is the same as the internal path.', array('%dst' => $dst)));
     }
@@ -466,7 +464,7 @@
 function pathauto_punctuation_chars() {
   $punctuation = array();
 
-  // Handle " ' , . - _ : ; | { { } ] + = * & % $ � # @ ! ~ ( ) ? < > \
+  // Handle " ' , . - _ : ; | { { } ] + = * & % $ � # @ ! ~ ( ) ? < > \ � �
   $punctuation['double_quotes']      = array('value' => '"', 'name' => t('Double quotes "'));
   $punctuation['quotes']             = array('value' => "'", 'name' => t("Single quotes (apostrophe) '"));
   $punctuation['backtick']           = array('value' => '`', 'name' => t('Back tick `'));
diff -u ./pathauto.js ../pathauto6x/pathauto.js
--- ./pathauto.js	2008-03-06 03:55:12.000000000 +0100
+++ ../pathauto6x/pathauto.js	2008-03-06 03:56:05.000000000 +0100
@@ -1,22 +1,22 @@
 // $Id: pathauto.js,v 1.1.2.4 2008/03/06 02:55:12 greggles Exp $
 if (Drupal.jsEnabled) {
   $(document).ready(function() {
     if ($("#edit-pathauto-perform-alias").size() && $("#edit-pathauto-perform-alias").attr("checked")) {
       // Disable input and hide its description.
       $("#edit-path").attr("disabled","disabled");
-      $("//#edit-path ~ div[@class=description]").hide(0);
+      $("#edit-path-wrapper > div.description").hide(0);
     }
     $("#edit-pathauto-perform-alias").bind("click", function() {
       if ($("#edit-pathauto-perform-alias").attr("checked")) {
         // Auto-alias checked; disable input.
         $("#edit-path").attr("disabled","disabled");
-        $("//#edit-path ~ div[@class=description]").slideUp('slow');
+        $("#edit-path-wrapper > div[@class=description]").slideUp('fast');
       }
       else {
         // Auto-alias unchecked; enable input.
         $("#edit-path").removeAttr("disabled");
         $("#edit-path")[0].focus();
-        $("//#edit-path ~ div[@class=description]").slideDown('slow');
+        $("#edit-path-wrapper > div[@class=description]").slideDown('fast');
       }
     });
   });
diff -u ./pathauto.module ../pathauto6x/pathauto.module
--- ./pathauto.module	2008-05-30 02:58:55.000000000 +0200
+++ ../pathauto6x/pathauto.module	2008-05-30 17:04:36.000000000 +0200
@@ -89,7 +88,353 @@
 }
 
 /**
- * Callback for admin settings page.
+ * Implementation of hook_token_values() for Pathauto specific tokens.
+ */
+function pathauto_token_values($type, $object = NULL) {
+  if (module_exists('taxonomy')) {
+    if ($type == 'taxonomy' || $type == 'node' || $type == 'all') {
+      _pathauto_include();
+      switch ($type) {
+        case 'node':
+          $vid = db_result(db_query_range("SELECT t.vid FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.nid = %d ORDER BY v.weight, t.weight, t.name", $object->nid, 0, 1));
+          $category = db_fetch_object(db_query_range("SELECT t.tid, t.name FROM {term_data} t INNER JOIN {term_node} r ON r.tid = t.tid WHERE t.vid = %d AND r.nid = %d ORDER BY weight", $vid, $object->nid, 0, 1));
+          $category->vid = $vid;
+          // In the realm of nodes these are terms, in the realm of Taxonomy, cats
+          $label = 'term';
+
+          // We're on a node and it's a book and it has a parent? Get the book path alias
+          if (module_exists('book')) {
+            if ($object->type == 'book' && $object->parent) {
+              $values['bookpathalias'] = drupal_get_path_alias('node/'. $object->parent);
+            }
+            else {
+              $values['bookpathalias'] = '';
+            }
+          }
+
+        case 'taxonomy':
+        default:
+          if (!isset($category)) {
+            $category = $object;
+          }
+          if (!isset($label)) {
+            $label = 'cat';
+          }
+          if (isset($category->tid)) {
+            $separator = variable_get('pathauto_separator', '-');
+            $parents = taxonomy_get_parents_all($category->tid);
+            array_shift($parents);
+            $catpath = '';
+            $catpath_raw = '';
+            foreach ($parents as $parent) {
+              // Replace any / characters in individual terms which might create confusing URLs
+              $catpath = pathauto_cleanstring(check_plain(preg_replace('/\//', '', $parent->name))) .'/'. $catpath;
+              $catpath_raw = pathauto_cleanstring(preg_replace('/\//', '', $parent->name)) .'/'. $catpath_raw;
+            }
+            $values[$label .'path'] = $catpath .'/'. check_plain($category->name);
+            $values[$label .'path-raw'] = $catpath_raw .'/'. $category->name;
+            $values[$label .'alias'] = drupal_get_path_alias('taxonomy/term/'. $category->tid);
+            if (!strncasecmp($values[$label .'alias'], 'taxonomy', 8)) {
+              $values[$label .'alias'] = check_plain($category->name);
+            }
+          }
+          else { // Provide some defaults if they aren't set.
+            $values[$label .'path'] = '';
+            $values[$label .'path-raw'] = '';
+            $values[$label .'alias'] = '';
+          }
+      }
+      return $values;
+    }
+  }
+}
+
+/**
+ * Implementation of hook_token_list() for Pathauto specific tokens.
+ */
+function pathauto_token_list($type = 'all') {
+  $tokens = array();
+  if (module_exists('taxonomy')) {
+    if ($type == 'taxonomy' || $type == 'all') {
+      $tokens['taxonomy']['catpath'] = t('As [cat], but including its supercategories separated by /.');
+      $tokens['taxonomy']['catpath-raw'] = t('As [cat-raw], but including its supercategories separated by /. WARNING - raw user input.');
+      $tokens['taxonomy']['catalias'] = t('URL alias for the term.');
+    }
+    if ($type == 'node' || $type == 'all') {
+      $tokens['node']['termpath'] = t('As [term], but including its supercategories separated by /.');
+      $tokens['node']['termpath-raw'] = t('As [term-raw], but including its supercategories separated by /. WARNING - raw user input.');
+      $tokens['node']['termalias'] = t('URL alias for the term.');
+    }
+  }
+  if (module_exists('book')) {
+    if ($type == 'node' || $type == 'all') {
+      $tokens['node']['bookpathalias'] = t('URL alias for the parent book.');
+    }
+  }
+  return $tokens;
+}
+
+/**
+ * Implementation of hook_path_alias_types().
+ *
+ * Used primarily by the bulk delete form.
+ */
+function pathauto_path_alias_types() {
+  $objects = array('user/' => t('users'), 'node/' => t('content'));
+  if (module_exists('blog')) {
+    $objects['blog/'] = t('user blogs');
+  }
+  if (module_exists('taxonomy')) {
+    $objects['taxonomy/'] = t('vocabularies and terms');
+  }
+  if (module_exists('taxonomy')) {
+    $objects['user/%/track'] = t('user trackers');
+  }
+  if (module_exists('forum')) {
+    $objects['forum/%'] = t('forums');
+  }
+
+  return $objects;
+}
+
+//==============================================================================
+// Some node related functions.
+
+/**
+ * Implementation of hook_nodeapi().
+ */
+function pathauto_nodeapi(&$node, $op, $teaser, $page) {
+  _pathauto_include();
+  if (module_exists('path')) {
+    switch ($op) {
+      case 'presave':
+        // About to be saved (before insert/update)
+        if (isset($node->pathauto_perform_alias) && isset($node->old_alias)
+            && $node->pathauto_perform_alias && $node->path == '' && $node->old_alias != '') {
+          /**
+           * There was an old alias, but when pathauto_perform_alias was checked
+           * the javascript disabled the textbox which led to an empty value being
+           * submitted. Restoring the old path-value here prevents the Path module
+           * from deleting any old alias before Pathauto gets control.
+           */
+          $node->path = $node->old_alias;
+        }
+        break;
+      case 'insert':
+      case 'update':
+        // Get the specific pattern or the default
+        if (!empty($node->language)) {
+          $pattern = variable_get('pathauto_node_'. $node->type .'_'. $node->language .'_pattern', FALSE);
+        }
+        if (!trim($pattern)) {
+          $pattern = variable_get('pathauto_node_'. $node->type .'_pattern', FALSE);
+          if (!trim($pattern)) {
+            $pattern = variable_get('pathauto_node_pattern', FALSE);
+          }
+        }
+        // Only do work if there's a pattern
+        if ($pattern) {
+          // Only create an alias if the checkbox was not provided or if the checkbox was provided and is checked
+          if (!isset($node->pathauto_perform_alias) || $node->pathauto_perform_alias) {
+            $placeholders = pathauto_get_placeholders('node', $node);
+            $src = "node/$node->nid";
+            $alias = pathauto_create_alias('node', $op, $placeholders, $src, $node->nid, $node->type, $node->language);
+          }
+        }
+        break;
+      case 'delete':
+        path_set_alias('node/'. $node->nid);
+        path_set_alias('node/'. $node->nid .'/feed');
+        break;
+      default:
+        break;
+    }
+  }
+}
+
+/**
+ * Implementation of hook_form_alter().
+ *
+ * This allows alias creators to override Pathauto and specify their
+ * own aliases (Pathauto will be invisible to other users). Inserted
+ * into the path module's fieldset in the node form.
+ */
+function pathauto_form_alter(&$form, $form_state, $form_id) {
+  // Only do this for node forms
+  if (isset($form['#id']) && ($form['#id'] == 'node-form') && arg(0) == 'node') {
+    // See if there is a pathauto pattern or default applicable
+    if (isset($form['language'])) {
+      $language = isset($form['language']['#value']) ? $form['language']['#value'] : $form['language']['#default_value'];
+      $pattern = variable_get('pathauto_node_'. $form['type']['#value'] .'_'. $language .'_pattern', FALSE);
+    }
+    if (!trim($pattern)) {
+      $pattern = variable_get('pathauto_node_'. $form['type']['#value'] .'_pattern', FALSE);
+      if (!trim($pattern)) {
+        $pattern = variable_get('pathauto_node_pattern', FALSE);
+      }
+    }
+    // If there is a pattern AND the user is allowed to create aliases AND the path textbox is present on this form
+    if ($pattern && user_access('create url aliases') && isset($form['path']['path'])) {
+      $output = t('An alias will be generated for you. If you wish to create your own alias below, untick this option.');
+      if (user_access('administer pathauto')) {
+        $output .= t(' To control the format of the generated aliases, see the <a href="@pathauto">Pathauto settings</a>.', array('@pathauto' => url('admin/build/path/pathauto')));
+      }
+
+      drupal_add_js(drupal_get_path('module', 'pathauto') .'/pathauto.js');
+      $form['path']['#collapsed'] = FALSE;
+
+      $form['path']['pathauto_perform_alias'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Automatic alias'),
+        '#default_value' => TRUE,
+        '#description' => $output,
+        '#weight' => 0
+      );
+
+      //For Pathauto to remember the old alias and prevent the Path-module from deleteing it when Pathauto wants to preserve it
+      $old_alias = $form['path']['path']['#default_value'];
+      $form['path']['old_alias'] = array('#type' => 'value', '#value' => $old_alias);
+    }
+  }
+}
+
+/**
+ * Implementation of hook_node_operations().
+ */
+function pathauto_node_operations() {
+  $operations = array(
+    'update_alias' => array(
+      'label' => t('Update path alias'),
+      'callback' => 'pathauto_node_operations_update',
+    ),
+  );
+  return $operations;
+}
+
+/**
+ * Callback function for updating node aliases.
+ *
+ * @param $nodes
+ *   Array of node nid's.
+ */
+function pathauto_node_operations_update($nodes) {
+  foreach ($nodes as $nid) {
+    $node = node_load($nid);
+    $placeholders = pathauto_get_placeholders('node', $node);
+    pathauto_create_alias('node', 'bulkupdate', $placeholders, "node/$node->nid", $node->nid, $node->type);
+  }
+}
+
+//==============================================================================
+// Taxonomy related functions.
+
+/**
+ * Implementation of hook_taxonomy().
+ */
+function pathauto_taxonomy($op, $type, $object = NULL) {
+  _pathauto_include();
+  switch ($type) {
+    case 'term':
+      switch ($op) {
+        case 'insert':
+        case 'update':
+          // Use the category info to automatically create an alias
+          $category = (object) $object;
+          if ($category->name) {
+            $count = _taxonomy_pathauto_alias($category, $op);
+          }
+
+          // For all children generate new alias (important if [catpath] used)
+          foreach (taxonomy_get_tree($category->vid, $category->tid) as $subcategory) {
+            $count = _taxonomy_pathauto_alias($subcategory, $op);
+          }
+
+          break;
+        case 'delete':
+          // If the category is deleted, remove the path aliases
+          $category = (object) $object;
+          path_set_alias('taxonomy/term/'. $category->tid);
+          path_set_alias(taxonomy_term_path($category));
+          path_set_alias('forum/'. $category->tid);
+          path_set_alias('taxonomy/term/'. $category->tid .'/0/feed');
+          break;
+        default:
+          break;
+      }
+      break;
+    default:
+      break;
+  }
+}
+
+//==============================================================================
+// User related functions.
+
+/**
+ * Implementation of hook_user() for users, trackers, and blogs.
+ */
+function pathauto_user($op, &$edit, &$user, $category = FALSE) {
+  _pathauto_include();
+  switch ($op) {
+    case 'insert':
+    case 'update':
+      // Use the username to automatically create an alias
+      $pathauto_user = (object) array_merge((array) $user, $edit);
+      if ($user->name) {
+        $placeholders = pathauto_get_placeholders('user', $pathauto_user);
+        $src = 'user/'. $user->uid;
+        $alias = pathauto_create_alias('user', $op, $placeholders, $src, $user->uid);
+
+        if (module_exists('blog')) {
+          $new_user = $user;
+          $new_user->roles = isset($edit['roles']) ? $edit['roles']: array();
+          $new_user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user'; // Add this back
+          if (user_access('create blog entries', $new_user)) {
+            $src = 'blog/'. $user->uid;
+            $alias = pathauto_create_alias('blog', $op, $placeholders, $src, $user->uid);
+          }
+          else {
+            path_set_alias('blog/'. $user->uid);
+            path_set_alias('blog/'. $user->uid .'/feed');
+          }
+        }
+        if (module_exists('tracker')) {
+          $src = 'user/'. $user->uid .'/track';
+          $alias = pathauto_create_alias('tracker', $op, $placeholders, $src, $user->uid);
+        }
+      }
+      break;
+    case 'delete':
+      // If the user is deleted, remove the path aliases
+      $user = (object) $user;
+      path_set_alias('user/'. $user->uid);
+
+      // They may have enabled these modules and/or feeds when the user was created, so let's try to delete all of them
+      path_set_alias('blog/'. $user->uid);
+      path_set_alias('blog/'. $user->uid .'/feed');
+      path_set_alias('user/'. $user->uid .'/track');
+      path_set_alias('user/'. $user->uid .'/track/feed');
+
+      break;
+    default:
+      break;
+  }
+}
+
+/**
+ * Form builder; Configure the Pathauto system.
+ *
+ * @ingroup forms
+ * @see system_settings_form()
  */
 function pathauto_admin_settings() {
   _pathauto_include();
@@ -284,7 +629,6 @@
     if (isset($settings->patternitems)) {
       foreach ($settings->patternitems as $itemname => $itemlabel) {
         $variable = 'pathauto_'. $module .'_'. $itemname .'_pattern';
-        $description = '';
         if (!count($_POST)) {
           $error = _pathauto_check_pattern(variable_get($variable, $patterndefault), $settings->token_type);
           if ($error) {
@@ -407,147 +752,53 @@
       $token = str_replace('[', '', str_replace(']', '', $token));
       // Check if the token is even valid in this context.
       if (!array_key_exists($token, $all_tokens)) {
-        drupal_set_message(t('You are using the token [%token] which is not valid within the scope of tokens where you are using it.', array('%token' => $token)), 'error');
-        $return[] = $token;
-      }
-      // Check if there is a raw companion that they should be using.
-      elseif (!preg_match('/\-raw/i', $token)) {
-        $raw_token = $token .'-raw';
-        if (array_key_exists($raw_token, $all_tokens)) {
-          if (!isset($warned) || !array_key_exists($token, $warned)) {
-            drupal_set_message(t('You are using the token [%token] which has a -raw companion available [%raw_token]. For Pathauto patterns you should use the -raw version of tokens unless you really know what you are doing. See the <a href="@pathauto-help">Pathauto help</a> for more details.', array('%token' => $token, '%raw_token' => $raw_token, '@pathauto-help' => url('admin/help/pathauto'))), 'error');
-            $warned[$token] = $token;
-          }
-          $return[] = $token;
-        }
-      }
-    }
-  }
-
-  if ($return) {
-    $description = t('NOTE: This field contains potentially incorrect patterns. ');
-    $description .= format_plural(count($return), 'Problem token: ', 'Problem tokens: ');
-    $description .= t('%problems', array('%problems' => implode(', ', $return)));
-    $return = $description;
-  }
-
-  return $return;
-}
-
-/**
- * Validate pathauto_admin_settings form submissions.
- */
-function pathauto_admin_settings_validate($form_id, $form_values) {
-  // Validate that the separator is not set to be removed per http://drupal.org/node/184119
-  // This isn't really all that bad so warn, but still allow them to save the value.
-  $separator = $form_values['pathauto_separator'];
-  $punctuation = pathauto_punctuation_chars();
-  foreach ($punctuation as $name => $details) {
-    if ($details['value'] == $separator) {
-      $action = $form_values['pathauto_punctuation_'. $name];
-      if ($action == 0) {
-        drupal_set_message(t('You have configured the @name to be the separator and to be removed when encountered in strings. This can cause problems with your patterns and especially with the catpath and termpath patterns. You should probably set the action for @name to be "replace by separator"', array('@name' => $details['name'])), 'error');
-      }
-    }
-  }
-}
-
-/**
- * Implementation of hook_token_values() for Pathauto specific tokens.
- */
-function pathauto_token_values($type, $object = NULL) {
-  if (module_exists('taxonomy')) {
-    if ($type == 'taxonomy' || $type == 'node' || $type == 'all') {
-      _pathauto_include();
-      switch ($type) {
-        case 'node':
-          $vid = db_result(db_query_range("SELECT t.vid FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.nid = %d ORDER BY v.weight, t.weight, t.name", $object->nid, 0, 1));
-          $category = db_fetch_object(db_query_range("SELECT t.tid, t.name FROM {term_data} t INNER JOIN {term_node} r ON r.tid = t.tid WHERE t.vid = %d AND r.nid = %d ORDER BY weight", $vid, $object->nid, 0, 1));
-          $category->vid = $vid;
-          // In the realm of nodes these are terms, in the realm of Taxonomy, cats
-          $label = 'term';
-
-          // We're on a node and it's a book and it has a parent? Get the book path alias
-          if (module_exists('book')) {
-            if ($object->type == 'book' && $object->parent) {
-              $values['bookpathalias'] = drupal_get_path_alias('node/'. $object->parent);
-            }
-            else {
-              $values['bookpathalias'] = '';
-            }
-          }
-
-        case 'taxonomy':
-        default:
-          if (!isset($category)) {
-            $category = $object;
-          }
-          if (!isset($label)) {
-            $label = 'cat';
-          }
-          if (isset($category->tid)) {
-            $separator = variable_get('pathauto_separator', '-');
-            $parents = taxonomy_get_parents_all($category->tid);
-            array_shift($parents);
-            $catpath = '';
-            $catpath_raw = '';
-            foreach ($parents as $parent) {
-              // Replace any / characters in individual terms which might create confusing URLs
-              $catpath = pathauto_cleanstring(check_plain(preg_replace('/\//', '', $parent->name))) .'/'. $catpath;
-              $catpath_raw = pathauto_cleanstring(preg_replace('/\//', '', $parent->name)) .'/'. $catpath_raw;
-            }
-            $values[$label .'path'] = $catpath .'/'. check_plain($category->name);
-            $values[$label .'path-raw'] = $catpath_raw .'/'. $category->name;
-
-            // We only do this for taxonomy because token already provides the [term] value but has problem with [cat] TODO: fix that?
-            if ($type == 'taxonomy') {
-              $values[$label] = check_plain($category->name);
-              $values[$label .'-raw'] = $category->name;
-            }
-
-            $values[$label .'alias'] = drupal_get_path_alias('taxonomy/term/'. $category->tid);
-            if (!strncasecmp($values[$label .'alias'], 'taxonomy', 8)) {
-              $values[$label .'alias'] = $values[$label];
-            }
-          }
-          else { // Provide some defaults if they aren't set.
-            $values[$label .'path'] = '';
-            $values[$label .'path-raw'] = '';
-            $values[$label .'alias'] = '';
+        drupal_set_message(t('You are using the token [%token] which is not valid within the scope of tokens where you are using it.', array('%token' => $token)), 'error');
+        $return[] = $token;
+      }
+      // Check if there is a raw companion that they should be using.
+      elseif (!preg_match('/\-raw/i', $token)) {
+        $raw_token = $token .'-raw';
+        if (array_key_exists($raw_token, $all_tokens)) {
+          if (!isset($warned) || !array_key_exists($token, $warned)) {
+            drupal_set_message(t('You are using the token [%token] which has a -raw companion available [%raw_token]. For Pathauto patterns you should use the -raw version of tokens unless you really know what you are doing. See the <a href="@pathauto-help">Pathauto help</a> for more details.', array('%token' => $token, '%raw_token' => $raw_token, '@pathauto-help' => url('admin/help/pathauto'))), 'error');
+            $warned[$token] = $token;
           }
+          $return[] = $token;
+        }
       }
-      return $values;
     }
   }
+
+  if ($return) {
+    $description = t('NOTE: This field contains potentially incorrect patterns. ');
+    $description .= format_plural(count($return), 'Problem token: ', 'Problem tokens: ');
+    $description .= t('%problems', array('%problems' => implode(', ', $return)));
+    $return = $description;
+  }
+
+  return $return;
 }
 
 /**
- * Implementation of hook_token_list() for Pathauto specific tokens.
+ * Validate pathauto_admin_settings form submissions.
  */
-function pathauto_token_list($type = 'all') {
-  $tokens = array();
-  if (module_exists('taxonomy')) {
-    if ($type == 'taxonomy' || $type == 'all') {
-      $tokens['taxonomy']['catpath'] = t('As [cat], but including its supercategories separated by /.');
-      $tokens['taxonomy']['catpath-raw'] = t('As [cat-raw], but including its supercategories separated by /. WARNING - raw user input.');
-      $tokens['taxonomy']['catalias'] = t('URL alias for the category.');
-    }
-    if ($type == 'node' || $type == 'all') {
-      $tokens['node']['termpath'] = t('As [term], but including its supercategories separated by /.');
-      $tokens['node']['termpath-raw'] = t('As [term-raw], but including its supercategories separated by /. WARNING - raw user input.');
-      $tokens['node']['termalias'] = t('URL alias for the term.');
-    }
-  }
-  if (module_exists('book')) {
-    if ($type == 'node' || $type == 'all') {
-      $tokens['node']['bookpathalias'] = t('URL alias for the parent book.');
+function pathauto_admin_settings_validate($form, &$form_state) {
+  // Validate that the separator is not set to be removed per http://drupal.org/node/184119
+  // This isn't really all that bad so warn, but still allow them to save the value.
+  $separator = $form_state['values']['pathauto_separator'];
+  $punctuation = pathauto_punctuation_chars();
+  foreach ($punctuation as $name => $details) {
+    if ($details['value'] == $separator) {
+      $action = $form_state['values']['pathauto_punctuation_'. $name];
+      if ($action == 0) {
+        drupal_set_message(t('You have configured the @name to be the separator and to be removed when encountered in strings. This can cause problems with your patterns and especially with the catpath and termpath patterns. You should probably set the action for @name to be "replace by separator"', array('@name' => $details['name'])), 'error');
+      }
     }
   }
-  return $tokens;
 }
 
 /**
- * Menu callback: select certain alias types to delete.
+ * Menu callback; select certain alias types to delete.
  */
 function pathauto_admin_delete() {
   /* TODO:
@@ -618,223 +869,5 @@
       }
     }
   }
-  return 'admin/build/path/delete_bulk';
-}
-
-/**
- * Implementation of hook_path_alias_types().
- *
- * Used primarily by the bulk delete form.
- */
-function pathauto_path_alias_types() {
-  $objects = array('user/' => t('users'), 'node/' => t('content'));
-  if (module_exists('blog')) {
-    $objects['blog/'] = t('user blogs');
-  }
-  if (module_exists('taxonomy')) {
-    $objects['taxonomy/'] = t('vocabularies and terms');
-  }
-  if (module_exists('taxonomy')) {
-    $objects['user/%/track'] = t('user trackers');
-  }
-  if (module_exists('forum')) {
-    $objects['forum/%'] = t('forums');
-  }
-
-  return $objects;
-}
-
-//==============================================================================
-// Some node related functions.
-
-/**
- * Implementation of hook_nodeapi().
- */
-function pathauto_nodeapi(&$node, $op, $teaser, $page) {
-  _pathauto_include();
-  if (module_exists('path')) {
-    switch ($op) {
-      case 'insert':
-      case 'update':
-        // Get the specific pattern or the default
-        $pattern = variable_get('pathauto_node_'. $node->type .'_pattern', FALSE);
-        if (!$pattern) {
-          $pattern = variable_get('pathauto_node_pattern', FALSE);
-        }
-        // Only do work if there's a pattern
-        if ($pattern) {
-          // Only create an alias if the checkbox was not provided or if the checkbox was provided and is checked
-          if (!isset($node->pathauto_perform_alias) || $node->pathauto_perform_alias) {
-            $placeholders = pathauto_get_placeholders('node', $node);
-            $src = "node/$node->nid";
-            $alias = pathauto_create_alias('node', $op, $placeholders, $src, $node->nid, $node->type);
-          }
-        }
-        break;
-      case 'delete':
-        path_set_alias('node/'. $node->nid);
-        path_set_alias('node/'. $node->nid .'/feed');
-        break;
-      default:
-        break;
-    }
-  }
-}
-
-/**
- * Implementation of hook_form_alter().
- *
- * This allows alias creators to override Pathauto and specify their
- * own aliases (Pathauto will be invisible to other users). Inserted
- * into the path module's fieldset in the node form.
- */
-function pathauto_form_alter($formid, &$form) {
-  // Only do this for node forms
-  if (isset($form['#id']) && ($form['#id'] == 'node-form') && arg(0) == 'node') {
-    // See if there is a pathauto pattern or default applicable
-    $pattern = variable_get('pathauto_node_'. $form['type']['#value'] .'_pattern', FALSE);
-    if (!$pattern) {
-      $pattern = variable_get('pathauto_node_pattern', FALSE);
-    }
-    // If there is a pattern AND the user is allowed to create aliases AND the path textbox is present on this form
-    if ($pattern && user_access('create url aliases') && isset($form['path']['path'])) {
-      $output = t('An alias will be generated for you. If you wish to create your own alias below, untick this option.');
-      if (user_access('administer pathauto')) {
-        $output .= t(' To control the format of the generated aliases, see the <a href="@pathauto">Pathauto settings</a>.', array('@pathauto' => url('admin/settings/pathauto')));
-      }
-
-      drupal_add_js(drupal_get_path('module', 'pathauto') .'/pathauto.js');
-
-      $form['path']['pathauto_perform_alias'] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Automatic alias'),
-        '#default_value' => TRUE,
-        '#description' => $output,
-        '#weight' => 0
-      );
-    }
-  }
-}
-
-/**
- * Implementation of hook_node_operations().
- */
-function pathauto_node_operations() {
-  $operations = array(
-    'update_alias' => array(
-      'label' => t('Update path alias'),
-      'callback' => 'pathauto_node_operations_update',
-    ),
-  );
-  return $operations;
-}
-
-/**
- * Callback function for updating node aliases.
- *
- * @param $nodes
- *   Array of node nid's.
- */
-function pathauto_node_operations_update($nodes) {
-  foreach ($nodes as $nid) {
-    $node = node_load($nid);
-    $placeholders = pathauto_get_placeholders('node', $node);
-    pathauto_create_alias('node', 'bulkupdate', $placeholders, "node/$node->nid", $node->nid, $node->type);
-  }
-}
-
-//==============================================================================
-// Taxonomy related functions.
-
-/**
- * Implementation of hook_taxonomy().
- */
-function pathauto_taxonomy($op, $type, $object = NULL) {
-  _pathauto_include();
-  switch ($type) {
-    case 'term':
-      switch ($op) {
-        case 'insert':
-        case 'update':
-          // Use the category info to automatically create an alias
-          $category = (object) $object;
-          if ($category->name) {
-            $count = _taxonomy_pathauto_alias($category, $op);
-          }
-
-          // For all children generate new alias (important if [catpath] used)
-          foreach (taxonomy_get_tree($category->vid, $category->tid) as $subcategory) {
-            $count = _taxonomy_pathauto_alias($subcategory, $op);
-          }
-
-          break;
-        case 'delete':
-          // If the category is deleted, remove the path aliases
-          $category = (object) $object;
-          path_set_alias('taxonomy/term/'. $category->tid);
-          path_set_alias(taxonomy_term_path($category));
-          path_set_alias('forum/'. $category->tid);
-          path_set_alias('taxonomy/term/'. $category->tid .'/0/feed');
-          break;
-        default:
-          break;
-      }
-      break;
-    default:
-      break;
-  }
-}
-
-//==============================================================================
-// User related functions.
-
-/**
- * Implementation of hook_user() for users, trackers, and blogs.
- */
-function pathauto_user($op, &$edit, &$user, $category = FALSE) {
-  _pathauto_include();
-  switch ($op) {
-    case 'insert':
-    case 'update':
-      // Use the username to automatically create an alias
-      $pathauto_user = (object) array_merge((array) $user, $edit);
-      if ($user->name) {
-        $placeholders = pathauto_get_placeholders('user', $pathauto_user);
-        $src = 'user/'. $user->uid;
-        $alias = pathauto_create_alias('user', $op, $placeholders, $src, $user->uid);
-
-        if (module_exists('blog')) {
-          $new_user = $user;
-          $new_user->roles = isset($edit['roles']) ? $edit['roles'] : array();
-          $new_user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user'; // Add this back
-          if (user_access('edit own blog', $new_user)) {
-            $src = 'blog/'. $user->uid;
-            $alias = pathauto_create_alias('blog', $op, $placeholders, $src, $user->uid);
-          }
-          else {
-            path_set_alias('blog/'. $user->uid);
-            path_set_alias('blog/'. $user->uid .'/feed');
-          }
-        }
-        if (module_exists('tracker')) {
-          $src = 'user/'. $user->uid .'/track';
-          $alias = pathauto_create_alias('tracker', $op, $placeholders, $src, $user->uid);
-        }
-      }
-      break;
-    case 'delete':
-      // If the user is deleted, remove the path aliases
-      $user = (object) $user;
-      path_set_alias('user/'. $user->uid);
-
-      // They may have enabled these modules and/or feeds when the user was created, so let's try to delete all of them
-      path_set_alias('blog/'. $user->uid);
-      path_set_alias('blog/'. $user->uid .'/feed');
-      path_set_alias('user/'. $user->uid .'/track');
-      path_set_alias('user/'. $user->uid .'/track/feed');
-
-      break;
-    default:
-      break;
-  }
+  $form_state['redirect'] = 'admin/build/path/delete_bulk';
 }
diff -u ./pathauto_node.inc ../pathauto6x/pathauto_node.inc
--- ./pathauto_node.inc	2008-05-30 02:58:55.000000000 +0200
+++ ../pathauto6x/pathauto_node.inc	2008-05-28 18:04:35.000000000 +0200
@@ -32,10 +32,15 @@
         }
       }
       $settings['supportsfeeds'] = 'feed';
-      $nodetypes = node_get_types();
-      foreach ($nodetypes as $ntype => $nodetype) {
-        $fieldlabel = t('Pattern for all @node_type paths', array('@node_type' => $nodetype->name));
-        $settings['patternitems'][$ntype] = $fieldlabel;
+
+      $languages = module_exists('locale') ? locale_language_list() : array();
+      foreach (node_get_types('names') as $node_type => $node_name) {
+        $fieldlabel = t('Pattern for all @node_type paths', array('@node_type' => $node_name));
+        $settings['patternitems'][$node_type] = $fieldlabel;
+        foreach ($languages as $lang_code => $lang_name) {
+          $fieldlabel = t('Pattern for all @node_type paths in @language', array('@node_type' => $node_name, '@language' => $lang_name));
+          $settings['patternitems'][$node_type .'_'. $lang_code] = $fieldlabel;
+        }
       }
       return (object) $settings;
     default:
@@ -50,45 +55,49 @@
 
   // From all node types, only attempt to update those with patterns
   $pattern_types = array();
-  $type_where = '';
-  foreach (node_get_types() as $type => $info) {
-    $pattern = '';
-    $pattern = variable_get('pathauto_node_'. $type .'_pattern', '');
-
-    // If it's not set, check the default
-    if (!trim($pattern)) {
-      $pattern = variable_get('pathauto_node_pattern', '');
-    }
-    if (trim($pattern)) {
-      $pattern_types[] = $type;
-      if (!trim($type_where)) {
-        $type_where = " AND (type = '%s' ";
+
+  // If there's a default pattern we assume all types might be updated.
+  if (trim(variable_get('pathauto_node_pattern', ''))) {
+    $pattern_types = array_keys(node_get_types('names'));
+  }
+  else {
+    // Check first for a node specific pattern...
+    $languages = module_exists('locale') ? locale_language_list() : array();
+    foreach (array_keys(node_get_types('names')) as $type) {
+      if (trim(variable_get('pathauto_node_'. $type .'_pattern', ''))) {
+        $pattern_types[$type] = $type;
+        continue;
       }
-      else {
-        $type_where .= " OR type = '%s'";
+      // ...then for a node-language pattern.
+      foreach ($languages as $lang_code => $lang_name) {
+        if (trim(variable_get('pathauto_node_'. $type .'_'. $lang_code .'_pattern', ''))) {
+          $pattern_types[$type] = $type;
+          continue 2;
+        }
       }
     }
   }
-  $type_where .= ')';
-
-  $query = "SELECT nid, type, title, uid, created, src, dst, vid FROM {node} LEFT JOIN {url_alias} ON CONCAT('node/', CAST(nid AS CHAR)) = src WHERE src IS NULL ". $type_where;
-  $result = db_query_range($query, $pattern_types, 0, variable_get('pathauto_max_bulk_update', 50));
 
   $count = 0;
-  $placeholders = array();
-  while ($node_ref = db_fetch_object($result)) {
-    $node = node_load($node_ref->nid, NULL, TRUE);
-    $node->src = $node_ref->src;
-    $node->dst = $node_ref->dst;
-    if (module_exists('taxonomy')) {
+  if (count($pattern_types)) {
+    $query = "SELECT n.nid, n.vid, n.type, n.title, n.uid, n.created, n.language, alias.src, alias.dst FROM {node} n LEFT JOIN {url_alias} alias ON CONCAT('node/', CAST(n.nid AS CHAR)) = alias.src WHERE alias.src IS NULL AND n.type IN (". db_placeholders($pattern_types, 'varchar') .')';
+    $result = db_query_range($query, $pattern_types, 0, variable_get('pathauto_max_bulk_update', 50));
+
+    $placeholders = array();
+    while ($node_ref = db_fetch_object($result)) {
+      $node = node_load($node_ref->nid, NULL, TRUE);
+      $node->src = $node_ref->src;
+      $node->dst = $node_ref->dst;
+      if (module_exists('taxonomy')) {
         // Must populate the terms for the node here for the category
         // placeholders to work
-        $node->taxonomy = array_keys(taxonomy_node_get_terms($node->nid));
-    }
-    $placeholders = pathauto_get_placeholders('node', $node);
-    $src = "node/$node->nid";
-    if ($alias = pathauto_create_alias('node', 'bulkupdate', $placeholders, $src, $node->nid, $node->type)) {
-      $count++;
+        $node->taxonomy = array_keys(taxonomy_node_get_terms($node));
+      }
+      $placeholders = pathauto_get_placeholders('node', $node);
+      $src = "node/$node->nid";
+      if ($alias = pathauto_create_alias('node', 'bulkupdate', $placeholders, $src, $node->nid, $node->type, $node->language)) {
+        $count++;
+      }
     }
   }
 
diff -u ./pathauto_taxonomy.inc ../pathauto6x/pathauto_taxonomy.inc
--- ./pathauto_taxonomy.inc	2008-05-30 02:58:55.000000000 +0200
+++ ../pathauto6x/pathauto_taxonomy.inc	2008-05-28 18:04:35.000000000 +0200
@@ -17,7 +17,7 @@
       $settings = array();
       $settings['module'] = 'taxonomy';
       $settings['token_type'] = 'taxonomy';
-      $settings['groupheader'] = t('Category path settings');
+      $settings['groupheader'] = t('Taxonomy term path settings');
       $settings['patterndescr'] = t('Default path pattern (applies to all vocabularies with blank patterns below)');
       $settings['patterndefault'] = t('category/[vocab-raw]/[catpath-raw]');
       $patterns = token_get_list('taxonomy');
@@ -29,8 +29,8 @@
         }
       }
       $settings['supportsfeeds'] = '0/feed';
-      $settings['bulkname'] = t('Bulk generate aliases for categories that are not aliased');
-      $settings['bulkdescr'] = t('Generate aliases for all existing categories which do not already have aliases.');
+      $settings['bulkname'] = t('Bulk generate aliases for terms that are not aliased');
+      $settings['bulkdescr'] = t('Generate aliases for all existing terms which do not already have aliases.');
 
       $vocabularies = taxonomy_get_vocabularies();
       if (sizeof($vocabularies) > 0) {
