Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.462
diff -u -p -r1.462 taxonomy.module
--- modules/taxonomy/taxonomy.module	8 Mar 2009 04:25:07 -0000	1.462
+++ modules/taxonomy/taxonomy.module	25 Mar 2009 12:03:35 -0000
@@ -19,6 +19,36 @@ function taxonomy_perm() {
 }
 
 /**
+ * Implementation of hook_fieldable().
+ */
+function taxonomy_fieldable_info() {
+  $return = array(
+    'term' => array(
+      'name' => t('Taxonomy term'),
+      'id key' => 'tid',
+      // @TODO 'bundle key' => 'vid',
+    ),
+  );
+  return $return;
+}
+
+/**
+ * Implementation of hook_field_build_modes();
+ *
+ * @TODO: build mode for display as a field (when attached to nodes etc.).
+ */
+function taxonomy_field_build_modes($obj_type) {
+  $modes = array();
+  if ($obj_type == 'term') {
+    $modes = array(
+      'full' => t('Taxonomy term page'),
+    );
+  }
+  return $modes;
+}
+
+
+/**
  * Implementation of hook_theme().
  */
 function taxonomy_theme() {
@@ -312,15 +342,19 @@ function taxonomy_term_save($term) {
     $term->name = trim($term->name);
   }
 
+  field_attach_presave('term', $term);
+
   if (!empty($term->tid) && $term->name) {
     $status = drupal_write_record('taxonomy_term_data', $term, 'tid');
+    field_attach_insert('term', $term);
     module_invoke_all('taxonomy_term_insert', $term);
   }
   else {
     $status = drupal_write_record('taxonomy_term_data', $term);
+    field_attach_update('term', $term);
     module_invoke_all('taxonomy_term_update', $term);
   }
-  
+
   $or = db_or()->condition('tid1', $term->tid)->condition('tid2', $term->tid);
   db_delete('taxonomy_term_relation')->condition($or)->execute();
 
@@ -1095,9 +1129,14 @@ function taxonomy_term_load_multiple($ti
       }
     }
     $queried_terms = $query->execute()->fetchAllAssoc('tid');
-    // Invoke hook_taxonomy_term_load() on the terms loaded from the database
-    // and add them to the static cache.
+
     if (!empty($queried_terms)) {
+
+      // Attach fields.
+      field_attach_load('term', $queried_terms);
+
+      // Invoke hook_taxonomy_term_load() and add the term objects to the
+      // static cache.
       foreach (module_implements('taxonomy_term_load') as $module) {
         $function = $module . '_taxonomy_term_load';
         $function($queried_terms);
