Ver código fonte

Fixed presave hook title setting for many of the node types. Links in TOC are now sorted if they have the same weight.

Stephen Ficklin 11 anos atrás
pai
commit
a28a0652c0

+ 0 - 100
tripal_analysis/includes/tripal_analysis.admin.inc

@@ -94,107 +94,7 @@ function tripal_analysis_admin() {
   return system_settings_form($form);
 }
 
-/**
- * Displays the Set Drupal Taxonomy for Analysis Features From
- *
- * @param $form
- *  The administrative form as it is currently
- *
- * @return
- *  A form API array describing an administrative form
- *
- * @ingroup tripal_analysis
- */
-function get_tripal_analysis_admin_form_taxonomy_set(&$form) {
-  $form['taxonify'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Assign Drupal Taxonomy to Analysis Features')
-  );
-
-  // get the list of analyses
-  $sql = "SELECT * FROM {analysis} ORDER BY name";
-  $lib_rset = chado_query($sql);
-
-  // iterate through all of the libraries
-  $lib_boxes = array();
-  while ($analysis = $lib_rset->fetchObject()) {
-    $lib_boxes[$analysis->analysis_id] = "$analysis->name";
-  }
-
-  $form['taxonify']['description'] = array(
-       '#type' => 'item',
-       '#value' => t("Drupal allows for assignment of \"taxonomy\" or catagorical terms to " .
-          "nodes. These terms allow for advanced filtering during searching. This option allows " .
-          "for setting taxonomy only for features that belong to the selected analyses below.  All other features will be unaffected.  To set taxonomy for all features in the site see the Feature Administration page."),
-     '#weight' => 1,
-  );
-
-  $form['taxonify']['tx-analyses'] = array(
-     '#title'       => t('Analyses'),
-     '#type'        => t('checkboxes'),
-     '#description' => t("Check the analyses whose features you want to reset taxonomy.  Note: this list contains all analyses, even those that may not be synced."),
-     '#required'    => FALSE,
-     '#prefix'      => '<div id="lib_boxes">',
-     '#suffix'      => '</div>',
-     '#options'     => $lib_boxes,
-     '#weight'      => 2
-  );
-  $form['taxonify']['tx-button'] = array(
-      '#type' => 'submit',
-      '#value' => t('Set Feature Taxonomy'),
-      '#weight'      => 3
-  );
-}
 
-/**
- * The "Reindex Analysis Nodes" form
- *
- * @param $form
- *  The administrative form as it is currently
- *
- * @return
- *  A form API array describing an administrative form
- *
- * @ingroup tripal_analysis
- */
-function get_tripal_analysis_admin_form_reindex_set(&$form) {
-  // define the fieldsets
-  $form['reindex'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Reindex Analysis Features')
-  );
-
-  // get the list of libraries
-  $sql = "SELECT * FROM {analysis} ORDER BY name";
-  $lib_rset = chado_query($sql);
-
-  // iterate through all of the libraries
-  $lib_boxes = array();
-  while ($analysis = $lib_rset->fetchObject()) {
-    $lib_boxes[$analysis->analysis_id] = "$analysis->name";
-  }
-  $form['reindex']['description'] = array(
-       '#type' => 'item',
-       '#value' => t("This option allows for reindexing of only those features that belong to the selected analyses below. All other features will be unaffected.  To reindex all features in the site see the Feature Administration page."),
-     '#weight' => 1,
-  );
-
-  $form['reindex']['re-analyses'] = array(
-     '#title'       => t('Libraries'),
-     '#type'        => t('checkboxes'),
-     '#description' => t("Check the analyses whoee features you want to reindex. Note: this list contains all analyses, even those that may not be synced."),
-     '#required'    => FALSE,
-     '#prefix'      => '<div id="lib_boxes">',
-     '#suffix'      => '</div>',
-     '#options'     => $lib_boxes,
-     '#weight' => 2,
-  );
-  $form['reindex']['re-button'] = array(
-      '#type' => 'submit',
-      '#value' => t('Reindex Features'),
-      '#weight' => 3,
-  );
-}
 
 
 

+ 22 - 19
tripal_analysis/includes/tripal_analysis.chado_node.inc

