? taxonomy_refactor.patch
? taxonomyrelation
? taxonomyrelation.tar.gz.txt
? taxonomysynonyms
Index: taxonomy.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.admin.inc,v
retrieving revision 1.27
diff -u -p -r1.27 taxonomy.admin.inc
--- taxonomy.admin.inc	16 Jul 2008 21:59:28 -0000	1.27
+++ taxonomy.admin.inc	10 Sep 2008 21:57:40 -0000
@@ -233,9 +233,9 @@ function taxonomy_admin_vocabulary_edit(
 /**
  * Page to edit a vocabulary term.
  */
-function taxonomy_admin_term_edit($tid) {
-  if ($term = (array)taxonomy_get_term($tid)) {
-    return drupal_get_form('taxonomy_form_term', taxonomy_vocabulary_load($term['vid']), $term);
+function taxonomy_admin_term_edit($term) {
+  if (isset($term)) {
+    return drupal_get_form('taxonomy_form_term', taxonomy_vocabulary_load($term->vid), (array)$term);
   }
   return drupal_not_found();
 }
@@ -835,7 +835,7 @@ function taxonomy_term_confirm_parents(&
  * @see taxonomy_term_confirm_delete_submit()
  */
 function taxonomy_term_confirm_delete(&$form_state, $tid) {
-  $term = taxonomy_get_term($tid);
+  $term = taxonomy_term_load($tid);
 
   $form['type'] = array('#type' => 'value', '#value' => 'term');
   $form['name'] = array('#type' => 'value', '#value' => $term->name);
Index: taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.425
diff -u -p -r1.425 taxonomy.module
--- taxonomy.module	24 Jul 2008 16:25:19 -0000	1.425
+++ taxonomy.module	10 Sep 2008 21:57:40 -0000
@@ -142,9 +142,10 @@ function taxonomy_menu() {
     'type' => MENU_CALLBACK,
   );
 
-  $items['admin/content/taxonomy/edit/term'] = array(
+  $items['admin/content/taxonomy/edit/term/%taxonomy_term'] = array(
     'title' => 'Edit term',
     'page callback' => 'taxonomy_admin_term_edit',
+    'page arguments' => array(5),
     'access arguments' => array('administer taxonomy'),
     'type' => MENU_CALLBACK,
   );
@@ -156,6 +157,18 @@ function taxonomy_menu() {
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
+  $items['taxonomy/term/%/view'] = array(
+    'title' => 'View',
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+  );
+  $items['taxonomy/term/%taxonomy_term/edit'] = array(
+    'title' => 'Edit term',
+    'page callback' => 'taxonomy_admin_term_edit',
+    'page arguments' => array(2),
+    'access arguments' => array('administer taxonomy'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 10,
+  );
 
   $items['taxonomy/autocomplete'] = array(
     'title' => 'Autocomplete taxonomy',
@@ -386,7 +399,7 @@ function taxonomy_del_term($tid) {
         }
       }
 
-      $term = (array) taxonomy_get_term($tid);
+      $term = (array) taxonomy_term_load($tid);
 
       db_query('DELETE FROM {term_data} WHERE tid = %d', $tid);
       db_query('DELETE FROM {term_hierarchy} WHERE tid = %d', $tid);
@@ -728,20 +741,19 @@ function taxonomy_node_type($op, $info) 
 }
 
 /**
- * Find all term objects related to a given term ID.
+ * Find all parent tids of a given term ID.
  */
-function taxonomy_get_related($tid, $key = 'tid') {
+function taxonomy_get_parent_tids($tid) {
   if ($tid) {
-    $result = db_query('SELECT t.*, tid1, tid2 FROM {term_relation}, {term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name', $tid, $tid, $tid);
-    $related = array();
-    while ($term = db_fetch_object($result)) {
-      $related[$term->$key] = $term;
+    $result = db_query(db_rewrite_sql("SELECT t.tid FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.parent = t.tid WHERE h.tid = :tid ORDER BY weight, name", 't', 'tid'), array(':tid' => $tid));
+    $parents = array();
+    foreach ($result AS $tid) {
+      drupal_set_message('<pre>' . var_dump($tid->tid) . '</pre>');
+
+      $parents[] = $tid->tid;
     }
-    return $related;
-  }
-  else {
-    return array();
   }
+  return $parents;
 }
 
 /**
@@ -1005,11 +1017,48 @@ function taxonomy_vocabulary_load($vid) 
  * @return Object
  *   A term object. Results are statically cached.
  */
+function taxonomy_term_load($tid) {
+  static $terms = array();
+  static $vocabularies = array();
+
+  // Ensure numeric tid to avoid loading the first term on 1+2 URLs.
+  // The db layer casts '1 2' to '1', so doesn't help here.
+  if (!is_numeric($tid)) {
+    return FALSE;
+  }
+
+  if (!isset($terms[$tid])) {
+    $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = :tid', array(':tid' => $tid)));
+
+    $term = $terms[$tid];
+    $vocabulary = taxonomy_vocabulary_load($term->vid);
+    if ($vocabulary->hierarchy) {
+      $term->parents = taxonomy_get_parent_tids($term->tid);
+    }
+    module_invoke_all('taxonomy_term_load', $term);
+    drupal_set_message('<pre>' . var_dump($term) . '</pre>');
+    $terms[$tid] = $term;
+  }
+  return $terms[$tid];
+}
+
+/**
+ * Return a term object with name and description.
+ * @param $tid
+ *   A term's ID
+ * @return Object
+ *  A term object. Results are statically cached.
+ */
 function taxonomy_get_term($tid) {
   static $terms = array();
+  // Ensure numeric tid to avoid loading the first term on 1+2 URLs.
+  // The db layer casts '1 2' to '1', so doesn't help here.
+  if (!is_numeric($tid)) {
+    return FALSE;
+  }
 
   if (!isset($terms[$tid])) {
-    $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
+    $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = :tid', array(':tid' => $tid)));
   }
 
   return $terms[$tid];
@@ -1240,7 +1289,6 @@ function taxonomy_help($path, $arg) {
       $output .= '<p>' . t('Preparation Time: <em>0-30mins, 30-60mins, 1-2 hrs, 2hrs+</em>') . '</p>';
       $output .= '<p>' . t("Each taxonomy term (often called a 'category' or 'tag' in other systems) automatically provides lists of posts and a corresponding RSS feed. These taxonomy/term URLs can be manipulated to generate AND and OR lists of posts classified with terms. In our recipe site example, it then becomes easy to create pages displaying 'Main courses', '30 minute recipes', or '30 minute main courses and appetizers' by using terms on their own or in combination with others. There are a significant number of contributed modules which you to alter and extend the behavior of the core module for both display and organization of terms.") . '</p>';
       $output .= '<p>' . t("Terms can also be organized in parent/child relationships from the admin interface. An example would be a vocabulary grouping countries under their parent geo-political regions. The taxonomy module also enables advanced implementations of hierarchy, for example placing Turkey in both the 'Middle East' and 'Europe'.") . '</p>';
-      $output .= '<p>' . t('The taxonomy module supports the use of both synonyms and related terms, but does not directly use this functionality. However, optional contributed or custom modules may make full use of these advanced features.') . '</p>';
       $output .= '<p>' . t('For more information, see the online handbook entry for <a href="@taxonomy">Taxonomy module</a>.', array('@taxonomy' => 'http://drupal.org/handbook/modules/taxonomy/')) . '</p>';
       return $output;
     case 'admin/content/taxonomy':
Index: taxonomy.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.pages.inc,v
retrieving revision 1.12
diff -u -p -r1.12 taxonomy.pages.inc
--- taxonomy.pages.inc	21 Aug 2008 19:36:38 -0000	1.12
+++ taxonomy.pages.inc	10 Sep 2008 21:57:40 -0000
@@ -51,7 +51,7 @@ function taxonomy_term_page($str_tids = 
           $channel['title'] = variable_get('site_name', 'Drupal') . ' - ' . $title;
           // Only display the description if we have a single term, to avoid clutter and confusion.
           if (count($tids) == 1) {
-            $term = taxonomy_get_term($tids[0]);
+            $term = taxonomy_term_load($tids[0]);
             // HTML will be removed from feed description, so no need to filter here.
             $channel['description'] = $term->description;
           }
@@ -92,7 +92,7 @@ function theme_taxonomy_term_page($tids,
 
   // Only display the description if we have a single term, to avoid clutter and confusion.
   if (count($tids) == 1) {
-    $term = taxonomy_get_term($tids[0]);
+    $term = taxonomy_term_load($tids[0]);
     $description = $term->description;
 
     // Check that a description is set.
