Index: pathauto_node.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/pathauto/pathauto_node.inc,v retrieving revision 1.29 diff -u -r1.29 pathauto_node.inc --- pathauto_node.inc 11 Nov 2006 23:34:51 -0000 1.29 +++ pathauto_node.inc 11 Dec 2006 00:21:10 -0000 @@ -155,11 +155,60 @@ // And now taxonomy, which is a bit more work if (module_exists('taxonomy') && is_array($node->taxonomy) && count($node->taxonomy) > 0) { - // When editing a node, the taxonomy array might have one or more zero - // term IDs. Ignore them... - foreach ($node->taxonomy as $firsttermid) { - if ($firsttermid) { - break; + if ($firsttermid) { + $firsttermid = FALSE; + //we loop through the array assuming it's in wheigh order, which is false, but close enough TODO: fix that + + foreach ($node->taxonomy as $key => $value) { //I'd use more descriptive variables, but the content isn't always a tid + if($key == 'tags') { //it's a freetag so make sure that there is a value in the array + //shamelessly stolen from taxonomy_node_save - most of it should be refactored out of that + //so it can be easily reused, but until then: copy-paste-antipattern here we come! + + $typed_input = $value; + foreach ((array)$typed_input as $vid => $vid_value) { + if ($firsttermid) break; + // This regexp allows the following types of user input: + // this, "somecmpany, llc", "and ""this"" w,o.rks", foo bar + $regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x'; + preg_match_all($regexp, $vid_value, $matches); + $typed_terms = array_unique($matches[1]); + + $inserted = array(); + foreach ($typed_terms as $typed_term) { + if ($firsttermid) break; + // If a user has escaped a term (to demonstrate that it is a group, + // or includes a comma or quote character), we remove the escape + // formatting so to save the term into the DB as the user intends. + $typed_term = str_replace('""', '"', preg_replace('/^"(.*)"$/', '\1', $typed_term)); + $typed_term = trim($typed_term); + if ($typed_term == "") { continue; } + + // See if the term exists in the chosen vocabulary + // and return the tid, otherwise, add a new record. + $possibilities = taxonomy_get_term_by_name($typed_term); + $typed_term_tid = NULL; // tid match if any. + foreach ($possibilities as $possibility) { + if ($possibility->vid == $vid) { + $firsttermid = $possibility->tid; + break; //we've got our first term ID, get out of here + } + } + } + } + } //not freetagging (or not yet) + // When editing a node, a multiselect vocabulary with nothing selected will have a "zero"" + // term IDs. Ignore them... + elseif (is_array($value)) { + $temptid = array_shift($value); + if($temptid) { + $firsttermid = $temptid; + break; + } + } + elseif ($value) { + $firsttermid = $value; + break; + } } } $term = taxonomy_get_term($firsttermid); Index: pathauto_taxonomy.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/pathauto/pathauto_taxonomy.inc,v retrieving revision 1.20 diff -u -r1.20 pathauto_taxonomy.inc --- pathauto_taxonomy.inc 11 Nov 2006 23:17:58 -0000 1.20 +++ pathauto_taxonomy.inc 11 Dec 2006 00:25:20 -0000 @@ -119,7 +119,7 @@ if ($category->parent) { $catpath = pathauto_cleanstring($category->name); - $parents = taxonomy_get_parents_all($category->parent); + $parents = taxonomy_get_parents_all(array_shift($category->parent)); } else { $catpath = '';