@@ -597,6 +597,7 @@ function tripal_analysis_node_view($node, $view_mode, $langcode) {
           '#markup' => theme('tripal_analysis_base', array('node' => $node)),
           '#tripal_toc_id'    => 'base',
           '#tripal_toc_title' => 'Details',
+          '#weight' => -100,
         );
         $node->content['tripal_analysis_properties'] = array(
           '#markup' => theme('tripal_analysis_properties', array('node' => $node)),
@@ -617,36 +618,38 @@ function tripal_analysis_node_view($node, $view_mode, $langcode) {
  * @param $node
  */
 function tripal_analysis_node_presave($node) {
+  $name = '';
+  $program = '';
+  $programversion = '';
+  $sourcename = '';
+  
   // If this is an analysis of some type it will should have three required
   // fields for the Chado analysis table: program, programversion and sourcename.
   // So we will set the title for any node that has these three fields. Some extension
   // modules will use this module as a type of "inherited" class, so we don't know
-  // for sure when type of analysis we have.
+  // for sure when type of analysis we have.  If this is a sync then 
   if (property_exists($node, 'program') and
       property_exists($node, 'programversion') and
       property_exists($node, 'sourcename')) {
-    $name = '';
-    $program = '';
-    $programversion = '';
-    $sourcename = '';
-    if (property_exists($node, 'analysis')) {
-      $name           = $node->analysis->name;
-      $program        = $node->analysis->program;
-      $programversion = $node->analysis->programversion;
-      $sourcename     = $node->analysis->sourcename;
-    }
-    else {
-      $name           = $node->analysisname;
-      $program        = $node->program;
-      $programversion = $node->programversion;
-      $sourcename     = $node->sourcename;
-    }
+    $name           = $node->analysisname;
+    $program        = $node->program;
+    $programversion = $node->programversion;
+    $sourcename     = $node->sourcename;
     // now construct the title
+    $node->title = "$program ($programversion) $sourcename";
     if ($name) {
       $node->title = $name;
     }
-    else {
-      $node->title = "$program ($programversion) $sourcename";
+  }
+  else if (property_exists($node, 'analysis')) {
+    $name           = $node->analysis->name;
+    $program        = $node->analysis->program;
+    $programversion = $node->analysis->programversion;
+    $sourcename     = $node->analysis->sourcename;
+    // now construct the title
+    $node->title = "$program ($programversion) $sourcename";
+    if ($name) {
+      $node->title = $name;
     }
   }
 }

+ 22 - 22
tripal_contact/includes/tripal_contact.chado_node.inc

@@ -60,7 +60,7 @@ function chado_contact_form(&$node, $form_state) {
   // set form field defaults
   $contact_id  = null;
   $type_id     = 0;
-  $title       = '';
+  $contactname       = '';
   $description = '';
 
   // if we are editing an existing node then the contact is already part of the node
@@ -70,7 +70,7 @@ function chado_contact_form(&$node, $form_state) {
 
     // get form defaults
     $type_id     = $contact->type_id->cvterm_id;
-    $title       = $contact->name;
+    $contactname       = $contact->name;
 
     // get the contact default values.  When this module was first created
     // the contact description was incorrectly stored in the $node->body field.
@@ -104,14 +104,14 @@ function chado_contact_form(&$node, $form_state) {
   // then use the $form_state['values'] values
   if (array_key_exists('values', $form_state)) {
     $type_id     = $form_state['values']['type_id'];
-    $title       = $form_state['values']['title'];
+    $contactname       = $form_state['values']['contactname'];
     $description = $form_state['values']['description'];
   }
   // if we are re building the form from after submission (from ajax call) then
   // the values are in the $form_state['input'] array
   if (array_key_exists('input', $form_state) and !empty($form_state['input'])) {
     $type_id     = $form_state['input']['type_id'];
-    $title       = $form_state['input']['title'];
+    $contactname       = $form_state['input']['contactname'];
     $description = $form_state['input']['description'];
   }
 
@@ -146,12 +146,12 @@ function chado_contact_form(&$node, $form_state) {
     '#default_value' => $type_id,
   );
 
-  $form['title']= array(
+  $form['contactname']= array(
     '#type'          => 'textfield',
     '#title'         => t('Contact Name'),
     '#description'   => t('Enter the name of this contact'),
     '#required'      => TRUE,
-    '#default_value' => $title,
+    '#default_value' => $contactname,
     '#maxlength'     => 255,
   );
 
@@ -234,7 +234,7 @@ function chado_contact_form(&$node, $form_state) {
  */
 function chado_contact_validate($node, $form, &$form_state) {
   // remove surrounding white-space on submitted values
-  $node->title          = trim($node->title);
+  $node->contactname          = trim($node->contactname);
   $node->description    = trim($node->description);
 
   // if this is a delete then don't validate
@@ -256,11 +256,11 @@ function chado_contact_validate($node, $form, &$form_state) {
     $contact = $result[0];
 
     // if the name has changed make sure it doesn't conflict with an existing name
-    if ($contact->name != $node->title) {
-      $values = array('name' => $node->title);
+    if ($contact->name != $node->contactname) {
+      $values = array('name' => $node->contactname);
       $result = tripal_core_chado_select('contact', array('contact_id'), $values);
       if ($result and count($result) > 0) {
-        form_set_error('title', 'Cannot update the contact with this contact name. A contact with this name already exists.');
+        form_set_error('contactname', 'Cannot update the contact with this contact name. A contact with this name already exists.');
         return;
       }
     }
@@ -269,11 +269,11 @@ function chado_contact_validate($node, $form, &$form_state) {
   else {
     // The unique constraint for the chado contact table is: name
     $values = array(
-      'name' => $node->title,
+      'name' => $node->contactname,
     );
     $contact = tripal_core_chado_select('contact', array('contact_id'), $values);
     if ($contact and count($contact) > 0) {
-      form_set_error('title', 'Cannot add the contact with this name. A contact with these values already exists.');
+      form_set_error('contactname', 'Cannot add the contact with this name. A contact with these values already exists.');
       return;
     }
   }
@@ -343,7 +343,7 @@ function chado_contact_node_access($node, $op, $account ) {
 function chado_contact_insert($node) {
 
   // remove surrounding white-space on submitted values
-  $node->title          = trim($node->title);
+  $node->contactname          = trim($node->contactname);
   $node->description    = trim($node->description);
 
   // if there is a contact_id in the $node object then this must be a sync so
@@ -352,7 +352,7 @@ function chado_contact_insert($node) {
   if (!property_exists($node, 'contact_id')) {
     // insert and then get the newly inserted contact record
     $values = array(
-      'name'           => $node->title,
+      'name'           => $node->contactname,
       'description'    => '',
       'type_id'        => $node->type_id,
     );
@@ -418,7 +418,7 @@ function chado_contact_insert($node) {
 */
 function chado_contact_update($node) {
   // remove surrounding white-space on submitted values
-  $node->title          = trim($node->title);
+  $node->contactname          = trim($node->contactname);
   $node->description    = trim($node->description);
 
   $contact_id = chado_get_id_for_node('contact', $node->nid) ;
@@ -428,7 +428,7 @@ function chado_contact_update($node) {
     'contact_id' => $contact_id,
   );
   $values = array(
-    'name' => $node->title,
+    'name' => $node->contactname,
     'description' => '',
     'type_id' => $node->type_id
   );
@@ -556,7 +556,7 @@ function tripal_contact_node_view($node, $view_mode, $langcode) {
           '#markup' => theme('tripal_contact_base', array('node' => $node)),
           '#tripal_toc_id'    => 'base',
           '#tripal_toc_title' => 'Details',
-          '#weight' => 0,
+          '#weight' => -100,
         );
         $node->content['tripal_contact_properties'] = array(
           '#markup' => theme('tripal_contact_properties', array('node' => $node)),
@@ -590,14 +590,14 @@ function tripal_contact_node_view($node, $view_mode, $langcode) {
 function tripal_contact_node_presave($node) {
   switch ($node->type) {
     case 'chado_contact':
-      // for a form submission the fields part of the node object
-      // but for a sync the feilds are in an object of the node
-      if(property_exists($node, 'contact')) {
+      // for a form submission the 'contactname' field will be set,
+      // for a sync, we must pull from the contact object
+      if(property_exists($node, 'contactname')) {
         // set the title
-        $node->title = $node->contact->name;
+        $node->title = $node->contactname;
       }
       else {
-        // the title is an element of the form and does not need to be set
+        $node->title = $node->contact->name;
       }
       break;
   }

+ 1 - 1
tripal_core/theme/css/tripal.css

@@ -58,7 +58,7 @@
   background-color: transparent !important;
 }
 .tripal-contents-table-td-toc { 
-  border-right: 1px solid #888888 !important;
+  border-right: 1px solid #CCCCCC !important;
   margin:  0px !important;
   padding: 0px !important;
   background-color: transparent !important;

+ 1 - 1
tripal_core/theme/node--chado-generic.tpl.php

@@ -17,7 +17,7 @@ else {
           // show the corresponding item in the details box 
           $(".tripal_toc_list_item_link").click(function(){
             var id = $(this).attr('id') + "-tripal-data-block";
-            $(".tripal-data-block").hide().filter("#"+ id).show();
+            $(".tripal-data-block").hide().filter("#"+ id).fadeIn('fast');
             return false;
           }); 
     

+ 8 - 5
tripal_core/tripal_core.module

@@ -658,11 +658,11 @@ function tripal_core_node_view_alter(&$build) {
         //-----------------------
         // set the weight of the TOC item and add it to our $toc array
         // for building of the TOC below
-        $weight = 10;
+        $weight = 0;
         if (array_key_exists('#weight', $build[$key])) {
           $weight = $build[$key]['#weight'];
         }
-        $toc[$weight][] = $toc_item_link;
+        $toc[$weight][$toc_item_title] = $toc_item_link;
     
         //-----------------------
         // CREATE THE DATA BLOCK
@@ -678,6 +678,7 @@ function tripal_core_node_view_alter(&$build) {
         ";
         
         $build[$key]['#markup'] = $updated_markup;
+        $build[$key]['#weight'] = $weight;
       }
     }
   }
@@ -685,15 +686,17 @@ function tripal_core_node_view_alter(&$build) {
   //-----------------------
   // BUILD THE TABLE OF CONTENTS LINKS
   //-----------------------
-  $toc_html = '';
+  // first sort the links numerically by their weight
   ksort($toc, SORT_NUMERIC);
+  $toc_html = '';
   foreach ($toc as $weight => $links) {
-    foreach ($links as $index => $toc_item_link) {
+    // for links in the same weight, sort them alphabetically
+    ksort($links);
+    foreach ($links as $toc_item_title => $toc_item_link) {
       $toc_html .= $toc_item_link;
     }
   }
   $build['tripal_toc']['#markup'] = "<div id=\"$node->type-tripal-toc-block\" class=\"tripal-toc-block\">$toc_html</div>";
-  
   //dpm($cache);
   //dpm($build);
 }

+ 1 - 0
tripal_example/includes/tripal_example.chado_node.inc

@@ -582,6 +582,7 @@ function tripal_example_node_view($node, $view_mode, $langcode) {
         //  '#markup' => theme('tripal_example_base', array('node' => $node)),
         //  '#tripal_toc_id'    => 'base',
         //  '#tripal_toc_title' => 'Details',
+        //  '#weight' => -100,
         //);
         // we can add other templates as well.
         //$node->content['tripal_example_properties'] = array(

+ 20 - 17
tripal_feature/includes/tripal_feature.chado_node.inc

@@ -639,13 +639,19 @@ function tripal_feature_node_presave($node) {
   // set the title to ensure it is always unique
   switch ($node->type) {
     case 'chado_feature':
-      // for a form submission the fields part of the node object
-      // but for a sync the feilds are in an object of the node
+      // for a form submission the fields are part of the node object
+      // but for a sync the fields are in an object of the node
       $name = '';
       $uname = '';
       $type = '';
       $organism_id = null;
-      if(property_exists($node, 'feature')) {
+      if(property_exists($node, 'uniquename')) {
+        $organism_id = $node->organism_id;
+        $name        = $node->name;
+        $uname       = $node->uniquename;
+        $type        = $node->feature_type;
+      }
+      else {
         $organism_id = $node->feature->organism_id;
         $name        = $node->feature->name;
         $uname       = $node->feature->uniquename;
@@ -653,17 +659,14 @@ function tripal_feature_node_presave($node) {
         $values = array('cvterm_id' => $type_id);
         $ftype = tripal_core_chado_select('cv', array('name'), $values);
         $type = $ftype[0]->name;
-
-      }
-      else {
-        $organism_id = $node->organism_id;
-        $name = $node->name;
-        $uname = $node->uniquename;
-        $type = $node->feature_type;
       }
       $values = array('organism_id' => $organism_id);
       $organism = tripal_core_chado_select('organism', array('genus', 'species'), $values);
-      $node->title = $name . ', ' . $uname . ' (' . $type . ') ' . $organism[0]->genus . ' ' . $organism[0]->species;
+      $node->title = "$name, $uname ($type) " . $organism[0]->genus . ' ' . $organism[0]->species;
+      
+      if ($name == $uname) {
+        $node->title = "$name ($type) " . $organism[0]->genus . ' ' . $organism[0]->species; 
+      }
       break;
   }
 }
@@ -770,12 +773,6 @@ function tripal_feature_node_view($node, $view_mode, $langcode) {
     case 'chado_feature':
       // Show feature browser and counts
       if ($view_mode == 'full') {
-        $node->content['tripal_feature_base'] = array(
-          '#markup' => theme('tripal_feature_base', array('node' => $node)),
-          '#tripal_toc_id'    => 'base',
-          '#tripal_toc_title' => 'Details',
-          '#weight' => 0,
-        );
         $node->content['tripal_feature_alignments'] = array(
           '#markup' => theme('tripal_feature_alignments', array('node' => $node)),
           '#tripal_toc_id'    => 'alignments',
@@ -786,6 +783,12 @@ function tripal_feature_node_view($node, $view_mode, $langcode) {
           '#tripal_toc_id'    => 'analyses',
           '#tripal_toc_title' => 'Analyses',
         );
+        $node->content['tripal_feature_base'] = array(
+          '#markup' => theme('tripal_feature_base', array('node' => $node)),
+          '#tripal_toc_id'    => 'base',
+          '#tripal_toc_title' => 'Details',
+          '#weight' => -100,
+        );
         $node->content['tripal_feature_featurepos'] = array(
           '#markup' => theme('tripal_feature_featurepos', array('node' => $node)),          
           '#tripal_toc_id'    => 'featurepos',

+ 27 - 24
tripal_featuremap/includes/tripal_featuremap.chado_node.inc

@@ -50,7 +50,7 @@ function chado_featuremap_form($node, &$form_state) {
   //
   // set form field defaults
   $featuremap_id = NULL;
-  $title = '';
+  $fmapname = '';
   $description = '';
   $unittype_id = '';
 
@@ -61,7 +61,7 @@ function chado_featuremap_form($node, &$form_state) {
     $featuremap_id = $featuremap->featuremap_id;
 
     // get form defaults
-    $title       = $featuremap->name;
+    $fmapname    = $featuremap->name;
     $description = $featuremap->description;
     $unittype_id = $featuremap->unittype_id->cvterm_id;
 
@@ -74,24 +74,24 @@ function chado_featuremap_form($node, &$form_state) {
   // if we are re constructing the form from a failed validation or ajax callback
   // then use the $form_state['values'] values
   if (array_key_exists('values', $form_state)) {
-    $title       = $form_state['values']['title'];
+    $fmapname       = $form_state['values']['fmapname'];
     $description = $form_state['values']['description'];
     $unittype_id = $form_state['values']['unittype_id'];
   }
   // if we are re building the form from after submission (from ajax call) then
   // the values are in the $form_state['input'] array
   if (array_key_exists('input', $form_state) and !empty($form_state['input'])) {
-    $title       = $form_state['input']['title'];
+    $fmapname       = $form_state['input']['fmapname'];
     $description = $form_state['input']['description'];
     $unittype_id = $form_state['input']['unittype_id'];
   }
 
-  $form['title']= array(
+  $form['fmapname']= array(
     '#type'          => 'textfield',
     '#title'         => t('Map Name'),
     '#description'   => t('Please enter a name for this map'),
     '#required'      => TRUE,
-    '#default_value' => $title,
+    '#default_value' => $fmapname,
     '#maxlength'     => 255
   );
   $form['description']= array(
@@ -146,7 +146,7 @@ function chado_featuremap_form($node, &$form_state) {
  * @ingroup tripal_featuremap
  */
 function chado_featuremap_validate($node, $form, &$form_state) {
-  $node->title          = trim($node->title);
+  $node->fmapname          = trim($node->fmapname);
   $node->description    = trim($node->description);
 
   // if this is a delete then don't validate
@@ -171,14 +171,14 @@ function chado_featuremap_validate($node, $form, &$form_state) {
       SELECT * FROM {featuremap}
       WHERE name = :name AND NOT featuremap_id = :featuremap_id
     ";
-    $featuremap = chado_query($sql, array(':name' => $node->title, ':featuremap_id' => $node->featuremap_id))->fetchObject();
+    $featuremap = chado_query($sql, array(':name' => $node->fmapname, ':featuremap_id' => $node->featuremap_id))->fetchObject();
   }
   else {
     $sql = "SELECT * FROM {featuremap} WHERE name = :name";
-    $featuremap = chado_query($sql, array(':name' => $node->title))->fetchObject();
+    $featuremap = chado_query($sql, array(':name' => $node->fmapname))->fetchObject();
   }
   if ($featuremap) {
-    form_set_error('title', t('The unique map name already exists. Please choose another'));
+    form_set_error('fmapname', t('The unique map name already exists. Please choose another'));
   }
 }
 
@@ -247,7 +247,7 @@ function chado_featuremap_node_access($node, $op, $account) {
  */
 function chado_featuremap_insert($node) {
 
-  $node->title          = trim($node->title);
+  $node->fmapname          = trim($node->fmapname);
   $node->description    = trim($node->description);
 
   // if there is an featuremap_id in the $node object then this must be a sync so
@@ -256,7 +256,7 @@ function chado_featuremap_insert($node) {
   if (!property_exists($node, 'featuremap_id')) {
 
     $values = array(
-      'name'        => $node->title,
+      'name'        => $node->fmapname,
       'description' => $node->description,
       'unittype_id' => $node->unittype_id
     );
@@ -319,7 +319,7 @@ function chado_featuremap_insert($node) {
  */
 function chado_featuremap_update($node) {
 
-  $node->title          = trim($node->title);
+  $node->fmapname          = trim($node->fmapname);
   $node->description    = trim($node->description);
 
   $featuremap_id = chado_get_id_for_node('featuremap', $node->nid) ;
@@ -329,7 +329,7 @@ function chado_featuremap_update($node) {
     'featuremap_id' => $featuremap_id,
   );
   $values = array(
-    'name' => $node->title,
+    'name' => $node->fmapname,
     'description' => $node->description,
     'unittype_id' => $node->unittype_id
   );
@@ -424,15 +424,18 @@ function chado_featuremap_delete(&$node) {
  * @param $node
  */
 function tripal_featuremap_node_presave($node) {
-  if ($node->type == 'chado_featuremap') {
-    // for a form submission the fields part of the node object
-    // but for a sync the feilds are in an object of the node
-    if(property_exists($node, 'featuremap')) {
-      $node->title = $node->featuremap->name;
-    }
-    else {
-      // the title is already set in the form
-    }
+  switch ($node->type) {
+    case 'chado_featuremap':
+      // for a form submission the 'fmapname' field will be set,
+      // for a sync, we must pull from the featuremap object
+      if(property_exists($node, 'fmapname')) {
+        // set the title
+        $node->title = $node->fmapname;
+      }
+      else {
+        $node->title = $node->featuremap->name;
+      }
+      break;
   }
 }
 /**
@@ -448,7 +451,7 @@ function tripal_featuremap_node_view($node, $view_mode, $langcode) {
           '#markup' => theme('tripal_featuremap_base', array('node' => $node)),
           '#tripal_toc_id'    => 'base',
           '#tripal_toc_title' => 'Details',
-          '#weight' => 0,
+          '#weight' => -100,
         );
         $node->content['tripal_featuremap_featurepos'] = array(
           '#markup' => theme('tripal_featuremap_featurepos', array('node' => $node)),

+ 19 - 22
tripal_library/includes/tripal_library.chado_node.inc

@@ -51,7 +51,7 @@ function chado_library_form($node, &$form_state) {
   //
   // set form field defaults
   $library_id = NULL;
-  $title = '';
+  $libraryname = '';
   $uniquename = '';
   $library_type = '';
   $organism_id = '';
@@ -62,7 +62,7 @@ function chado_library_form($node, &$form_state) {
     $library = $node->library;
     $library_id = $library->library_id;
 
-    $title        = $library->name;
+    $libraryname  = $library->name;
     $uniquename   = $library->uniquename;
     $library_type = $library->type_id->cvterm_id;
     $organism_id  = $library->organism_id->organism_id;
@@ -80,7 +80,7 @@ function chado_library_form($node, &$form_state) {
   // if we are re constructing the form from a failed validation or ajax callback
   // then use the $form_state['values'] values
   if (array_key_exists('values', $form_state)) {
-    $title        = $form_state['values']['title'];
+    $libraryname  = $form_state['values']['libraryname'];
     $uniquename   = $form_state['values']['uniquename'];
     $library_type = $form_state['values']['library_type'];
     $organism_id  = $form_state['values']['organism_id'];
@@ -89,20 +89,19 @@ function chado_library_form($node, &$form_state) {
   // if we are re building the form from after submission (from ajax call) then
   // the values are in the $form_state['input'] array
   if (array_key_exists('input', $form_state) and !empty($form_state['input'])) {
-    $title        = $form_state['input']['title'];
+    $libraryname  = $form_state['input']['libraryname'];
     $uniquename   = $form_state['input']['uniquename'];
     $library_type = $form_state['input']['library_type'];
     $organism_id  = $form_state['input']['organism_id'];
     $description  = $form_state['input']['description'];
   }
 
-  $form['title']= array(
+  $form['libraryname']= array(
     '#type'          => 'textfield',
     '#title'         => t('Library Name'),
     '#description'   => t('Please enter the name for this library. Library names should be recognizable but do not need to be unique.'),
     '#required'      => TRUE,
-    '#default_value' => $title,
-    '#weight'        => 1
+    '#default_value' => $libraryname,
   );
 
   $form['uniquename']= array(
@@ -111,7 +110,6 @@ function chado_library_form($node, &$form_state) {
     '#description'   => t('Please enter a unique name for this library. This can be any value used to uniquely identify a library.'),
     '#required'      => TRUE,
     '#default_value' => $uniquename,
-    '#weight'        => 2
   );
 
   // get the list of library types
@@ -136,7 +134,6 @@ function chado_library_form($node, &$form_state) {
     '#required'    => TRUE,
     '#default_value' => $library_type,
     '#options'     => $types,
-    '#weight'      => 3
   );
 
   // get the list of organisms
@@ -157,7 +154,6 @@ function chado_library_form($node, &$form_state) {
     '#required'    => TRUE,
     '#default_value' => $organism_id,
     '#options'     => $organisms,
-    '#weight'      => 4,
   );
 
   $form['description']= array(
@@ -166,7 +162,6 @@ function chado_library_form($node, &$form_state) {
     '#description'   => t('A brief description of the library'),
     '#required'      => TRUE,
     '#default_value' => $description,
-    '#weight'        => 5
   );
 
   // PROPERTIES FORM
@@ -198,7 +193,7 @@ function chado_library_form($node, &$form_state) {
  */
 function chado_library_validate($node, $form, &$form_state) {
 
-  $node->title       = trim($node->title);
+  $node->libraryname = trim($node->libraryname);
   $node->uniquename  = trim($node->uniquename);
   $node->description = trim($node->description);
 
@@ -230,7 +225,7 @@ function chado_library_validate($node, $form, &$form_state) {
  */
 function chado_library_insert($node) {
 
-  $node->title       = trim($node->title);
+  $node->libraryname = trim($node->libraryname);
   $node->uniquename  = trim($node->uniquename);
   $node->description = trim($node->description);
 
@@ -239,7 +234,7 @@ function chado_library_insert($node) {
   // we do need to proceed with the rest of the insert
   if (!property_exists($node, 'library_id')) {
     $values = array(
-      'name' => $node->title,
+      'name' => $node->libraryname,
       'uniquename' => $node->uniquename,
       'organism_id' => $node->organism_id,
       'type_id' => $node->library_type,
@@ -290,7 +285,7 @@ function chado_library_insert($node) {
  */
 function chado_library_update($node) {
 
-  $node->title       = trim($node->title);
+  $node->libraryname = trim($node->libraryname);
   $node->uniquename  = trim($node->uniquename);
   $node->description = trim($node->description);
 
@@ -299,8 +294,9 @@ function chado_library_update($node) {
   $match = array(
     'library_id' => $library_id,
   );
+  
   $values = array(
-    'name'        => $node->title,
+    'name'        => $node->libraryname,
     'uniquename'  => $node->uniquename,
     'organism_id' => $node->organism_id,
     'type_id'     => $node->library_type,
@@ -435,7 +431,7 @@ function tripal_library_node_view($node, $view_mode, $langcode) {
           '#markup' => theme('tripal_library_base', array('node' => $node)),
           '#tripal_toc_id'    => 'base',
           '#tripal_toc_title' => 'Details',
-          '#weight' => 0,
+          '#weight' => -100,
         );
         $node->content['tripal_library_properties'] = array(
           '#markup' => theme('tripal_library_properties', array('node' => $node)),
@@ -495,16 +491,17 @@ function tripal_library_node_view($node, $view_mode, $langcode) {
  * @param $node
  */
 function tripal_library_node_presave($node) {
+  
   switch ($node->type) {
     case 'chado_library':
-      // for a form submission the fields part of the node object
-      // but for a sync the feilds are in an object of the node
-      if(property_exists($node, 'library')) {
+      // for a form submission the 'libraryname' field will be set,
+      // for a sync, we must pull from the library object
+      if(property_exists($node, 'libraryname')) {
         // set the title
-        $node->title = $node->name;
+        $node->title = $node->libraryname;
       }
       else {
-        // the title field is already in the form
+        $node->title = $node->library->name;
       }
       break;
   }

+ 0 - 91
tripal_organism/includes/tripal_organism.admin.inc

@@ -45,101 +45,10 @@ function tripal_organism_admin() {
   $form['nothing'] = array(
     '#markup' => t('There are currently no settings to configure.')
   );
-  //get_tripal_organism_admin_form_reindex_set($form);
-  //get_tripal_organism_admin_form_taxonomy_set($form);
 
   return system_settings_form($form);
 }
 
-/**
- *
- *
- * @ingroup tripal_organism
- */
-function get_tripal_organism_admin_form_taxonomy_set(&$form) {
-  $form['taxonify'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Assign Drupal Taxonomy to Organism Features')
-  );
-
-  // get the list of libraries
-  $sql = "SELECT * FROM {Organism} ORDER BY genus,species";
-  $org_rset = chado_query($sql);
-
-  // iterate through all of the libraries
-  $org_boxes = array();
-  foreach ($org_rset as $organism) {
-    $org_boxes[$organism->organism_id] = "$organism->genus $organism->species";
-  }
-
-  $form['taxonify']['description'] = array(
-    '#type' => 'item',
-    '#value' => t(
-      "Drupal allows for assignment of \"taxonomy\" or catagorical terms to " .
-      "nodes. These terms allow for advanced filtering during searching. This option allows " .
-      "for setting taxonomy only for features that belong to the selected organisms below.  All " .
-      "other features will be unaffected.  To set taxonomy for all features in the site see the Feature Administration page."),
-    '#weight' => 1,
-  );
-
-  $form['taxonify']['tx-organisms'] = array(
-    '#title'       => t('Organisms'),
-    '#type'        => t('checkboxes'),
-    '#description' => t("Check the organisms whose features you want to reset taxonomy.  Note: this list contains all organisms, even those that may not be synced."),
-    '#required'    => FALSE,
-    '#prefix'      => '<div id="lib_boxes">',
-    '#suffix'      => '</div>',
-    '#options'     => $org_boxes,
-    '#weight'      => 2
-  );
-  $form['taxonify']['tx-button'] = array(
-    '#type' => 'submit',
-    '#value' => t('Set Feature Taxonomy'),
-    '#weight'      => 3
-  );
-}
-/**
- *
- * @ingroup tripal_organism
- */
-function get_tripal_organism_admin_form_reindex_set(&$form) {
-  // define the fieldsets
-  $form['reindex'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Reindex Organism Features')
-  );
-
-  // get the list of libraries
-  $sql = "SELECT * FROM {Organism} ORDER BY genus,species";
-  $org_rset = chado_query($sql);
-
-  // iterate through all of the libraries
-  $org_boxes = array();
-  foreach ($org_rset as $organism) {
-    $org_boxes[$organism->organism_id] = "$organism->genus $organism->species";
-  }
-  $form['reindex']['description'] = array(
-    '#type' => 'item',
-    '#value' => t("This option allows for reindexing of only those features that belong to the selected organisms below. All other features will be unaffected.  To reindex all features in the site see the Feature Administration page."),
-    '#weight' => 1,
-  );
-
-  $form['reindex']['re-organisms'] = array(
-    '#title'       => t('Organisms'),
-    '#type'        => t('checkboxes'),
-    '#description' => t("Check the organisms whose features you want to reindex. Note: this list contains all organisms, even those that may not be synced."),
-    '#required'    => FALSE,
-    '#prefix'      => '<div id="lib_boxes">',
-    '#suffix'      => '</div>',
-    '#options'     => $org_boxes,
-    '#weight' => 2,
-  );
-  $form['reindex']['re-button'] = array(
-    '#type' => 'submit',
-    '#value' => t('Reindex Features'),
-    '#weight' => 3,
-  );
-}
 
 /**
  *

+ 6 - 6
tripal_organism/includes/tripal_organism.chado_node.inc

@@ -450,15 +450,15 @@ function chado_organism_load($nodes) {
 function tripal_organism_node_presave($node) {
   switch ($node->type) {
     case 'chado_organism':
-      // for a form submission the fields part of the node object
-      // but for a sync the feilds are in an object of the node
-      if(property_exists($node, 'organism')) {
+      // for a form submission the 'genus' field will be set,
+      // for a sync, we must pull from the organism object
+      if(property_exists($node, 'genus')) {
         // set the title
-        $node->title = $node->organism->genus . " " . $node->organism->species;
+        $node->title = $node->genus  . " " . $node->species;
       }
       else {
         // set the title
-        $node->title = $node->genus  . " " . $node->species;
+        $node->title = $node->organism->genus . " " . $node->organism->species;
       }
       break;
   }
@@ -474,9 +474,9 @@ function tripal_organism_node_view($node, $view_mode, $langcode) {
       if ($view_mode == 'full') {
         $node->content['tripal_organism_base'] = array(
           '#markup'  => theme('tripal_organism_base', array('node' => $node)),
-          '#weight' => 0,
           '#tripal_toc_id'    => 'base',
           '#tripal_toc_title' => 'Details',
+          '#weight' => -100,
         );
       }
       if ($view_mode == 'teaser') {

+ 1 - 1
tripal_project/includes/tripal_project.chado_node.inc

@@ -467,7 +467,7 @@ function tripal_project_node_view($node, $view_mode, $langcode) {
           '#markup' => theme('tripal_project_base', array('node' => $node)),
           '#tripal_toc_id'    => 'base',
           '#tripal_toc_title' => 'Details',
-          '#weight' => 0,
+          '#weight' => -100,
         );
         $node->content['tripal_project_contact'] = array(
           '#markup' => theme('tripal_project_contact', array('node' => $node)),

+ 1 - 1
tripal_pub/includes/tripal_pub.chado_node.inc

@@ -986,7 +986,7 @@ function tripal_pub_node_view($node, $view_mode, $langcode) {
           '#markup' => theme('tripal_pub_base', array('node' => $node)),
           '#tripal_toc_id'    => 'base',
           '#tripal_toc_title' => 'Details',
-          '#weight' => 0
+          '#weight' => -100,
         );
         $node->content['tripal_pub_featuremaps'] = array(
           '#markup' => theme('tripal_pub_featuremaps', array('node' => $node)),

+ 0 - 42
tripal_stock/includes/tripal_stock.admin.inc

@@ -252,45 +252,3 @@ function get_tripal_stock_admin_form_vocabulary_set(&$form) {
     '#value' => t('Set Controlled Vacabularies')
   );
 }
-/**
- *
- *
- * @ingroup tripal_stock
- */
-function get_tripal_stock_admin_form_cleanup_set(&$form) {
-  $form['cleanup'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Clean Up'),
-    '#collapsible' => TRUE,
-    '#collapsed' => TRUE,
-  );
-  $form['cleanup']['description'] = array(
-     '#type' => 'item',
-     '#value' => t("With Drupal and Chado residing in different databases ".
-        "it is possible that nodes in Drupal and stocks in Chado become ".
-        "\"orphaned\".  This can occur if an stock node in Drupal is ".
-        "deleted but the corresponding chado stock is not and/or vice ".
-        "versa. Click the button below to resolve these discrepancies."),
-     '#weight' => 1,
-  );
-  $form['cleanup']['button'] = array(
-    '#type' => 'submit',
-    '#value' => t('Clean up orphaned stocks'),
-    '#weight' => 2,
-  );
-}
-/**
- * Remove orphaned drupal nodes
- *
- * @param $dummy
- *   Not Used -kept for backwards compatibility
- * @param $job_id
- *   The id of the tripal job executing this function
- *
- * @ingroup tripal_stock
- */
-function tripal_stock_cleanup($dummy = NULL, $job_id = NULL) {
-
-  return tripal_core_chado_node_cleanup_orphaned('stock', $job_id);
-
-}

+ 20 - 7
tripal_stock/includes/tripal_stock.chado_node.inc

@@ -786,17 +786,30 @@ function tripal_stock_node_presave($node) {
       // for a form submission the fields part of the node object
       // but for a sync the feilds are in an object of the node
       $organism_id = null;
-      if(property_exists($node, 'stock')) {
-        $organism_id = $node->stock->organism_id;
+      $sname = '';
+      $uniquename = '';
+      $type = '';
+      if(property_exists($node, 'organism_id')) {
+        $organism_id = $node->organism_id;
+        $sname       = $node->sname;
+        $uniquename  = $node->uniquename;
+        $type_id     = $node->type_id;
+        $values = array('cvterm_id' => $node->type_id);
+        $cvterm = tripal_core_chado_select('cvterm', array('name'), $values);
+        $type = $cvterm[0]->name;
       }
       else {
-        $organism_id = $node->organism_id;
+        $organism_id = $node->stock->organism_id;
+        $sname       = $node->stock->name;
+        $uniquename  = $node->stock->uniquename;
+        $type        = $node->stock->type_id->name;
       }
       $values = array('organism_id' => $organism_id);
       $organism = tripal_core_chado_select('organism', array('genus','species'), $values);
-      $values = array('cvterm_id' => $node->type_id);
-      $cvterm = tripal_core_chado_select('cvterm', array('name'), $values);
-      $node->title = $node->sname . ', ' . $node->uniquename . ' (' . $cvterm[0]->name . ') ' . $organism[0]->genus . ' ' . $organism[0]->species;
+      $node->title = "$sname, $uniquename ($type) " . $organism[0]->genus . ' ' . $organism[0]->species;
+      if ($name == $uname) {
+        $node->title = "$sname ($type) " . $organism[0]->genus . ' ' . $organism[0]->species;
+      }
       break;
   }
 }
@@ -855,7 +868,7 @@ function tripal_stock_node_view($node, $view_mode, $langcode) {
           '#markup' => theme('tripal_stock_base', array('node' => $node)),
           '#tripal_toc_id'    => 'base',
           '#tripal_toc_title' => 'Details',
-          '#weight' => 0,
+          '#weight' => -100,
         );
         $node->content['tripal_stock_collections'] = array(
           '#markup' => theme('tripal_stock_collections', array('node' => $node)),