Browse Source

Fixed bugs in using Tv2 templates for Tv3 entities. Removed Tv3 fields from Tv2 templates

Stephen Ficklin 9 years ago
parent
commit
5ee35c6760

+ 1 - 0
legacy/tripal_feature/includes/tripal_feature.chado_node.inc

@@ -842,6 +842,7 @@ function tripal_feature_node_update($node) {
  * @ingroup tripal_feature
  */
 function tripal_feature_node_view($node, $view_mode, $langcode) {
+
   switch ($node->type) {
     case 'chado_feature':
       // Show feature browser and counts

+ 1 - 0
legacy/tripal_organism/includes/tripal_organism.chado_node.inc

@@ -689,6 +689,7 @@ function tripal_organism_node_presave($node) {
  * @ingroup tripal_organism
  */
 function tripal_organism_node_view($node, $view_mode, $langcode) {
+
   switch ($node->type) {
     case 'chado_organism':
 

+ 33 - 25
tripal_chado/tripal_chado.module

@@ -608,21 +608,32 @@ function tripal_chado_entity_view($entity, $type, $view_mode, $langcode) {
       $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);
+      // Remove the fields added by the chado_field_storage.
+      $fields = field_info_fields();
+      foreach($fields as $field) {
+        if ($field['storage']['type'] == 'field_chado_storage' or
+            $field['storage']['type'] == 'tripal_no_storage') {
+          $field_name = $field['field_name'];
+          if (property_exists($entity, $field_name)) {
+            $entity->$field_name = NULL;
+            unset($entity->content[$field_name]);
+          }
+        }
       }
-      // Now call the module's hook.
-      $function_name = 'tripal_' . $chado_table . '_node_view';
-      if (function_exists($function_name)) {
-        $function_name($entity, $view_mode, $langcode);
+
+      // Now call the module's node_view hook to add additional
+      // content to our 'fake' entity node.
+      $entity->type = 'chado_' . $chado_table;
+      $entity->$chado_table = $entity->chado_record;
+      // The comment module is expecting a 'comment' property
+      // is attached to the node, so just set it to NULL.
+      $entity->comment = NULL;
+      $modules = module_list();
+      foreach ($modules as $mname => $details) {
+        $function_name = $mname . '_node_view';
+        if (function_exists($function_name)) {
+          $function_name($entity, $view_mode, $langcode);
+        }
       }
     }
   }
@@ -637,17 +648,14 @@ function tripal_chado_entity_view($entity, $type, $view_mode, $langcode) {
 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);
+  $build['#entity']->nid = NULL;
+  $build['#node'] = $build['#entity'];
+  $modules = module_list();
+  foreach ($modules as $mname => $details) {
+    $function_name = $mname . '_node_view_alter';
+    if (function_exists($function_name)) {
+      $function_name($build);
+    }
   }
 }