Browse Source

Continued fixes to the theming

spficklin 14 years ago
parent
commit
bcb9dedeb5

+ 61 - 51
tripal_feature/tripal_feature-db_references.inc

@@ -163,57 +163,62 @@ function tripal_feature_edit_ALL_db_references_form($form_state, $node) {
 
   $i=0;
 
+  $feature = $node->feature;
+  $references = tripal_feature_load_references ($feature->feature_id);
+
   // pre populate the database options
   $db_options = tripal_db_get_db_options();
   $db_options[0] = 'Select a Database';
   ksort($db_options);
 
-  if (sizeof($node->references) != 0) {
-  foreach ($node->references as $ref) {
-    $i++;
-    $form["num-$i"] = array(
-      '#type' => 'item',
-      '#value' => $i.'.'
-    );
-
-    $form["accession-$i"] = array(
-      '#type' => 'textfield',
-      '#title' => t('Accession'),
-      '#size' => 30,
-      '#required' => TRUE,
-      '#default_value' => $ref->accession
-    );
-
-    $form["db_id-$i"] = array( 
-      '#type' => 'select', 
-      '#title' => t('Database'),
-      '#options' => $db_options, 
-      '#default_value' => $ref->db_id
-    );
-
-
-    $form["dbxref_id-$i"] = array(
-      '#type' => 'hidden',
-      '#value' => $ref->dbxref_id
-    );
-
-    $form["submit-$i"] = array(
-      '#type' => 'submit',
-      '#value' => t("Delete #$i")
-    );
-
-  }} //end of foreach db ref
-
-  $form['num_db_references'] = array(
-    '#type' => 'hidden',
-    '#value' => $i
-  );
+  if (sizeof($references) != 0) {
+     foreach ($references as $ref) {
+       $i++;
+       $form["num-$i"] = array(
+         '#type' => 'fieldset',
+         '#title' => t("Database Reference")." $i"
+       );
+
+       $form["num-$i"]["accession-$i"] = array(
+         '#type' => 'textfield',
+         '#title' => t('Accession'),
+         '#size' => 30,
+         '#required' => TRUE,
+         '#default_value' => $ref->accession
+       );
+
+       $form["num-$i"]["db_id-$i"] = array( 
+         '#type' => 'select', 
+         '#title' => t('Database'),
+         '#options' => $db_options,
+         '#required' => TRUE, 
+         '#default_value' => $ref->db_id
+       );
+
+
+       $form["num-$i"]["dbxref_id-$i"] = array(
+         '#type' => 'hidden',
+         '#value' => $ref->dbxref_id
+       );
+
+       $form["num-$i"]["delete-$i"] = array(
+         '#type' => 'submit',
+         '#value' => t("Delete"),
+         '#name' => "delete-$i",
+       );
 
-  $form["submit-edits"] = array(
-    '#type' => 'submit',
-    '#value' => t('Update References')
-  );
+     }
+
+     $form['num_db_references'] = array(
+       '#type' => 'hidden',
+       '#value' => $i
+     );
 
+     $form["submit-edits"] = array(
+       '#type' => 'submit',
+       '#value' => t('Update All References')
+     );
+  } //end of foreach db ref
   return $form;
 }
 /*******************************************************************************
@@ -223,9 +228,10 @@ function tripal_feature_edit_ALL_db_references_form_submit($form, &$form_state)
 
   $num_refs = $form_state['values']['num_db_references'];
   $action = $form_state['clicked_button']['#value'];
+  $button = $form_state['clicked_button']['#name'];
   $nid = $form_state['values']['nid'];
 
-  if (strcmp($action,'Update References')==0) {
+  if (strcmp($action,'Update All References')==0) {
      for ($i=1; $i<=$num_refs; $i++) {
 		 $dbxref_id = $form_state['values']["dbxref_id-$i"]; 
 		 $db_id = $form_state['values']["db_id-$i"];
@@ -235,12 +241,16 @@ function tripal_feature_edit_ALL_db_references_form_submit($form, &$form_state)
      drupal_set_message("Updated all Database References");
      drupal_goto('node/'.$nid);
   } 
-  elseif ( preg_match('/Delete #(\d+)/', $action, $matches) ) {
-     $i = $matches[1];
-	  $dbxref_id = $form_state['values']["dbxref_id-$i"]; 
-     tripal_feature_delete_db_reference($dbxref_id);
-     drupal_set_message("Deleted Database Reference");
-     drupal_goto('node/'.$nid);
+  elseif (strcmp($action,'Delete')==0){
+     if(preg_match('/delete-(\d+)/', $button, $matches) ) {
+        $i = $matches[1];
+	     $dbxref_id = $form_state['values']["dbxref_id-$i"]; 
+        tripal_feature_delete_db_reference($dbxref_id);
+        drupal_set_message("Deleted Database Reference");
+        drupal_goto('node/'.$nid);
+     } else {
+        drupal_set_message("Could not remove database reference: ",'error');
+     }
   } 
   else {
     drupal_set_message("Unrecognized Button Pressed",'error');

+ 105 - 148
tripal_feature/tripal_feature-properties.inc

@@ -7,41 +7,38 @@
 
 /**
  * Implements Hook_form()
- * Handles adding of Properties & Synonyms to Stocks
+ * Handles adding of Properties for features
  */
 function tripal_getfeature_add_ALL_property_page($node) {
   $output = '';
 
-  $output .= implement_add_chado_properties_progress('properties').'<br>';
-  $output .= '<b>All Properties should strictly pertain to THE CURRENT Individual</b><br>';
+  $output .= tripal_feature_implement_add_chado_properties_progress('properties').'<br>';
   $output .= '<br><b>Current Properties</b><br>';
-  $output .= list_properties_for_node($node->properties, $node->synonyms);
+  $output .= tripal_feature_list_properties_for_node($node->properties);
   $output .= '<br><br>';
   $output .= drupal_get_form('tripal_feature_add_ONE_property_form', $node);
   $output .= '<br>';
-  $output .= drupal_get_form('implement_add_chado_properties_navigate', 'properties', $node->nid);
+  $output .= drupal_get_form('tripal_feature_implement_add_chado_properties_navigate', 'properties', $node->nid);
   return $output;
 }
