Browse Source

Added support for legacy v2 templates for v3 entities

Stephen Ficklin 9 years ago
parent
commit
e705de10bd

+ 12 - 4
README.txt

@@ -54,7 +54,8 @@ Upgrade Instructions:
 
 Step 1: Put the site in maintenance mode.
 
-Step 3: Disable tripal modules
+Step 2: Disable tripal modules. Disabling the core module will disable all
+other Tripal modules:
 
   drush pm-disable tripal_core
   
@@ -67,10 +68,17 @@ Step 5: Enable the tripal_chado module
 
   drush pm-enable tripal_chado
   
-Step 6:  Apply updates
+Step 6:  Tripal v2 modules are now called 'legacy modules'. these are the
+modules that were disabled in step #2.  For backwards compatibility, you 
+should re-enable these modules:
+
+  drush pm-enable tripal_core, tripal_views, tripal_db, tripal_cv, \
+    tripal_analysis, tripal_organism, tripal_feature, tripal_pub, \
+    tripal_stock
+
+Be sure to enable any additional modules not included in the example
+drush command above.
 
-  drush updatedb
-  
 Step 7:  Return to your Tripal site, and click the link that appears for
 preparing Chado and launch the job.
 

+ 18 - 19
legacy/tripal_core/theme/templates/node--chado-generic.tpl.php

@@ -1,28 +1,27 @@
 <?php
