Index: includes/uuid_term.features.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uuid_features/includes/uuid_term.features.inc,v
retrieving revision 1.1.2.1
diff -u -p -w -r1.1.2.1 uuid_term.features.inc
--- includes/uuid_term.features.inc	27 Jul 2010 14:42:19 -0000	1.1.2.1
+++ includes/uuid_term.features.inc	10 Nov 2010 16:59:00 -0000
@@ -53,6 +53,23 @@ function uuid_term_features_export($data
       $parent_uuid = uuid_get_uuid('term_data', 'tid', $parent->tid);
       $export['features']['uuid_term'][$parent_uuid] = $parent_uuid;
     }
+
+    // Get the UUID of the term's relations.
+    $relations = uuid_term_features_get_related_terms_l2r($tid);
+    foreach ($relations as $relation) {
+      $relation_uuid = uuid_get_uuid('term_data', 'tid', $relation->tid);
+      $export['features']['uuid_term'][$relation_uuid] = $relation_uuid;
+
+      // Get the UUID of the related term's vocabulary.
+      $query = 'SELECT uv.uuid FROM {uuid_term_data} utd
+        INNER JOIN {term_data} t ON utd.tid = t.tid
+        INNER JOIN {uuid_vocabulary} uv ON t.vid = uv.vid
+        WHERE utd.uuid = "%s"';
+      $related_voc_uuid = db_result(db_query($query, $relation_uuid));
+
+      // Add the related vocab UUID to the pipe, to be processed by uuid_vocabulary.
+      $export['features']['uuid_vocabulary'][$related_voc_uuid] = $related_voc_uuid;
+    }
   }
 
   return $pipe;
@@ -89,6 +106,21 @@ function uuid_term_features_export_rende
     	$export['parent'][] = uuid_get_uuid('term_data', 'tid', $parent->tid);
     }
 
+    // Get synonyms - no associated UUID so just export the synonym text.
+    $synonyms = taxonomy_get_synonyms($tid);
+    if (!empty($synonyms)) {
+      $export['synonyms'] = implode("\n", taxonomy_get_synonyms($tid));
+    }
+
+    // Get related terms - similar to parent handling
+    // Gets relationships originating from this term (i.e. left to right).
+    // taxonomy_get_related() treats relationships as bi-directional but exporting
+    // directed relationships re-creates the data structure more accurately.
+    $relations = uuid_term_features_get_related_terms_l2r($tid);
+    foreach ($relations as $relation) {
+      $export['relations'][] = uuid_get_uuid('term_data', 'tid', $relation->tid);
+    }
+
     // Get the UUID of the term's vocabulary.
     $query = 'SELECT uv.uuid FROM {uuid_vocabulary} uv WHERE uv.vid = "%s"';
     $voc_uuid = db_result(db_query($query, $term->vid));
@@ -138,6 +170,12 @@ function uuid_term_features_rebuild($mod
 	        }
 	      }
 
+        if (isset($data['relations']) && is_array($data['relations'])) {
+          foreach ($data['relations'] as $key => $related_uuid) {
+            $data['relations'][$key] = uuid_get_serial_id('term_data', 'tid', $related_uuid);
+          }
+        }
+
         $ret = taxonomy_save_term($data);
 
         // TODO: remove when http://drupal.org/node/860442 is resolved.
@@ -147,3 +185,21 @@ function uuid_term_features_rebuild($mod
     }
   }
 }
+
+/**
+ * Find all term objects related to a given term ID.
+ * Left to right directed version of core taxonomy_get_related().
+ */
+function uuid_term_features_get_related_terms_l2r($tid, $key = 'tid') {
+  if ($tid) {
+    $result = db_query('SELECT t.*, tid1, tid2 FROM {term_relation}, {term_data} t WHERE t.tid = tid2 AND tid1 = %d ORDER BY weight, name', $tid);
+    $related = array();
+    while ($term = db_fetch_object($result)) {
+      $related[$term->$key] = $term;
+    }
+    return $related;
+  }
+  else {
+    return array();
+  }
+}