-
+/**
+* 
+*/
 function tripal_feature_add_ONE_property_form($form_state, $node) {
   $form = array();
-  $stock_id = $node->stock_id;
+  $feature_id = $node->feature->feature_id;
 
   $form['add_properties'] = array(
     '#type' => 'fieldset',
-    '#title' => t('Add Property') . '<span class="form-optional" title="This field is optional"> (optional)</span>',
+    '#title' => t('Add Property'),
   ); 
 
   $form['prop_nid'] = array(
     '#type' => 'hidden',
     '#value' => $node->nid
   );
-
-  $tmp_obj = tripal_cv_get_cvterm(array('name' => array('type'=>'STRING','exact'=>TRUE, 'value'=>'synonym'),
-  																	'cv_id' => array('type'=>'INT','value'=>variable_get('chado_stock_prop_types_cv', 'null') )));
-	$synonym_id = $tmp_obj->cvterm_id;
 	
-  $prop_type_options = tripal_cv_get_cvterm_options( variable_get('chado_stock_prop_types_cv', 'null') ); 
+  $prop_type_options = tripal_cv_get_cvterm_options( variable_get('chado_feature_prop_types_cv', 'null') ); 
   $prop_type_options[0] = 'Select a Type';
   ksort($prop_type_options);
   $form['add_properties']['prop_type_id'] = array(
@@ -52,17 +49,12 @@ function tripal_feature_add_ONE_property_form($form_state, $node) {
 
   $form['add_properties']['prop_value'] = array(
     '#type' => 'textfield',
-    '#title' => t('Value') . '<span class="form-optional" title="This field is optional">+</span>',
-  );
-
-  $form['add_properties']['preferred_synonym'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Preferred Synonym (only applicable if type is synonym)'),
+    '#title' => t('Value'),
   );
 
-  $form['add_properties']['prop_stock_id'] = array(
+  $form['add_properties']['prop_feature_id'] = array(
     '#type' => 'value',
-    '#value' => $stock_id,
+    '#value' => $feature_id,
     '#required' => TRUE
   );
 
@@ -73,15 +65,18 @@ function tripal_feature_add_ONE_property_form($form_state, $node) {
 
   return $form;
 }
+/**
+* 
+*/
 
 function tripal_feature_add_ONE_property_form_validate($form, &$form_state) {
 
   // Only Require if Adding Property
   if ($form_state['clicked_button']['#value'] == t('Add Property') ) {
 
-		// Check that there is a stock
-		if ( $form_state['values']['prop_stock_id'] <= 0 ) {
-			form_set_error('prop_stock_id', 'There is no associated stock.');
+		// Check that there is a feature
+		if ( $form_state['values']['prop_feature_id'] <= 0 ) {
+			form_set_error('prop_feature_id', 'There is no associated feature.');
 		}
 		
     // Check that Selected a type
@@ -97,34 +92,30 @@ function tripal_feature_add_ONE_property_form_validate($form, &$form_state) {
       } // end of if more or less than 1 row
     } // if no prop type
 
-    // only check preferred synonym if type is synonym
-    if ($form_state['values']['preferred_synonym'] == 1) {
-    $tmp_obj = tripal_cv_get_cvterm(array('name' => array('type'=>'STRING','exact'=>TRUE, 'value'=>'synonym'),
-  																	'cv_id' => array('type'=>'INT','value'=>variable_get('chado_stock_prop_types_cv', 'null') )));
-      if ($form_state['values']['prop_type_id'] != $tmp_obj->cvterm_id) {
-        form_set_error('preferred_synonym', 'Preferred Synonym Checkbox Only Applicable if Type of Property is Synonym');
-      }
-    }
+
 
   } // if add Property
 
 }
+/**
+* 
+*/
 
 function tripal_feature_add_ONE_property_form_submit($form, &$form_state) {
 	
   // if there is a property add it (only won't be a property if clicked next step w/ no property)
   if ($form_state['values']['prop_type_id'] != 0) {
     //determine the rank for this property
-    $max_rank = get_max_chado_rank('stockprop', 
-    															array('stock_id'=>array('type'=>'INT','value'=>$form_state['values']['prop_stock_id']), 
-    																		'type_id'=>array('type'=>'INT','value'=> $form_state['values']['prop_type_id']) ));
+    $max_rank = get_max_chado_rank('featureprop', 
+       array('feature_id'=>array('type'=>'INT','value'=>$form_state['values']['prop_feature_id']), 
+       'type_id'=>array('type'=>'INT','value'=> $form_state['values']['prop_type_id']) ));
     if ($max_rank == -1) { $rank = 0; 
     } else { $rank = $max_rank+1; }
     
     $previous_db = tripal_db_set_active('chado');
     db_query(
-      "INSERT INTO stockprop (stock_id, type_id, value, rank) VALUES (%d, %d, '%s', %d)",
-      $form_state['values']['prop_stock_id'],
+      "INSERT INTO featureprop (feature_id, type_id, value, rank) VALUES (%d, %d, '%s', %d)",
+      $form_state['values']['prop_feature_id'],
       $form_state['values']['prop_type_id'],
       $form_state['values']['prop_value'],
       $rank
@@ -133,23 +124,6 @@ function tripal_feature_add_ONE_property_form_submit($form, &$form_state) {
 
     drupal_set_message("Successfully Added Property");
 
-    // Set Preferred Synonym
-    if ($form_state['values']['preferred_synonym'] == 1) {
-
-      //use update node form so that both title and name get set
-      $node = node_load($form_state['values']['prop_nid']);
-      $node->title = $form_state['values']['prop_value'];
-      $node_form_state = array( 
-        'values' => array(
-					'title' => $form_state['values']['prop_value'], 
-					'op' => 'Save'
-				) 
-      );
-      module_load_include('inc', 'node', 'node.pages');
-      drupal_execute('chado_stock_node_form', $node_form_state, $node);
-
-    }
-
   } //end of if property to add
 }
 
@@ -165,14 +139,14 @@ function tripal_feature_edit_ALL_properties_page($node) {
   $output .= '<br>';
   $output .= drupal_get_form('tripal_feature_add_ONE_property_form', $node);
   $output .= '<br>';
-  $output .= drupal_get_form('implement_back_to_stock_button', $node->nid);
+  $output .= drupal_get_form('tripal_feature_implement_back_to_feature_button', $node->nid);
 
   return $output;
 }
 
 /**
  * Implements Hook_form()
- * Handles adding of Properties & Synonyms to Stocks
+ * Handles adding of Properties for features
  */
 function tripal_feature_edit_ALL_properties_form($form_state, $node) {
   $form = array();
@@ -183,58 +157,47 @@ function tripal_feature_edit_ALL_properties_form($form_state, $node) {
   );
 
   $i=0;
-  if (is_array($node->properties) && is_array($node->synonyms)) { 
-  	$all_properties = array_merge($node->properties, $node->synonyms);
-  } elseif (is_array($node->properties)) { 
-  	$all_properties = $node->properties; 
-  } elseif (is_array($node->synonyms)) { 
-  	$all_properties = $node->synonyms;
-  } else { $all_properties = array(); }
-
-  if (sizeof($all_properties) != 0) {
-  foreach ($all_properties as $property) {
-    $i++;
-    $form["num-$i"] = array(
-      '#type' => 'item',
-      '#value' => $i.'.'
-    );
-
-    $form["id-$i"] = array(
-      '#type' => 'hidden',
-      '#value' => $property->stockprop_id
-    );
-
-    $prop_type_options = tripal_cv_get_cvterm_options( variable_get('chado_stock_prop_types_cv', 'null') );
-    ksort($prop_type_options);
- 
-    $default = array_search($property->type, $prop_type_options);
-
-    $form["type-$i"] = array(
-      '#type' => 'select',
-      //'#title' => t('Type of Property'),
-      '#options' => $prop_type_options,
-      '#default_value' => $default 
-    );
-
-    $form["value-$i"] = array(
-      '#type' => 'textfield',
-      //'#title' => t('Value'),
-      '#default_value' => $property->value
-    );
-
-    if ($property->type == 'synonym') {
-      $form["preferred-$i"] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Preferred Synonym'),
-      );
-    }
-
-    $form["submit-$i"] = array(
-      '#type' => 'submit',
-      '#value' => t("Delete #$i")
-    );
-
-  }} //end of foreach property
+  $feature = $node->feature;
+  $properties = tripal_feature_load_properties ($feature->feature_id);
+
+  if (sizeof($properties) != 0) {
+     foreach ($properties as $property) {
+       $i++;
+       $form["num-$i"] = array(
+         '#type' => 'fieldset',
+         '#value' => "Property $i"
+       );
+
+       $form["num-$i"]["id-$i"] = array(
+         '#type' => 'hidden',
+         '#value' => $property->featureprop_id
+       );
+
+       $prop_type_options = tripal_cv_get_cvterm_options( variable_get('chado_feature_prop_types_cv', 'null') );
+       ksort($prop_type_options);
+    
+       $default = array_search($property->type, $prop_type_options);
+
+       $form["num-$i"]["type-$i"] = array(
+         '#type' => 'select',
+         //'#title' => t('Type of Property'),
+         '#options' => $prop_type_options,
+         '#default_value' => $default 
+       );
+
+       $form["num-$i"]["value-$i"] = array(
+         '#type' => 'textfield',
+         //'#title' => t('Value'),
+         '#default_value' => $property->value
+       );
+
+       $form["num-$i"]["delete-$i"] = array(
+         '#type' => 'submit',
+         '#value' => t("Delete"),
+         '#name' => "delete-$i",
+       );
+     }//end of foreach property
+  } 
 
   $form['num_properties'] = array(
     '#type' => 'hidden',
@@ -243,15 +206,18 @@ function tripal_feature_edit_ALL_properties_form($form_state, $node) {
 
   $form["submit-edits"] = array(
     '#type' => 'submit',
-    '#value' => t('Update Properties')
+    '#value' => t('Update All Properties')
   );
 
   return $form;
 }
+/**
+* 
+*/
 
 function tripal_feature_edit_ALL_properties_form_submit($form, &$form_state) {
 
-  if ($form_state['clicked_button']['#value'] == t('Update Properties') ) {
+  if ($form_state['clicked_button']['#value'] == t('Update All Properties') ) {
      //Update all
      for ($i=1; $i<=$form_state['values']['num_properties']; $i++) {
        tripal_feature_update_property($form_state['values']["id-$i"], $form_state['values']["type-$i"], $form_state['values']["value-$i"], $form_state['values']["preferred-$i"], $form_state['values']["nid"]);
@@ -268,11 +234,14 @@ function tripal_feature_edit_ALL_properties_form_submit($form, &$form_state) {
 
   
 }
+/**
+* 
+*/
 
-function tripal_feature_update_property($stockprop_id, $cvterm_id, $value, $preferred, $nid) {
+function tripal_feature_update_property($featureprop_id, $cvterm_id, $value, $preferred, $nid) {
 
 	$previous_db = tripal_db_set_active('chado');
-	$old_obj = db_fetch_object(db_query("SELECT * FROM stockprop WHERE stockprop_id=%d",$stockprop_id));
+	$old_obj = db_fetch_object(db_query("SELECT * FROM featureprop WHERE featureprop_id=%d",$featureprop_id));
 	tripal_db_set_active($previous_db);
 	
 	// if they changed the type need to check rank
@@ -280,66 +249,59 @@ function tripal_feature_update_property($stockprop_id, $cvterm_id, $value, $pref
 	if ($cvterm_id == $old_obj->type_id) {
 	  $previous_db = tripal_db_set_active('chado');
   	db_query(
-    	"UPDATE stockprop SET type_id=%d, value='%s' WHERE stockprop_id=%d",
+    	"UPDATE featureprop SET type_id=%d, value='%s' WHERE featureprop_id=%d",
     	$cvterm_id, 
     	$value,
-    	$stockprop_id
+    	$featureprop_id
   	);
   	tripal_db_set_active($previous_db);
   } else {
       //determine the rank for this property
-    $max_rank = get_max_chado_rank('stockprop', 
-    															array('stock_id'=>array('type'=>'INT','value'=> $old_obj->stock_id), 
-    																		'type_id'=>array('type'=>'INT','value'=> $cvterm_id ) ));
+    $max_rank = get_max_chado_rank('featureprop', 
+       array('feature_id'=>array('type'=>'INT','value'=> $old_obj->feature_id), 
+    	 'type_id'=>array('type'=>'INT','value'=> $cvterm_id ) ));
     if ($max_rank == -1) { $rank = 0; 
     } else { $rank = $max_rank+1; }
 	  $previous_db = tripal_db_set_active('chado');
   	db_query(
-    	"UPDATE stockprop SET type_id=%d, value='%s', rank=%d WHERE stockprop_id=%d",
+    	"UPDATE featureprop SET type_id=%d, value='%s', rank=%d WHERE featureprop_id=%d",
     	$cvterm_id, 
     	$value,
     	$rank,
-    	$stockprop_id
+    	$featureprop_id
   	);
   	tripal_db_set_active($previous_db);  	
   }
-
-  // Set Preferred Synonym
-  //use update node form so that both title and name get set                                                                                                                                                                       
-  if ($preferred) {
-    $node = node_load($nid);                                                                                                                                                                            
-    $node->title = $value;                                                                                                                                                                              
-    $node_form_state = array(                                                                                                                                                                                                        
-      'values' => array(                                                                                                                                                                                                             
-        'title' => $value,                                                                                                                                               
-        'op' => 'Save'                                                                                                                                                                                
-      )                                                                                                                                                                                                            
-    );                                                                                                                                                                                                                               
+                                                                                                                                                                                                                          
     module_load_include('inc', 'node', 'node.pages');                                                                                                                                                                                
-    drupal_execute('chado_stock_node_form', $node_form_state, $node);  
-  }
+    drupal_execute('chado_feature_node_form', $node_form_state, $node);  
+
 }
+/**
+* 
+*/
 
-function tripal_feature_delete_property($stockprop_id) {
+function tripal_feature_delete_property($featureprop_id) {
 
   $previous_db = tripal_db_set_active('chado');
   db_query(
-    "DELETE FROM stockprop WHERE stockprop_id=%d",
-    $stockprop_id
+    "DELETE FROM featureprop WHERE featureprop_id=%d",
+    $featureprop_id
   );
   tripal_db_set_active($previous_db);
 
 }
+/**
+* 
+*/
 
 function theme_tripal_feature_edit_ALL_properties_form ($form) {
   $output = '';
 
   $output .= '<br><fieldset>';
   $output .= '<legend>Edit Already Existing Properties<span class="form-optional" title="This field is optional">(optional)</span></legend>';
-  $output .= '<p>Below is a list of already existing properties for this stock, one property per line. The type refers to the type of '
-  	     .'property and the value is the value for that property. For example, if this stock has a seed coat colour of green then '
-	     .'the property type=sead coat colour and the value=green. When the type of property is synonym, there is an extra checkbox '
-	     .'allowing you to specify which is the <b>Preferred Synonym</b>. This will change the current name of the stock.</p>';
+  $output .= '<p>Below is a list of already existing properties for this feature, one property per line. The type refers to the type of '
+  	     .'property and the value is the value for that property. </p>';
   $output .= '<table>';
   $output .= '<tr><th>#</th><th>Type</th><th>Value</th><th></th></tr>';
 
@@ -362,17 +324,12 @@ function theme_tripal_feature_edit_ALL_properties_form ($form) {
 /**
  * 
  */
-function list_properties_for_node($properties, $synonyms) {
+function list_properties_for_node($properties) {
 
-  if (!empty($properties) OR !empty($synonyms) ) {
+  if (!empty($properties)) {
     $output = '<table>';
     $output .= '<tr><th>Type</th><th>Value</th></tr>';
 
-    if (!empty($synonyms) ) {
-      foreach ($synonyms as $s) {
-        $output .= '<tr><td>synonym</td><td>'.$s.'</td></tr>';
-      }
-    }
 
     if (!empty($properties) ) {
       foreach ($properties as $p) {
@@ -383,7 +340,7 @@ function list_properties_for_node($properties, $synonyms) {
     $output .= '</table>';
 
   } else {
-    $output = 'No Properties Added to the Current Stock';
+    $output = 'No properties exist forony the current feature';
   }
 
   return $output;

+ 27 - 20
tripal_feature/tripal_feature-relationships.inc

@@ -100,6 +100,7 @@ function tripal_feature_add_ONE_relationship_form_validate($form, &$form_state)
 
   //Require Validation if adding
   if ($form_state['clicked_button']['#value'] == t('Add a Relationship') ) {
+
     // check valid feature selected for subject
     $criteria = array('unknown' => array('value'=> $form_state['values']['subject_id'], 
       																		'columns'=>array('name','uniquename','accession','synonym') ));
@@ -213,23 +214,22 @@ function tripal_feature_edit_ALL_relationships_form($form_state, $node) {
   );
 
   $i=0;
-  $relationships = array();
-  if(is_array($node->object_relationships)){    
-     $relationships = array_merge($relationships,$node->object_relationships);
-  }
-  if(is_array($node->subject_relationships)){    
-     $relationships = array_merge($relationships,$node->subject_relationships);
-  }
+
+  $feature = $node->feature;
+  $orelationships = tripal_feature_load_relationships ($feature->feature_id,'as_object');
+  $srelationships = tripal_feature_load_relationships ($feature->feature_id,'as_subject');
+  $relationships = array_merge($orelationships,$srelationships);
+
   if (sizeof($relationships) != 0) {
      foreach ($relationships as $r) {
 
        $i++;
        $form["num-$i"] = array(
-         '#type' => 'item',
-         '#value' => $i.'.'
+         '#type' => 'fieldset',
+         '#title' => "Relationship $i",
        );
 
-       $form["id-$i"] = array(
+       $form["num-$i"]["id-$i"] = array(
          '#type' => 'hidden',
          '#value' => $r->stock_relationship_id
        );
@@ -239,9 +239,11 @@ function tripal_feature_edit_ALL_relationships_form($form_state, $node) {
          $default = $r->subject_uniquename;
          $description = l($r->subject_name, 'node/'.$r->subject_nid); 
        } else { 
-          $default = $node->uniquename; $description = 'Current Feature'; 
+          $default = $node->uniquename; 
+          $description = "Current Feature"; 
        }
-       $form["subject_id-$i"] = array(
+       $description .= " (".$r->subject_type.")";
+       $form["num-$i"]["subject_id-$i"] = array(
          '#type' => 'textfield',      
          //'#title' => t('Subject'), 
          '#required'   => TRUE,
@@ -253,7 +255,7 @@ function tripal_feature_edit_ALL_relationships_form($form_state, $node) {
        $cv = tripal_cv_get_cv_by_name('relationship');
        $type_options = tripal_cv_get_cvterm_options($cv->cv_id);
        ksort($type_options);          
-       $form["type_id-$i"] = array(  
+       $form["num-$i"]["type_id-$i"] = array(  
          '#type' => 'select',    
          //'#title' => t('Type of Relationship'), 
          '#options' => $type_options,
@@ -261,11 +263,15 @@ function tripal_feature_edit_ALL_relationships_form($form_state, $node) {
          '#default_value' => $r->relationship_type_id
        );
 
-       if ( !empty($r->object_id) ) { 
+       if (!empty($r->object_id) ) { 
          $default = $r->object_uniquename;
          $description = l($r->object_name, 'node/'.$r->object_nid);
-       } else { $default = $node->uniquename; $description = 'Current Feature'; }
-       $form["object_id-$i"] = array(
+       } else { 
+         $default = $node->uniquename; 
+         $description = 'Current Feature'; 
+       }
+       $description .= " (".$r->object_type.")";
+       $form["num-$i"]["object_id-$i"] = array(
          '#type' => 'textfield',          
          //'#title' => t('Object'),      
          '#required'   => TRUE,
@@ -274,9 +280,10 @@ function tripal_feature_edit_ALL_relationships_form($form_state, $node) {
          '#description' => $description
        );
 
-       $form["submit-$i"] = array(
+       $form["num-$i"]["delete-$i"] = array(
          '#type' => 'submit',
-         '#value' => t("Delete #$i")
+         '#value' => t("Delete"),
+         '#name' => "delete-$i",
        );
 
      } //end of foreach relationship
@@ -287,7 +294,7 @@ function tripal_feature_edit_ALL_relationships_form($form_state, $node) {
 
      $form["submit-edits"] = array(
        '#type' => 'submit',
-       '#value' => t('Update Relationships')
+       '#value' => t('Update All Relationships')
      );
   } else {
      $form["info"] = array(
@@ -306,7 +313,7 @@ function tripal_feature_edit_ALL_relationships_form($form_state, $node) {
 function tripal_feature_edit_ALL_relationships_form_validate($form, &$form_state) {
 
   // Only Require if Updating Relationships
-  if ($form_state['clicked_button']['#value'] == t('Update Relationships') ) {
+  if ($form_state['clicked_button']['#value'] == t('Update All Relationships') ) {
 
     for ($i=1; $i<=$form_state['values']['num_relationships']; $i++) {
       

+ 136 - 64
tripal_feature/tripal_feature.module

@@ -154,36 +154,12 @@ function tripal_feature_menu() {
      'page arguments' => array('tripal_core_gff3_load_form'),
      'access arguments' => array('access administration pages'),
      'type' => MENU_NORMAL_ITEM,
-   );
-
-
-   // managing relationship aggregates
-   $items['admin/tripal/tripal_feature/aggregate'] = array(
-     'title' => 'Feature Relationship Aggegators',
-     'description' => t('Features have relationships with other features and it may be desirable to aggregate the content from one ore more child or parent feature.'),
-     'page callback' => 'tripal_feature_aggregator_page',
-     'access arguments' => array('manage chado_feature aggregator'),
-     'type' => MENU_NORMAL_ITEM,
-   );
-
-   $items['admin/tripal/tripal_feature/aggregate/new'] = array(
-     'title' => 'Add an Aggregator',
-     'page callback' => 'drupal_get_form',
-     'page arguments' => array('tripal_feature_aggregator_form'),
-     'access arguments' => array('manage chado_feature aggregator'),
-     'type' => MENU_NORMAL_ITEM,
-   );
-   $items['admin/tripal/tripal_feature/aggregate/edit/js'] = array(
-     'title' => 'Edit an Aggegator',
-     'page callback' => 'tripal_feature_aggregator_ajax_edit',
-     'access arguments' => array('manage chado_feature aggregator'),
-     'type' => MENU_CALLBACK,
-   );
+   );  
 
+  // Adding Secondary Properties
 
 
-  // Adding Secondary Properties
-  $items['node/%tripal_feature_node/properties'] = array(       
+  $items['node/%tf_node/tf_properties'] = array(       
     'title' => t('Add Properties & Synonyms'),                         
     'description' => t('Settings for Features'),
     'page callback' => 'tripal_feature_add_ALL_property_page',           
@@ -192,7 +168,7 @@ function tripal_feature_menu() {
     'type' => MENU_CALLBACK
   ); 
 
-  $items['node/%tripal_feature_node/db_references'] = array(                        
+  $items['node/%tf_node/tf_db_references'] = array(                        
     'title' => t('Add Database References'),                   
     'description' => t('Settings for Features'),              
     'page callback' => 'tripal_feature_add_ALL_dbreferences_page',                         
@@ -201,7 +177,7 @@ function tripal_feature_menu() {
     'type' => MENU_CALLBACK
   ); 
 
-  $items['node/%tripal_feature_node/relationships'] = array(                      
+  $items['node/%tf_node/tf_relationships'] = array(                      
     'title' => t('Add Relationships'),                      
     'description' => t('Settings for Features'),               
     'page callback' => 'tripal_feature_add_ALL_relationships_page',                          
@@ -210,7 +186,8 @@ function tripal_feature_menu() {
     'type' => MENU_CALLBACK
   );
   //Edit/Deleting Secondary Properties-------------
-  $items['node/%tripal_feature_node/edit_properties'] = array(
+/*
+  $items['node/%tf_node/tf_edit_properties'] = array(
     'title' => t('Edit Properties'),
     'description' => t('Settings for Features'),
     'page callback' => 'tripal_feature_edit_ALL_properties_page',
@@ -220,7 +197,7 @@ function tripal_feature_menu() {
     'weight' => 8,
   );
 
-    $items['node/%tripal_feature_node/edit_relationships'] = array(
+    $items['node/%tf_node/tf_edit_relationships'] = array(
     'title' => t('Edit Relationships'),
     'description' => t('Settings for Feature'), 
     'page callback' => 'tripal_feature_edit_ALL_relationships_page',
@@ -229,8 +206,8 @@ function tripal_feature_menu() {
     'type' => MENU_LOCAL_TASK,
     'weight' => 9,
   );
-
-  $items['node/%tripal_feature_node/edit_db_references'] = array(
+*/
+  $items['node/%tf_node/tf_edit_db_references'] = array(
     'title' => t('Edit References'),
     'description' => t('Settings for Feature'),
     'page callback' => 'tripal_feature_edit_ALL_dbreferences_page',
@@ -240,6 +217,29 @@ function tripal_feature_menu() {
     'weight' => 10,
   );
 
+ // managing relationship aggregates
+   $items['admin/tripal/tripal_feature/aggregate'] = array(
+     'title' => 'Feature Relationship Aggegators',
+     'description' => t('Features have relationships with other features and it may be desirable to aggregate the content from one ore more child or parent feature.'),
+     'page callback' => 'tripal_feature_aggregator_page',
+     'access arguments' => array('manage chado_feature aggregator'),
+     'type' => MENU_NORMAL_ITEM,
+   );
+
+   $items['admin/tripal/tripal_feature/aggregate/new'] = array(
+     'title' => 'Add an Aggregator',
+     'page callback' => 'drupal_get_form',
+     'page arguments' => array('tripal_feature_aggregator_form'),
+     'access arguments' => array('manage chado_feature aggregator'),
+     'type' => MENU_NORMAL_ITEM,
+   );
+   $items['admin/tripal/tripal_feature/aggregate/edit/js'] = array(
+     'title' => 'Edit an Aggegator',
+     'page callback' => 'tripal_feature_aggregator_ajax_edit',
+     'access arguments' => array('manage chado_feature aggregator'),
+     'type' => MENU_CALLBACK,
+   );
+
    return $items;
 }
 
@@ -249,7 +249,7 @@ function tripal_feature_menu() {
  *   pulled from the path. The node is loaded from this node ID
  *   and supplied to the page as an arguement
  */
-function tripal_feature_node_load($nid) {
+function tf_node_load($nid) {
   if (is_numeric($nid)) {
     $node = node_load($nid);
     if ($node->type == 'chado_feature') {
@@ -273,6 +273,12 @@ function tripal_feature_block($op = 'list', $delta = 0, $edit=array()){
          $blocks['sequence']['info'] = t('Tripal Feature Sequence');
          $blocks['sequence']['cache'] = BLOCK_NO_CACHE;
 
+         $blocks['synonyms']['info'] = t('Tripal Feature Synonyms');
+         $blocks['synonyms']['cache'] = BLOCK_NO_CACHE;
+
+         $blocks['properties']['info'] = t('Tripal Feature Properties');
+         $blocks['properties']['cache'] = BLOCK_NO_CACHE;;
+
          $blocks['featureloc_sequences']['info'] = t('Tripal Formatted Location Sequence');
          $blocks['featureloc_sequences']['cache'] = BLOCK_NO_CACHE;
 
@@ -306,6 +312,14 @@ function tripal_feature_block($op = 'list', $delta = 0, $edit=array()){
                   $block['subject'] = t('Feature Details');
                   $block['content'] = theme('tripal_feature_base',$node);
                   break;
+               case 'synonyms':
+                  $block['subject'] = t('Synonyms');
+                  $block['content'] = theme('tripal_feature_synonyms',$node);
+                  break;
+               case 'properties':
+                  $block['subject'] = t('Properties');
+                  $block['content'] = theme('tripal_feature_properties',$node);
+                  break;;
                case 'sequence':
                   $block['subject'] = t('Sequence');
                   $block['content'] = theme('tripal_feature_sequence',$node);
@@ -860,7 +874,7 @@ function tripal_feature_load_synonyms ($feature_id){
 
    $sql = "SELECT S.name ".
           "FROM {Feature_Synonym} FS ".
-          "  INNER JOIN Synonym S ".
+          "  INNER JOIN {Synonym} S ".
           "    ON FS.synonym_id = S.Synonym_id ".
           "WHERE FS.feature_id = %d";
    $previous_db = tripal_db_set_active('chado');  // use chado database
@@ -873,6 +887,31 @@ function tripal_feature_load_synonyms ($feature_id){
    }
    return $synonyms;
 }
+/************************************************************************
+ *  
+ */
+function tripal_feature_load_properties ($feature_id){
+
+   $sql = "SELECT CVT.name as cvname, FS.type_id, FS.value, FS.rank,
+             CVT.definition, CVT.is_obsolete, 
+             DBX.dbxref_id,DBX.accession,DB.name as dbname, 
+             DB.urlprefix, DB.description as db_description, DB.url
+           FROM {featureprop} FS 
+             INNER JOIN {cvterm} CVT ON FS.type_id = CVT.cvterm_id
+             INNER JOIN {dbxref} DBX ON CVT.dbxref_id = DBX.dbxref_id
+             INNER JOIN {db} DB      ON DB.db_id = DBX.db_id
+           WHERE FS.feature_id = %d
+           ORDER BY FS.rank ASC";
+   $previous_db = tripal_db_set_active('chado');  // use chado database
+   $results = db_query($sql,$feature_id);
+   tripal_db_set_active($previous_db);  // now use drupal database
+   $i=0;
+   $properties = array();
+   while($property = db_fetch_object($results)){
+      $properties[$i++] = $property;
+   }
+   return $properties;
+}
 /************************************************************************
  *  
  */
@@ -1285,9 +1324,6 @@ function tripal_feature_nodeapi(&$node, $op, $teaser, $page) {
       // Note that this function only adds feature view to an organism node.
       // The view of a feature node is controled by the theme *.tpl file
       case 'view':
-         // Set the node types for showing feature information
-         $types_to_show = array('chado_organism', 'chado_library');
-
  
          // if this is a feature node then add the boxes of content for the 
          // ancillary data
@@ -1305,6 +1341,10 @@ function tripal_feature_nodeapi(&$node, $op, $teaser, $page) {
                   '#value' => theme('tripal_feature_references', $node),
                   '#weight' => 4
                );
+               $node->content['tripal_feature_synonyms'] = array(
+                  '#value' => theme('tripal_feature_synonyms', $node),
+                  '#weight' => 4
+               );
                $node->content['tripal_feature_featurelocs_as_parent'] = array(
                   '#value' => theme('tripal_feature_featurelocs_as_parent', $node),
                   '#weight' => 6
@@ -1325,27 +1365,34 @@ function tripal_feature_nodeapi(&$node, $op, $teaser, $page) {
                   '#value' => theme('tripal_feature_relationships_as_subject', $node),
                   '#weight' => 10
                );
-           
+               break;
+            case 'chado_organism':
+               // Show feature browser
+               $types_to_show = array('chado_organism', 'chado_library');
+               if (in_array($node->type, $types_to_show, TRUE)) {
+                  $node->content['tripal_feature_browser'] = array(
+                     '#value' => theme('tripal_feature_browser', $node),
+                     '#weight' => 5
+                  );
+                  $node->content['tripal_feature_org_counts'] = array(
+                     '#value' => theme('tripal_feature_org_counts', $node),
+                     '#weight' => 4
+                  );
+               }
+               break;
+            case 'chado_library':
+               break;
+            default:           
          }
 
 
          // Abort if this node is not one of the types we should show.
-         if (!in_array($node->type, $types_to_show, TRUE)) {
-            break;
-         }
+
 
          // Add feature to the content item if it's not a teaser
          if (!$teaser) {
 
-            // Show feature browser
-            $node->content['tripal_feature_browser'] = array(
-               '#value' => theme('tripal_feature_browser', $node),
-               '#weight' => 5
-            );
-            $node->content['tripal_feature_org_counts'] = array(
-               '#value' => theme('tripal_feature_counts', $node),
-               '#weight' => 4
-            );
+
          }
    }
 }
@@ -1365,7 +1412,7 @@ function tripal_feature_theme () {
       'tripal_feature_browser' => array (
          'arguments' => array('node'),
       ),
-      'tripal_feature_counts' => array (
+      'tripal_feature_org_counts' => array (
          'arguments' => array('node'),
       ),
       'tripal_feature_base' => array (
@@ -1376,6 +1423,10 @@ function tripal_feature_theme () {
          'arguments' => array('node'=> null),
          'template' => 'tripal_feature_sequence',
       ),
+      'tripal_feature_synonyms' => array (
+         'arguments' => array('node'=> null),
+         'template' => 'tripal_feature_synonyms',
+      ),
       'tripal_feature_featureloc_sequences' => array (
          'arguments' => array('node'=> null),
          'template' => 'tripal_feature_featureloc_sequences',
@@ -1384,6 +1435,10 @@ function tripal_feature_theme () {
          'arguments' => array('node'=> null),
          'template' => 'tripal_feature_references',
       ),
+      'tripal_feature_properties' => array (
+         'arguments' => array('node'=> null),
+         'template' => 'tripal_feature_properties',
+      ),
       'tripal_feature_featurelocs_as_parent' => array (
          'arguments' => array('node'=> null),
          'template' => 'tripal_feature_featurelocs_as_parent',
@@ -1402,33 +1457,47 @@ function tripal_feature_theme () {
       ),
    );
 }
+/*******************************************************************************
+ *  
+ */
+function tripal_feature_preprocess_tripal_feature_properties(&$variables){
+   $feature = $variables['node']->feature;
+   $variables['tripal_feature']['properties'] = tripal_feature_load_properties($feature->feature_id);
+}
+/*******************************************************************************
+ *  
+ */
+function tripal_feature_preprocess_tripal_feature_synonyms(&$variables){
+   $feature = $variables['node']->feature;
+   $variables['tripal_feature']['synonyms'] = tripal_feature_load_synonyms($feature->feature_id);
+}
 /*******************************************************************************
  *  
  */
 function tripal_feature_preprocess_tripal_feature_relationships_as_object(&$variables){
    $feature = $variables['node']->feature;
-   $variables['object_relationships'] = tripal_feature_get_aggregate_relationships($feature->feature_id,0);
+   $variables['tripal_feature']['object_relationships'] = tripal_feature_get_aggregate_relationships($feature->feature_id,0);
 }
 /*******************************************************************************
  *  
  */
 function tripal_feature_preprocess_tripal_feature_relationships_as_subject(&$variables){
    $feature = $variables['node']->feature;
-   $variables['subject_relationships'] = tripal_feature_load_relationships($feature->feature_id,'as_subject');
+   $variables['tripal_feature']['subject_relationships'] = tripal_feature_load_relationships($feature->feature_id,'as_subject');
 }
 /*******************************************************************************
 *
 */
 function tripal_feature_preprocess_tripal_feature_featurelocs_as_child(&$variables){
    $feature = $variables['node']->feature;
-   $variables['featurelocs_as_child'] = tripal_feature_load_featurelocs($feature->feature_id,'as_child',0);
+   $variables['tripal_feature']['featurelocs_as_child'] = tripal_feature_load_featurelocs($feature->feature_id,'as_child',0);
 }
 /*******************************************************************************
  *  
  */
 function tripal_feature_preprocess_tripal_feature_featurelocs_as_parent(&$variables){
    $feature = $variables['node']->feature;
-   $variables['featurelocs_as_parent'] = tripal_feature_load_featurelocs($feature->feature_id,'as_parent');
+   $variables['tripal_feature']['featurelocs_as_parent'] = tripal_feature_load_featurelocs($feature->feature_id,'as_parent');
 }
 /*******************************************************************************
  *  
@@ -1443,12 +1512,14 @@ function tripal_feature_preprocess_tripal_feature_references(&$variables){
 function tripal_feature_preprocess_tripal_feature_featureloc_sequences(&$variables){
    $feature = $variables['node']->feature;
    $featurelocs = tripal_feature_load_featurelocs($feature->feature_id,'as_child',0);
-   $variables['featureloc_sequences'] = tripal_feature_load_featureloc_sequences ($feature->feature_id,$featurelocs);   
+   $variables['tripal_feature']['featureloc_sequences'] = tripal_feature_load_featureloc_sequences ($feature->feature_id,$featurelocs);   
 }
 /*******************************************************************************
  *  
  */
-function theme_tripal_feature_counts($node){
+function theme_tripal_feature_org_counts($node){
+
+   $organism = $node->organism;
 
    // don't show the summary if the settings in the admin page is turned off
    $show_browser = variable_get('tripal_feature_summary_setting',array('show_feature_summary'));
@@ -1460,13 +1531,13 @@ function theme_tripal_feature_counts($node){
    // get the feature counts.  This is dependent on a materialized view
    // installed with the organism module
    $content = '';
-   if ($node->organism_id && $node->type == 'chado_organism') {
+   if ($organism->organism_id && $node->type == 'chado_organism') {
       $sql = "SELECT * FROM {organism_feature_count} ".
       		 "WHERE organism_id = %d AND NOT feature_type = 'EST_match' ".
              "ORDER BY num_features desc";
       $features = array();
       $previous_db = tripal_db_set_active('chado');  // use chado database
-      $results = db_query($sql,$node->organism_id);
+      $results = db_query($sql,$organism->organism_id);
       tripal_db_set_active($previous_db);  // now use drupal database
       $feature = db_fetch_object($results); // retrieve the first result
       if ($feature) {
@@ -1488,7 +1559,7 @@ function theme_tripal_feature_counts($node){
          } while($feature = db_fetch_object($results));
          $content .= "</table>";
          $content .= "
-            <img class=\"tripal_cv_chart\" id=\"tripal_feature_cv_chart_$node->organism_id\" src=\"\" border=\"0\">
+            <img class=\"tripal_cv_chart\" id=\"tripal_feature_cv_chart_$organism->organism_id\" src=\"\" border=\"0\">
          ";
          $content .= "</div></div>";
       }
@@ -1540,6 +1611,7 @@ function tripal_feature_cv_tree($tree_id){
  *  create a simple paged feature browser
  */
 function theme_tripal_feature_browser($node){
+   $organism = $node->organism;
 
    // don't show the browser if the settings in the admin page is turned off
    $show_browser = variable_get('tripal_feature_browse_setting',array('show_feature_browser'));
@@ -1547,7 +1619,7 @@ function theme_tripal_feature_browser($node){
    if(strcmp($show_browser[0],'show_feature_browser')!=0){
       return;
    }
-   if ($node->organism_id && $node->type == 'chado_organism') {
+   if ($organism->organism_id && $node->type == 'chado_organism') {
       # get the list of available sequence ontology terms for which
       # we will build drupal pages from features in chado.  If a feature
       # is not one of the specified typse we won't build a node for it.
@@ -1564,14 +1636,14 @@ function theme_tripal_feature_browser($node){
       $sql  = "SELECT F.name,F.feature_id,F.uniquename,CVT.name as cvname ".
               "FROM {feature} F ".
                  "  INNER JOIN {cvterm} CVT on F.type_id = CVT.cvterm_id ".
-               "WHERE organism_id = $node->organism_id and ($where_cvt) ".
+               "WHERE organism_id = $organism->organism_id and ($where_cvt) ".
                "ORDER BY feature_id ASC";
 
       // the counting SQL
       $csql  = "SELECT count(*) ".
                "FROM {feature} F".
                "  INNER JOIN {cvterm} CVT on F.type_id = CVT.cvterm_id ".
-               "WHERE organism_id = $node->organism_id and ($where_cvt) ".
+               "WHERE organism_id = $organism->organism_id and ($where_cvt) ".
                "GROUP BY organism_id ";
 
       $previous_db = tripal_db_set_active('chado');  // use chado database

+ 91 - 37
tripal_organism/tripal_organism.module

@@ -2,6 +2,16 @@
 
 require_once "tripal_organism.api.inc";
 
+
+/*************************************************************************
+*
+*/
+function tripal_organism_init(){
+
+   // add the jGCharts JS and CSS
+   drupal_add_js (drupal_get_path('theme', 'tripal').'/js/tripal_organism.js'); 
+   drupal_add_css(drupal_get_path('theme', 'tripal').'/css/tripal_organism.css');
+}
 /*******************************************************************************
  *  Provide information to drupal about the node types that we're creating
  *  in this module
@@ -29,30 +39,41 @@ function tripal_organism_node_info() {
  */
 function tripal_organism_block($op = 'list', $delta = '0', $edit = array()){
    switch($op){
-         case 'list':
-            $blocks[0]['info'] = t('Organisms');
-            return $blocks;
-
-         case 'view':
-            if(user_access('access chado_organism content')){
-               // Show libraries stored in Drupal's {chado_organism} table
-               $sql = "SELECT COUNT(organism_id) FROM {chado_organism}";
-               $no_orgs = db_result(db_query ($sql));
-               if($no_orgs != 0) {
-                  $organisms = get_chado_organisms();
-                  foreach($organisms as $organism){
-                     // get the node id for this organism
-                     $items[] = l($organism->common_name,
-                                  'node/'.$organism->node_id);
-                  }
-               } else {
-                  $items[] = t("No organism exists.");
-               }
-                $block['subject'] = t('Organisms');
-                //We theme our array of links as an unordered list
-                $block['content'] = theme('item_list', $items);
+      case 'list':
+         $blocks['base']['info'] = t('Tripal Organism Details');
+         $blocks['base']['cache'] = BLOCK_NO_CACHE;
+
+         $blocks['description']['info'] = t('Tripal Organism Description');
+         $blocks['description']['cache'] = BLOCK_NO_CACHE;
+
+         $blocks['image']['info'] = t('Tripal Organism Image');
+         $blocks['image']['cache'] = BLOCK_NO_CACHE;
+
+         return $blocks;
+
+      case 'view':
+         if(user_access('access chado_feature content') and arg(0) == 'node' and is_numeric(arg(1))) {
+            $nid = arg(1);
+            $node = node_load($nid);
+
+            $block = array();
+            switch($delta){
+               case 'base':
+                  $block['subject'] = t('Organism Details');
+                  $block['content'] = theme('tripal_organism_base',$node);
+                  break;
+               case 'description':
+                  $block['subject'] = t('Organism Description');
+                  $block['content'] = theme('tripal_organism_description',$node);
+                  break;
+               case 'image':
+                  $block['subject'] = t('Organism Image');
+                  $block['content'] = theme('tripal_organism_image',$node);
+                  break;
+               default:
             }
             return $block;
+      }
    }
 }
 /*******************************************************************************
@@ -495,8 +516,47 @@ function tripal_organism_theme () {
       'tripal_organism_organism_page' => array (
          'arguments' => array('organisms'),
       ),
+      'tripal_organism_base' => array (
+         'arguments' => array('node'=> null),
+         'template' => 'tripal_organism_base',
+      ),
+      'tripal_organism_description' => array (
+         'arguments' => array('node'=> null),
+         'template' => 'tripal_organism_description',
+      ),
+      'tripal_organism_image' => array (
+         'arguments' => array('node'=> null),
+         'template' => 'tripal_organism_image',
+      ),
    );
 }
+/*******************************************************************************
+ * 
+ */
+function tripal_organism_nodeapi(&$node, $op, $teaser, $page) {
+
+   switch ($op) {
+      case 'view':
+         switch($node->type){
+            case 'chado_organism':
+               $node->content['tripal_organism_image'] = array(
+                  '#value' => theme('tripal_organism_image', $node),
+                  '#weight' => 0
+               );
+               $node->content['tripal_organism_base'] = array(
+                  '#value' => theme('tripal_organism_base', $node),
+                  '#weight' => 1
+               );
+               $node->content['tripal_organism_description'] = array(
+                  '#value' => theme('tripal_organism_description', $node),
+                  '#weight' => 2
+               );
+               break;
+            default:          
+           
+         }
+   }
+}
 /*******************************************************************************
  *
  */
@@ -671,6 +731,8 @@ function chado_organism_update($node){
  *  a form.  This function creates the form that will be used for this.
  */
 function chado_organism_form ($node, $param){
+   $organism = $node->organism;
+
    $type = node_get_types('type',$node);
    $form = array();
    $form['#attributes']['enctype'] = 'multipart/form-data';
@@ -679,28 +741,28 @@ function chado_organism_form ($node, $param){
       '#type' => 'textfield',
       '#title' => t('Abbreviation'),
       '#required' => TRUE,
-      '#default_value' => $node->abbreviation,
+      '#default_value' => $organism->abbreviation,
       '#weight' => 3
    );
    $form['genus']= array(
       '#type' => 'textfield',
       '#title' => t('Genus'),
       '#required' => TRUE,
-      '#default_value' => $node->genus,
+      '#default_value' => $organism->genus,
       '#weight' => 1
    );
    $form['species']= array(
       '#type' => 'textfield',
       '#title' => t('Species'),
       '#required' => TRUE,
-      '#default_value' => $node->species,
+      '#default_value' => $organism->species,
       '#weight' => 2
    );
    $form['common_name']= array(
       '#type' => 'textfield',
       '#title' => t('Common Name'),
       '#required' => TRUE,
-      '#default_value' => $node->common_name,
+      '#default_value' => $organism->common_name,
       '#weight' => 4
    );
    $form['description']= array(
@@ -708,7 +770,7 @@ function chado_organism_form ($node, $param){
       '#rows' => 15,
       '#title' => t('Description'),
       '#required' => TRUE,
-      '#default_value' => check_plain($node->description),
+      '#default_value' => check_plain($organism->description),
       '#weight' => 5
    );
    $form['organism-image']= array(
@@ -729,24 +791,16 @@ function chado_organism_load($node){
    $sql = "SELECT organism_id FROM {chado_organism} WHERE vid = %d";
    $org_node = db_fetch_object(db_query($sql, $node->vid));
 
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-
    // get information about this organism and add it to the items in this node
+   $previous_db = tripal_db_set_active('chado');  // use chado database
    if ($org_node->organism_id) {
       $sql = "SELECT O.organism_id,O.genus,O.species, ".
       		 "  O.common_name, O.comment as description, O.abbreviation ".
              "FROM {Organism} O ".
           	 "WHERE O.Organism_id = $org_node->organism_id";
       $organism = db_fetch_object(db_query($sql));
-      $additions->organism_id = $org_node->organism_id;
+      $additions->organism  = $organism;
    }
-   $additions->abbreviation = $organism->abbreviation;
-   $additions->genus = $organism->genus;
-   $additions->species = $organism->species;
-   $additions->common_name = $organism->common_name;
-   $additions->description = $organism->description;
-
-
    tripal_db_set_active($previous_db);  // now use drupal database
 
    return $additions;