-
-if($teaser) {
+if ($teaser) {
   print render($content);
 }
 else {
   $node_type = $node->type; ?>
-  
+
   <script type="text/javascript">
     // We do not use Drupal Behaviors because we do not want this
-    // code to be executed on AJAX callbacks. This code only needs to 
+    // code to be executed on AJAX callbacks. This code only needs to
     // be executed once the page is ready.
     jQuery(document).ready(function($){
 
-      // Hide all but the first data pane 
+      // Hide all but the first data pane
       $(".tripal-data-pane").hide().filter(":first-child").show();
-  
-      // When a title in the table of contents is clicked, then 
-      // show the corresponding item in the details box 
+
+      // When a title in the table of contents is clicked, then
+      // show the corresponding item in the details box
       $(".tripal_toc_list_item_link").click(function(){
         var id = $(this).attr('id') + "-tripal-data-pane";
         $(".tripal-data-pane").hide().filter("#"+ id).fadeIn('fast');
         return false;
       });
-  
+
       // If a ?pane= is specified in the URL then we want to show the
       // requested content pane. For previous version of Tripal,
       // ?block=, was used.  We support it here for backwards
@@ -47,34 +46,34 @@ else {
       $("a.active").removeClass('active');
     });
   </script>
-  
+
   <div id="tripal_<?php print $node_type?>_contents" class="tripal-contents">
     <table id ="tripal-<?php print $node_type?>-contents-table" class="tripal-contents-table">
       <tr class="tripal-contents-table-tr">
         <td nowrap class="tripal-contents-table-td tripal-contents-table-td-toc"  align="left"><?php
-        
-          // print the table of contents. It's found in the content array 
+
+          // print the table of contents. It's found in the content array
           if (array_key_exists('tripal_toc', $content)) {
             print $content['tripal_toc']['#markup'];
-          
+
             // we may want to add the links portion of the contents to the sidebar
             //print render($content['links']);
-            
-            // remove the table of contents and links so thye doent show up in the 
+
+            // remove the table of contents and links so thye doent show up in the
             // data section when the rest of the $content array is rendered
             unset($content['tripal_toc']);
-            unset($content['links']); 
+            unset($content['links']);
           } ?>
 
         </td>
         <td class="tripal-contents-table-td-data" align="left" width="100%"> <?php
-         
-          // print the rendered content 
+
+          // print the rendered content
           print render($content); ?>
         </td>
       </tr>
     </table>
-  </div> <?php 
+  </div> <?php
 }
 
 

+ 1 - 0
legacy/tripal_core/tripal_core.info

@@ -14,3 +14,4 @@ dependencies[] = path
 dependencies[] = search
 dependencies[] = php
 dependencies[] = tripal
+dependencies[] = tripal_chado

+ 0 - 1
legacy/tripal_core/tripal_core.module

@@ -212,7 +212,6 @@ function tripal_core_node_view($node, $view_mode, $langcode) {
   // the we want to add a table of contents to it's content list
   // this table of contents will be an empty
   if (preg_match('/^chado_/', $node->type)) {
-    // Show feature browser and counts
     if ($view_mode == 'full') {
       if (!isset($node->content['#tripal_generic_node_template'])) {
         $node->content['#tripal_generic_node_template'] = TRUE;

+ 3 - 3
tripal/api/tripal.entities.api.inc

@@ -75,7 +75,7 @@ function tripal_load_vocab_entity($values) {
  *
  * @param $values
  *   An associative array used to match a bundle.  Valid keys may:
- *     - name:  the bundle name (e.g. 'bio-data_234')
+ *     - name:  the bundle name (e.g. 'bio_data_234')
  *     - label: the bundle label (e.g. 'Organism')
  *     - term_id: the term ID to which the bundle belongs
  *
@@ -142,7 +142,7 @@ function tripal_create_bundle($namespace, $accession, $term_name, &$error = '')
   }
 
   // If the bundle doesn't already exist, then add it.
-  $bundle_name = 'bio-data_' . $term->id;
+  $bundle_name = 'bio_data_' . $term->id;
   $einfo = entity_get_info('TripalEntity');
   if (!in_array($bundle_name, array_keys($einfo['bundles']))) {
     // Insert the bundle.
@@ -176,7 +176,7 @@ function tripal_create_bundle($namespace, $accession, $term_name, &$error = '')
  * Refreshes the bundle such that new fields added by modules will be found.
  *
  * @param $bundle_name
- *   The name of the bundle to refresh (e.g. bio-data_4).
+ *   The name of the bundle to refresh (e.g. bio_data_4).
  */
 function tripal_refresh_bundle_fields($bundle_name) {
   // Get the bundle object.

+ 6 - 6
tripal/includes/TripalBundleUIController.inc

@@ -76,7 +76,7 @@ function tripal_tripal_bundle_form($form, &$form_state, $entityDataType) {
   $entity_type = $form_state['build_info']['args'][0];
   $term = NULL;
   $vocab = NULL;
-  if (preg_match('/bio-data_(\d+)/', $entity_type->name, $matches)) {
+  if (preg_match('/bio_data_(\d+)/', $entity_type->name, $matches)) {
     $term = entity_load('TripalTerm', array('id' => $matches[1]));
     $term = reset($term);
     $vocab = entity_load('TripalVocab', array('id' => $term->vocab_id));
@@ -376,13 +376,13 @@ function tripal_tripal_bundle_form_submit($form, &$form_state) {
       tripal_set_bundle_variable('url_format', $bundle_entity->id, $form_state['values']['url']['url_pattern']);
     }
 
-    $form_state['redirect'] = 'admin/structure/bio-data';
+    $form_state['redirect'] = 'admin/structure/bio_data';
     drupal_set_message(t('Successfully saved %type content type.', array('%type' => $form_state['build_info']['args'][0]->label)));
   }
   else {
     $form_state['redirect'] = array(
-      'admin/structure/bio-data/manage/' . $bundle_entity->name . '/delete',
-      array('query' => array('destination' => 'admin/structure/bio-data'))
+      'admin/structure/bio_data/manage/' . $bundle_entity->name . '/delete',
+      array('query' => array('destination' => 'admin/structure/bio_data'))
     );
   }
 }
@@ -466,11 +466,11 @@ function tripal_admin_add_type_form_submit($form, &$form_state) {
       $success = tripal_create_bundle($namespace, $accession, $term_name, $error);
       if (!$success) {
         drupal_set_message($error, 'error');
-        $form_state['redirect'] = "admin/structure/bio-data";
+        $form_state['redirect'] = "admin/structure/bio_data";
       }
       else {
         drupal_set_message('New data type created.');
-        $form_state['redirect'] = "admin/structure/bio-data";
+        $form_state['redirect'] = "admin/structure/bio_data";
       }
     }
     else {

+ 3 - 3
tripal/includes/TripalEntityController.inc

@@ -133,7 +133,7 @@ class TripalEntityController extends EntityAPIController {
    * Sets the URL alias for an entity.
    */
   public function setAlias($entity, $alias = NULL) {
-    $source_url = "bio-data/$entity->id";
+    $source_url = "bio_data/$entity->id";
 
     // If no alias was supplied then we should try to generate one using the
     // default format set by admins.
@@ -203,7 +203,7 @@ class TripalEntityController extends EntityAPIController {
             supplied on the <a href="!link" target="_blank">%type Edit Page</a> under URL Path options is unique.';
           $msg_var = array(
               '%alias' => $alias,
-              '!link' => url("admin/structure/bio-data/manage/$entity->bundle"),
+              '!link' => url("admin/structure/bio_data/manage/$entity->bundle"),
               '%type' => $bundle_entity->label
             );
           tripal_report_error(
@@ -232,7 +232,7 @@ class TripalEntityController extends EntityAPIController {
           supplied on the <a href="!link" target="_blank">%type Edit Page</a> under URL Path options is unique.';
         $msg_var = array(
             '%alias' => $alias,
-            '!link' => url("admin/structure/bio-data/manage/$entity->bundle"),
+            '!link' => url("admin/structure/bio_data/manage/$entity->bundle"),
             '%type' => $bundle_entity->label
           );
         drupal_set_message(t($msg, $msg_var), 'error');

+ 17 - 17
tripal/includes/TripalEntityUIController.inc

@@ -27,7 +27,7 @@ class TripalEntityUIController extends EntityDefaultUIController {
       'weight' => -9
     );
 
-    $items['bio-data/add'] = array(
+    $items['bio_data/add'] = array(
       'title' => 'Add Tripal Content',
       'page callback' => 'tripal_add_page',
       'access arguments' => array('administer tripal data'),
@@ -37,14 +37,14 @@ class TripalEntityUIController extends EntityDefaultUIController {
     $bundles = array_keys($this->entityInfo['bundles']);
     foreach ($bundles as $bundle_name) {
       $matches = array();
-      if (preg_match('/^bio-data_(.*?)$/', $bundle_name, $matches)) {
+      if (preg_match('/^bio_data_(.*?)$/', $bundle_name, $matches)) {
         $bundle = tripal_load_bundle_entity(array('name' => $bundle_name));
         // Get the term for this bundle
         $term = entity_load('TripalTerm', array('id' => $matches[1]));
         $term = reset($term);
         $default_description = $term->definition ? $term->definition : '';
         // Set a custom page for adding new tripal data entities.
-        $items['bio-data/add/' . $term->id] = array(
+        $items['bio_data/add/' . $term->id] = array(
           'title' => ucfirst($bundle->label),
           'description' => tripal_get_bundle_variable('description', $bundle->id, $default_description),
           'page callback'  => 'drupal_get_form',
@@ -56,7 +56,7 @@ class TripalEntityUIController extends EntityDefaultUIController {
     }
 
     // Link for viewing a tripal data type.
-    $items['bio-data/' . $wildcard] = array(
+    $items['bio_data/' . $wildcard] = array(
       'title callback' => 'tripal_entity_title',
       'title arguments' => array(1),
       'page callback' => 'tripal_view_entity',
@@ -67,7 +67,7 @@ class TripalEntityUIController extends EntityDefaultUIController {
     );
 
     // 'View' tab for an individual entity page.
-    $items['bio-data/' . $wildcard . '/view'] = array(
+    $items['bio_data/' . $wildcard . '/view'] = array(
       'title' => 'View',
       'page callback' => 'tripal_view_entity',
       'page arguments' => array(1),
@@ -78,7 +78,7 @@ class TripalEntityUIController extends EntityDefaultUIController {
     );
 
     // 'Edit' tab for an individual entity page.
-    $items['bio-data/' . $wildcard . '/edit'] = array(
+    $items['bio_data/' . $wildcard . '/edit'] = array(
       'title' => 'Edit',
       'page callback' => 'drupal_get_form',
       'page arguments' => array('tripal_entity_form', NULL, 1),
@@ -89,7 +89,7 @@ class TripalEntityUIController extends EntityDefaultUIController {
     );
 
     // Menu item for deleting tripal data entities.
-    $items['bio-data/' . $wildcard . '/delete'] = array(
+    $items['bio_data/' . $wildcard . '/delete'] = array(
       'title'  => 'Delete',
       'page callback' => 'drupal_get_form',
       'page arguments' => array('tripal_entity_delete_form', 1),
@@ -107,7 +107,7 @@ class TripalEntityUIController extends EntityDefaultUIController {
  * @param unknown $entity
  */
 function tripal_entity_manage_fields($entity) {
-  drupal_goto('admin/structure/bio-data/manage/' . $entity->name . '/fields');
+  drupal_goto('admin/structure/bio_data/manage/' . $entity->name . '/fields');
   return '';
 }
 
@@ -191,14 +191,14 @@ function tripal_view_entity($entity, $view_mode = 'full') {
 
      // Add information to the table.
      $rows[] = array(
-       l($entity->title, 'bio-data/' . $entity->id),
+       l($entity->title, 'bio_data/' . $entity->id),
        $vocab->namespace,
        $term->name,
        l($author->name, 'user/' . $entity->uid),
        $entity->status == 1 ? 'published' : 'unpublished',
        format_date($entity->changed, 'short'),
-       l('edit', 'bio-data/' . $entity->id . '/edit') . '&nbsp;&nbsp;' .
-       l('delete', 'bio-data/' . $entity->id . '/delete')
+       l('edit', 'bio_data/' . $entity->id . '/edit') . '&nbsp;&nbsp;' .
+       l('delete', 'bio_data/' . $entity->id . '/delete')
      );
    }
 
@@ -236,7 +236,7 @@ function tripal_view_entity($entity, $view_mode = 'full') {
   */
  function tripal_entity_form($form, &$form_state, $term_id = '', $entity = NULL) {
 
-   $bundle_name = 'bio-data_' . $term_id;
+   $bundle_name = 'bio_data_' . $term_id;
 
    // Add a vertical tabs element
    $form['entity_form_vtabs'] = array(
@@ -311,7 +311,7 @@ function tripal_entity_form_ajax_callback($form, $form_state) {
    $entity = $form_state['TripalEntity'];
 
    if ($form_state['clicked_button']['#name'] =='cancel') {
-     $form_state['redirect'] = "bio-data/" . $entity->id;
+     $form_state['redirect'] = "bio_data/" . $entity->id;
    }
 
    if ($form_state['clicked_button']['#name'] =='update_data' or
@@ -319,14 +319,14 @@ function tripal_entity_form_ajax_callback($form, $form_state) {
 
      $entityform = entity_ui_controller('TripalEntity')->entityFormSubmitBuildEntity($form, $form_state);
      if ($entityform->save()) {
-       $form_state['redirect'] = "bio-data/" . $entity->id;
+       $form_state['redirect'] = "bio_data/" . $entity->id;
      }
      else {
        drupal_set_message('Cannot save entity', 'error');
      }
    }
    if ($form_state['clicked_button']['#name'] =='delete_data') {
-     $form_state['redirect'] = 'bio-data/' . $entity->id .'/delete';
+     $form_state['redirect'] = 'bio_data/' . $entity->id .'/delete';
    }
  }
 
@@ -381,7 +381,7 @@ function tripal_entity_form_ajax_callback($form, $form_state) {
      $output .= '<p>' . t('You have not created any biological data types yet. ' .
          'Go to the <a href="@create-content">data type creation page</a> to ' .
          'add a new data type.',
-         array('@create-content' => url('admin/structure/bio-data/add'))) . '</p>';
+         array('@create-content' => url('admin/structure/bio_data/add'))) . '</p>';
    }
    return $output;
  }
@@ -416,7 +416,7 @@ function tripal_entity_form_ajax_callback($form, $form_state) {
 
    if ($entity_controller->delete(array($entity->id))) {
      drupal_set_message(t('The record title "%name" has been deleted.', array('%name' => $entity->title)));
-     $form_state['redirect'] = 'admin/content/bio-data';
+     $form_state['redirect'] = 'admin/content/bio_data';
    }
    else {
      drupal_set_message(t('The tripal_entity %name was not deleted.', array('%name' => $entity->title)), "error");

+ 16 - 16
tripal/tripal.module

@@ -268,7 +268,7 @@ function tripal_entity_access($entity) {
  * @ingroup tripal
  */
 function tripal_theme($existing, $type, $theme, $path) {
-  return array(
+  $themes = array(
     'tripal_customize' => array(
       'arguments' => array('job_id' => NULL),
       'template' => 'tripal_customize',
@@ -304,9 +304,9 @@ function tripal_theme($existing, $type, $theme, $path) {
       'variables' => array('content' => NULL),
     ),
   );
+  return $themes;
 }
 
-
 /**
  * Implements hook_coder_ignore().
  * Defines the path to the file (tripal.coder_ignores.txt) where ignore rules for coder are stored
@@ -349,10 +349,10 @@ function tripal_libraries_info() {
 function tripal_admin_paths() {
   if (variable_get('node_admin_theme')) {
     $paths = array(
-      'bio-data/*/edit' => TRUE,
-      'bio-data/*/delete' => TRUE,
-      'bio-data/add' => TRUE,
-      'bio-data/add/*' => TRUE,
+      'bio_data/*/edit' => TRUE,
+      'bio_data/*/delete' => TRUE,
+      'bio_data/add' => TRUE,
+      'bio_data/add/*' => TRUE,
     );
     return $paths;
   }
@@ -367,8 +367,8 @@ function tripal_menu_local_tasks_alter(&$data, $router_item, $root_path) {
 
   // Add an "Add Tripal Content" action link to the Admin >> Content >>
   // Biological Content page.
-  if ($root_path == 'admin/content/bio-data') {
-    $item = menu_get_item('bio-data/add');
+  if ($root_path == 'admin/content/bio_data') {
+    $item = menu_get_item('bio_data/add');
     if ($item['access']) {
       $data['actions']['output'][] = array(
         '#theme' => 'menu_local_action',
@@ -408,7 +408,7 @@ function tripal_shortcut_default_set($account) {
         'weight' => -35,
       ),
       array(
-        'link_path' => 'bio-data/add',
+        'link_path' => 'bio_data/add',
         'link_title' => 'Add Tripal Content',
         'weight' => -30,
       ),
@@ -418,7 +418,7 @@ function tripal_shortcut_default_set($account) {
         'weight' => -25,
       ),
       array(
-        'link_path' => 'admin/content/bio-data',
+        'link_path' => 'admin/content/bio_data',
         'link_title' => 'Find Tripal Content',
         'weight' => -20,
       ),
@@ -598,7 +598,7 @@ function tripal_entity_info() {
     // key here is mean to appear on the 'Find Content' page of the
     // administrative menu.
     'admin ui' => array (
-      'path' => 'admin/content/bio-data',
+      'path' => 'admin/content/bio_data',
       'controller class' => 'TripalEntityUIController',
       'menu wildcard' => '%TripalEntity',
       'file' => 'includes/TripalEntityUIController.inc'
@@ -637,7 +637,7 @@ function tripal_entity_info() {
     'module' => 'tripal',
     // Enable the entity API's admin UI.
     'admin ui' => array (
-      'path' => 'admin/structure/bio-data',
+      'path' => 'admin/structure/bio_data',
       'controller class' => 'TripalBundleUIController',
       'file' => 'includes/TripalBundleUIController.inc',
       'menu wildcard' => '%TripalBundle',
@@ -671,8 +671,8 @@ function tripal_entity_info_alter(&$entity_info){
       $entity_info['TripalEntity']['bundles'][$bundle_name] = array (
         'label' => $label,
         'admin' => array (
-          'path' => 'admin/structure/bio-data/manage/%TripalBundle',
-          'real path' => 'admin/structure/bio-data/manage/' . $bundle_name,
+          'path' => 'admin/structure/bio_data/manage/%TripalBundle',
+          'real path' => 'admin/structure/bio_data/manage/' . $bundle_name,
           'bundle argument' => 4,
           'access arguments' => array (
             'administer tripal data types'
@@ -819,8 +819,8 @@ function tripal_menu_alter(&$items) {
   // We don't want to allow deletion of fields added by the storage backend.
   // TODO: this shouldn't be hardcoded here.  These settings
   // should be part of the field and handled by the tripal_entity module.
-  $items['admin/structure/bio-data/manage/%TripalBundle/fields/%field_ui_menu/delete']['page callback'] = 'tripal_field_no_delete';
-  $items['admin/structure/bio-data/manage/%TripalBundle/fields/%field_ui_menu/delete']['page arguments'] = array();
+  $items['admin/structure/bio_data/manage/%TripalBundle/fields/%field_ui_menu/delete']['page callback'] = 'tripal_field_no_delete';
+  $items['admin/structure/bio_data/manage/%TripalBundle/fields/%field_ui_menu/delete']['page arguments'] = array();
 }
 
 /**

+ 1 - 0
tripal_chado/includes/fields/chado_linker__featureloc.inc

@@ -0,0 +1 @@
+<?php

+ 1 - 0
tripal_chado/includes/fields/chado_organism__type_id.inc

@@ -0,0 +1 @@
+<?php

+ 1 - 1
tripal_chado/includes/tripal_chado.migrate.inc

@@ -362,7 +362,7 @@ function tripal_chado_migrate_selected_types($tv3_content_types) {
       $term = tripal_load_term_entity($tv3_content_type);
     }
     // Create bundle name
-    $bundle_name = 'bio-data_' . $term->id;
+    $bundle_name = 'bio_data_' . $term->id;
 
     // Publish records for the bundle
     $value = array(

+ 1 - 1
tripal_chado/includes/tripal_chado.publish.inc

@@ -69,7 +69,7 @@ function tripal_chado_publish_form_submit($form, &$form_state) {
     global $user;
 
     $term_id = $form_state['values']['term_id'];
-    $bundle_name = 'bio-data_' . $term_id;
+    $bundle_name = 'bio_data_' . $term_id;
     $bundle = tripal_load_bundle_entity(array('name' => $bundle_name));
     $args = array(
       array('bundle_name' => $bundle_name),

+ 95 - 3
tripal_chado/tripal_chado.module

@@ -150,7 +150,7 @@ function tripal_chado_menu() {
     'weight' => -99
   );
 
-  $items['admin/structure/bio-data/publish'] = array(
+  $items['admin/structure/bio_data/publish'] = array(
     'title' => 'Publish Chado Content',
     'description' => t('Publish data that is present in Chado but which does
         not yet have a page on this site for viewing. In Tripal v2.0 or
@@ -527,7 +527,7 @@ function tripal_chado_permission() {
  * Implements hook_theme().
  */
 function tripal_chado_theme($existing, $type, $theme, $path) {
-  return array(
+  $themes = array(
     // Theme fields.
     'chado_base__dbxref_id_widget' => array(
       'render element' => 'element',
@@ -568,9 +568,24 @@ function tripal_chado_theme($existing, $type, $theme, $path) {
       'file' => 'includes/loaders/tripal_chado.pub_importers.inc',
     ),
   );
-}
 
+  // Override the theme for each entity to use the legacy modules
+  // templates.
+  $core_path = drupal_get_path('module', 'tripal_core');
+  $bundles = db_select('tripal_bundle', 'tb')
+    ->fields('tb')
+    ->execute();
+  while ($bundle = $bundles->fetchObject()) {
+    $themes['TripalEntity__' . $bundle->name] = array(
+      'template' => 'node--chado-generic',
+      'render element' => 'entity',
+      'base hook' => 'entity',
+      'path' => "$core_path/theme/templates",
+    );
+  }
 
+  return $themes;
+}
 
 
 /**
@@ -711,3 +726,80 @@ function tripal_chado_node_delete($node) {
   $sql = "UPDATE chado_entity SET nid = NULL WHERE nid = :nid";
   db_query($sql, array('nid' => $nid));
 }
+
+/**
+ * Implements hook_entity_view().
+ *
+ * This function is used to support legacy Tripal v2 templates
+ * for use with Tripal v3 entities.
+ */
+function tripal_chado_entity_view($entity, $type, $view_mode, $langcode) {
+  // If this entity is a TripalEntity and is a full view, then
+  // we want to support the legacy view, but only if the legacy
+  // module is enabled (the functions exist).
+  if ($type =='TripalEntity') {
+    // Use the generic template to render the fields
+    if ($view_mode == 'full') {
+
+      // Get the Chado table for this data type.
+      $bundle = tripal_load_bundle_entity(array('name' => $entity->bundle));
+      $chado_table = tripal_get_bundle_variable('chado_table', $bundle->id);
+      $chado_field = tripal_get_bundle_variable('chado_column', $bundle->id);
+
+      // TODO remove the fields added by the chado_field_storage.
+
+      // If the legacy module is enabled then we can make this
+      // entity look like a node and use the legacy node_view hooks to
+      // use the legacy templates.
+      $function_name = 'tripal_core_node_view';
+      if (function_exists($function_name)) {
+        $entity->type = 'chado_' . $chado_table;
+        $entity->$chado_table = $entity->chado_record;
+        $function_name($entity, $view_mode, $langcode);
+      }
+      // Now call the module's hook.
+      $function_name = 'tripal_' . $chado_table . '_node_view';
+      if (function_exists($function_name)) {
+        $function_name($entity, $view_mode, $langcode);
+      }
+    }
+  }
+}
+
+/**
+ * Implements hook_entity_view_alter().
+ *
+ * This function is used to support legacy Tripal v2 templates
+ * for use with Tripal v3 entities.
+ */
+function tripal_chado_entity_view_alter(&$build) {
+  // For the legacy support, we need to make sure the TOC
+  // is built.
+  module_load_include('inc', 'tripal_core', 'includes/tripal_core.toc');
+  if (function_exists('tripal_core_node_view_build_toc')) {
+
+    // The tripal_core_node_view_build_toc expects a #node
+    // and an nid property as part of the entity. However,
+    // we don't want to support use of node IDs with entities
+    // because that could cause problems, so always set the
+    // nid to NULL.
+    $build['#entity']->nid = NULL;
+    $build['#node'] = $build['#entity'];
+    tripal_core_node_view_build_toc($build);
+  }
+}
+
+/**
+ * Implements hook_preprocess().
+ *
+ * This function is used to support legacy Tripal v2 templates
+ * for use with Tripal v3 entities.
+ */
+function tripal_chado_preprocess(&$variables, $hook) {
+  if ($hook == 'entity' and array_key_exists('TripalEntity', $variables)) {
+    // The node--chado-generic template expets there to be a
+    // teaser and node variables.  So, we'll add them.
+    $variables['teaser'] = FALSE;
+    $variables['node'] = $variables['TripalEntity'];
+  }
+}

+ 1 - 1
tripal_chado/tripal_chado.views.inc

@@ -90,7 +90,7 @@ function tripal_chado_add_field_views_data(&$data) {
 
       // The help should be 'Appears in: TripalEntity: gene, organism'
       // so that users know where they can use it. This requires a little extra work since all
-      // we have access to at this point is bio-data_2, bio-data_4 but since that's not very
+      // we have access to at this point is bio_data_2, bio_data_4 but since that's not very
       // informative, extra work is worth it ;-).
       $entity_info = entity_get_info('TripalEntity');
       $bundle_labels = array();

+ 2 - 2
tripal_ws/includes/tripal_ws.rest.inc

@@ -383,7 +383,7 @@ function tripal_ws_get_content_type($api_url, &$response, $ws_args, $ctype) {
         '@id' => $api_url . '/content/' . urlencode($ctype) . '/' .  $entity->id,
         '@type' => $vocab->namespace . ':' . $term->accession,
         'label' => $entity->title,
-        'itemPage' => url('/bio-data/' . $entity->id, array('absolute' => TRUE)),
+        'itemPage' => url('/bio_data/' . $entity->id, array('absolute' => TRUE)),
       );
       $i++;
     }
@@ -438,7 +438,7 @@ function tripal_ws_get_content($api_url, &$response, $ws_args, $ctype, $entity_i
   $response['@id'] = $api_url . '/content/' . $ctype . '/' . $entity_id;
   $response['@type'] = $vocab->namespace . ':' . $term->accession;
   $response['label'] = $entity->title;
-  $response['itemPage'] = url('/bio-data/' . $bundle->id, array('absolute' => TRUE));
+  $response['itemPage'] = url('/bio_data/' . $bundle->id, array('absolute' => TRUE));
 
   // Get information about the fields attached to this bundle and sort them
   // in the order they were set for the display.