Browse Source

Migrating theming to modules

spficklin 11 years ago
parent
commit
c04071eab2
89 changed files with 6297 additions and 0 deletions
  1. 7 0
      tripal_analysis/theme/css/tripal_analysis.css
  2. 137 0
      tripal_analysis/theme/node--chado-analysis.tpl.php
  3. 53 0
      tripal_analysis/theme/tripal_analysis/tripal_analysis_base.tpl.php
  4. 39 0
      tripal_analysis/theme/tripal_analysis/tripal_analysis_properties.tpl.php
  5. 53 0
      tripal_analysis/theme/tripal_analysis/tripal_analysis_teaser.tpl.php
  6. 7 0
      tripal_contact/theme/css/tripal_contact.css
  7. 139 0
      tripal_contact/theme/node--chado-contact.tpl.php
  8. 24 0
      tripal_contact/theme/tripal_contact/tripal_contact_base.tpl.php
  9. 43 0
      tripal_contact/theme/tripal_contact/tripal_contact_properties.tpl.php
  10. 58 0
      tripal_contact/theme/tripal_contact/tripal_contact_publications.tpl.php
  11. 81 0
      tripal_contact/theme/tripal_contact/tripal_contact_relationships.tpl.php
  12. 212 0
      tripal_core/theme/css/tripal.css
  13. 31 0
      tripal_cv/theme/css/tripal_cv.css
  14. 110 0
      tripal_feature/theme/css/tripal_feature.css
  15. 173 0
      tripal_feature/theme/node--chado-feature.tpl.php
  16. 116 0
      tripal_feature/theme/tripal_feature/tripal_feature_alignments.tpl.php
  17. 51 0
      tripal_feature/theme/tripal_feature/tripal_feature_analyses.tpl.php
  18. 47 0
      tripal_feature/theme/tripal_feature/tripal_feature_base.tpl.php
  19. 28 0
      tripal_feature/theme/tripal_feature/tripal_feature_featureloc_sequences.tpl.php
  20. 112 0
      tripal_feature/theme/tripal_feature/tripal_feature_featurepos.tpl.php
  21. 134 0
      tripal_feature/theme/tripal_feature/tripal_feature_genotypes.tpl.php
  22. 57 0
      tripal_feature/theme/tripal_feature/tripal_feature_libraries.tpl.php
  23. 151 0
      tripal_feature/theme/tripal_feature/tripal_feature_nd_genotypes.tpl.php
  24. 56 0
      tripal_feature/theme/tripal_feature/tripal_feature_phenotypes.tpl.php
  25. 36 0
      tripal_feature/theme/tripal_feature/tripal_feature_properties.tpl.php
  26. 72 0
      tripal_feature/theme/tripal_feature/tripal_feature_references.tpl.php
  27. 94 0
      tripal_feature/theme/tripal_feature/tripal_feature_relationships.tpl.php
  28. 18 0
      tripal_feature/theme/tripal_feature/tripal_feature_sequence.tpl.php
  29. 33 0
      tripal_feature/theme/tripal_feature/tripal_feature_synonyms.tpl.php
  30. 45 0
      tripal_feature/theme/tripal_feature/tripal_feature_teaser.tpl.php
  31. 52 0
      tripal_feature/theme/tripal_feature/tripal_feature_terms.tpl.php
  32. 78 0
      tripal_feature/theme/tripal_organism/tripal_organism_feature_browser.tpl.php
  33. 70 0
      tripal_feature/theme/tripal_organism/tripal_organism_feature_counts.tpl.php
  34. 7 0
      tripal_featuremap/theme/css/tripal_featuremap.css
  35. 142 0
      tripal_featuremap/theme/node--chado-featuremap.tpl.php
  36. 39 0
      tripal_featuremap/theme/tripal_featuremap/tripal_featuremap_base.tpl.php
  37. 126 0
      tripal_featuremap/theme/tripal_featuremap/tripal_featuremap_featurepos.tpl.php
  38. 50 0
      tripal_featuremap/theme/tripal_featuremap/tripal_featuremap_properties.tpl.php
  39. 33 0
      tripal_featuremap/theme/tripal_featuremap/tripal_featuremap_publication.tpl.php
  40. 56 0
      tripal_featuremap/theme/tripal_featuremap/tripal_featuremap_references.tpl.php
  41. 60 0
      tripal_featuremap/theme/tripal_featuremap/tripal_featuremap_teaser.tpl.php
  42. 142 0
      tripal_library/theme/node--chado-library.tpl.php
  43. 54 0
      tripal_library/theme/tripal_library/tripal_library_base.tpl.php
  44. 44 0
      tripal_library/theme/tripal_library/tripal_library_properties.tpl.php
  45. 49 0
      tripal_library/theme/tripal_library/tripal_library_references.tpl.php
  46. 31 0
      tripal_library/theme/tripal_library/tripal_library_synonyms.tpl.php
  47. 54 0
      tripal_library/theme/tripal_library/tripal_library_teaser.tpl.php
  48. 51 0
      tripal_library/theme/tripal_library/tripal_library_terms.tpl.php
  49. 35 0
      tripal_organism/theme/css/tripal_organism.css
  50. 147 0
      tripal_organism/theme/node--chado-organism.tpl.php
  51. 95 0
      tripal_organism/theme/tripal_organism/tripal_organism_base.tpl.php
  52. 11 0
      tripal_organism/theme/tripal_organism/tripal_organism_description.tpl.php
  53. 20 0
      tripal_organism/theme/tripal_organism/tripal_organism_image.tpl.php
  54. 74 0
      tripal_organism/theme/tripal_organism/tripal_organism_libraries.tpl.php
  55. 66 0
      tripal_organism/theme/tripal_organism/tripal_organism_stocks.tpl.php
  56. 9 0
      tripal_organism/theme/tripal_organism/tripal_organism_teaser.tpl.php
  57. 142 0
      tripal_project/theme/node--chado-project.tpl.php
  58. 53 0
      tripal_project/theme/tripal_project/tripal_project_base.tpl.php
  59. 50 0
      tripal_project/theme/tripal_project/tripal_project_contact.tpl.php
  60. 41 0
      tripal_project/theme/tripal_project/tripal_project_properties.tpl.php
  61. 58 0
      tripal_project/theme/tripal_project/tripal_project_publications.tpl.php
  62. 81 0
      tripal_project/theme/tripal_project/tripal_project_relationships.tpl.php
  63. 20 0
      tripal_project/theme/tripal_project/tripal_project_teaser.tpl.php
  64. 69 0
      tripal_pub/theme/css/tripal_pub.css
  65. 161 0
      tripal_pub/theme/node--chado-pub.tpl.php
  66. 52 0
      tripal_pub/theme/tripal_pub/pub_types/conference_proceedings.inc
  67. 52 0
      tripal_pub/theme/tripal_pub/pub_types/journal_article.inc
  68. 36 0
      tripal_pub/theme/tripal_pub/pub_types/patent.inc
  69. 94 0
      tripal_pub/theme/tripal_pub/tripal_pub_authors.tpl.php
  70. 135 0
      tripal_pub/theme/tripal_pub/tripal_pub_base.tpl.php
  71. 60 0
      tripal_pub/theme/tripal_pub/tripal_pub_featuremaps.tpl.php
  72. 62 0
      tripal_pub/theme/tripal_pub/tripal_pub_features.tpl.php
  73. 64 0
      tripal_pub/theme/tripal_pub/tripal_pub_libraries.tpl.php
  74. 60 0
      tripal_pub/theme/tripal_pub/tripal_pub_projects.tpl.php
  75. 77 0
      tripal_pub/theme/tripal_pub/tripal_pub_properties.tpl.php
  76. 56 0
      tripal_pub/theme/tripal_pub/tripal_pub_references.tpl.php
  77. 81 0
      tripal_pub/theme/tripal_pub/tripal_pub_relationships.tpl.php
  78. 62 0
      tripal_pub/theme/tripal_pub/tripal_pub_stocks.tpl.php
  79. 147 0
      tripal_stock/theme/node--chado-stock.tpl.php
  80. 52 0
      tripal_stock/theme/tripal_stock/tripal_stock_base.tpl.php
  81. 47 0
      tripal_stock/theme/tripal_stock/tripal_stock_collections.tpl.php
  82. 125 0
      tripal_stock/theme/tripal_stock/tripal_stock_genotypes.tpl.php
  83. 100 0
      tripal_stock/theme/tripal_stock/tripal_stock_nd_genotypes.tpl.php
  84. 110 0
      tripal_stock/theme/tripal_stock/tripal_stock_nd_phenotypes.tpl.php
  85. 47 0
      tripal_stock/theme/tripal_stock/tripal_stock_properties.tpl.php
  86. 61 0
      tripal_stock/theme/tripal_stock/tripal_stock_references.tpl.php
  87. 101 0
      tripal_stock/theme/tripal_stock/tripal_stock_relationships.tpl.php
  88. 44 0
      tripal_stock/theme/tripal_stock/tripal_stock_synonyms.tpl.php
  89. 85 0
      tripal_stock/theme/tripal_stock/tripal_stock_teaser.tpl.php

+ 7 - 0
tripal_analysis/theme/css/tripal_analysis.css

@@ -0,0 +1,7 @@
+#tripal-analysis-edit-properties-table {
+  width: auto;
+}
+
+#tripal-analysis-edit-properties-table .form-item {
+  white-space: normal;
+}

+ 137 - 0
tripal_analysis/theme/node--chado-analysis.tpl.php

@@ -0,0 +1,137 @@
+<?php
+// Purpose: This template provides the layout of the organism node (page)
+//   using the same templates used for the various feature content blocks.
+//
+// To Customize the Featture Node Page:
+//   - This Template: customize basic layout and which elements are included
+//   - Using Panels: Override the node page using Panels3 and place the blocks
+//       of content as you please. This method requires no programming. See
+//       the Tripal User Guide for more details
+//   - Block Templates: customize the content/layout of each block of stock 
+//       content. These templates are found in the tripal_stock subdirectory
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+$analysis  = $variables['node']->organism;
+
+// get the template settings
+$template_settings = theme_get_setting('tripal');
+
+// toggle the sidebar if desired
+$no_sidebar = 0;
+if (is_array($template_settings['tripal_no_sidebar']) and 
+   $template_settings['tripal_no_sidebar']['analysis']) {
+  $no_sidebar = 1;
+}
+ 
+if ($teaser) { 
+  print theme('tripal_analysis_teaser', $variables); 
+} 
+else { ?>
+
+<script type="text/javascript">
+(function ($) {
+  Drupal.behaviors.analysisBehavior = {
+    attach: function (context, settings){<?php 
+      if ($no_sidebar) { ?>    
+        // hide the resource side bar and strech the details section    
+        $(".tripal_toc").hide();
+        $(".tripal_details").addClass("tripal_details_full");
+        $(".tripal_details_full").removeClass("tripal_details"); <?php
+      } else { ?>
+        // use default resource sidebar
+        $(".tripal-info-box").hide(); <?php
+      } ?>
+	    
+      // hide all tripal info boxes at the start
+      $(".tripal-info-box").hide();
+ 
+      // iterate through all of the info boxes and add their titles
+      // to the table of contents
+      $(".tripal-info-box-title").each(function(){
+        var parent = $(this).parent();
+        var id = $(parent).attr('id');
+        var title = $(this).text();
+        $('#tripal_analysis_toc_list').append('<li><a href="#'+id+'" class="tripal_analysis_toc_item">'+title+'</a></li>');
+      });
+
+      // when a title in the table of contents is clicked, then
+      // show the corresponding item in the details box
+      $(".tripal_analysis_toc_item").click(function(){
+         $(".tripal-info-box").hide();
+         href = $(this).attr('href');
+         $(href).fadeIn('slow');
+         // we want to make sure our table of contents and the details
+         // box stay the same height
+         $("#tripal_analysis_toc").height($(href).parent().height());
+         return false;
+      }); 
+
+      // we want the base details to show up when the page is first shown 
+      // unless the user specified a specific block
+      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
+      if(block == null){
+         block = window.location.href.match(/[\?|\&]block=(.+)/)
+      }
+      if(block != null){
+         $("#tripal_analysis-"+block[1]+"-box").show();
+      } else {
+         $("#tripal_analysis-base-box").show();
+      }
+      
+      // make the height of the table of contents match the height of the details box
+      $("#tripal_analysis_toc").height($("#tripal_analysis-base-box").parent().height());
+      
+    }     
+  };
+})(jQuery);
+</script>
+
+<div id="tripal_analysis_details" class="tripal_details">
+
+   <!-- Basic Details Theme -->
+   <?php print theme('tripal_analysis_base',$node); ?>
+   
+   <!-- Resource Blocks CCK elements --><?php
+   for($i = 0; $i < count($node->field_resource_titles); $i++){
+     if($node->field_resource_titles[$i]['value']){ ?>
+       <div id="tripal_analysis-resource_<?php print $i?>-box" class="tripal_analysis-info-box tripal-info-box">
+         <div class="tripal_analysis-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
+         <?php print $node->field_resource_blocks[$i]['value']; ?>
+       </div><?php
+     }
+   }?>
+   
+   <!-- Properties Theme -->
+   <?php print theme('tripal_analysis_properties',$node); ?>
+   
+   <!-- Let modules add more content -->
+   <?php print $content ?>
+</div>
+
+<!-- Table of contents -->
+<div id="tripal_analysis_toc" class="tripal_toc">
+   <div id="tripal_analysis_toc_title" class="tripal_toc_title">Resources</i></div>
+   <span id="tripal_analysis_toc_desc" class="tripal_toc_desc"></span>
+   <ul id="tripal_analysis_toc_list"  class="tripal_toc_list">
+   
+     <!-- Resource Links CCK elements --><?php
+     for($i = 0; $i < count($node->field_resource_links); $i++){
+       if($node->field_resource_links[$i]['value']){
+         $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
+         <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
+       }
+     }?>
+     
+     <?php // ADD CUSTOMIZED <li> LINKS HERE ?>
+   </ul>
+</div>
+
+<?php } ?>

+ 53 - 0
tripal_analysis/theme/tripal_analysis/tripal_analysis_base.tpl.php

@@ -0,0 +1,53 @@
+<?php
+
+$analysis = $variables['node']->analysis;
+
+// the description is a text field so we want to expand that
+$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
+
+
+?>
+<div id="tripal_analysis-base-box" class="tripal_analysis-info-box tripal-info-box">
+  <div class="tripal_analysis-info-box-title tripal-info-box-title">Details</div>
+   <table id="tripal_analysis-table-base" class="tripal_analysis-table tripal-table tripal-table-vert">
+      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
+        <th>Analysis Name</th>
+        <td><?php print $analysis->name; ?></td>
+      </tr>
+      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
+        <th nowrap>Software</th>
+        <td><?php 
+          print $analysis->program; 
+          if($analysis->programversion and $analysis->programversion != 'n/a'){
+             print " (" . $analysis->programversion . ")"; 
+          }
+          if($analysis->algorithm){
+             print ". " . $analysis->algorithm; 
+          }
+          ?>
+        </td>
+      </tr>
+      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
+        <th nowrap>Source</th>
+        <td><?php 
+          if($analysis->sourceuri){
+             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
+          } else {
+             print $analysis->sourcename; 
+          }
+          if($analysis->sourceversion){
+             print " (" . $analysis->sourceversion . ")"; 
+          }
+          ?>
+          </td>
+      </tr>
+      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
+        <th nowrap>Date performed</th>
+        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
+      </tr>
+      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
+        <th nowrap>Materials & Methods</th>
+        <td><?php print $analysis->description; ?></td>
+      </tr>             	                                
+   </table>   
+</div>

+ 39 - 0
tripal_analysis/theme/tripal_analysis/tripal_analysis_properties.tpl.php

@@ -0,0 +1,39 @@
+<?php
+$analysis = $node->analysis;
+
+// expand the analysis to include the properties.
+$analysis = tripal_core_expand_chado_vars($analysis,'table', 'analysisprop', array('return_array' => 1));
+$analysisprops = $analysis->analysisprop;
+$properties = array();
+if (is_array($analysisprops)) {
+  foreach ($analysisprops as $property) {
+    $property = tripal_core_expand_chado_vars($property,'field','analysisprop.value');
+    $properties[] = $property;
+  }
+}
+
+if (count($properties) > 0) { ?>
+  <div id="tripal_analysis-properties-box" class="tripal_analysis-info-box tripal-info-box">
+    <div class="tripal_analysis-info-box-title tripal-info-box-title">More Details</div>
+    <div class="tripal_analysis-info-box-desc tripal-info-box-desc">Additional information about this analysis:</div>
+    <table class="tripal_analysis-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Property Name</th>
+        <th>Value</th>
+      </tr> <?php
+      $i = 0;
+      foreach ($properties as $property) {
+        $class = 'tripal_analysis-table-odd-row tripal-table-odd-row';
+        if ($i % 2 == 0 ) {
+           $class = 'tripal_analysis-table-odd-row tripal-table-even-row';
+        }
+        $i++; 
+        ?>
+        <tr class="<?php print $class ?>">
+          <td><?php print ucfirst(preg_replace('/_/', ' ', $property->type_id->name)) ?></td>
+          <td><?php print $property->value ?></td>
+        </tr><?php 
+      } ?>
+    </table>
+  </div> <?php
+}

+ 53 - 0
tripal_analysis/theme/tripal_analysis/tripal_analysis_teaser.tpl.php

@@ -0,0 +1,53 @@
+<?php
+$node = $variables['node'];
+$analysis = $variables['node']->analysis;
+
+// the description is a text field so we want to expand that
+$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
+
+
+?>
+<div id="tripal_analysis-base-box" class="tripal_analysis-info-box tripal-info-box">
+  <div class="tripal_analysis-info-box-title tripal-info-box-title">Details</div>
+   <table id="tripal_analysis-table-base" class="tripal_analysis-table tripal-table tripal-table-vert">
+      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
+        <th>Analysis Name</th>
+        <td><?php print $analysis->name; ?></td>
+      </tr>
+      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
+        <th nowrap>Software</th>
+        <td><?php 
+          print $analysis->program; 
+          if($analysis->programversion){
+             print " (" . $analysis->programversion . ")"; 
+          }
+          if($analysis->algorithm){
+             print ". " . $analysis->algorithm; 
+          }
+          ?>
+        </td>
+      </tr>
+      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
+        <th nowrap>Source</th>
+        <td><?php 
+          if($analysis->sourceuri){
+             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
+          } else {
+             print $analysis->sourcename; 
+          }
+          if($analysis->sourceversion){
+             print " (" . $analysis->sourceversion . ")"; 
+          }
+          ?>
+          </td>
+      </tr>
+      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
+        <th nowrap>Date performed</th>
+        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
+      </tr>
+      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
+        <th nowrap>Description</th>
+        <td><?php print $analysis->description; ?></td>
+      </tr>             	                                
+   </table>   
+</div>

+ 7 - 0
tripal_contact/theme/css/tripal_contact.css

@@ -0,0 +1,7 @@
+#tripal-contact-edit-properties-table {
+  width: auto;
+}
+
+#tripal-contact-edit-properties-table .form-item {
+  white-space: normal;
+}

+ 139 - 0
tripal_contact/theme/node--chado-contact.tpl.php

@@ -0,0 +1,139 @@
+<?php
+// Purpose: This template provides the layout of the contact node (page)
+//   using the same templates used for the various contact content blocks.
+//
+// To Customize the Libray Node Page:
+//   - This Template: customize basic layout and which elements are included
+//   - Using Panels: Override the node page using Panels3 and place the blocks
+//       of content as you please. This method requires no programming. See
+//       the Tripal User Guide for more details
+//   - Block Templates: customize the content/layout of each block of stock 
+//       content. These templates are found in the tripal_stock subdirectory
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+ 
+$contact  = $variables['node']->contact;
+
+// get the template settings
+$template_settings = theme_get_setting('tripal');
+
+// toggle the sidebar if desired
+$no_sidebar = 0;
+if (is_array($template_settings['tripal_no_sidebar']) and 
+   $template_settings['tripal_no_sidebar']['contact']) {
+  $no_sidebar = 1;
+}
+
+if ($teaser) { 
+  print theme('tripal_contact_teaser', $variables); 
+} 
+else { ?>
+
+<script type="text/javascript">
+(function ($) {
+  Drupal.behaviors.contactBehavior = {
+    attach: function (context, settings){ <?php 
+      if($no_sidebar){ ?>    
+        // hide the resource side bar and strech the details section    
+        $(".tripal_toc").hide();
+        $(".tripal_details").addClass("tripal_details_full");
+        $(".tripal_details_full").removeClass("tripal_details"); <?php
+      } else { ?>
+        // use default resource sidebar
+        $(".tripal-info-box").hide(); <?php
+      } ?>
+ 
+      // iterate through all of the info boxes and add their titles
+      // to the table of contents
+      $(".tripal-info-box-title").each(function(){
+        var parent = $(this).parent();
+        var id = $(parent).attr('id');
+        var title = $(this).text();
+        $('#tripal_contact_toc_list').append('<li><a href="#'+id+'" class="tripal_contact_toc_item">'+title+'</a></li>');
+      });
+
+      // when a title in the table of contents is clicked, then
+      // show the corresponding item in the details box
+      $(".tripal_contact_toc_item").click(function(){
+         $(".tripal-info-box").hide();
+         href = $(this).attr('href');
+         $(href).fadeIn('slow');
+         // we want to make sure our table of contents and the details
+         // box stay the same height
+         $("#tripal_contact_toc").height($(href).parent().height());
+         return false;
+      }); 
+
+      // we want the base details to show up when the page is first shown 
+      // unless the user specified a specific block
+      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
+      if(block == null){
+         block = window.location.href.match(/[\?|\&]block=(.+)/)
+      }
+      if(block != null){
+         $("#tripal_contact-"+block[1]+"-box").show();
+      } else {
+         $("#tripal_contact-base-box").show();
+      }
+
+      $("#tripal_contact_toc").height($("#tripal_contact-base-box").parent().height());
+    }     
+  };
+})(jQuery);
+</script>
+
+<div id="tripal_contact_details" class="tripal_details">
+
+   <!-- Basic Details Theme -->
+   <?php print theme('tripal_contact_base',$node); ?>
+   
+   <!-- Properties Theme -->
+   <?php print theme('tripal_contact_properties',$node); ?>
+   
+   <!-- Relationships Theme -->
+   <?php print theme('tripal_contact_relationships',$node); ?>
+   
+   <!-- Relationships Theme -->
+   <?php print theme('tripal_contact_publications',$node); ?>
+   
+   <!-- Resource Blocks CCK elements --><?php
+   for($i = 0; $i < count($node->field_resource_titles); $i++){
+     if($node->field_resource_titles[$i]['value']){ ?>
+       <div id="tripal_contact-resource_<?php print $i?>-box" class="tripal_contact-info-box tripal-info-box">
+         <div class="tripal_contact-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
+         <?php print $node->field_resource_blocks[$i]['value']; ?>
+       </div><?php
+     }
+   }?>
+   
+   <!-- Let modules add more content -->
+
+   <?php print $content ?>
+</div>
+
+<!-- Table of contents -->
+<div id="tripal_contact_toc" class="tripal_toc">
+   <div id="tripal_contact_toc_title" class="tripal_toc_title">Resources</div>
+   <ul id="tripal_contact_toc_list" class="tripal_toc_list">
+   
+     <!-- Resource Links CCK elements --><?php
+     for($i = 0; $i < count($node->field_resource_links); $i++){
+       if($node->field_resource_links[$i]['value']){
+         $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
+         <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
+       }
+     }?>
+     
+     <?php // ADD CUSTOMIZED <li> LINKS HERE ?>
+   </ul>
+</div>
+
+<?php } ?>

+ 24 - 0
tripal_contact/theme/tripal_contact/tripal_contact_base.tpl.php

@@ -0,0 +1,24 @@
+<?php
+$node = $variables['node'];
+$contact = $variables['node']->contact;
+
+?>
+<div id="tripal_contact-base-box" class="tripal_contact-info-box tripal-info-box">
+  <div class="tripal_contact-info-box-title tripal-info-box-title">Details</div>
+  <div class="tripal_contact-info-box-desc tripal-info-box-desc"></div>   
+
+  <table id="tripal_contact-table-base" class="tripal_contact-table tripal-table tripal-table-vert">
+    <tr class="tripal_contact-table-even-row tripal-table-even-row">
+      <th>Name</th>
+      <td><?php print $contact->name; ?></td>
+    </tr>
+    <tr class="tripal_contact-table-odd-row tripal-table-odd-row">
+      <th>Contact Type</th>
+      <td><?php print $contact->type_id->name; ?></td>
+    </tr>
+    <tr class="tripal_contact-table-even-row tripal-table-even-row">
+      <th>Description</th>
+      <td><?php print $contact->description; ?></td>
+    </tr>
+  </table> 
+</div>

+ 43 - 0
tripal_contact/theme/tripal_contact/tripal_contact_properties.tpl.php

@@ -0,0 +1,43 @@
+<?php
+$contact = $node->contact;
+
+// expand the contact to include the properties.
+$contact = tripal_core_expand_chado_vars($contact,'table', 'contactprop', array('return_array' => 1));
+$contactprops = $contact->contactprop;
+$properties = array();
+if (is_array($contactprops)) {
+  foreach ($contactprops as $property) {
+    // we want to keep all properties but the contact_description as that
+    // property is shown on the base template page.
+    if($property->type_id->name != 'contact_description') {
+      $property = tripal_core_expand_chado_vars($property,'field','contactprop.value');
+      $properties[] = $property;
+    }
+  }
+}
+
+if (count($properties) > 0) { ?>
+  <div id="tripal_contact-properties-box" class="tripal_contact-info-box tripal-info-box">
+    <div class="tripal_contact-info-box-title tripal-info-box-title">More Details</div>
+    <div class="tripal_contact-info-box-desc tripal-info-box-desc">Additional information about this contact:</div>
+    <table class="tripal_contact-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Property Name</th>
+        <th>Value</th>
+      </tr> <?php
+      $i = 0;
+      foreach ($properties as $property) {
+        $class = 'tripal_contact-table-odd-row tripal-table-odd-row';
+        if ($i % 2 == 0 ) {
+           $class = 'tripal_contact-table-odd-row tripal-table-even-row';
+        }
+        $i++; 
+        ?>
+        <tr class="<?php print $class ?>">
+          <td><?php print ucfirst(preg_replace('/_/', ' ', $property->type_id->name)) ?></td>
+          <td><?php print $property->value ?></td>
+        </tr><?php 
+      } ?>
+    </table>
+  </div> <?php
+}

+ 58 - 0
tripal_contact/theme/tripal_contact/tripal_contact_publications.tpl.php

@@ -0,0 +1,58 @@
+<?php
+$contact  = $variables['node']->contact;
+
+// expand contact to include pubs 
+$options = array('return_array' => 1);
+$contact = tripal_core_expand_chado_vars($contact, 'table', 'pubauthor_contact', $options);
+
+$pubauthor_contacts = $contact->pubauthor_contact;
+?>
+
+<div id="tripal_pubauthor_contact-pub-box" class="tripal_pubauthor_contact-info-box tripal-info-box">
+  <div class="tripal_pubauthor_contact-info-box-title tripal-info-box-title">Publications</div>
+  <div class="tripal_pubauthor_contact-info-box-desc tripal-info-box-desc"></div>
+
+  <table id="tripal_pubauthor_contact-pub-table" class="tripal_pubauthor_contact-table tripal-table tripal-table-vert" style="border-bottom:solid 2px #999999">
+    <tr>
+      <th>Year</th>
+      <th>Publication</th></tr> <?php
+      $i = 0;
+      foreach ($pubauthor_contacts AS $pubauthor_contact) {
+        $pub = $pubauthor_contact->pubauthor_id->pub_id;
+        $pub = tripal_core_expand_chado_vars($pub, 'field', 'pub.title');
+        $citation = $pub->title;  // use the title as the default citation
+        
+        // get the citation for this pub if it exists
+        $values = array(
+          'pub_id' => $pub->pub_id, 
+          'type_id' => array(
+            'name' => 'Citation',
+          ),
+        );
+        $options = array('return_array' => 1);
+        $citation_prop = tripal_core_generate_chado_var('pubprop', $values, $options); 
+        if (count($citation_prop) == 1) {
+          $citation_prop = tripal_core_expand_chado_vars($citation_prop, 'field', 'pubprop.value');
+          $citation = $citation_prop[0]->value;
+        }
+        
+        // if the publicatio is synced then link to it
+        if ($pub->nid) {
+          // replace the title with a link
+          $link = l($pub->title, 'node/' . $pub->nid ,array('attributes' => array('target' => '_blank')));
+          $citation = preg_replace('/' . $pub->title . '/', $link, $citation);
+        }
+          
+        
+        $class = 'tripal_pubauthor_contact-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_pubauthor_contact-table-odd-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td><?php print $pub->pyear ?></td>
+          <td><?php print $citation ?></td>
+        </tr><?php 
+        $i++;
+      }  ?>
+  </table>
+</div>

+ 81 - 0
tripal_contact/theme/tripal_contact/tripal_contact_relationships.tpl.php

@@ -0,0 +1,81 @@
+<?php
+// this template does not follow the typical Tripal API. Normally
+// variables are expanded using the tripal_core_expand_chado_vars API
+// function call, but expanding the relationships table does not yeild
+// a meaningful order to the data.  Therefore, relationships are preprocessed
+// into an array named 'all_relationships', which is used in the template below.
+
+$contact = $variables['node']->contact;
+
+$all_relationships = $contact->all_relationships;
+$object_rels = $all_relationships['object'];
+$subject_rels = $all_relationships['subject'];
+
+// make the contact type a bit more human readable
+$contact_type =  preg_replace("/_/", ' ', $contact->type_id->name);
+
+if (count($object_rels) > 0 or count($subject_rels) > 0) {
+?>
+  <div id="tripal_contact-relationships-box" class="tripal_contact-info-box tripal-info-box">
+    <div class="tripal_contact-info-box-title tripal-info-box-title">Relationships</div>
+    <!--  <div class="tripal_contact-info-box-desc tripal-info-box-desc"></div> --><?php
+    
+      // first add in the subject relationships.  
+      foreach ($subject_rels as $rel_type => $rels){
+         // make the type a bit more human readable
+         $rel_type = preg_replace("/_/", ' ', $rel_type);
+         $rel_type = preg_replace("/^is/", '', $rel_type);
+         // iterate through each parent   
+         foreach ($rels as $obj_type => $objects){?>
+           <p>This contact is a <b><?php print $rel_type ?></b> of the following contact(s):
+           <table id="tripal_contact-relationships_as_object-table" class="tripal_contact-table tripal-table tripal-table-horz">
+             <tr>
+               <th>contact Name</th>
+             </tr> <?php
+             foreach ($objects as $object){ ?>
+               <tr>
+                 <td><?php 
+                    if ($object->nid) {
+                      print "<a href=\"" . url("node/" . $object->nid) . "\" target=\"_blank\">" . $object->name . "</a>";
+                    }
+                    else {
+                      print $object->name;
+                    } ?>
+                 </td>
+               </tr> <?php
+             } ?>
+             </table>
+             </p><br><?php
+         }
+      }
+      
+      // second add in the object relationships.  
+      foreach ($object_rels as $rel_type => $rels){
+         // make the type more human readable
+         $rel_type = preg_replace('/_/', ' ', $rel_type);
+         $rel_type = preg_replace("/^is/", '', $rel_type);
+         // iterate through the children         
+         foreach ($rels as $subject_type => $subjects){?>
+           <p>The following contacts are a <b><?php print $rel_type ?></b> of this contact:
+           <table id="tripal_contact-relationships_as_object-table" class="tripal_contact-table tripal-table tripal-table-horz">
+             <tr>
+               <th>Name</th>
+             </tr> <?php
+             foreach ($subjects as $subject){ ?>
+               <tr>
+                 <td><?php 
+                    if ($subject->nid) {
+                      print "<a href=\"" . url("node/" . $subject->nid) . "\" target=\"_blank\">" . $subject->name . "</a>";
+                    }
+                    else {
+                      print $subject->name;
+                    } ?>
+                 </td>
+               </tr> <?php
+             } ?>
+             </table>
+             </p><br><?php
+         }
+      } ?>
+  </div> <?php
+}

+ 212 - 0
tripal_core/theme/css/tripal.css

@@ -0,0 +1,212 @@
+.tripal-info-box {
+   width: 100%;
+   padding-bottom: 10px;
+}
+
+.tripal-info-box-nosidebar {
+   width: 100%;
+   padding-bottom: 10px;
+}
+
+.tripal-table {
+   width: 100%; 
+}
+.tripal-table th, 
+.tripal-table td {
+   vertical-align:text-top;
+   padding-left: 10px;
+   padding-right: 10px;
+   padding-top: 5px;
+   padding-bottom: 5px;
+}
+.tripal-table-horz {
+   border-top: 1px solid #999999;
+   border-bottom: 1px solid #999999; 
+}
+
+/* settings for vertical tables (headers across left-side) */
+table.tripal-table-vert .tripal-table-even-row th {
+   background-color: #EEEEEE;
+   font-weight: none;
+   text-align: right;
+}
+table.tripal-table-vert .tripal-table-odd-row th {
+   background-color: #FFFFFF;
+   text-align: right;
+}
+table.tripal-table-vert .tripal-table-even-row {
+   background-color: #EEEEEE;
+   border-top: 1px solid #CCCCCC;
+   border-bottom: 1px solid #CCCCCC;
+}
+table.tripal-table-vert .tripal-table-odd-row {
+   background-color: #FFFFFF;
+   border-top: 1px solid #CCCCCC;
+   border-bottom: 1px solid #CCCCCC;
+}
+/* settings for horizontal tables (headers across top) */
+table.tripal-table-horz th {
+   background-color: #EEEEFF;
+   font-weight: none;
+   text-align: left;
+}
+table.tripal-table-horz .tripal-table-even-row {
+   background-color: #FFFFFF;
+   font-weight: none;
+   text-align: left;
+   border-top: 1px solid #CCCCCC;
+   border-bottom: 1px solid #CCCCCC;
+}
+table.tripal-table-horz .tripal-table-odd-row {
+   background-color: #EEEEEE;
+   text-align: left;
+   border-top: 1px solid #CCCCCC;
+   border-bottom: 1px solid #CCCCCC;
+}
+
+.tripal-info-box-title {
+  font-size: 1.5em;
+  padding-bottom: 15px;
+}
+
+.tripal-info-box-title-nosidebar {
+  font-size: 1.5em;
+  padding-bottom: 15px;
+}
+
+.tripal-info-box-desc {
+  padding-bottom: 15px;
+}
+/* hide the title when inside of a block on a panel */
+.pane-block .tripal-info-box-title {
+   visibility: hidden;
+   padding: 0;
+   margin: 0;
+   height: 0px;
+}
+
+/* Ajax loader */
+#tripal_ajaxLoading {
+   position: fixed;
+   top: 40%;
+   left: 40%;
+   padding: 15px;
+   border: 1px solid #000000;
+   background-color: #EEEEEE;
+   opacity: 0.75;
+   -moz-opacity: 0.75;
+   z-index: 10;
+}
+
+#tripal_ajaxLoading #loadingText {
+   font-weight: bold;
+   font-size: 1.5em;
+   color: #000000;
+}
+
+/* Restrict the list of checkboxes in a 300px window */
+.form-checkboxes {
+   height: auto;
+   max-height: 300px;
+   overflow: auto;
+}
+
+/* no results message */
+.tripal-no-results {
+   font-style: italic;
+   padding: 10px;
+   background-color: #FFEEEE;
+}
+
+.tripal_toc {
+  float: left;
+  width: 20%;
+  background-color: #EEEEEE;
+
+  -moz-border-radius: 15px;
+  -webkit-border-radius: 15px;
+  -khtml-border-radius: 15px;
+  border-radius: 15px;
+
+  -moz-box-shadow: 3px 3px 4px #888888;
+  -webkit-box-shadow: 3px 3px 4px #888888;
+  box-shadow: 3px 3px 4px #888888;
+
+  padding: 20px;
+  min-height: 500px;
+  border-style:solid;
+  border-width:1px;
+}
+.tripal_toc ul {
+ margin-left: 0px;
+ margin-top: 5px;
+ padding-left: 15px;
+}
+.tripal_toc_title {
+  font-size: 1.5em;
+  line-height: 110%;
+  padding-bottom: 10px;
+}
+.tripal_toc_desc {
+ /*font-style: italic; */
+}
+.tripal_details {
+  float: left;
+  width: 69%;
+  background-color: #FFFFFF;
+
+  -moz-border-radius: 15px;
+  -webkit-border-radius: 15px;
+  -khtml-border-radius: 15px;
+  border-radius: 15px;
+
+  -moz-box-shadow: 3px 3px 4px #888888;
+  -webkit-box-shadow: 3px 3px 4px #888888;
+  box-shadow: 3px 3px 4px #888888;
+  padding: 20px;
+  min-height: 500px;
+  margin-right: 10px;
+  margin-bottom: 10px;
+  border-style:solid;
+  border-width:1px;
+  
+  overflow:auto;
+}
+
+.tripal_details_full {
+  float: left;
+  width: 95%;
+  background-color: #FFFFFF;
+
+  -moz-border-radius: 15px;
+  -webkit-border-radius: 15px;
+  -khtml-border-radius: 15px;
+  border-radius: 15px;
+
+  -moz-box-shadow: 3px 3px 4px #888888;
+  -webkit-box-shadow: 3px 3px 4px #888888;
+  box-shadow: 3px 3px 4px #888888;
+  padding: 20px;
+  min-height: 500px;
+  margin-right: 10px;
+  margin-bottom: 10px;
+  border-style:solid;
+  border-width:1px;
+  
+  overflow:auto;
+}
+
+.tripal-subtable {
+  border-collapse:collapse;
+  border: 0px solid black;
+  width: auto;
+}
+
+.tripal-subtable td {
+  padding: 0px 5px 5px 0px; 
+  border: 0px solid black;
+}
+
+.tripal-notice {
+  color: red;
+}

+ 31 - 0
tripal_cv/theme/css/tripal_cv.css

@@ -0,0 +1,31 @@
+.treeview .placeholder {
+	/* background: url(images/ajax-loader.gif) 0 0 no-repeat; */
+	height: 16px;
+	width: 16px;
+	display: block;
+}
+
+#tripal_cv_cvterm_info_box {
+   position: absolute;
+   top: 0%; left: 30%;
+   padding:10px;
+   width:650px;
+   display: none;
+   border: 1px solid #000000;
+   background-color: #EFEFEF;
+   opacity: 0.90;
+   -moz-opacity: 0.90;
+   z-index: 10;
+   -webkit-border-radius: 5px;
+   -moz-border-radius: 5px;
+   border-radius: 5px;
+   color: #000000;
+}
+
+#tripal_cv_cvterm_info_box h3 {
+   border-bottom: 1px solid #AAAAAA;
+}
+
+#tripal_cv_cvterm_info {
+   color: #000000;
+}

+ 110 - 0
tripal_feature/theme/css/tripal_feature.css

@@ -0,0 +1,110 @@
+#tripal_feature-featureloc_sequence,
+#tripal_feature-sequence-residues {
+  background-color: #FFFFFF;
+  font-family: monospace;
+}
+
+pre#tripal_feature-featureloc_sequence {
+  color: #000000;
+  height: 400px;
+  overflow: scroll;
+}
+
+div#tripal_feature-featureloc_sequence-legend {
+   padding: 0px 0px 10px 0px;
+   margin: 0px 0px 10px 0px;
+}
+div#tripal_feature-legend-item {
+   padding: 10px;
+   margin: 10px;
+}
+/* styles for cvterm types in sequences */
+div#tripal_feature-featureloc_sequence-legend span {
+   margin: 5px;
+   padding: 10px;
+}
+span.tripal_feature-featureloc_sequence-five_prime_UTR {
+   background-image: url('../images/type_color1.png');
+}
+
+span.tripal_feature-featureloc_sequence-three_prime_UTR {
+   background-image: url('../images/type_color2.png');
+}
+
+span.tripal_feature-featureloc_sequence-mRNA {
+   background-image: url('../images/type_color3.png');
+}
+
+span.tripal_feature-featureloc_sequence-CDS {
+   background-image: url('../images/type_color3.png');
+}
+
+span.tripal_feature-featureloc_sequence-exon {
+   background-image: url('../images/type_color1.png');
+}
+
+span.tripal_feature-featureloc_sequence-intron {
+   background-image: url('../images/type_color6.png');
+ 
+}
+/* information tables on the feature pages */
+table.tripal_feature-relationships-subject-table th {
+   background-color: #EEEEEE;
+   text-align: left;
+}
+table.tripal_feature-relationships-object-table th {
+   background-color: #EEEEEE;
+   text-align: left;
+}
+table.tripal_feature-locations-table th {
+   background-color: #EEEEEE;
+   text-align: left;
+}
+table.tripal_feature-references-table th {
+   background-color: #EEEEEE;
+   text-align: left;
+
+}
+/* feature relationship edit form */
+#tripal-feature-edit-ALL-relationships-form .form-item,
+#tripal-feature-edit-ALL-db-references-form .form-item {
+   float: left;
+   margin: 0 10px 0 0;
+   
+}
+#tripal-feature-edit-ALL-db-references-form .form-submit {
+   float: none;
+   display: block;
+}
+.tripal_feature-obsolete {
+   color: red;
+   font-weight: bold;
+   font-style: italic;
+   padding-bottom: 15px; 
+   text-align: center;
+}
+
+
+/* 
+ * Sequence Retrieval Form
+ */
+#tripal-feature-seq-extract-form-table {
+  border-collapse: collapse;
+  border: 0px solid #DDDDDD;
+  border-spacing: 0;  
+  margin: 1em 0;
+  width: auto;
+}
+#tripal-feature-seq-extract-form-table tr {
+  background-color: transparent;
+  border: 0px solid #CCCCCC;
+  padding: 0.1em 0.6em;  
+}
+#tripal-feature-seq-extract-form-table td {
+  border: 0px solid #DDDDDD;
+  padding: 0.25em 0.5em;
+  vertical-align: top;
+}
+#tripal-feature-seq-extract-form-table .form-item {
+  white-space: normal;
+}

+ 173 - 0
tripal_feature/theme/node--chado-feature.tpl.php

@@ -0,0 +1,173 @@
+<?php
+// Purpose: This template provides the layout of the feature node (page)
+//   using the same templates used for the various feature content blocks.
+//
+// To Customize the Featture Node Page:
+//   - This Template: customize basic layout and which elements are included
+//   - Using Panels: Override the node page using Panels3 and place the blocks
+//       of content as you please. This method requires no programming. See
+//       the Tripal User Guide for more details
+//   - Block Templates: customize the content/layout of each block of stock 
+//       content. These templates are found in the tripal_stock subdirectory
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+
+$feature  = $variables['node']->feature;
+
+// get the template settings
+$template_settings = theme_get_setting('tripal');
+
+// toggle the sidebar if desired
+$no_sidebar = 0;
+if (is_array($template_settings['tripal_no_sidebar']) and 
+   $template_settings['tripal_no_sidebar']['feature']) {
+  $no_sidebar = 1;
+}
+$feature_no_sidebar = preg_split('/\n/', $template_settings['tripal_feature_no_sidebar']);
+
+if ($teaser) { 
+  print theme('tripal_feature_teaser', $variables); 
+} 
+else { ?>
+
+<script type="text/javascript">
+(function ($) {
+  Drupal.behaviors.featureBehavior = {
+    attach: function (context, settings){ <?php 
+      if ($no_sidebar or in_array($feature->type_id->name, $feature_no_sidebar)) { ?>    
+        // hide the resource side bar and strech the details section    
+        $(".tripal_toc").hide();
+        $(".tripal_details").addClass("tripal_details_full");
+        $(".tripal_details_full").removeClass("tripal_details"); <?php
+      } else { ?>
+        // use default resource sidebar
+        $(".tripal-info-box").hide(); <?php
+      } ?>
+ 
+      // iterate through all of the info boxes and add their titles
+      // to the table of contents
+      $(".tripal-info-box-title").each(function(){
+        var parent = $(this).parent();
+        var id = $(parent).attr('id');
+        var title = $(this).text();
+        $('#tripal_feature_toc_list').append('<li><a href="#'+id+'" class="tripal_feature_toc_item">'+title+'</a></li>');
+      });
+
+      // when a title in the table of contents is clicked, then
+      // show the corresponding item in the details box
+      $(".tripal_feature_toc_item").click(function(){
+         $(".tripal-info-box").hide();
+         href = $(this).attr('href');
+         $(href).fadeIn('slow');
+         // we want to make sure our table of contents and the details
+         // box stay the same height
+         $("#tripal_feature_toc").height($(href).parent().height());
+         return false;
+      }); 
+
+      // we want the base details to show up when the page is first shown 
+      // unless the user specified a specific block
+      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
+      if(block == null){
+         block = window.location.href.match(/[\?|\&]block=(.+)/)
+      }
+      if(block != null){
+         $("#tripal_feature-"+block[1]+"-box").show();
+      } else {
+         $("#tripal_feature-base-box").show();
+      }
+
+      $("#tripal_organism_toc").height($("#tripal_feature-base-box").parent().height());
+    }     
+  };
+})(jQuery);
+</script>
+
+<div id="tripal_feature_details" class="tripal_details">
+
+   <!-- Basic Details Theme -->
+   <?php print theme('tripal_feature_base',$node); ?>
+
+   <!-- Database References -->
+   <?php print theme('tripal_feature_references', $node); ?>
+
+   <!-- Properties -->
+   <?php print theme('tripal_feature_properties', $node); ?>
+
+   <!-- Annotated Terms -->
+   <?php print theme('tripal_feature_terms', $node); ?>
+
+   <!-- Synonyms -->
+   <?php print theme('tripal_feature_synonyms', $node); ?>
+   
+   <!-- Phenotypes -->
+   <?php print theme('tripal_feature_phenotypes', $node); ?>
+   
+   <!-- Maps -->   
+   <?php print theme('tripal_feature_featurepos', $node); ?>
+
+   <!-- Sequence --> <?php 
+   if(strcmp($feature->type_id->name,'scaffold')!=0 and 
+      strcmp($feature->type_id->name,'chromosome')!=0 and
+      strcmp($feature->type_id->name,'supercontig')!=0 and
+      strcmp($feature->type_id->name,'pseudomolecule')!=0)
+   {
+      print theme('tripal_feature_sequence', $node); 
+   } ?>
+
+   <!-- Formatted Sequences -->
+   <?php print theme('tripal_feature_featureloc_sequences', $node); ?>
+
+   <!-- Relationships -->
+   <?php print theme('tripal_feature_relationships', $node); ?>
+   
+   <!-- Feature locations --> <?php 
+   if(strcmp($feature->type_id->name,'scaffold')!=0 and 
+      strcmp($feature->type_id->name,'chromosome')!=0 and
+      strcmp($feature->type_id->name,'supercontig')!=0 and
+      strcmp($feature->type_id->name,'pseudomolecule')!=0)
+   {
+      print theme('tripal_feature_alignments', $node); 
+   } ?>
+     
+  
+   <!-- Resource Blocks CCK elements --><?php
+   for($i = 0; $i < count($node->field_resource_titles); $i++){
+     if($node->field_resource_titles[$i]['value']){ ?>
+       <div id="tripal_feature-resource_<?php print $i?>-box" class="tripal_feature-info-box tripal-info-box">
+         <div class="tripal_feature-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
+         <?php print $node->field_resource_blocks[$i]['value']; ?>
+       </div><?php
+     }
+   }?>
+   
+   <!-- Let modules add more content -->
+   <?php print $content ?>
+</div>
+
+<!-- Table of contents -->
+<div id="tripal_feature_toc" class="tripal_toc">
+   <div id="tripal_feature_toc_title" class="tripal_toc_title">Resources</div>
+   <ul id="tripal_feature_toc_list" class="tripal_toc_list">
+   
+     <!-- Resource Links CCK elements --><?php
+     for($i = 0; $i < count($node->field_resource_links); $i++){
+       if($node->field_resource_links[$i]['value']){
+         $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
+         <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
+       }
+     }?>
+     
+     <?php // ADD CUSTOMIZED <li> LINKS HERE ?>
+   </ul>
+</div>
+
+<?php } ?>

+ 116 - 0
tripal_feature/theme/tripal_feature/tripal_feature_alignments.tpl.php

@@ -0,0 +1,116 @@
+<?php
+/*
+* Typically in a Tripal template, the data needed is retrieved using a call to
+* tripal_core_expand_chado_vars function.  For example, to retrieve all 
+* of the feature alignments for this node, the following function call would be made:
+* 
+*   $feature = tripal_core_expand_chado_vars($feature,'table','featureloc');
+*   
+* However, this will return all records from the featureloc table without any context.
+* To help provide context, a special variable is provided to this template named
+* 'all_featurelocs'.   
+* 
+*   $feature->all_featurelocs
+*   
+* The records in the 'all_featurelocs' array are all properly arranged for easy iteration.
+* 
+* However, access to the original alignment records is possible through the 
+* $feature->featureloc object.  In the following ways:  
+*
+* Alignment context #1:
+* --------------------
+* If the feature for this node is the parent in the alignment relationships,
+* then those alignments are available in this variable:
+* 
+*    $feature->featureloc->srcfeature_id;
+*    
+*
+* Alignment context #2:
+* ---------------------
+* If the feature for this node is the child in the alignment relationsips,
+* then those alignments are available in this variable:
+* 
+*   $feature->featureloc->feature_id;
+*   
+*
+* Alignment context #3:
+* --------------------
+* If the feature is aligned to another through an intermediary feature (e.g.
+* a feature of type 'match', 'EST_match', 'primer_match', etc) then those
+* alignments are stored in this variable:
+*   feature->matched_featurelocs
+*
+* Below is an example of a feature that may be aligned to another through
+* an intermediary:
+*
+*    Feature 1: Contig      ---------------   (left feature)
+*    Feature 2: EST_match           -------
+*    Feature 3: EST                 --------- (right feature)
+*
+* The feature for this node is always "Feature 1".  The purpose of this type 
+* alignment is to indicate cases where there is the potential for overhang
+* in the alignments, or, the ends of the features are not part of the alignment
+* prehaps due to poor quality of the ends.  Blast results and ESTs mapped to
+* contigs in Unigenes would fall under this category.
+*
+*/
+$feature = $variables['node']->feature;
+$alignments = $feature->all_featurelocs;
+
+if(count($alignments) > 0){ ?>
+  <div id="tripal_feature-alignments-box" class="tripal_feature-info-box tripal-info-box">
+    <div class="tripal_feature-info-box-title tripal-info-box-title">Alignments</div>
+    <div class="tripal_feature-info-box-desc tripal-info-box-desc">The following features are aligned to this <b><?php print $feature->type_id->name;?></b></div>
+    <table id="tripal_feature-featurelocs_as_child-table" class="tripal_feature-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Aligned Feature</th>
+        <th>Feature Type</th>
+        <th>Alignment Location</th>
+      </tr><?php
+      $i = 0; 
+      foreach ($alignments as $alignment){
+        $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
+        if ($i % 2 == 0 ) {
+          $class = 'tripal_feature-table-odd-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td><?php 
+            if ($alignment->nid) {
+              print "<a href=\"" . url("node/".$alignment->nid) . "\">".$alignment->name."</a>";
+            } else {
+              print $alignment->name;
+            }?>
+          </td>
+          <td><?php print $alignment->type ?></td>
+          <td><?php  
+            $strand = '.';
+            if ($alignment->strand == -1) {
+              $strand = '-';
+            } 
+            elseif ($alignment->strand == 1) {
+               $strand = '+';
+            } 
+              
+            // if this is a match then make the other location 
+            if($alignment->right_feature){
+              $rstrand = '.';
+              if ($alignment->right_strand == -1) {
+                   $rstrand = '-';
+              } 
+              elseif ($alignment->right_strand == 1) {
+                   $rstrand = '+';
+              }
+              print $feature->name .":". ($alignment->fmin + 1) . ".." . $alignment->fmax . " " . $strand; 
+              print "<br>" . $alignment->name .":". ($alignment->right_fmin + 1) . ".." . $alignment->right_fmax . " " . $rstrand; 
+            }
+            else {
+              print $alignment->name .":". ($alignment->fmin + 1) . ".." . $alignment->fmax . " " . $strand; 
+            }?>
+          </td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table>
+  </div><?php
+}
+

+ 51 - 0
tripal_feature/theme/tripal_feature/tripal_feature_analyses.tpl.php

@@ -0,0 +1,51 @@
+<?php
+$feature = $variables['node']->feature;
+
+// expand the feature object to include the libraries from the library_feature
+// table in chado.
+$feature = tripal_core_expand_chado_vars($feature,'table','analysisfeature');
+
+// get the references. if only one reference exists then we want to convert
+// the object into an array, otherwise the value is an array
+$analyses = $feature->analysisfeature;
+if (!$analyses) {
+   $analyses = array();
+} 
+elseif (!is_array($analyses)) { 
+   $analyses = array($analyses); 
+}
+
+// don't show this page if there are no libraries
+if (count($analyses) > 0) { ?>
+  <div id="tripal_feature-analyses-box" class="tripal_feature-info-box tripal-info-box">
+    <div class="tripal_feature-info-box-title tripal-info-box-title">Analyses</div>
+    <div class="tripal_feature-info-box-desc tripal-info-box-desc">This <?php print $feature->type_id->name ?> is derived from or has results from the following analyses</div>
+    <table id="tripal_feature-analyses-table" class="tripal_feature-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Analysis Name</th>
+        <th>Date Performed</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($analyses as $analysis) {
+        $class = 'tripal-table-odd-row';
+        if ($i % 2 == 0 ) {
+           $class = 'tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td><?php 
+            $nid = chado_get_node_id('analysis', $analysis->analysis_id->analysis_id);
+            if ($nid) {
+               print "<a href=\"". url("node/".$nid) . "\">".$analysis->analysis_id->name."</a>";
+            } else {
+               print $analysis->analysis_id->name;
+            } ?>
+          </td>
+          <td> <?php print preg_replace('/\d\d:\d\d:\d\d/', '',  $analysis->analysis_id->timeexecuted) ?>
+          </td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table> 
+  </div><?php 
+} 
+

+ 47 - 0
tripal_feature/theme/tripal_feature/tripal_feature_base.tpl.php

@@ -0,0 +1,47 @@
+<?php
+
+$feature  = $variables['node']->feature;
+
+?>
+<div id="tripal_feature-base-box" class="tripal_feature-info-box tripal-info-box">
+  <div class="tripal_feature-info-box-title tripal-info-box-title">Feature Details</div>
+  <div class="tripal_feature-info-box-desc tripal-info-box-desc"></div>
+
+   <?php if(strcmp($feature->is_obsolete,'t')==0){ ?>
+      <div class="tripal_feature-obsolete">This feature is obsolete</div>
+   <?php }?>
+   <table id="tripal_feature-base-table" class="tripal_feature-table tripal-table tripal-table-vert">
+      <tr class="tripal_feature-table-even-row tripal-table-even-row">
+        <th>Name</th>
+        <td><?php print $feature->name; ?></td>
+      </tr>
+      <tr class="tripal_feature-table-odd-row tripal-table-odd-row">
+        <th nowrap>Unique Name</th>
+        <td><?php print $feature->uniquename; ?></td>
+      </tr>
+      <tr class="tripal_feature-table-even-row tripal-table-even-row">
+        <th>Internal ID</th>
+        <td><?php print $feature->feature_id; ?></td>
+      </tr>
+      <tr class="tripal_feature-table-odd-row tripal-table-odd-row">
+        <th>Type</th>
+        <td><?php print $feature->type_id->name; ?></td>
+      </tr>
+      <tr class="tripal_feature-table-even-row tripal-table-even-row">
+        <th>Organism</th>
+        <td>
+          <?php if ($feature->organism_id->nid) { 
+      	   print "<a href=\"".url("node/".$feature->organism_id->nid)."\">".$feature->organism_id->genus ." " . $feature->organism_id->species ." (" .$feature->organism_id->common_name .")</a>";      	 
+          } else { 
+            print $feature->organism_id->genus ." " . $feature->organism_id->species ." (" .$feature->organism_id->common_name .")";
+          } ?>
+        </td>
+     	</tr> <?php   
+     	if ($feature->seqlen) { ?>
+        <tr class="tripal_feature-table-odd-row tripal-table-odd-row">
+          <th>Length</th>
+          <td><?php print $feature->seqlen ?></td>
+        </tr> <?php 
+     	} ?>   	                                
+   </table>
+</div>

+ 28 - 0
tripal_feature/theme/tripal_feature/tripal_feature_featureloc_sequences.tpl.php

@@ -0,0 +1,28 @@
+<?php
+// get the featurelocs for this feature. If the variable is not already 
+// expanded then do so
+$feature = $variables['node']->feature;
+
+$feature = tripal_core_expand_chado_vars($feature, 'table', 'featureloc');
+$featurelocs = $feature->featureloc;
+
+// get the featurelocs. if only one featureloc exists then we want to convert
+// the object into an array, otherwise the value is an array
+$ffeaturelocs = $feature->featureloc->feature_id;
+if (!$ffeaturelocs) {
+   $ffeaturelocs = array();
+} elseif (!is_array($ffeaturelocs)) { 
+   $ffeaturelocs = array($ffeaturelocs); 
+}
+$featureloc_sequences = tripal_feature_load_featureloc_sequences ($feature->feature_id,$ffeaturelocs);
+
+if(count($featureloc_sequences) > 0){
+   foreach($featureloc_sequences as $src => $attrs){ ?>
+       <div id="tripal_feature-<?php print $attrs['type']?>-box" class="tripal_feature-info-box tripal-info-box">
+         <div class="tripal_feature-info-box-title tripal-info-box-title">Annotated Sequence</div>
+         <div class="tripal_feature-info-box-desc tripal-info-box-desc"></div>
+            <?php print $attrs['formatted_seq'] ?>
+       </div>
+   <?php } 
+}?>
+

+ 112 - 0
tripal_feature/theme/tripal_feature/tripal_feature_featurepos.tpl.php

@@ -0,0 +1,112 @@
+<?php
+$feature = $variables['node']->feature;
+$map_positions = array();
+
+// expand the feature object to include the records from the featurepos table
+// specify the number of features to show by default and the unique pager ID
+$num_results_per_page = 25; 
+$featurepos_pager_id = 0;
+
+// get the maps associated with this feature
+$options = array(  
+  'return_array' => 1,
+  'order_by' => array('map_feature_id' => 'ASC'),
+  'pager' => array('limit' => $num_results_per_page, 'element' => $featurepos_pager_id),
+  'include_fk' => array(
+    'map_feature_id' => array(
+      'type_id' => 1,
+      'organism_id' => 1,
+    ),
+    'featuremap_id' => array(
+       'unittype_id' => 1,
+    ),
+  ),
+);
+
+$feature = tripal_core_expand_chado_vars($feature, 'table', 'featurepos', $options);
+
+// because the featurepos table has  FK relationships with map_feature_id and feature_id with the feature table 
+// the function call above will try to expand both and will create an array of matches for each FK.
+// we only want to show the map that this feature belongs to
+$map_positions = $feature->featurepos->feature_id;
+
+// create the pager.  
+$featurepos_pager = theme('pager', array(), $num_results_per_page, $featurepos_pager_id, array('block' => 'featurepos'));
+
+
+if(count($map_positions) > 0){ ?>
+  <div id="tripal_feature-featurepos-box" class="tripal_feature-info-box tripal-info-box">
+    <div class="tripal_feature-info-box-title tripal-info-box-title">Maps</div>
+    <div class="tripal_feature-info-box-desc tripal-info-box-desc">This feature is contained in the following maps:</div>
+    <table id="tripal_feature-featurepos-table" class="tripal_feature-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Map Name</th>
+        <th>Landmark</th>
+        <th>Type</th>
+        <th>Position</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($map_positions as $position){
+        $map_feature = $position->map_feature_id;
+
+        // check if there are any values in the featureposprop table for the start and stop
+        $mappos = $position->mappos;
+        $options = array(
+          'return_array' => 1,
+          'include_fk' => array(
+            'type_id' => 1,            
+          ),
+        );
+        $position = tripal_core_expand_chado_vars($position, 'table', 'featureposprop', $options);
+        $featureposprop = $position->featureposprop;
+        if (is_array($featureposprop)) {
+          foreach ($featureposprop as $index => $property) {
+             if ($property->type_id->name == 'start') {
+               $start = $property->value;
+             }
+             if ($property->type_id->name == 'stop') {
+               $stop = $property->value;
+             }
+          }      
+        }  
+        if ($start and $stop and $start != $stop) {
+          $mappos = "$start-$stop";
+        }
+        if ($start and !$stop) {
+          $mappos = $start;
+        }
+        if ($start and $stop and $start == $stop) {
+          $mappos = $start;
+        }
+        
+        $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_feature-table-even-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td> <?php 
+            if ($position->featuremap_id->nid) { 
+              print l($position->featuremap_id->name, 'node/' . $position->featuremap_id->nid, array('attributes' => array('target' => '_blank')));
+            } 
+            else { 
+              print $position->featuremap_id->name;
+            } ?>
+          </td>
+          <td> <?php 
+            if ($map_feature->nid) { 
+              print l($map_feature->name, 'node/' . $map_feature->nid, array('attributes' => array('target' => '_blank')));
+            } 
+            else { 
+              print $map_feature->name;
+            } ?>
+          </td>          
+          <td><?php print $map_feature->type_id->name ?></td>
+          <td><?php print $mappos ?> <?php print $position->featuremap_id->unittype_id->name ?> </td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table> <?php 
+    print $featurepos_pager ?>
+  </div><?php 
+}?>
+

+ 134 - 0
tripal_feature/theme/tripal_feature/tripal_feature_genotypes.tpl.php

@@ -0,0 +1,134 @@
+<?php
+/*
+ * NOTE: if the tripal_natural_diversity module is enabled this template will be
+ * ignored and the tripal_feature_nd_genotypes.tpl.php template will be used instead
+ *
+ * There are two ways that feature genotypes can be housed in Chado.  The first, more simple
+ * method, is via the feature_genotype table.  This is simply a linker table between the
+ * feature and genotype tables of Chado.  A more complex method is via the Natural Diversity
+ * tables.  In these tables, the genotypes are in the nd_experiment_genotype table 
+ * and there may be an associated project, contact info, etc. This template is for the simple
+ * feature_genotype linker table.
+ */
+$feature = $variables['node']->feature;
+
+// specify the number of genotypes to show by default and the unique pager ID
+$num_results_per_page = 25; 
+$feature_pager_id = 5;
+
+// get the genotypes from the feature_genotype table
+$options = array(  
+  'return_array' => 1,
+  'pager' => array('limit' => $num_results_per_page, 'element' => $feature_pager_id),
+);
+$feature = tripal_core_expand_chado_vars($feature, 'table', 'feature_genotype', $options); 
+
+// because this table has two FK constraints for the feature table, the expand function call
+// above doesn't know which one we're interested in, so it expands both the feature_id and the
+// chromosome_id and makes both available to us.  This feature can only have a genotype if
+// it matches the feature_genotype through the 'feature_id' FK (not the chromosome_id) so, we
+// retrieve our results from the 'feature_id' key.
+$feature_genotypes = $feature->feature_genotype->feature_id;
+
+// create the pager.  
+$feature_pager = theme('pager', array(), $num_results_per_page, $feature_pager_id, array('block' => 'genotypes'));
+
+
+// now iterate through the feature genotypes and print a paged table.
+if (count($feature_genotypes) > 0) {?>
+  <div id="tripal_feature-genotypes-box" class="tripal_feature-info-box tripal-info-box">
+    <div class="tripal_feature-info-box-title tripal-info-box-title">Genotypes</div>
+    <div class="tripal_feature-info-box-desc tripal-info-box-desc">This following genotypes have been recorded for this feature.</div>
+    <table id="tripal_feature-table-feature_genotypes_exp" class="tripal_feature-table tripal-table tripal-table-horz">     
+      <tr class="tripal_feature-table-odd-row tripal-table-even-row">
+        <th>Name</th>
+        <th>Type</th>
+        <th>Genotype</th>
+        <th>Details</th>
+        <th>Germplasm</th>
+      </tr> <?php       
+      $i = 0;   
+      foreach($feature_genotypes as $feature_genotype) {        
+        $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+          $class = 'tripal_feature-table-odd-row tripal-table-even-row';
+        }         
+        $genotype = $feature_genotype->genotype_id;        
+        
+        // get the genotype properties
+        $options = array('return_array' => 1);
+        $genotype = tripal_core_expand_chado_vars($genotype, 'table', 'genotypeprop', $options);
+        $properties = $genotype->genotypeprop; 
+        
+        // add in stocks associated with this genotype if any
+        $options = array(
+          'return_array' => 1,
+          'inlude_fk' => array(
+            'stock_id' => array(
+              'type_id' => 1
+            )
+          ),
+        );
+        $genotype = tripal_core_expand_chado_vars($genotype, 'table', 'stock_genotype', $options);
+        $stock_genotypes = $genotype->stock_genotype; ?>
+        <tr class="<?php print $class ?>">
+          <td><?php
+          if($genotype->name){
+             print $genotype->name;
+          } 
+          else {
+             print $genotype->uniquename;
+          } ?>
+          </td>
+          <td><?php
+            // Chado versions < v1.2 did not have a type_id field
+            if ($genotype->type_id) {
+              print ucwords(preg_replace('/_/', ' ', $genotype->type_id->name));
+            } 
+            else {
+              print 'N/A';
+            } ?>
+          </td>
+          <td><?php print $genotype->description ?></td>
+          <td><?php 
+            if(count($properties) > 0) { ?>           
+              <table class="tripal-subtable"> <?php
+                foreach ($properties as $property){ ?>
+                  <tr> 
+                    <td><?php print ucwords(preg_replace('/_/', ' ', $property->type_id->name)) ?></td>
+                    <td>:</td>                  
+                    <td><?php print $property->value ?>
+                    </td>
+                  </tr> <?php                 
+                } ?>
+              </table><?php 
+            } ?>
+          </td>
+          <td><?php 
+            if(count($stock_genotypes) > 0) { ?>                      
+              <table class="tripal-subtable"> <?php
+                foreach ($stock_genotypes as $stock_genotype){ 
+                  $stock = $stock_genotype->stock_id; ?>
+                  <tr> 
+                    <td><?php print ucwords(preg_replace('/_/', ' ', $stock->type_id->name)) ?></td>
+                    <td>:</td>                  
+                    <td><?php 
+                      if($stock->nid) {
+                        print l($stock->name, 'node/' . $stock->nid);
+                      }
+                      else {
+                        print $stock->name;
+                      }?>
+                    </td>
+                  </tr> <?php                 
+                } ?>
+              </table><?php 
+            } ?>
+          </td>
+        </tr> <?php
+        $i++;
+      } ?>  
+    </table> <?php 
+    print $feature_pager ?>
+  </div><?php
+} 

+ 57 - 0
tripal_feature/theme/tripal_feature/tripal_feature_libraries.tpl.php

@@ -0,0 +1,57 @@
+<?php
+$feature = $variables['node']->feature;
+
+// expand the feature object to include the libraries from the library_feature
+// table in chado.
+$feature = tripal_core_expand_chado_vars($feature,'table','library_feature');
+
+// get the references. if only one reference exists then we want to convert
+// the object into an array, otherwise the value is an array
+$library_features = $feature->library_feature;
+if (!$library_features) {
+   $library_features = array();
+} 
+elseif (!is_array($library_features)) { 
+   $library_features = array($library_features); 
+}
+
+// don't show this page if there are no libraries
+if (count($library_features) > 0) { ?>
+  <div id="tripal_feature-libraries-box" class="tripal_feature-info-box tripal-info-box">
+    <div class="tripal_feature-info-box-title tripal-info-box-title">Libraries</div>
+    <div class="tripal_feature-info-box-desc tripal-info-box-desc">This <?php print $feature->type_id->name ?> is derived, or can be located in the following libraries</div>
+    <table id="tripal_feature-libraries-table" class="tripal_feature-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Library Name</th>
+        <th>Type</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($library_features as $library_feature) {
+        $class = 'tripal-table-odd-row';
+        if ($i % 2 == 0 ) {
+           $class = 'tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td><?php 
+            if ($library_feature->library_id->nid) {
+               print "<a href=\"". url("node/".$library_feature->library_id->nid) . "\">".$library_feature->library_id->name."</a>";
+            } else {
+               print $library_feature->library_id->name;
+            } ?>
+          </td>
+          <td> <?php 
+              if ($library_feature->library_id->type_id->name == 'cdna_library') {
+                 print 'cDNA';
+              } else if ($library_feature->library_id->type_id->name == 'bac_library') {
+                 print 'BAC';
+              } else {
+                 print $library_feature->library_id->type_id->name;
+              } ?>
+          </td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table> 
+  </div><?php 
+} 
+

+ 151 - 0
tripal_feature/theme/tripal_feature/tripal_feature_nd_genotypes.tpl.php

@@ -0,0 +1,151 @@
+<?php
+/*
+ * NOTE: if the tripal_natural_diversity module is enabled this template will be
+ * used and the tripal_feature_genotypes.tpl.php template will be ignored
+ *
+ * There are two ways that feature genotypes can be housed in Chado.  The first, more simple
+ * method, is via the feature_genotype table.  This is simply a linker table between the
+ * feature and genotype tables of Chado.  A more complex method is via the Natural Diversity
+ * tables.  In these tables, the genotypes are in the nd_experiment_genotype table
+ * and there may be an associated project, contact info, etc. This template is for Natural 
+ * Diversity tables.
+ */
+$feature = $variables['node']->feature;
+
+// specify the number of genotypes to show by default and the unique pager ID
+$num_results_per_page = 25;
+$feature_pager_id = 6;
+
+// get the genotypes from the feature_genotype table
+$options = array(
+  'return_array' => 1,
+  'pager' => array('limit' => $num_results_per_page, 'element' => $feature_pager_id),
+);
+$feature = tripal_core_expand_chado_vars($feature, 'table', 'feature_genotype', $options);
+
+// because this table has two FK constraints for the feature table, the expand function call
+// above doesn't know which one we're interested in, so it expands both the feature_id and the
+// chromosome_id and makes both available to us.  This feature can only have a genotype if
+// it matches the feature_genotype through the 'feature_id' FK (not the chromosome_id) so, we
+// retrieve our results from the 'feature_id' key.
+$feature_genotypes = $feature->feature_genotype->feature_id;
+
+// create the pager.
+$feature_pager = theme('pager', array(), $num_results_per_page, $feature_pager_id, array('block' => 'nd_genotypes'));
+
+
+// now iterate through the feature genotypes and print a paged table.
+if (count($feature_genotypes) > 0) {?>
+  <div id="tripal_feature-nd_genotypes-box" class="tripal_feature-info-box tripal-info-box">
+    <div class="tripal_feature-info-box-title tripal-info-box-title">Genotypes</div>
+    <div class="tripal_feature-info-box-desc tripal-info-box-desc">This following genotypes have been recorded for this feature.</div>
+    <table id="tripal_feature-table-feature_genotypes_exp" class="tripal_feature-table tripal-table tripal-table-horz">
+      <tr class="tripal_feature-table-odd-row tripal-table-even-row">
+        <th>Name</th>
+        <th>Type</th>
+        <th>Genotype</th>
+        <th>Details</th>
+        <th>Germplasm</th>
+        <th>Project</th>
+      </tr> <?php
+      $i = 0;
+      foreach($feature_genotypes as $feature_genotype) {
+        $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+          $class = 'tripal_feature-table-odd-row tripal-table-even-row';
+        }
+        $genotype = $feature_genotype->genotype_id;
+
+        // get the genotype properties
+        $options = array('return_array' => 1);
+        $genotype = tripal_core_expand_chado_vars($genotype, 'table', 'genotypeprop', $options);
+        $properties = $genotype->genotypeprop;
+
+        // get the experiment via the genotype:
+        $options = array(
+          'return_array' => 1,
+          'inlude_fk' => array(
+            'nd_experiment_id' => 1
+          ),
+        );
+        $values = array('genotype_id' => $genotype->genotype_id);
+        $nd_experiment_genotype = tripal_core_generate_chado_var('nd_experiment_genotype', $values);
+        $nd_experiment_genotype = tripal_core_expand_chado_vars($nd_experiment_genotype, 'table', 'nd_experiment_stock', $options);
+        $nd_experiment = $nd_experiment_genotype->nd_experiment_id;
+
+        // get the project via the experiment
+        $options = array(
+          'return_array' => 1,
+          'inlude_fk' => array(
+            'project_id' => 1
+          ),
+        );
+        $values = array('nd_experiment_id' => $nd_experiment->nd_experiment_id);
+        $nd_experiment_project = tripal_core_generate_chado_var('nd_experiment_project', $values, $options);
+
+        $nd_experiment_stock = $nd_experiment->nd_experiment_stock;
+        $nd_experiment_stock = tripal_core_expand_chado_vars($nd_experiment_stock, 'node', 'stock', $options);
+        ?>
+        <tr class="<?php print $class ?>">
+          <td><?php
+          if($genotype->name){
+             print $genotype->name;
+          }
+          else {
+             print $genotype->uniquename;
+          } ?>
+          </td>
+          <td><?php
+            // Chado versions < v1.2 did not have a type_id field
+            if ($genotype->type_id) {
+              print ucwords(preg_replace('/_/', ' ', $genotype->type_id->name));
+            }
+            else {
+              print 'N/A';
+            } ?>
+          </td>
+          <td><?php print $genotype->description ?></td>
+          <td><?php
+            if(count($properties) > 0) { ?>
+              <table class="tripal-subtable"> <?php
+                foreach ($properties as $property){ ?>
+                  <tr>
+                    <td><?php print ucwords(preg_replace('/_/', ' ', $property->type_id->name)) ?></td>
+                    <td>:</td>
+                    <td><?php print $property->value ?>
+                    </td>
+                  </tr> <?php
+                } ?>
+              </table><?php
+            } ?>
+          </td>
+          <td><?php
+            if(count($nd_experiment_stock) > 0) {
+              $name = $nd_experiment_stock->stock_id->stock->name . ' (' . $nd_experiment_stock->stock_id->stock->uniquename . ')';
+              print l($name, 'node/' . $nd_experiment_stock->stock_id->nid);
+            } ?>
+          </td>
+          <td><?php
+            if(count($nd_experiment_project) == 0) {
+              print $project->name;
+            }
+            elseif(count($nd_experiment_project) == 1) {
+              $project = $nd_experiment_project[0]->project_id;
+              if($project->nid){
+                print  l($project->name, "node/$project->nid");
+              }
+              else {
+                print $project->name;
+              }
+            }
+            elseif(count($nd_experiment_project) > 1) {
+              drupal_set_message("A feature genotype has multiple projects for the same experiment. Data warning.", 'warning');
+            } ?>
+          </td>
+        </tr> <?php
+        $i++;
+      } ?>
+    </table> <?php
+    print $feature_pager ?>
+  </div><?php
+}

+ 56 - 0
tripal_feature/theme/tripal_feature/tripal_feature_phenotypes.tpl.php

@@ -0,0 +1,56 @@
+<?php
+$feature = $variables['node']->feature;
+
+// expand the feature object to include the phenotypes from the feature_phenotypes 
+// table in chado.
+$options = array(
+  'return_array' => 1,
+  'include_fk' => array(
+    'phenotype_id' => array(
+      'attr_id' => 1,
+      'cvalue_id' => 1,
+      'assay_id' => 1,
+      'observable_id' => 1,
+    )
+  )
+);
+$feature = tripal_core_expand_chado_vars($feature, 'table', 'feature_phenotype', $options);
+$feature_phenotypes = $feature->feature_phenotype;
+
+// expand the text fields
+$options = array('return_array' => 1);
+$feature = tripal_core_expand_chado_vars($feature, 'field', 'phenotype.value', $options);
+$feature = tripal_core_expand_chado_vars($feature, 'field', 'phenotype.uniquename', $options);
+$feature = tripal_core_expand_chado_vars($feature, 'field', 'phenotype.name', $options);
+
+
+if(count($feature_phenotypes) > 0){ ?>
+  <div id="tripal_feature-phenotypes-box" class="tripal_feature-info-box tripal-info-box">
+    <div class="tripal_feature-info-box-title tripal-info-box-title">Phenotypes</div>
+    <div class="tripal_feature-info-box-desc tripal-info-box-desc">The feature is associated with the following phenotypes</div>
+
+    <table id="tripal_feature-phenotypes-table" class="tripal_feature-table tripal-table tripal-table-horz">
+      <tr>   
+        <th>Attribute</th>     
+        <th>Observed Unit</th>               
+        <th>Value</th>
+        <th>Evidence Type</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($feature_phenotypes as $index => $feature_phenotype){
+        $phenotype = $feature_phenotype->phenotype_id;
+        $class = 'tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td><?php print $phenotype->attr_id->name?></td>
+          <td><?php print $phenotype->observable_id->name?></td>          
+          <td><?php print $phenotype->cvalue_id ? $phenotype->cvalue_id->name : $phenotype->value ?></td>
+          <td><?php print $phenotype->assay_id ?></td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table>
+  </div><?php
+}

+ 36 - 0
tripal_feature/theme/tripal_feature/tripal_feature_properties.tpl.php

@@ -0,0 +1,36 @@
+<?php
+
+$feature = $node->feature;
+$options = array('return_array' => 1);
+$feature = tripal_core_expand_chado_vars($feature, 'table', 'featureprop', $options);
+$properties = $feature->featureprop;
+
+
+if(count($properties) > 0){ ?>
+
+  <div id="tripal_feature-properties-box" class="tripal_feature-info-box tripal-info-box">
+    <div class="tripal_feature-info-box-title tripal-info-box-title">Properties</div>
+    <div class="tripal_feature-info-box-desc tripal-info-box-desc">Properties for the feature '<?php print $node->feature->name ?>' include:</div>
+
+    <table class="tripal_feature-table tripal-table tripal-table-horz">
+    <tr>
+      <th>Property Name</th>
+      <th>Value</th>
+    </tr>
+	  <?php	// iterate through each property
+		  $i = 0;
+		  foreach ($properties as $result){
+		    $result = tripal_core_expand_chado_vars($result,'field','featureprop.value');
+		    $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_feature-table-odd-row tripal-table-even-row';
+        } ?>
+			  <tr class="<?php print $class ?>">
+  			  <td><?php print ucfirst(preg_replace('/_/', ' ', $result->type_id->name)) ?></td>
+  			  <td><?php print urldecode($result->value) ?></td>
+  			</tr> <?php
+			  $i++;
+		  } ?>
+		</table>
+  </div> <?php
+}

+ 72 - 0
tripal_feature/theme/tripal_feature/tripal_feature_references.tpl.php

@@ -0,0 +1,72 @@
+<?php
+$feature = $variables['node']->feature;
+$references = array();
+
+// First, get the dbxref record from feature recrod itself if one exists
+if ($feature->dbxref_id) {
+  $feature->dbxref_id->is_primary = 1;  // add this new property so we know it's the primary reference
+  $references[] = $feature->dbxref_id;
+}
+
+// Second, expand the feature object to include the records from the feature_dbxref table
+$options = array('return_array' => 1);
+$feature = tripal_core_expand_chado_vars($feature, 'table', 'feature_dbxref', $options);
+$feature_dbxrefs = $feature->feature_dbxref;
+if (count($feature_dbxrefs) > 0 ) {
+  foreach ($feature_dbxrefs as $feature_dbxref) {    
+    if($feature_dbxref->dbxref_id->db_id->name == 'GFF_source'){
+      // check to see if the reference 'GFF_source' is there.  This reference is
+      // used to if the Chado Perl GFF loader was used to load the features   
+    }
+    else {
+      $references[] = $feature_dbxref->dbxref_id;
+    }
+  }
+}
+
+
+if(count($references) > 0){ ?>
+  <div id="tripal_feature-references-box" class="tripal_feature-info-box tripal-info-box">
+    <div class="tripal_feature-info-box-title tripal-info-box-title">Cross References</div>
+    <div class="tripal_feature-info-box-desc tripal-info-box-desc">External references for this <?php print $feature->type_id->name ?></div>
+    <table id="tripal_feature-references-table" class="tripal_feature-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Dababase</th>
+        <th>Accession</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($references as $dbxref){ 
+        if($dbxref_id->db_id->name == 'GFF_source'){
+           continue;  // skip the GFF_source entry as this is just needed for the GBrowse chado adapter
+        }
+        $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_feature-table-even-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td> <?php 
+            if ($dbxref->db_id->url) { 
+              print l($dbxref->db_id->name, $dbxref->db_id->url);
+            } 
+            else { 
+              print $dbxref->db_id->name; 
+            } ?>
+          </td>
+          <td> <?php 
+            if ($dbxref->db_id->urlprefix) { 
+              print l($dbxref->accession, $dbxref->db_id->urlprefix.$dbxref->accession);
+            } 
+            else { 
+              print $dbxref->accession; 
+            }
+            if ($dbxref->is_primary) {
+              print " <i>(primary cross-reference)</i>";
+            } ?>
+          </td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table>
+  </div><?php 
+}?>
+

+ 94 - 0
tripal_feature/theme/tripal_feature/tripal_feature_relationships.tpl.php

@@ -0,0 +1,94 @@
+<?php
+/* Typically in a Tripal template, the data needed is retrieved using a call to
+ * tripal_core_expand_chado_vars function.  For example, to retrieve all 
+ * of the feature relationships for this node, the following function call would be made:
+ * 
+ *   $feature = tripal_core_expand_chado_vars($feature,'table','feature_relationship');
+ * 
+ * However, this function call can be extremely slow when there are numerous relationships.
+ * This is because the tripal_core_expand_chado_vars function is recursive and expands 
+ * all data following the foreign key relationships tree.  Therefore, to speed retrieval
+ * of data, a special variable is provided to this template:
+ * 
+ *   $feature->all_relationships;
+ *   
+ * This variable is an array with two sub arrays with the keys 'object' and 'subject'.  The array with
+ * key 'object' contains relationships where the feature is the object, and the array with
+ * the key 'subject' contains relationships where the feature is the subject
+ */
+$feature = $variables['node']->feature;
+
+$all_relationships = $feature->all_relationships;
+$object_rels = $all_relationships['object'];
+$subject_rels = $all_relationships['subject'];
+
+if (count($object_rels) > 0 or count($subject_rels) > 0) {
+?>
+  <div id="tripal_feature-relationships-box" class="tripal_feature-info-box tripal-info-box">
+    <div class="tripal_feature-info-box-title tripal-info-box-title">Relationships</div>
+    <div class="tripal_feature-info-box-desc tripal-info-box-desc"></div> <?php
+    
+      // first add in the subject relationships.  
+      foreach ($subject_rels as $rel_type => $rels){
+         foreach ($rels as $obj_type => $objects){?>           
+           <p>This <?php print $feature->type_id->name;?> is <?php print $rel_type ?> the following <b><?php print $obj_type ?></b> feature(s):
+           <table id="tripal_feature-relationships_as_object-table" class="tripal_feature-table tripal-table tripal-table-horz">
+             <tr>
+               <th>Feature Name</th>
+               <th>Unique Name</th>
+               <th>Species</th>
+               <th>Type</th>
+             </tr> <?php
+             foreach ($objects as $object){ ?>
+               <tr>
+                 <td><?php 
+                    if ($object->record->nid) {
+                      print "<a href=\"" . url("node/" . $object->record->nid) . "\" target=\"_blank\">" . $object->record->object_id->name . "</a>";
+                    }
+                    else {
+                      print $object->record->object_id->name;
+                    } ?>
+                 </td>
+                 <td><?php print $object->record->object_id->uniquename ?></td>
+                 <td><?php print $object->record->object_id->organism_id->genus . " " . $object->record->object_id->organism_id->species; ?></td>
+                 <td><?php print $object->record->object_id->type_id->name ?></td>                 
+               </tr> <?php
+             } ?>
+             </table>
+             </p><br><?php
+         }
+      }
+      
+      // second add in the object relationships.  
+      foreach ($object_rels as $rel_type => $rels){
+         foreach ($rels as $subject_type => $subjects){?>
+           <p>The following <b><?php print $subjects[0]->record->subject_id->type_id->name ?></b> feature(s) are <?php print $rel_type ?> this <?php print $feature->type_id->name;?>:
+           <table id="tripal_feature-relationships_as_object-table" class="tripal_feature-table tripal-table tripal-table-horz">
+             <tr>
+               <th>Feature Name</th>
+               <th>Unique Name</th>
+               <th>Species</th>
+               <th>Type</th>
+             </tr> <?php
+             foreach ($subjects as $subject){ ?>
+               <tr>
+                 <td><?php 
+                    if ($subject->record->nid) {
+                      print "<a href=\"" . url("node/" . $subject->record->nid) . "\" target=\"_blank\">" . $subject->record->subject_id->name . "</a>";
+                    }
+                    else {
+                      print $subject->record->subject_id->name;
+                    } ?>
+                 </td>
+                 <td><?php print $subject->record->subject_id->uniquename ?></td>
+                 <td><?php print $subject->record->subject_id->organism_id->genus . " " . $subject->record->subject_id->organism_id->species; ?></td>
+                 <td><?php print $subject->record->subject_id->type_id->name ?></td>                 
+               </tr> <?php
+             } ?>
+             </table>
+             </p><br><?php
+         }
+      }
+    ?>
+  </div> <?php
+}

+ 18 - 0
tripal_feature/theme/tripal_feature/tripal_feature_sequence.tpl.php

@@ -0,0 +1,18 @@
+<?php
+$feature = $variables['node']->feature;
+
+// add the residues to the feature object.  Fields of type 'text' in Chado
+// are not automatically added, so we must add them manually
+$feature = tripal_core_expand_chado_vars($feature,'field','feature.residues');
+
+if ($feature->residues) { ?>
+  <div id="tripal_feature-sequence-box" class="tripal_feature-info-box tripal-info-box">
+    <div class="tripal_feature-info-box-title tripal-info-box-title">Sequence</div>
+    <div class="tripal_feature-info-box-desc tripal-info-box-desc">The sequence for this <?php print $feature->type_id->name; ?> </div>
+    <pre id="tripal_feature-sequence-residues"><?php 
+      // format the sequence to break ever 100 residues
+      print ereg_replace("(.{60})","\\1<br>",$feature->residues); ?>  
+    </pre>
+  </div><?php
+}
+

+ 33 - 0
tripal_feature/theme/tripal_feature/tripal_feature_synonyms.tpl.php

@@ -0,0 +1,33 @@
+<?php
+$feature = $variables['node']->feature;
+
+// expand the feature object to include the synonyms from the feature_synonym 
+// table in chado.
+$options = array('return_array' => 1);
+$feature = tripal_core_expand_chado_vars($feature, 'table', 'feature_synonym', $options);
+$synonyms = $feature->feature_synonym;
+
+
+if(count($synonyms) > 0){ ?>
+  <div id="tripal_feature-synonyms-box" class="tripal_feature-info-box tripal-info-box">
+    <div class="tripal_feature-info-box-title tripal-info-box-title">Synonyms</div>
+    <div class="tripal_feature-info-box-desc tripal-info-box-desc">The feature '<?php print $feature->name ?>' has the following synonyms</div>
+
+    <table id="tripal_feature-synonyms-table" class="tripal_feature-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Synonym</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($synonyms as $feature_synonym){
+        $class = 'tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td><?php print $feature_synonym->synonym_id->name?></td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table>
+  </div><?php
+}

+ 45 - 0
tripal_feature/theme/tripal_feature/tripal_feature_teaser.tpl.php

@@ -0,0 +1,45 @@
+<?php
+
+$feature  = $variables['node']->feature;
+
+?>
+<div id="tripal_feature-base-box" class="tripal_feature-info-box tripal-info-box">
+  <div class="tripal_feature-info-box-title tripal-info-box-title">Feature Details</div>
+  <div class="tripal_feature-info-box-desc tripal-info-box-desc"></div>
+
+   <?php if(strcmp($feature->is_obsolete,'t')==0){ ?>
+      <div class="tripal_feature-obsolete">This feature is obsolete</div>
+   <?php }?>
+   <table id="tripal_feature-base-table" class="tripal_feature-table tripal-table tripal-table-vert">
+      <tr class="tripal_feature-table-odd-row tripal-table-even-row">
+        <th>Name</th>
+        <td><?php print $feature->name; ?></td>
+      </tr>
+      <tr class="tripal_feature-table-odd-row tripal-table-odd-row">
+        <th nowrap>Unique Name</th>
+        <td><?php print $feature->uniquename; ?></td>
+      </tr>
+      <tr class="tripal_feature-table-odd-row tripal-table-even-row">
+        <th>Internal ID</th>
+        <td><?php print $feature->feature_id; ?></td>
+      </tr>
+      <tr class="tripal_feature-table-odd-row tripal-table-odd-row">
+        <th>Length</th>
+        <td><?php print $feature->seqlen ?></td>
+      </tr>
+      <tr class="tripal_feature-table-odd-row tripal-table-even-row">
+        <th>Type</th>
+        <td><?php print $feature->type_id->name; ?></td>
+      </tr>
+      <tr class="tripal_feature-table-odd-row tripal-table-odd-row">
+        <th>Organism</th>
+        <td>
+          <?php if ($feature->organism_id->nid) { 
+      	   print "<a href=\"".url("node/".$feature->organism_id->nid)."\">".$feature->organism_id->genus ." " . $feature->organism_id->species ." (" .$feature->organism_id->common_name ." )</a>";      	 
+          } else { 
+            print $feature->organism_id->genus ." " . $feature->organism_id->species ." (" .$feature->organism_id->common_name .")";
+          } ?>
+        </td>
+     	</tr>           	                                
+   </table>
+</div>

+ 52 - 0
tripal_feature/theme/tripal_feature/tripal_feature_terms.tpl.php

@@ -0,0 +1,52 @@
+<?php
+
+$feature = $node->feature;
+$feature = tripal_core_expand_chado_vars($feature, 'table', 'feature_cvterm');
+
+$terms = $feature->feature_cvterm;
+if (!$terms) {
+  $terms = array();
+} elseif (!is_array($terms)) { 
+  $terms = array($terms); 
+}
+
+// order the terms by CV
+$s_terms = array();
+foreach ($terms as $term) {
+  $s_terms[$term->cvterm_id->cv_id->name][] = $term;  
+}
+
+if (count($s_terms) > 0) { ?>
+  <div id="tripal_feature-terms-box" class="tripal_feature-info-box tripal-info-box">
+    <div class="tripal_feature-info-box-title tripal-info-box-title">Annotated Terms</div>
+    <div class="tripal_feature-info-box-desc tripal-info-box-desc">The following terms have been associated with this <?php print $node->feature->type_id->name ?>:</div>  <?php
+    // iterate through each term
+    foreach ($s_terms as $cv => $terms) {  ?>
+      <p><?php print ucwords(preg_replace('/_/', ' ', $cv)) ?></p>
+      <table class="tripal_feature-table tripal-table tripal-table-horz">
+        <tr>
+          <th>Term</th>
+          <th>Definition</th>
+        </tr> <?php
+        $i = 0;
+        foreach ($terms as $term) { 
+          $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
+          if($i % 2 == 0 ){
+            $class = 'tripal_feature-table-even-row tripal-table-even-row';
+          }
+          $accession = $term->cvterm_id->dbxref_id->accession;
+          if (is_numeric($term->cvterm_id->dbxref_id->accession)) {
+            $accession = $term->cvterm_id->dbxref_id->db_id->name . ":" . $term->cvterm_id->dbxref_id->accession;
+          }
+          if ($term->cvterm_id->dbxref_id->db_id->urlprefix) {
+            $accession =  "<a href=\"" . $term->cvterm_id->dbxref_id->db_id->urlprefix . "$accession\" target=\"_blank\">$accession</a>";
+          } ?>
+          <tr class="<?php print $class ?>">
+            <td><?php print $accession ?></td>
+            <td><?php print $term->cvterm_id->name ?></td>
+          </tr> <?php
+        } ?>
+      </table> <?php
+  } ?>
+  </div> <?php
+} ?>

+ 78 - 0
tripal_feature/theme/tripal_organism/tripal_organism_feature_browser.tpl.php

@@ -0,0 +1,78 @@
+<?php
+
+$organism = $variables['node']->organism;
+$features = $organism->feature_browser['features'];
+$pager    = $organism->feature_browser['pager'];
+$enabled  = $organism->feature_browser['enabled'];
+
+// only show this block if it is enabled
+if ($enabled) { 
+  if (count($features) > 0) { ?>
+    <div id="tripal_organism-feature_browser-box" class="tripal_organism-info-box tripal-info-box">
+      <div class="tripal_organism-info-box-title tripal-info-box-title">Feature Browser</div>
+      <div class="tripal_organism-info-box-desc tripal-info-box-desc">The following browser provides a quick view for new visitors.  Use the searching mechanism to find specific features.</div> <?php
+      // let admins know they can customize the terms that appear in the list
+      if (user_access('access administration pages')) { ?>
+         <div class="tripal-no-results">Administrators, to disable this browser and 
+         remove it from the list of resources, navigate to the <a href="<?php print url('admin/tripal/tripal_feature/configuration') ?>">Tripal feature configuration page</a> 
+         and hide the "Feature Browser".
+         </div><?php 
+      }?>
+      <table id="tripal_organism-table-feature_browser" class="tripal_organism-table tripal-table tripal-table-horz">     
+        <tr class="tripal_organism-table-odd-row tripal-table-even-row">
+          <th>Feature Name</th>
+          <th>Unique Name</th>
+          <th>Type</th>
+        </tr> <?php
+        foreach ($features as $feature){ 
+          $class = 'tripal_organism-table-odd-row tripal-table-odd-row';
+          if ($i % 2 == 0 ) {
+            $class = 'tripal_organism-table-odd-row tripal-table-even-row';
+          } ?>
+          <tr class="<?php print $class ?>">
+            <td><?php 
+              if ($feature->nid) {    
+                $link =   url("node/$feature->nid");        
+                print "<a href=\"$link\">$feature->name</a>";
+              } else {
+                print $feature->name;
+              }?>
+            </td>
+            <td><?php print $feature->uniquename?></td>
+            <td><?php print $feature->type_name?></td>
+          </tr><?php
+          $i++;  
+        } ?>
+      </table>
+      <?php print $pager ?>
+    </div> <?php
+  } 
+  else {
+    // if there are no results and this is the admin user then show some instructions
+    // otherwise nothing is shown.
+    if(user_access('access administration pages')){ ?>
+      <div id="tripal_organism-feature_browser-box" class="tripal_organism-info-box tripal-info-box">
+        <div class="tripal_organism-info-box-title tripal-info-box-title">Feature Browser</div>
+        <div class="tripal-no-results">
+          There are no features available for browsing
+          <p><br>Administrators, perform the following to show features in this browser:
+          <ul>
+            <li>Load features for this organism using the <a href="<?php print url('admin/tripal/tripal_feature/fasta_loader');?>">FASTA loader</a>, <a href="<?php print url('admin/tripal/tripal_feature/gff3_load');?>">GFF loader</a> or <a href="<?php print url('admin/tripal/tripal_bulk_loader_template');?>">Bulk Loader</a>.</li>
+            <li>Sync the features that should have pages using the <a href="<?php print url('admin/tripal/tripal_feature/sync');?>">Sync Features</a> tool.</li>
+            <li>Return to this page to browse features.</li>
+            <li>Ensure the user <a href="<?php print url('admin/user/permissions'); ?>"> has permission</a> to view the feature content</li>
+          </ul> 
+          <br><br>To disable this browser and remove it from the list of resources:
+          <ul>
+            <li>Navigate to the <a href="<?php print url('admin/tripal/tripal_feature/configuration') ?>">Tripal feature configuration page</a> and hide the "Feature Browser"</li>
+          </ul>
+          </p>
+          This page will not appear to site visitors unless features are present.
+        </div>         
+      </div><?php
+    }
+  }
+}
+
+
+

+ 70 - 0
tripal_feature/theme/tripal_organism/tripal_organism_feature_counts.tpl.php

@@ -0,0 +1,70 @@
+<?php
+
+$organism = $variables['node']->organism;
+$types    = $organism->feature_counts['types'];
+$names    = $organism->feature_counts['names'];
+$enabled  = $organism->feature_counts['enabled'];
+
+// only show this block if it is enabled
+if ($enabled) { 
+  if (count($types) > 0){ ?>
+    <div id="tripal_organism-feature_counts-box" class="tripal_organism-info-box tripal-info-box">
+      <div class="tripal_organism-info-box-title tripal-info-box-title">Data Type Summary</div>
+      <div class="tripal_organism-info-box-desc tripal-info-box-desc">The following data types are currently present for this organism</div> <?php
+      // let admins know they can customize the terms that appear in the list
+      if (user_access('access administration pages')) { ?>
+         <div class="tripal-no-results">Administrators, you can customize the types of terms that appear in this report by 
+         navigating to the <a href="<?php print url('admin/tripal/tripal_feature/configuration') ?>">Tripal 
+         feature configuration page</a> opening the section "Feature Summary Report" and adding the list of
+         terms you want to appear in the list. You can rename terms as well.  To disable this report and 
+         remove it from the list of resources, navigate to the <a href="<?php print url('admin/tripal/tripal_feature/configuration') ?>">Tripal feature configuration page</a> 
+         and hide the "Feature Summary". To refresh the data,re-populate the <a href="<?php print url('admin/tripal/mviews');?>" target="_blank">organism_feature_count</a> materialized view. 
+         </div><?php 
+      }?>
+      <table id="tripal_organism-table-feature_counts" class="tripal_organism-table tripal-table tripal-table-horz">     
+        <tr class="tripal_organism-table-odd-row tripal-table-even-row">
+          <th>Feature Type</th>
+          <th>Count</th>
+        </tr> <?php
+        for ($j = 0; $j < count($types); $j++) {
+          $type = $types[$j];
+          $name = $names[$j];
+          $class = 'tripal_organism-table-odd-row tripal-table-odd-row';
+          if ($i % 2 == 0 ) {
+           $class = 'tripal_organism-table-even-row tripal-table-even-row';
+          }?>
+          <tr class="<?php print $class ?>">
+            <td><span title="<?php print $type->definition ?>"><?php print $name?></span></td>
+            <td><?php print number_format($type->num_features) ?></td>
+          </tr> <?php
+          $i++;  
+        } ?>
+      </table>
+      <img class="tripal_cv_chart" id="tripal_feature_cv_chart_<?php print $organism->organism_id?>" src="" border="0">
+    </div><?php           
+   } 
+   else { 
+    if (user_access('access administration pages')) { ?>
+      <div id="tripal_organism-feature_counts-box" class="tripal_organism-info-box tripal-info-box">
+        <div class="tripal_organism-info-box-title tripal-info-box-title">Data Type Summary</div>
+        <div class="tripal_organism-info-box-desc tripal-info-box-desc">The following data types are currently present for this organism</div>
+        <div class="tripal-no-results">There are no features available.
+           <p><br>Administrators, to view the feature type report:
+           <ul>
+              <li>Populate the <a href="<?php print url('admin/tripal/mviews');?>" target="_blank">organism_feature_count</a> materialized view</li>
+              <li>Refresh this page</li>
+           </ul> 
+           <br><br>To disable this report and remove it from the list of resources:
+           <ul>
+             <li>Navigate to the <a href="<?php print url('admin/tripal/tripal_feature/configuration') ?>">Tripal feature configuration page</a> and hide the "Feature Summary"</li>
+            </ul>
+           </p>
+           This page will not appear to site visitors unless features are present. 
+         </div>
+      </div><?php               
+    }
+  }
+} 
+
+
+

+ 7 - 0
tripal_featuremap/theme/css/tripal_featuremap.css

@@ -0,0 +1,7 @@
+#tripal-featuremap-edit-properties-table {
+  width: auto;
+}
+
+#tripal-featuremap-edit-properties-table .form-item {
+  white-space: normal;
+}

+ 142 - 0
tripal_featuremap/theme/node--chado-featuremap.tpl.php

@@ -0,0 +1,142 @@
+<?php
+// Purpose: This template provides the layout of the featuremap node (page)
+//   using the same templates used for the various featuremap content blocks.
+//
+// To Customize the Libray Node Page:
+//   - This Template: customize basic layout and which elements are included
+//   - Using Panels: Override the node page using Panels3 and place the blocks
+//       of content as you please. This method requires no programming. See
+//       the Tripal User Guide for more details
+//   - Block Templates: customize the content/layout of each block of stock 
+//       content. These templates are found in the tripal_stock subdirectory
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+
+$featuremap  = $variables['node']->featuremap;
+
+// get the template settings
+$template_settings = theme_get_setting('tripal');
+
+// toggle the sidebar if desired
+$no_sidebar = 0;
+if (is_array($template_settings['tripal_no_sidebar']) and 
+   $template_settings['tripal_no_sidebar']['featuremap']) {
+  $no_sidebar = 1;
+}
+
+if ($teaser) { 
+  print theme('tripal_featuremap_teaser',$variables); 
+} 
+else { ?>
+
+<script type="text/javascript">
+(function ($) {
+  Drupal.behaviors.featuremapBehavior = {
+    attach: function (context, settings){ <?php 
+      if ($no_sidebar) { ?>    
+        // hide the resource side bar and strech the details section    
+        $(".tripal_toc").hide();
+        $(".tripal_details").addClass("tripal_details_full");
+        $(".tripal_details_full").removeClass("tripal_details"); <?php
+      } else { ?>
+        // use default resource sidebar
+        $(".tripal-info-box").hide(); <?php
+      } ?>
+ 
+      // iterate through all of the info boxes and add their titles
+      // to the table of contents
+      $(".tripal-info-box-title").each(function(){
+        var parent = $(this).parent();
+        var id = $(parent).attr('id');
+        var title = $(this).text();
+        $('#tripal_featuremap_toc_list').append('<li><a href="#'+id+'" class="tripal_featuremap_toc_item">'+title+'</a></li>');
+      });
+
+      // when a title in the table of contents is clicked, then
+      // show the corresponding item in the details box
+      $(".tripal_featuremap_toc_item").click(function(){
+         $(".tripal-info-box").hide();
+         href = $(this).attr('href');
+         $(href).fadeIn('slow');
+         // we want to make sure our table of contents and the details
+         // box stay the same height
+         $("#tripal_featuremap_toc").height($(href).parent().height());
+         return false;
+      }); 
+
+      // we want the base details to show up when the page is first shown 
+      // unless the user specified a specific block
+      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
+      if(block == null){
+         block = window.location.href.match(/[\?|\&]block=(.+)/)
+      }
+      if(block != null){
+         $("#tripal_featuremap-"+block[1]+"-box").show();
+      } else {
+         $("#tripal_featuremap-base-box").show();
+      }
+
+      $("#tripal_featuremap_toc").height($("#tripal_featuremap-base-box").parent().height());
+    }     
+  };
+})(jQuery);
+</script>
+
+<div id="tripal_featuremap_details" class="tripal_details">
+
+   <!-- Basic Details Theme -->
+   <?php print theme('tripal_featuremap_base',$node); ?>
+   
+   <!-- Map Features -->
+   <?php print theme('tripal_featuremap_featurepos',$node); ?>
+
+   <!-- Properties -->
+   <?php print theme('tripal_featuremap_properties',$node); ?>
+   
+   <!-- Publications -->
+   <?php print theme('tripal_featuremap_publications',$node); ?>
+   
+   <!-- Cross References -->
+   <?php print theme('tripal_featuremap_references',$node); ?>
+
+   <!-- Resource Blocks CCK elements --><?php
+   for($i = 0; $i < count($node->field_resource_titles); $i++){
+     if($node->field_resource_titles[$i]['value']){ ?>
+       <div id="tripal_featuremap-resource_<?php print $i?>-box" class="tripal_featuremap-info-box tripal-info-box">
+         <div class="tripal_featuremap-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
+         <?php print $node->field_resource_blocks[$i]['value']; ?>
+       </div><?php
+     }
+   }?>
+   
+   <!-- Let modules add more content -->
+
+   <?php print $content ?>
+</div>
+
+<!-- Table of contents -->
+<div id="tripal_featuremap_toc" class="tripal_toc">
+   <div id="tripal_featuremap_toc_title" class="tripal_toc_title">Resources</div>
+   <ul id="tripal_featuremap_toc_list" class="tripal_toc_list">
+   
+     <!-- Resource Links CCK elements --><?php
+     for($i = 0; $i < count($node->field_resource_links); $i++){
+       if($node->field_resource_links[$i]['value']){
+         $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
+         <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
+       }
+     }?>
+     
+     <?php // ADD CUSTOMIZED <li> LINKS HERE ?>
+   </ul>
+</div>
+
+<?php } ?>

+ 39 - 0
tripal_featuremap/theme/tripal_featuremap/tripal_featuremap_base.tpl.php

@@ -0,0 +1,39 @@
+<?php
+
+$featuremap  = $variables['node']->featuremap;
+
+// expand the description field
+$featuremap = tripal_core_expand_chado_vars($featuremap, 'field', 'featuremap.description');
+
+?>
+<div id="tripal_featuremap-base-box" class="tripal_featuremap-info-box tripal-info-box">
+  <div class="tripal_featuremap-info-box-title tripal-info-box-title">Map Details</div>
+  <div class="tripal_featuremap-info-box-desc tripal-info-box-desc"></div>
+
+   <table id="tripal_featuremap-base-table" class="tripal_featuremap-table tripal-table tripal-table-vert">
+      <tr class="tripal_featuremap-table-even-row tripal-table-even-row">
+        <th nowrap>Name</th>
+        <td><?php print $featuremap->name; ?></td>
+      </tr>
+      <tr class="tripal_featuremap-table-odd-row tripal-table-odd-row">
+        <th>Map Units</th>
+        <td><?php print $featuremap->unittype_id->name; ?></td>
+      </tr>
+      <tr class="tripal_featuremap-table-even-row tripal-table-even-row">
+        <th>Description</th>
+        <td><?php
+           // right now we only have one property for featuremaps. So we can just
+           // refernece it directly.  If we had more than one property
+           // we would need to convert this to an if statment and loop
+           // until we found the right one.
+           print $featuremap->description?>
+        </td>
+     	</tr>
+     	<!--     
+     	<tr class="tripal_featuremap-table-odd-row tripal-table-odd-row">
+        <th>Internal ID</th>
+        <td><?php print $featuremap->featuremap_id; ?></td>
+      </tr>  
+       -->     	                                
+   </table>
+</div>

+ 126 - 0
tripal_featuremap/theme/tripal_featuremap/tripal_featuremap_featurepos.tpl.php

@@ -0,0 +1,126 @@
+<?php
+$featuremap = $variables['node']->featuremap;
+$feature_positions = array();
+
+// expand the featuremap object to include the records from the featurepos table
+// specify the number of features to show by default and the unique pager ID
+$num_results_per_page = 25; 
+$featurepos_pager_id = 0;
+
+// get the features aligned on this map
+$options = array(  
+  'return_array' => 1,
+  'order_by' => array('map_feature_id' => 'ASC'),
+  'pager' => array('limit' => $num_results_per_page, 'element' => $featurepos_pager_id),
+  'include_fk' => array(
+    'map_feature_id' => array(
+      'type_id' => 1,
+      'organism_id' => 1,
+    ),
+    'feature_id' => array(
+      'type_id' => 1,
+    ),
+    'featuremap_id' => array(
+       'unittype_id' => 1,
+    ),
+  ),
+);
+
+$featuremap = tripal_core_expand_chado_vars($featuremap, 'table', 'featurepos', $options);
+$feature_positions = $featuremap->featurepos;
+
+// create the pager.  
+global $pager_total_items;
+$featurepos_pager = theme('pager', array(), $num_results_per_page, $featurepos_pager_id, array('block' => 'featurepos'));
+$total_features = $pager_total_items[$featurepos_pager_id];
+
+
+if(count($feature_positions) > 0){ ?>
+  <div id="tripal_featuremap-featurepos-box" class="tripal_featuremap-info-box tripal-info-box">
+    <div class="tripal_featuremap-info-box-title tripal-info-box-title">Map Features</div>
+    <div class="tripal_featuremap-info-box-desc tripal-info-box-desc">This Map contains <?php print number_format($total_features) ?> features:</div>
+    <table id="tripal_featuremap-featurepos-table" class="tripal_featuremap-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Landmark</th>
+        <th>Type</th>
+        <th>Organism</th>
+        <th>Feature Name</th>
+        <th>Type</th>
+        <th>Position</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($feature_positions as $position){
+        $map_feature = $position->map_feature_id;
+        $feature = $position->feature_id;  
+        $organism = $map_feature->organism_id; 
+
+        // check if there are any values in the featureposprop table for the start and stop
+        $mappos = $position->mappos;
+        $options = array(
+          'return_array' => 1,
+          'include_fk' => array(
+            'type_id' => 1,            
+          ),
+        );
+        $position = tripal_core_expand_chado_vars($position, 'table', 'featureposprop', $options);
+        $featureposprop = $position->featureposprop;
+        if (is_array($featureposprop)) {
+          foreach ($featureposprop as $index => $property) {
+             if ($property->type_id->name == 'start') {
+               $start = $property->value;
+             }
+             if ($property->type_id->name == 'stop') {
+               $stop = $property->value;
+             }
+          }      
+        }  
+        if ($start and $stop and $start != $stop) {
+          $mappos = "$start-$stop";
+        }
+        if ($start and !$stop) {
+          $mappos = $start;
+        } 
+        if ($start and $stop and $start == $stop) {
+          $mappos = $start;
+        }
+        
+        $class = 'tripal_featuremap-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_featuremap-table-even-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td> <?php 
+            if ($map_feature->nid) { 
+              print l($map_feature->name, 'node/' . $map_feature->nid, array('attributes' => array('target' => '_blank')));
+            } 
+            else { 
+              print $map_feature->name;
+            } ?>
+          </td>          
+          <td><?php print $map_feature->type_id->name ?></td>
+          <td><?php 
+            if ($organism->nid) { 
+              print l($organism->genus . ' ' . $organism->species, 'node/' . $organism->nid, array('attributes' => array('target' => '_blank')));
+            } 
+            else { 
+              print $organism->genus . ' ' . $organism->species;
+            } ?>
+          </td>
+          <td> <?php 
+            if ($feature->nid) { 
+              print l($feature->name, 'node/' . $feature->nid, array('attributes' => array('target' => '_blank')));
+            } 
+            else { 
+              print $feature->name;
+            } ?>
+          </td>
+          <td><?php print $feature->type_id->name ?></td>
+          <td><?php print $mappos ?>&nbsp;<?php print $position->featuremap_id->unittype_id->name ?> </td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table> <?php 
+    print $featurepos_pager ?>
+  </div><?php 
+}?>
+

+ 50 - 0
tripal_featuremap/theme/tripal_featuremap/tripal_featuremap_properties.tpl.php

@@ -0,0 +1,50 @@
+<?php
+
+$featuremap = $node->featuremap;
+
+// expand the featuremap to include the properties.
+$options = array(
+  'return_array' => 1,
+  'order_by' => array('rank' => 'ASC'),
+);
+$featuremap = tripal_core_expand_chado_vars($featuremap, 'table', 'featuremapprop', $options);
+$featuremapprops = $featuremap->featuremapprop;
+$properties = array();
+if (is_array($featuremapprops)) {
+  foreach ($featuremapprops as $property) {
+    // skip the following properties as those are already on other templates
+    if ($property->type_id->name == 'Map Dbxref')  {
+      continue;
+    }
+    $property = tripal_core_expand_chado_vars($property,'field','featuremapprop.value');
+    $properties[] = $property;
+  }
+}
+if(count($properties) > 0){ ?>
+
+  <div id="tripal_featuremap-properties-box" class="tripal_featuremap-info-box tripal-info-box">
+    <div class="tripal_featuremap-info-box-title tripal-info-box-title">Properties</div>
+    <div class="tripal_featuremap-info-box-desc tripal-info-box-desc">Properties for the featuremap '<?php print $node->featuremap->name ?>' include:</div>
+
+    <table class="tripal_featuremap-table tripal-table tripal-table-horz">
+    <tr>
+      <th>Property Name</th>
+      <th>Value</th>
+    </tr>
+	  <?php	// iterate through each property
+		  $i = 0;
+		  foreach ($properties as $result){
+		    $result = tripal_core_expand_chado_vars($result,'field','featuremapprop.value');
+		    $class = 'tripal_featuremap-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_featuremap-table-odd-row tripal-table-even-row';
+        } ?>
+			  <tr class="<?php print $class ?>">
+  			  <td><?php print $result->type_id->name ?></td>
+  			  <td><?php print urldecode($result->value) ?></td>
+  			</tr> <?php
+			  $i++;
+		  } ?>
+		</table>
+  </div> <?php
+}

+ 33 - 0
tripal_featuremap/theme/tripal_featuremap/tripal_featuremap_publication.tpl.php

@@ -0,0 +1,33 @@
+<?php
+$featuremap  = $variables['node']->featuremap;
+
+// expand featuremap to include pubs 
+$featuremap = tripal_core_expand_chado_vars($featuremap, 'table', 'featuremap_pub');
+$pubs = $featuremap->featuremap_pub;
+$pubs = tripal_core_expand_chado_vars($pubs, 'field', 'pub.title', array('return_array' => 1));
+?>
+
+<div id="tripal_featuremap-pub-box" class="tripal_featuremap-info-box tripal-info-box">
+  <div class="tripal_featuremap-info-box-title tripal-info-box-title">Publications</div>
+  <div class="tripal_featuremap-info-box-desc tripal-info-box-desc"></div>
+
+  <table id="tripal_featuremap-pub-table" class="tripal_featuremap-table tripal-table tripal-table-vert" style="border-bottom:solid 2px #999999">
+    <tr>
+      <th>Year</th>
+      <th>Reference</th>
+      <th>Title</th></tr> <?php
+      $i = 0;
+      foreach ($pubs AS $pub) {
+        $class = 'tripal_featuremap-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_featuremap-table-odd-row tripal-table-even-row';
+        } ?>
+    	  <tr class="<?php print $class ?>">
+    	    <td><?php print $pub->pub_id->pyear ?></td>
+    	    <td><?php print $pub->pub_id->uniquename ?></td>
+    	    <td><?php print $pub->pub_id->title ?></td>
+    	  </tr><?php 
+    	  $i++;
+      }  ?>
+  </table>
+</div>

+ 56 - 0
tripal_featuremap/theme/tripal_featuremap/tripal_featuremap_references.tpl.php

@@ -0,0 +1,56 @@
+<?php
+$featuremap = $variables['node']->featuremap;
+$references = array();
+
+// expand the featuremap object to include the records from the featuremap_dbxref table
+$options = array('return_array' => 1);
+$featuremap = tripal_core_expand_chado_vars($featuremap, 'table', 'featuremap_dbxref', $options);
+$featuremap_dbxrefs = $featuremap->featuremap_dbxref;
+if (count($featuremap_dbxrefs) > 0 ) {
+  foreach ($featuremap_dbxrefs as $featuremap_dbxref) {    
+    $references[] = $featuremap_dbxref->dbxref_id;
+  }
+}
+
+if(count($references) > 0){ ?>
+  <div id="tripal_featuremap-references-box" class="tripal_featuremap-info-box tripal-info-box">
+    <div class="tripal_featuremap-info-box-title tripal-info-box-title">Cross References</div>
+    <div class="tripal_featuremap-info-box-desc tripal-info-box-desc">This Map is also available in the following databases:</div>
+    <table id="tripal_featuremap-references-table" class="tripal_featuremap-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Dababase</th>
+        <th>Accession</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($references as $dbxref){         
+        $class = 'tripal_featuremap-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_featuremap-table-even-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td> <?php 
+            if ($dbxref->db_id->url) { 
+              print l($dbxref->db_id->name, $dbxref->db_id->url, array('attributes' => array('target' => '_blank'))) . '<br> ' . $dbxref->db_id->description;             
+            } 
+            else { 
+              print $dbxref->db_id->name . '<br>' . $dbxref->db_id->description;
+            } ?>
+          </td>
+          <td> <?php 
+            if ($dbxref->db_id->urlprefix) { 
+              print l($dbxref->db_id->name . ':' . $dbxref->accession, $dbxref->db_id->urlprefix . $dbxref->accession, array('attributes' => array('target' => '_blank')));
+            } 
+            else { 
+              print $dbxref->db_id->name . ':' . $dbxref->accession; 
+            }
+            if ($dbxref->is_primary) {
+              print " <i>(primary cross-reference)</i>";
+            } ?>
+          </td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table>
+  </div><?php 
+}?>
+

+ 60 - 0
tripal_featuremap/theme/tripal_featuremap/tripal_featuremap_teaser.tpl.php

@@ -0,0 +1,60 @@
+<?php
+
+$featuremap  = $variables['node']->featuremap;
+
+// expand the featuremap to include the properties.
+$featuremap = tripal_core_expand_chado_vars($featuremap,'table','featuremapprop');
+$featuremap = tripal_core_expand_chado_vars($featuremap,'field','featuremapprop.value');
+
+?>
+<div id="tripal_featuremap-base-box" class="tripal_featuremap-info-box tripal-info-box">
+  <div class="tripal_featuremap-info-box-title tripal-info-box-title">featuremap Details</div>
+  <div class="tripal_featuremap-info-box-desc tripal-info-box-desc"></div>
+
+   <?php if(strcmp($featuremap->is_obsolete,'t')==0){ ?>
+      <div class="tripal_featuremap-obsolete">This featuremap is obsolete</div>
+   <?php }?>
+   <table id="tripal_featuremap-base-table" class="tripal_featuremap-table tripal-table tripal-table-vert">
+      <tr class="tripal_featuremap-table-even-row tripal-table-even-row">
+        <th nowrap>Unique Name</th>
+        <td><?php print $featuremap->uniquename; ?></td>
+      </tr>
+      <tr class="tripal_featuremap-table-odd-row tripal-table-odd-row">
+        <th>Internal ID</th>
+        <td><?php print $featuremap->featuremap_id; ?></td>
+      </tr>
+      <tr class="tripal_featuremap-table-even-row tripal-table-even-row">
+        <th>Organism</th>
+        <td>
+          <?php if ($featuremap->organism_id->nid) { 
+      	   print "<a href=\"".url("node/".$featuremap->organism_id->nid)."\">".$featuremap->organism_id->genus ." " . $featuremap->organism_id->species ." (" .$featuremap->organism_id->common_name .")</a>";      	 
+          } else { 
+            print $featuremap->organism_id->genus ." " . $featuremap->organism_id->species ." (" .$featuremap->organism_id->common_name .")";
+          } ?>
+        </td>
+      </tr>      
+      <tr class="tripal_featuremap-table-odd-row tripal-table-odd-row">
+        <th>Type</th>
+        <td><?php 
+            if ($featuremap->type_id->name == 'cdna_featuremap') {
+               print 'cDNA';
+            } else if ($featuremap->type_id->name == 'bac_featuremap') {
+               print 'BAC';
+            } else {
+               print $featuremap->type_id->name;
+            }
+          ?>
+        </td>
+      </tr>
+      <tr class="tripal_featuremap-table-even-row tripal-table-even-row">
+        <th>Description</th>
+        <td><?php
+           // right now we only have one property for libraries. So we can just
+           // refernece it directly.  If we had more than one property
+           // we would need to convert this to an if statment and loop
+           // until we found the right one.
+           print $featuremap->featuremapprop->value?>
+        </td>
+     	</tr>           	                                
+   </table>
+</div>

+ 142 - 0
tripal_library/theme/node--chado-library.tpl.php

@@ -0,0 +1,142 @@
+<?php
+// Purpose: This template provides the layout of the library node (page)
+//   using the same templates used for the various library content blocks.
+//
+// To Customize the Libray Node Page:
+//   - This Template: customize basic layout and which elements are included
+//   - Using Panels: Override the node page using Panels3 and place the blocks
+//       of content as you please. This method requires no programming. See
+//       the Tripal User Guide for more details
+//   - Block Templates: customize the content/layout of each block of stock 
+//       content. These templates are found in the tripal_stock subdirectory
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+
+$library  = $variables['node']->library;
+
+// get the template settings
+$template_settings = theme_get_setting('tripal');
+
+// toggle the sidebar if desired
+$no_sidebar = 0;
+if (is_array($template_settings['tripal_no_sidebar']) and 
+   $template_settings['tripal_no_sidebar']['library']) {
+  $no_sidebar = 1;
+}
+
+if ($teaser) { 
+  print theme('tripal_library_teaser',$variables); 
+} 
+else { ?>
+
+<script type="text/javascript">
+(function ($) {
+  Drupal.behaviors.libraryBehavior = {
+	attach: function (context, settings){ <?php 
+	  if ($no_sidebar) { ?>    
+        // hide the resource side bar and strech the details section    
+        $(".tripal_toc").hide();
+        $(".tripal_details").addClass("tripal_details_full");
+        $(".tripal_details_full").removeClass("tripal_details"); <?php
+      } else { ?>
+        // use default resource sidebar
+        $(".tripal-info-box").hide(); <?php
+      } ?>
+ 
+      // iterate through all of the info boxes and add their titles
+      // to the table of contents
+      $(".tripal-info-box-title").each(function(){
+        var parent = $(this).parent();
+        var id = $(parent).attr('id');
+        var title = $(this).text();
+        $('#tripal_library_toc_list').append('<li><a href="#'+id+'" class="tripal_library_toc_item">'+title+'</a></li>');
+      });
+
+      // when a title in the table of contents is clicked, then
+      // show the corresponding item in the details box
+      $(".tripal_library_toc_item").click(function(){
+         $(".tripal-info-box").hide();
+         href = $(this).attr('href');
+         $(href).fadeIn('slow');
+         // we want to make sure our table of contents and the details
+         // box stay the same height
+         $("#tripal_library_toc").height($(href).parent().height());
+         return false;
+      }); 
+
+      // we want the base details to show up when the page is first shown 
+      // unless the user specified a specific block
+      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
+      if(block == null){
+         block = window.location.href.match(/[\?|\&]block=(.+)/)
+      }
+      if(block != null){
+         $("#tripal_library-"+block[1]+"-box").show();
+      } else {
+         $("#tripal_library-base-box").show();
+      }
+
+      $("#tripal_library_toc").height($("#tripal_library-base-box").parent().height());
+    }     
+  };
+})(jQuery);
+</script>
+
+<div id="tripal_library_details" class="tripal_details">
+
+   <!-- Basic Details Theme -->
+   <?php print theme('tripal_library_base',$node); ?>
+
+   <!-- External References -->
+   <?php print theme('tripal_library_references',$node); ?>
+
+   <!-- Properties -->
+   <?php print theme('tripal_library_properties',$node); ?>
+   
+   <!-- Terms -->
+   <?php print theme('tripal_library_terms',$node); ?>
+
+   <!-- Synonyms -->
+   <?php print theme('tripal_library_synonyms',$node); ?>
+
+   <!-- Resource Blocks CCK elements --><?php
+   for($i = 0; $i < count($node->field_resource_titles); $i++){
+     if($node->field_resource_titles[$i]['value']){ ?>
+       <div id="tripal_library-resource_<?php print $i?>-box" class="tripal_library-info-box tripal-info-box">
+         <div class="tripal_library-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
+         <?php print $node->field_resource_blocks[$i]['value']; ?>
+       </div><?php
+     }
+   }?>
+   
+   <!-- Let modules add more content -->
+
+   <?php print $content ?>
+</div>
+
+<!-- Table of contents -->
+<div id="tripal_library_toc" class="tripal_toc">
+   <div id="tripal_library_toc_title" class="tripal_toc_title">Resources</div>
+   <ul id="tripal_library_toc_list" class="tripal_toc_list">
+   
+     <!-- Resource Links CCK elements --><?php
+     for($i = 0; $i < count($node->field_resource_links); $i++){
+       if($node->field_resource_links[$i]['value']){
+         $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
+         <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
+       }
+     }?>
+     
+     <?php // ADD CUSTOMIZED <li> LINKS HERE ?>
+   </ul>
+</div>
+
+<?php } ?>

+ 54 - 0
tripal_library/theme/tripal_library/tripal_library_base.tpl.php

@@ -0,0 +1,54 @@
+<?php
+
+$library  = $variables['node']->library;
+
+// expand the library to include the properties so that we can get the description
+$library = tripal_core_expand_chado_vars($library,'table','libraryprop', array('return_array' => 1));  
+$libraryprops = $library->libraryprop;
+if (count($libraryprops) > 0){ 
+  foreach ($libraryprops as $property) {
+    if($property->type_id->name == 'library_description') {
+      $property = tripal_core_expand_chado_vars($property,'field','libraryprop.value');
+      $library_description = $property->value;      
+    }
+  }
+}
+
+?>
+<div id="tripal_library-base-box" class="tripal_library-info-box tripal-info-box">
+  <div class="tripal_library-info-box-title tripal-info-box-title">Library Details</div>
+  <div class="tripal_library-info-box-desc tripal-info-box-desc"></div>
+
+   <?php if(strcmp($library->is_obsolete,'t')==0){ ?>
+      <div class="tripal_library-obsolete">This library is obsolete</div>
+   <?php }?>
+   <table id="tripal_library-base-table" class="tripal_library-table tripal-table tripal-table-vert">
+      <tr class="tripal_library-table-even-row tripal-table-even-row">
+        <th nowrap>Unique Name</th>
+        <td><?php print $library->uniquename; ?></td>
+      </tr>
+      <tr class="tripal_library-table-odd-row tripal-table-odd-row">
+        <th>Internal ID</th>
+        <td><?php print $library->library_id; ?></td>
+      </tr>
+      <tr class="tripal_library-table-even-row tripal-table-even-row">
+        <th>Organism</th>
+        <td>
+          <?php if ($library->organism_id->nid) { 
+      	   print "<a href=\"".url("node/".$library->organism_id->nid)."\">".$library->organism_id->genus ." " . $library->organism_id->species ." (" .$library->organism_id->common_name .")</a>";      	 
+          } else { 
+            print $library->organism_id->genus ." " . $library->organism_id->species ." (" .$library->organism_id->common_name .")";
+          } ?>
+        </td>
+      </tr>      
+      <tr class="tripal_library-table-odd-row tripal-table-odd-row">
+        <th>Type</th>
+        <td><?php print $library->type_id->definition ?></td>
+      </tr>
+      <tr class="tripal_library-table-even-row tripal-table-even-row">
+        <th>Description</th>
+        <td><?php print $library_description ?>
+        </td>
+     	</tr>           	                                
+   </table>
+</div>

+ 44 - 0
tripal_library/theme/tripal_library/tripal_library_properties.tpl.php

@@ -0,0 +1,44 @@
+<?php
+$library = $node->library;
+
+// expand the library to include the properties.
+$library = tripal_core_expand_chado_vars($library, 'table', 'libraryprop', array('return_array' => 1));
+$libraryprops = $library->libraryprop;
+$properties = array();
+
+if (count($libraryprops) > 0) {
+  foreach ($libraryprops as $property) {
+    // we want to keep all properties but the library_description as that
+    // property is shown on the base template page.
+    if($property->type_id->name != 'library_description') {
+      $property = tripal_core_expand_chado_vars($property,'field','libraryprop.value');
+      $properties[] = $property;
+    }
+  }
+}
+
+if (count($properties) > 0) { ?>
+  <div id="tripal_library-properties-box" class="tripal_library-info-box tripal-info-box">
+    <div class="tripal_library-info-box-title tripal-info-box-title">Properties</div>
+    <div class="tripal_library-info-box-desc tripal-info-box-desc">Properties for this library include:</div>
+    <table class="tripal_library-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Property Name</th>
+        <th>Value</th>
+      </tr> <?php
+      $i = 0;
+      foreach ($properties as $property) {
+        $class = 'tripal_library-table-odd-row tripal-table-odd-row';
+        if ($i % 2 == 0 ) {
+           $class = 'tripal_library-table-odd-row tripal-table-even-row';
+        }
+        $i++; 
+        ?>
+        <tr class="<?php print $class ?>">
+          <td><?php print ucfirst(preg_replace('/_/', ' ', $property->type_id->name)) ?></td>
+          <td><?php print $property->value ?></td>
+        </tr><?php 
+      } ?>
+    </table>
+  </div> <?php
+}

+ 49 - 0
tripal_library/theme/tripal_library/tripal_library_references.tpl.php

@@ -0,0 +1,49 @@
+<?php
+$library = $variables['node']->library;
+
+// expand the library object to include the external references stored
+// in the library_dbxref table
+$options = array('return_array' => 1);
+$library = tripal_core_expand_chado_vars($library,'table','library_dbxref', $options);
+$references = $library->library_dbxref;
+
+
+if(count($references) > 0){ ?>
+  <div id="tripal_library-references-box" class="tripal_library-info-box tripal-info-box">
+    <div class="tripal_library-info-box-title tripal-info-box-title">Cross References</div>
+    <div class="tripal_library-info-box-desc tripal-info-box-desc">External references for this <?php print $library->type_id->name ?> library</div>
+    <table id="tripal_library-references-table" class="tripal_library-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Dababase</th>
+        <th>Accession</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($references as $library_dbxref) { 
+        $dbxref = $library_dbxref->dbxref_id;
+        $class = 'tripal_library-table-odd-row tripal-table-odd-row';
+        if ($i % 2 == 0 ) {
+           $class = 'tripal_library-table-odd-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td> <?php 
+            if ($dbxref->db_id->url) { 
+              print l($dbxref->db_id->name, $dbxref->db_id->url);
+            } 
+            else { 
+              print $dbxref->db_id->name; 
+            } ?>
+          </td>
+          <td> <?php 
+            if ($dbxref->db_id->urlprefix) { 
+              print l($dbxref->accession, $dbxref->db_id->urlprefix.$dbxref->accession);
+            } 
+            else { 
+              print $dbxref->accession; 
+            } ?>
+          </td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table>
+  </div><?
+}

+ 31 - 0
tripal_library/theme/tripal_library/tripal_library_synonyms.tpl.php

@@ -0,0 +1,31 @@
+<?php
+$library = $variables['node']->library;
+
+// expand the library object to include the synonyms from the library_synonym 
+// table in chado.
+$options = array('return_array' => 1); 
+$library = tripal_core_expand_chado_vars($library,'table','library_synonym', $options);
+$synonyms = $library->library_synonym;
+
+if (count($synonyms) > 0) { ?>
+  <div id="tripal_library-synonyms-box" class="tripal_library-info-box tripal-info-box">
+    <div class="tripal_library-info-box-title tripal-info-box-title">Synonyms</div>
+    <div class="tripal_library-info-box-desc tripal-info-box-desc">The library '<?php print $library->name ?>' has the following synonyms</div>
+    <table id="tripal_library-synonyms-table" class="tripal_library-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Synonym</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($synonyms as $library_synonym) {
+        $class = 'tripal-table-odd-row';
+        if ($i % 2 == 0 ) {
+          $class = 'tripal-table-even-row';
+        }?>
+        <tr class="<?php print $class ?>">
+          <td> <?php print $library_synonym->synonym_id->name?></td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table>
+  </div> <?php 
+}

+ 54 - 0
tripal_library/theme/tripal_library/tripal_library_teaser.tpl.php

@@ -0,0 +1,54 @@
+<?php
+
+$library  = $variables['node']->library;
+
+// expand the library to include the properties so that we can get the description
+$library = tripal_core_expand_chado_vars($library,'table','libraryprop', array('return_array' => 1));  
+$libraryprops = $library->libraryprop;
+if (count($libraryprops) > 0){ 
+  foreach ($libraryprops as $property) {
+    if($property->type_id->name == 'library_description') {
+      $property = tripal_core_expand_chado_vars($property,'field','libraryprop.value');
+      $library_description = $property->value;      
+    }
+  }
+}
+
+?>
+<div id="tripal_library-base-box" class="tripal_library-info-box tripal-info-box">
+  <div class="tripal_library-info-box-title tripal-info-box-title">Library Details</div>
+  <div class="tripal_library-info-box-desc tripal-info-box-desc"></div>
+
+   <?php if(strcmp($library->is_obsolete,'t')==0){ ?>
+      <div class="tripal_library-obsolete">This library is obsolete</div>
+   <?php }?>
+   <table id="tripal_library-base-table" class="tripal_library-table tripal-table tripal-table-vert">
+      <tr class="tripal_library-table-even-row tripal-table-even-row">
+        <th nowrap>Unique Name</th>
+        <td><?php print $library->uniquename; ?></td>
+      </tr>
+      <tr class="tripal_library-table-odd-row tripal-table-odd-row">
+        <th>Internal ID</th>
+        <td><?php print $library->library_id; ?></td>
+      </tr>
+      <tr class="tripal_library-table-even-row tripal-table-even-row">
+        <th>Organism</th>
+        <td>
+          <?php if ($library->organism_id->nid) { 
+           print "<a href=\"".url("node/".$library->organism_id->nid)."\">".$library->organism_id->genus ." " . $library->organism_id->species ." (" .$library->organism_id->common_name .")</a>";         
+          } else { 
+            print $library->organism_id->genus ." " . $library->organism_id->species ." (" .$library->organism_id->common_name .")";
+          } ?>
+        </td>
+      </tr>      
+      <tr class="tripal_library-table-odd-row tripal-table-odd-row">
+        <th>Type</th>
+        <td><?php print $library->type_id->definition ?></td>
+      </tr>
+      <tr class="tripal_library-table-even-row tripal-table-even-row">
+        <th>Description</th>
+        <td><?php print $library_description ?>
+        </td>
+      </tr>                                             
+   </table>
+</div>

+ 51 - 0
tripal_library/theme/tripal_library/tripal_library_terms.tpl.php

@@ -0,0 +1,51 @@
+<?php
+
+$library = $node->library;
+
+// expand the library object to inlucde the records from the library_cvterm table
+$options = array('return_array' => 1);
+$library = tripal_core_expand_chado_vars($library, 'table', 'library_cvterm', $options);
+$terms = $library->library_cvterm;
+
+// re-organize the terms by CV
+$s_terms = array();
+if (count($terms) > 0) {
+  foreach ($terms as $term) {
+    $s_terms[$term->cvterm_id->cv_id->name][] = $term;  
+  }
+}
+
+if (count($s_terms) > 0) { ?>
+  <div id="tripal_library-terms-box" class="tripal_library-info-box tripal-info-box">
+    <div class="tripal_library-info-box-title tripal-info-box-title">Annotated Terms</div>
+    <div class="tripal_library-info-box-desc tripal-info-box-desc">The following terms have been associated with this <?php print $node->library->type_id->name ?>:</div>  <?php
+    // iterate through each term
+    foreach ($s_terms as $cv => $terms) {  ?>
+      <p><?php print ucwords(preg_replace('/_/', ' ', $cv)) ?></p>
+      <table class="tripal_library-table tripal-table tripal-table-horz">
+        <tr>
+          <th>Term</th>
+          <th>Definition</th>
+        </tr> <?php
+        $i = 0;
+        foreach ($terms as $term) { 
+          $class = 'tripal_library-table-odd-row tripal-table-odd-row';
+          if($i % 2 == 0 ){
+            $class = 'tripal_library-table-even-row tripal-table-even-row';
+          }
+          $accession = $term->cvterm_id->dbxref_id->accession;
+          if (is_numeric($term->cvterm_id->dbxref_id->accession)) {
+            $accession = $term->cvterm_id->dbxref_id->db_id->name . ":" . $term->cvterm_id->dbxref_id->accession;
+          }
+          if ($term->cvterm_id->dbxref_id->db_id->urlprefix) {
+            $accession =  "<a href=\"" . $term->cvterm_id->dbxref_id->db_id->urlprefix . "$accession\" target=\"_blank\">$accession</a>";
+          } ?>
+          <tr class="<?php print $class ?>">
+            <td><?php print $accession ?></td>
+            <td><?php print $term->cvterm_id->name ?></td>
+          </tr> <?php
+        } ?>
+      </table> <?php
+  } ?>
+  </div> <?php
+} ?>

+ 35 - 0
tripal_organism/theme/css/tripal_organism.css

@@ -0,0 +1,35 @@
+
+#tripal_organism-image-box {
+   float: left;
+   margin-left: 10px;
+   margin-bottom: 10px;
+   margin-right: 10px;
+   width: auto;
+}
+#tripal_organism-image-box img {
+   max-height: 200px;
+}
+
+#tripal_organism-base-box {
+   float: left;
+}
+#tripal_organism-description-box {
+   clear: left;
+   width: auto;
+}
+
+#tripal_organism-base-box img {
+ float: left;
+ margin-bottom: 5px;
+ margin-right: 10px;
+ margin-top: 5px;
+
+}
+#tripal_organism-table-base {
+ width: auto;
+ margin-bottom: 10px;
+ min-width: 300px;
+ margin-top: 0px;
+
+}
+

+ 147 - 0
tripal_organism/theme/node--chado-organism.tpl.php

@@ -0,0 +1,147 @@
+<?php
+// Purpose: This template provides the layout of the organism node (page)
+//   using the same templates used for the various feature content blocks.
+//
+// To Customize the Featture Node Page:
+//   - This Template: customize basic layout and which elements are included
+//   - Using Panels: Override the node page using Panels3 and place the blocks
+//       of content as you please. This method requires no programming. See
+//       the Tripal User Guide for more details
+//   - Block Templates: customize the content/layout of each block of stock 
+//       content. These templates are found in the tripal_stock subdirectory
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+
+$organism  = $variables['node']->organism;
+
+// get the template settings
+$template_settings = theme_get_setting('tripal');
+
+// toggle the sidebar if desired
+$no_sidebar = 0;
+if (is_array($template_settings['tripal_no_sidebar']) and 
+   $template_settings['tripal_no_sidebar']['organism']) {
+  $no_sidebar = 1;
+}
+
+if ($teaser) { 
+  print theme('tripal_organism_teaser', $variables); 
+} 
+else { ?>
+
+<script type="text/javascript">
+(function ($) {
+  Drupal.behaviors.organismBehavior = {
+    attach: function (context, settings){<?php 
+      if ($no_sidebar) { ?>    
+        // hide the resource side bar and strech the details section    
+        $(".tripal_toc").hide();
+        $(".tripal_details").addClass("tripal_details_full");
+        $(".tripal_details_full").removeClass("tripal_details"); <?php
+      } else { ?>
+        // use default resource sidebar
+        $(".tripal-info-box").hide(); <?php
+      } ?>
+ 
+      // iterate through all of the info boxes and add their titles
+      // to the table of contents
+      $(".tripal-info-box-title").each(function(){
+        var parent = $(this).parent();
+        var id = $(parent).attr('id');
+        var title = $(this).text();
+        $('#tripal_organism_toc_list').append('<li><a href="#'+id+'" class="tripal_organism_toc_item">'+title+'</a></li>');
+      });
+
+      // when a title in the table of contents is clicked, then
+      // show the corresponding item in the details box
+      $(".tripal_organism_toc_item").click(function(){
+         $(".tripal-info-box").hide();
+         href = $(this).attr('href');
+         if(href.match(/^#/)){
+            //alert("correct: " + href);
+         }
+         else{
+            tmp = href.replace(/^.*?#/, "#");
+            href = tmp;
+            //alert("fixed: " + href);
+         }
+         $(href).fadeIn('slow');
+         // we want to make sure our table of contents and the details
+         // box stay the same height
+         $("#tripal_organism_toc").height($(href).parent().height());
+         return false;
+      }); 
+
+      // we want the base details to show up when the page is first shown 
+      // unless we're using the feature browser then we want that page to show
+      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
+      if(block == null){
+         block = window.location.href.match(/[\?|\&]block=(.+)/)
+      }
+      if(block != null){
+         $("#tripal_organism-"+block[1]+"-box").show();
+      } 
+      else if(window.location.href.match(/\?page=\d+/)){
+         $("#tripal_organism-feature_browser-box").show();
+      } 
+      else {
+         $("#tripal_organism-base-box").show();
+      }
+
+      $("#tripal_organism_toc").height($("#tripal_organism-base-box").parent().height());
+    }     
+  };
+})(jQuery);
+</script>
+
+<div id="tripal_organism_details" class="tripal_details">
+
+   <!-- Basic Details Theme -->
+   <?php print theme('tripal_organism_base', $variables); ?>
+   
+   <!-- Resource Blocks CCK elements --> <?php
+   if(property_exists($node, 'field_resource_titles')) {
+	   for($i = 0; $i < count($node->field_resource_titles); $i++){
+	     if($node->field_resource_titles[$i]['value']){ ?>
+	       <div id="tripal_organism-resource_<?php print $i?>-box" class="tripal_organism-info-box tripal-info-box">
+	         <div class="tripal_organism-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
+	         <?php print $node->field_resource_blocks[$i]['value']; ?>
+	       </div> <?php
+	     }
+	   } 
+	 }?>
+   <!-- Let modules add more content -->
+   <?php print $content ?>
+   
+</div>
+
+<!-- Table of contents -->
+<div id="tripal_organism_toc" class="tripal_toc">
+   <div id="tripal_organism_toc_title" class="tripal_toc_title">Resources</i></div>
+   <span id="tripal_organism_toc_desc" class="tripal_toc_desc"></span>
+   <ul id="tripal_organism_toc_list" class="tripal_toc_list">
+   
+     <!-- Resource Links CCK elements --><?php
+     if(property_exists($node, 'field_resource_links')) {
+	     for($i = 0; $i < count($node->field_resource_links); $i++){
+	       if($node->field_resource_links[$i]['value']){
+	         $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
+	         <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
+	       }
+	     }
+     }
+     
+     // ADD CUSTOMIZED <li> LINKS HERE 
+     ?> 
+   </ul>
+</div> <?php 
+} ?>
+

+ 95 - 0
tripal_organism/theme/tripal_organism/tripal_organism_base.tpl.php

@@ -0,0 +1,95 @@
+<?php
+// the comment field is a database text field so we have to expand it so that
+// it is included in the organism object
+$organism = tripal_core_expand_chado_vars($organism,'field','organism.comment');
+ 
+?>
+<div id="tripal_organism-base-box" class="tripal_organism-info-box tripal-info-box">
+  <div class="tripal_organism-info-box-title tripal-info-box-title">Details</div>
+  <!--  <div class="tripal_organism-info-box-desc tripal-info-box-desc"></div> --><?php      
+  
+  // generate the image tag
+  $image = '';
+  $image_url = tripal_organism_get_image_url($organism, $node->nid); 
+  if ($image_url) {
+    $image = "<img src=\"$image_url\">";
+  }
+  
+  // the $headers array is an array of fields to use as the colum headers. 
+  // additional documentation can be found here 
+  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+  // This table for the organism has a vertical header (down the first column)
+  // so we do not provide headers here, but specify them in the $rows array below.
+  $headers = array();
+  
+  // the $rows array contains an array of rows where each row is an array
+  // of values for each column of the table in that row.  Additional documentation
+  // can be found here:
+  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7 
+  $rows = array();
+  
+  // common name row
+  $rows[] = array(
+    array(
+      'data' => 'Common Name', 
+      'header' => TRUE
+    ), 
+    $organism->common_name,
+  );
+  
+  // genus row
+  $rows[] = array(
+    array(
+      'data' => 'Genus', 
+      'header' => TRUE
+    ),
+    '<i>' . $organism->genus . '</i>'
+  );
+  
+  // species row
+  $rows[] = array(
+    array(
+      'data' => 'Species', 
+      'header' => TRUE
+    ), 
+    '<i>' . $organism->species . '</i>'
+  );
+  
+  // abbreviation row
+  $rows[] = array(
+    array(
+      'data' => 'Abbreviation', 
+      'header' => TRUE
+    ),
+    $organism->abbreviation
+  );
+  
+  // photo and description row (spans both colums)
+  $rows[] = array(
+    array(
+      'data' => $image . $organism->comment, 
+      'colspan' => 2
+    ),
+  );
+  
+  // the $table array contains the headers and rows array as well as other
+  // options for controlling the display of the table.  Additional 
+  // documentation can be found here:
+  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+  $table = array(
+    'header' => $headers, 
+    'rows' => $rows, 
+    'attributes' => array(
+      'id' => 'tripal_organism-table-base',
+      'class' => 'tripal-table',
+    ), 
+    'sticky' => FALSE,
+    'caption' => '',
+    'colgroups' => array(), 
+    'empty' => '', 
+  ); 
+  
+  // once we have our table array structure defined, we call Drupal's theme_table()
+  // function to generate the table.
+  print theme_table($table); ?>
+</div>

+ 11 - 0
tripal_organism/theme/tripal_organism/tripal_organism_description.tpl.php

@@ -0,0 +1,11 @@
+<?php
+$organism = $variables['node']->organism;
+?>
+<div id="tripal_organism-description-box" class="tripal_organism-info-box tripal-info-box">
+  <div class="tripal_organism-info-box-title tripal-info-box-title">Organism Description</div>
+   <table id="tripal_organism-table-description" class="tripal_organism-table tripal-table tripal-table-horz">
+      <tr class="tripal_organism-table-odd-row tripal-table-even-row">
+        <td><?php print $organism->comment; ?></td>
+      </tr>        	                                
+   </table>
+</div>

+ 20 - 0
tripal_organism/theme/tripal_organism/tripal_organism_image.tpl.php

@@ -0,0 +1,20 @@
+<?php
+$node = $variables['node'];
+$organism = $variables['node']->organism;
+
+?>
+<div id="tripal_organism-image-box" class="tripal_organism-info-box tripal-info-box">
+  <div class="tripal_analysis_interpro-info-box-title tripal-info-box-title"><?php $organism->genus." ".$organism->species?> Image</div>
+  <div class="tripal_analysis_interpro-info-box-desc tripal-info-box-desc"></div>
+  <img src="<?php 
+      $image_name = $organism->genus."_".$organism->species.".jpg";
+      $image_dir = file_directory_path() . "/tripal/tripal_organism/images";
+      $files = file_scan_directory($image_dir,$image_name);
+      if(sizeof($files) > 0){
+         print file_create_url("$image_dir/$image_name"); 
+      } else {
+         $image_file = file_directory_path() . "/tripal/tripal_organism/images/".$node->nid.".jpg";
+         print file_create_url($image_file); 
+      }
+   ?>"> 
+</div>

+ 74 - 0
tripal_organism/theme/tripal_organism/tripal_organism_libraries.tpl.php

@@ -0,0 +1,74 @@
+<?php
+$organism = $variables['node']->organism;
+
+// expand the organism object to include the libraries from the library
+// table in chado.
+$organism = tripal_core_expand_chado_vars($organism,'table','library');
+
+
+// get the references. if only one reference exists then we want to convert
+// the object into an array, otherwise the value is an array
+$libraries = $organism->library;
+if (!$libraries) {
+   $libraries = array();
+} 
+elseif (!is_array($libraries)) { 
+   $libraries = array($libraries); 
+}
+
+if (count($libraries) > 0) {?>
+  <div id="tripal_organism-library_list-box" class="tripal_organism-info-box tripal-info-box">
+    <div class="tripal_organism-info-box-title tripal-info-box-title">Libraries</div>
+    <div class="tripal_organism-info-box-desc tripal-info-box-desc">The following libraries are associated with this organism.</div>
+    <table id="tripal_organism-table-library_list" class="tripal_organism-table tripal-table tripal-table-horz">     
+      <tr class="tripal_organism-table-odd-row tripal-table-even-row">
+        <th>Library Name</th>
+        <th>Description</th>
+        <th>Type</th>
+      </tr> <?php
+      foreach ($libraries as $library){ 
+        // expand the library to include the properties.
+        $library = tripal_core_expand_chado_vars($library,'table','libraryprop');
+        $library = tripal_core_expand_chado_vars($library,'field','libraryprop.value');
+        $class = 'tripal_organism-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+          $class = 'tripal_organism-table-odd-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td><?php 
+            if($library->nid){    
+              $link =  url("node/$library->nid");        
+              print "<a href=\"$link\">$library->name</a>";
+            } 
+            else {
+              print $library->name;
+            } ?>
+          </td>
+          <td><?php 
+            // right now we only have one property for libraries. So we can just
+            // refernece it directly.  If we had more than one property
+            // we would need to convert this to an if statment and loop
+            // until we found the right one.
+            print $library->libraryprop->value?>
+          </td>
+          <td> <?php 
+            if ($library->type_id->name == 'cdna_library') {
+              print 'cDNA';
+            } 
+            else if ($library->type_id->name == 'bac_library') {
+              print 'BAC';
+            } 
+            else {
+              print $library->type_id->name;
+            }?>
+          </td>
+        </tr> <?php
+        $i++; 
+      }?>  
+    </table> 
+  </div><?php
+}
+
+
+
+

+ 66 - 0
tripal_organism/theme/tripal_organism/tripal_organism_stocks.tpl.php

@@ -0,0 +1,66 @@
+<?php
+$organism = $variables['node']->organism;
+
+// expand the featuremap object to include the records from the featurepos table
+// specify the number of features to show by default and the unique pager ID
+$num_results_per_page = 25; 
+$pager_id = 3;
+
+// get the features aligned on this map
+$options = array(  
+  'return_array' => 1,
+  'order_by' => array('name' => 'ASC'),
+  'pager' => array('limit' => $num_results_per_page, 'element' => $pager_id),
+  'include_fk' => array(
+    'type_id' => 1    
+  ),
+);
+
+$organism = tripal_core_expand_chado_vars($organism, 'table', 'stock', $options);
+$stocks = $organism->stock;
+
+// create the pager.  
+global $pager_total_items;
+$pager = theme('pager', array(), $num_results_per_page, $pager_id, array('block' => 'stocks'));
+$total_features = $pager_total_items[$pager_id];
+
+ 
+if (count($stocks) > 0) { ?>
+  <div id="tripal_organism-stocks-box" class="tripal_organism-info-box tripal-info-box">
+    <div class="tripal_organism-info-box-title tripal-info-box-title">Stocks</div>
+    <div class="tripal_organism-info-box-desc tripal-info-box-desc">This organism is associated with <?php print number_format($total_features) ?> stock(s):</div>
+    
+    <table id="tripal_organism-table-stocks" class="tripal_organism-table tripal-table tripal-table-horz">     
+      <tr class="tripal_organism-table-odd-row tripal-table-even-row">
+        <th>Name</th>
+        <th>Type</th>
+      </tr> <?php
+      foreach ($stocks as $stock){ 
+        $class = 'tripal_organism-table-odd-row tripal-table-odd-row';
+        if ($i % 2 == 0 ) {
+          $class = 'tripal_organism-table-odd-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td><?php
+            $name = $stock->name;
+            if (!$stock->name) {
+            	$name = $stock->uniquename;
+            }
+            if ($stock->nid) {    
+              print l($name, "node/$stock->nid", array('attributes' => array('target' => '_blank')));        
+            } else {
+              print $name;
+            }?>
+          </td>
+          <td><?php print $stock->type_id->name?></td>
+        </tr><?php
+        $i++;  
+      } ?>
+    </table>
+    <?php print $pager ?>
+  </div> <?php
+} 
+
+
+
+

+ 9 - 0
tripal_organism/theme/tripal_organism/tripal_organism_teaser.tpl.php

@@ -0,0 +1,9 @@
+<?php
+
+$image_url = tripal_organism_get_image_url($organism, $node->nid); ?>
+
+<div style="clear:both">
+  <a href="<?php print url("node/" . $node->nid) ?>"><?php print $organism->genus. " " . $organism->species . ", " . $organism->common_name; ?></a>
+  <img src="<?php print $image_url ?>" width="100px" height="100px" style="float: left; padding-right: 10px; padding-bottom: 5px;">   
+  <?php print $organism->comment; ?>
+</div>

+ 142 - 0
tripal_project/theme/node--chado-project.tpl.php

@@ -0,0 +1,142 @@
+<?php
+// Purpose: This template provides the layout of the project node (page)
+//   using the same templates used for the various project content blocks.
+//
+// To Customize the Libray Node Page:
+//   - This Template: customize basic layout and which elements are included
+//   - Using Panels: Override the node page using Panels3 and place the blocks
+//       of content as you please. This method requires no programming. See
+//       the Tripal User Guide for more details
+//   - Block Templates: customize the content/layout of each block of stock 
+//       content. These templates are found in the tripal_stock subdirectory
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+
+$project  = $variables['node']->project;
+
+// get the template settings
+$template_settings = theme_get_setting('tripal');
+
+// toggle the sidebar if desired
+$no_sidebar = 0;
+if (is_array($template_settings['tripal_no_sidebar']) and 
+   $template_settings['tripal_no_sidebar']['project']) {
+  $no_sidebar = 1;
+}
+
+if ($teaser) { 
+  print theme('tripal_project_teaser',$node); 
+} 
+else { ?>
+
+<script type="text/javascript">
+(function ($) {
+  Drupal.behaviors.projectBehavior = {
+    attach: function (context, settings){ <?php 
+      if ($no_sidebar) { ?>    
+        // hide the resource side bar and strech the details section    
+        $(".tripal_toc").hide();
+        $(".tripal_details").addClass("tripal_details_full");
+        $(".tripal_details_full").removeClass("tripal_details"); <?php
+      } else { ?>
+        // use default resource sidebar
+        $(".tripal-info-box").hide(); <?php
+      } ?>
+ 
+      // iterate through all of the info boxes and add their titles
+      // to the table of contents
+      $(".tripal-info-box-title").each(function(){
+        var parent = $(this).parent();
+        var id = $(parent).attr('id');
+        var title = $(this).text();
+        $('#tripal_project_toc_list').append('<li><a href="#'+id+'" class="tripal_project_toc_item">'+title+'</a></li>');
+      });
+
+      // when a title in the table of contents is clicked, then
+      // show the corresponding item in the details box
+      $(".tripal_project_toc_item").click(function(){
+         $(".tripal-info-box").hide();
+         href = $(this).attr('href');
+         $(href).fadeIn('slow');
+         // we want to make sure our table of contents and the details
+         // box stay the same height
+         $("#tripal_project_toc").height($(href).parent().height());
+         return false;
+      }); 
+
+      // we want the base details to show up when the page is first shown 
+      // unless the user specified a specific block
+      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
+      if(block == null){
+         block = window.location.href.match(/[\?|\&]block=(.+)/)
+      }
+      if(block != null){
+         $("#tripal_project-"+block[1]+"-box").show();
+      } else {
+         $("#tripal_project-base-box").show();
+      }
+
+      $("#tripal_project_toc").height($("#tripal_project-base-box").parent().height());
+    }     
+  };
+})(jQuery);
+</script>
+
+<div id="tripal_project_details" class="tripal_details">
+
+   <!-- Basic Details Theme -->
+   <?php print theme('tripal_project_base',$node); ?>
+   
+   <!-- Properties Theme -->
+   <?php print theme('tripal_project_properties',$node); ?>
+   
+   <!-- Contact Theme -->
+   <?php print theme('tripal_project_contact',$node); ?>
+   
+   <!-- Relationships Theme -->
+   <?php print theme('tripal_project_relationships',$node); ?>
+   
+   <!-- Publications Theme -->
+   <?php print theme('tripal_project_publications',$node); ?>
+
+   <!-- Resource Blocks CCK elements --><?php
+   for($i = 0; $i < count($node->field_resource_titles); $i++){
+     if($node->field_resource_titles[$i]['value']){ ?>
+       <div id="tripal_project-resource_<?php print $i?>-box" class="tripal_project-info-box tripal-info-box">
+         <div class="tripal_project-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
+         <?php print $node->field_resource_blocks[$i]['value']; ?>
+       </div><?php
+     }
+   }?>
+   
+   <!-- Let modules add more content -->
+
+   <?php print $content ?>
+</div>
+
+<!-- Table of contents -->
+<div id="tripal_project_toc" class="tripal_toc">
+   <div id="tripal_project_toc_title" class="tripal_toc_title">Resources</div>
+   <ul id="tripal_project_toc_list" class="tripal_toc_list">
+   
+     <!-- Resource Links CCK elements --><?php
+     for($i = 0; $i < count($node->field_resource_links); $i++){
+       if($node->field_resource_links[$i]['value']){
+         $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
+         <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
+       }
+     }?>
+     
+     <?php // ADD CUSTOMIZED <li> LINKS HERE ?>
+   </ul>
+</div>
+
+<?php } ?>

+ 53 - 0
tripal_project/theme/tripal_project/tripal_project_base.tpl.php

@@ -0,0 +1,53 @@
+<?php
+$node = $variables['node'];
+$project = $variables['node']->project;
+
+// get the project description.  The first iteration of the project
+// module incorrectly stored the project description in the Drupal 
+// node->body field.  It should have been in the chado.projectprop 
+// table.  Therefore, for backwards compatibility, we will check if the
+// node->body is empty and if not we'll use that instead. Otherwise,
+// we'll pull from the projectprop table.
+$project_description = '';
+if ($node->body) {
+  $project_description = $node->body;
+}
+else {
+  // expand the project to include the properties.
+  $project = tripal_core_expand_chado_vars($project,'table','projectprop', array('return_array' => 1));  
+  $projectprops = $project->projectprop;
+  foreach ($projectprops as $property) {
+    if($property->type_id->name == 'project_description') {
+      $property = tripal_core_expand_chado_vars($property,'field','projectprop.value');
+      $project_description = $property->value;      
+    }
+  }
+  // if there is no project_description property then see if
+  // there is anything in the project.description field.  This field is only 255
+  // characters and isn't large enough for some project description, which is why
+  // the description is stored as a property.  But if we have no property then
+  // use the field
+  if (!$project_description) {
+    // we expect the project.description field will one day get changed to
+    // a text field so, we'll expand it now so that the template won't break if the field ever does change.
+    tripal_core_expand_chado_vars($project,'field','project.description');
+    $project_description = $project->description;
+  }
+}
+
+?>
+<div id="tripal_project-base-box" class="tripal_project-info-box tripal-info-box">
+  <div class="tripal_project-info-box-title tripal-info-box-title">Project Details</div>
+  <div class="tripal_project-info-box-desc tripal-info-box-desc"></div>   
+
+  <table id="tripal_project-table-base" class="tripal_project-table tripal-table tripal-table-vert">
+    <tr class="tripal_project-table-even-row tripal-table-even-row">
+      <th>Project Name</th>
+      <td><?php print $project->name; ?></td>
+    </tr>
+    <tr class="tripal_project-table-odd-row tripal-table-odd-row">
+      <th>Description</th>
+      <td><?php print $project_description?></td>
+    </tr>
+  </table> 
+</div>

+ 50 - 0
tripal_project/theme/tripal_project/tripal_project_contact.tpl.php

@@ -0,0 +1,50 @@
+<?php
+$project = $variables['node']->project;
+
+// expand the project object to include the contacts from the project_contact
+// table in chado.
+$project = tripal_core_expand_chado_vars($project,'table','project_contact', array('return_array' => 1));
+$contacts = $project->project_contact;
+
+if (count($contacts) > 0) { ?>
+  <div id="tripal_project-contacts-box" class="tripal_project-info-box tripal-info-box">
+    <div class="tripal_project-info-box-title tripal-info-box-title">People</div>
+    <div class="tripal_project-info-box-desc tripal-info-box-desc">The following people particpated in development or execution of this project</div><?php     
+    $i = 0; 
+    foreach ($contacts as $contact) { ?>
+      <b><?php print $contact->contact_id->name ?></b>, <?php print $contact->contact_id->description ?>
+      <table id="tripal_project-contacts-table" class="tripal_project-table tripal-table tripal-table-horz"> <?php
+      
+        // expand the contact to include the properties.  This table doesn't
+        // actually exist in Chado v1.11 or Chado v1.2. But, for some sites it has been
+        // added manually, and it is expected that this table will be added to fiture
+        // versions of Chado, so the code is included below to handle contact properties.
+        $contact = tripal_core_expand_chado_vars($contact,'table','contactprop');       
+        if ($contact->contactprop) {
+          foreach ($contact->contactprop as $prop) {
+             $class = 'tripal-table-odd-row';
+             if ($i % 2 == 0 ) {
+               $class = 'tripal-table-even-row';
+             }
+             # make the type a bit more reader friendly
+             $type = $prop->type_id->name;
+             $type = preg_replace("/_/", " ", $type);
+             $type = ucwords($type);
+             ?>
+             <tr class="<?php print $class ?>">
+               <td> <?php print $type ?></td>
+               <td> <?php print $prop->value ?></td>
+             </tr> <?php
+             $i++;  
+          } 
+        }
+        /* else { ?>
+          <tr class="tripal-table-odd-row">
+            <td>No contact information available for <?php print $contact->contact_id->name ?></td>
+          </tr> <?php
+        } */
+        ?>
+      </table> <?php 
+    } ?>    
+  </div> <?php 
+}

+ 41 - 0
tripal_project/theme/tripal_project/tripal_project_properties.tpl.php

@@ -0,0 +1,41 @@
+<?php
+$project = $node->project;
+
+// expand the project to include the properties.
+$project = tripal_core_expand_chado_vars($project,'table', 'projectprop', array('return_array' => 1));
+$projectprops = $project->projectprop;
+$properties = array();
+foreach ($projectprops as $property) {
+  // we want to keep all properties but the project_description as that
+  // property is shown on the base template page.
+  if($property->type_id->name != 'project_description') {
+    $property = tripal_core_expand_chado_vars($property,'field','projectprop.value');
+    $properties[] = $property;
+  }
+}
+
+if (count($properties) > 0) { ?>
+  <div id="tripal_project-properties-box" class="tripal_project-info-box tripal-info-box">
+    <div class="tripal_project-info-box-title tripal-info-box-title">Properties</div>
+    <div class="tripal_project-info-box-desc tripal-info-box-desc">Properties for this project include:</div>
+    <table class="tripal_project-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Property Name</th>
+        <th>Value</th>
+      </tr> <?php
+      $i = 0;
+      foreach ($properties as $property) {
+        $class = 'tripal_project-table-odd-row tripal-table-odd-row';
+        if ($i % 2 == 0 ) {
+           $class = 'tripal_project-table-odd-row tripal-table-even-row';
+        }
+        $i++; 
+        ?>
+        <tr class="<?php print $class ?>">
+          <td><?php print ucfirst(preg_replace('/_/', ' ', $property->type_id->name)) ?></td>
+          <td><?php print $property->value ?></td>
+        </tr><?php 
+      } ?>
+    </table>
+  </div> <?php
+}

+ 58 - 0
tripal_project/theme/tripal_project/tripal_project_publications.tpl.php

@@ -0,0 +1,58 @@
+<?php
+$project  = $variables['node']->project;
+
+// expand project to include pubs 
+$project = tripal_core_expand_chado_vars($project, 'table', 'project_pub', array('return_array' => 1));
+$project_pubs = $project->project_pub;
+
+if (count($project_pubs) > 0) { ?>
+  <div id="tripal_project-pub-box" class="tripal_project-info-box tripal-info-box">
+    <div class="tripal_project-info-box-title tripal-info-box-title">Publications</div>
+    <div class="tripal_project-info-box-desc tripal-info-box-desc"></div>
+  
+    <table id="tripal_project-pub-table" class="tripal_project-table tripal-table tripal-table-vert" style="border-bottom:solid 2px #999999">
+      <tr>
+        <th>Year</th>
+        <th>Publication</th>
+      </tr> <?php
+      $i = 0;
+      foreach ($project_pubs AS $project_pubs) {
+        $pub = $project_pubs->pub_id;
+        $class = 'tripal_project-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_project-table-odd-row tripal-table-even-row';
+        }
+        $pub = tripal_core_expand_chado_vars($pub, 'field', 'pub.title'); 
+        $citation = $pub->title;  // use the title as the default citation
+        
+        // get the citation for this pub if it exists
+        $values = array(
+          'pub_id' => $pub->pub_id, 
+          'type_id' => array(
+            'name' => 'Citation',
+          ),
+        );
+
+        $options = array('return_array' => 1);
+        $citation_prop = tripal_core_generate_chado_var('pubprop', $values, $options); 
+        if (count($citation_prop) == 1) {
+          $citation_prop = tripal_core_expand_chado_vars($citation_prop, 'field', 'pubprop.value');
+          $citation = $citation_prop[0]->value;
+        }
+        
+        // if the publication is synced then link to it
+        if ($pub->nid) {
+          // replace the title with a link
+          $link = l($pub->title, 'node/' . $pub->nid ,array('attributes' => array('target' => '_blank')));
+          $citation = preg_replace('/' . $pub->title . '/', $link, $citation);
+        }
+        ?>
+        <tr class="<?php print $class ?>">
+          <td><?php print $pub->pyear ?></td>
+          <td><?php print $citation ?></td>
+        </tr><?php 
+        $i++;
+      }  ?>
+    </table>
+  </div><?php 
+}

+ 81 - 0
tripal_project/theme/tripal_project/tripal_project_relationships.tpl.php

@@ -0,0 +1,81 @@
+<?php
+// this template does not follow the typical Tripal API. Normally
+// variables are expanded using the tripal_core_expand_chado_vars API
+// function call, but expanding the relationships table does not yeild
+// a meaningful order to the data.  Therefore, relationships are preprocessed
+// into an array named 'all_relationships', which is used in the template below.
+
+$project = $variables['node']->project;
+
+$all_relationships = $project->all_relationships;
+$object_rels = $all_relationships['object'];
+$subject_rels = $all_relationships['subject'];
+
+// make the project type a bit more human readable
+$project_type =  preg_replace("/_/", ' ', $project->type_id->name);
+
+if (count($object_rels) > 0 or count($subject_rels) > 0) {
+?>
+  <div id="tripal_project-relationships-box" class="tripal_project-info-box tripal-info-box">
+    <div class="tripal_project-info-box-title tripal-info-box-title">Relationships</div>
+    <!--  <div class="tripal_project-info-box-desc tripal-info-box-desc"></div> --><?php
+    
+      // first add in the subject relationships.  
+      foreach ($subject_rels as $rel_type => $rels){
+         // make the type a bit more human readable
+         $rel_type = preg_replace("/_/", ' ', $rel_type);
+         $rel_type = preg_replace("/^is/", '', $rel_type);
+         // iterate through each parent   
+         foreach ($rels as $obj_type => $objects){?>
+           <p>This project is a <b><?php print $rel_type ?></b> of the following project(s):
+           <table id="tripal_project-relationships_as_object-table" class="tripal_project-table tripal-table tripal-table-horz">
+             <tr>
+               <th>Project Name</th>
+             </tr> <?php
+             foreach ($objects as $object){ ?>
+               <tr>
+                 <td><?php 
+                    if ($object->nid) {
+                      print "<a href=\"" . url("node/" . $object->nid) . "\" target=\"_blank\">" . $object->name . "</a>";
+                    }
+                    else {
+                      print $object->name;
+                    } ?>
+                 </td>
+               </tr> <?php
+             } ?>
+             </table>
+             </p><br><?php
+         }
+      }
+      
+      // second add in the object relationships.  
+      foreach ($object_rels as $rel_type => $rels){
+         // make the type more human readable
+         $rel_type = preg_replace('/_/', ' ', $rel_type);
+         $rel_type = preg_replace("/^is/", '', $rel_type);
+         // iterate through the children         
+         foreach ($rels as $subject_type => $subjects){?>
+           <p>The following projects are a <b><?php print $rel_type ?></b> of this project:
+           <table id="tripal_project-relationships_as_object-table" class="tripal_project-table tripal-table tripal-table-horz">
+             <tr>
+               <th>Project Name</th>
+             </tr> <?php
+             foreach ($subjects as $subject){ ?>
+               <tr>
+                 <td><?php 
+                    if ($subject->nid) {
+                      print "<a href=\"" . url("node/" . $subject->nid) . "\" target=\"_blank\">" . $subject->name . "</a>";
+                    }
+                    else {
+                      print $subject->name;
+                    } ?>
+                 </td>
+               </tr> <?php
+             } ?>
+             </table>
+             </p><br><?php
+         }
+      } ?>
+  </div> <?php
+}

+ 20 - 0
tripal_project/theme/tripal_project/tripal_project_teaser.tpl.php

@@ -0,0 +1,20 @@
+<?php
+$node = $variables['node'];
+$project = $variables['node']->project;
+
+?>
+<div id="tripal_project-base-box" class="tripal_project-info-box tripal-info-box">
+  <div class="tripal_project-info-box-title tripal-info-box-title">Project Details</div>
+  <div class="tripal_project-info-box-desc tripal-info-box-desc"></div>   
+
+  <table id="tripal_project-table-base" class="tripal_project-table tripal-table tripal-table-vert">
+    <tr class="tripal_project-table-even-row tripal-table-even-row">
+      <th>Project Name</th>
+      <td><?php print $project->name; ?></td>
+    </tr>
+    <tr class="tripal_project-table-odd-row tripal-table-odd-row">
+      <th>Description</th>
+      <td><i><?php print $project->description; ?></i></td>
+    </tr>
+  </table> 
+</div>

+ 69 - 0
tripal_pub/theme/css/tripal_pub.css

@@ -0,0 +1,69 @@
+#tripal-pub-edit-properties-table {
+  width: auto;
+}
+
+#tripal-pub-edit-properties-table .form-item {
+  white-space: normal;
+}
+
+.tripal_pub-obsolete {
+   color: red;
+   font-weight: bold;
+   font-style: italic;
+   padding-bottom: 15px; 
+   text-align: center;
+}
+
+/*
+ * Importer Form Table 
+ */
+#tripal-pub-importer-table .form-item {
+  white-space: normal;
+}
+
+/* 
+ * Search Form Table 
+ */
+#tripal-pub-search-form-table{
+  border-collapse: collapse;
+  border: 0px solid #DDDDDD;
+  border-spacing: 0;  
+  margin: 1em 0;
+  width: auto;
+}
+#tripal-pub-search-form-table tr {
+  background-color: transparent;
+  border: 0px solid #CCCCCC;
+  padding: 0.1em 0.6em;  
+}
+#tripal-pub-search-form-table td {
+  border: 0px solid #DDDDDD;
+  padding: 0.25em 0.5em;
+  vertical-align: top;
+}
+#pub-search-form-dates-row {
+  clear: both;
+}
+#pub-search-form-dates label {
+  float: left; 
+  margin-right: 10px;
+}
+#pub-search-form-dates .form-item {
+  float: left; 
+  margin-right: 10px;
+}
+#edit-to-year-wrapper {
+  margin-top: 0px;
+  margin-bottom: 10px;
+}
+#edit-from-year-wrapper {
+  margin-top: 0px;
+  margin-bottom: 10px;
+}
+#tripal-pub-search-form-table #edit-search {
+  clear: both;
+}
+
+.tripal-pub-search-form-scope-select {
+  width: 150px;
+}

+ 161 - 0
tripal_pub/theme/node--chado-pub.tpl.php

@@ -0,0 +1,161 @@
+<?php
+// Purpose: This template provides the layout of the pub node (page)
+//   using the same templates used for the various pub content blocks.
+//
+// To Customize the Libray Node Page:
+//   - This Template: customize basic layout and which elements are included
+//   - Using Panels: Override the node page using Panels3 and place the blocks
+//       of content as you please. This method requires no programming. See
+//       the Tripal User Guide for more details
+//   - Block Templates: customize the content/layout of each block of stock 
+//       content. These templates are found in the tripal_stock subdirectory
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+
+$pub  = $variables['node']->pub;
+
+// get the template settings
+$template_settings = theme_get_setting('tripal');
+
+// toggle the sidebar if desired
+$no_sidebar = 0;
+if (is_array($template_settings['tripal_no_sidebar']) and 
+   $template_settings['tripal_no_sidebar']['pub']) {
+  $no_sidebar = 1;
+}
+
+if ($teaser) { 
+  print theme('tripal_pub_teaser',$node); 
+} 
+else { ?>
+
+<script type="text/javascript">
+// hide the node title. It is not informative to the viewer
+$(".title").hide();
+   
+(function ($) {
+  Drupal.behaviors.pubBehavior = {
+    attach: function (context, settings){ <?php 
+      if ($no_sidebar) { ?>    
+        // hide the resource side bar and strech the details section    
+        $(".tripal_toc").hide();
+        $(".tripal_details").addClass("tripal_details_full");
+        $(".tripal_details_full").removeClass("tripal_details"); <?php
+      } else { ?>
+        // use default resource sidebar
+        $(".tripal-info-box").hide(); <?php
+      } ?>
+ 
+      // iterate through all of the info boxes and add their titles
+      // to the table of contents
+      $(".tripal-info-box-title").each(function(){
+        var parent = $(this).parent();
+        var id = $(parent).attr('id');
+        var title = $(this).text();
+        $('#tripal_pub_toc_list').append('<li><a href="#'+id+'" class="tripal_pub_toc_item">'+title+'</a></li>');
+      });
+
+      // when a title in the table of contents is clicked, then
+      // show the corresponding item in the details box
+      $(".tripal_pub_toc_item").click(function(){
+         $(".tripal-info-box").hide();
+         href = $(this).attr('href');
+         $(href).fadeIn('slow');
+         // we want to make sure our table of contents and the details
+         // box stay the same height
+         $("#tripal_pub_toc").height($(href).parent().height());
+         return false;
+      }); 
+
+      // we want the base details to show up when the page is first shown 
+      // unless the user specified a specific block
+      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
+      if(block == null){
+         block = window.location.href.match(/[\?|\&]block=(.+)/)
+      }
+      if(block != null){
+         $("#tripal_pub-"+block[1]+"-box").show();
+      } else {
+         $("#tripal_pub-base-box").show();
+      }
+
+      $("#tripal_pub_toc").height($("#tripal_pub-base-box").parent().height());
+    }     
+  };
+})(jQuery);
+</script>
+
+<div id="tripal_pub_details" class="tripal_details">
+
+   <!-- Basic Details Theme -->   
+   <?php print theme('tripal_pub_base', $node); ?>
+   
+   <!-- Properties Theme -->
+   <?php print theme('tripal_pub_properties', $node); ?>
+   
+   <!-- Authors Theme -->
+   <?php print theme('tripal_pub_authors', $node); ?>   
+   
+   <!-- References Theme -->
+   <?php print theme('tripal_pub_references', $node); ?>
+        
+   <!-- Relationships Theme -->
+   <?php print theme('tripal_pub_relationships', $node); ?>
+
+   <!-- FeatureMaps Theme -->
+   <?php print theme('tripal_pub_featuremaps', $node); ?>
+
+   <!-- Features Theme -->
+   <?php print theme('tripal_pub_features', $node); ?>
+
+   <!-- Libraries Theme -->
+   <?php print theme('tripal_pub_libraries', $node); ?>
+
+   <!-- Projects Theme -->
+   <?php print theme('tripal_pub_projects', $node); ?>
+
+   <!-- Stocks Theme -->
+   <?php print theme('tripal_pub_stocks', $node); ?>
+
+
+   <!-- Resource Blocks CCK elements --><?php
+   for($i = 0; $i < count($node->field_resource_titles); $i++){
+     if($node->field_resource_titles[$i]['value']){ ?>
+       <div id="tripal_pub-resource_<?php print $i?>-box" class="tripal_pub-info-box tripal-info-box">
+         <div class="tripal_pub-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
+         <?php print $node->field_resource_blocks[$i]['value']; ?>
+       </div><?php
+     }
+   }?>
+   
+   <!-- Let modules add more content -->
+
+   <?php print $content ?>
+</div>
+
+<!-- Table of contents -->
+<div id="tripal_pub_toc" class="tripal_toc">
+   <div id="tripal_pub_toc_title" class="tripal_toc_title">Resources</div>
+   <ul id="tripal_pub_toc_list" class="tripal_toc_list">
+   
+     <!-- Resource Links CCK elements --><?php
+     for($i = 0; $i < count($node->field_resource_links); $i++){
+       if($node->field_resource_links[$i]['value']){
+         $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
+         <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
+       }
+     }?>
+     
+     <?php // ADD CUSTOMIZED <li> LINKS HERE ?>
+   </ul>
+</div>
+
+<?php } ?>

+ 52 - 0
tripal_pub/theme/tripal_pub/pub_types/conference_proceedings.inc

@@ -0,0 +1,52 @@
+<table id="tripal_pub-table-base" class="tripal_pub-table tripal-table tripal-table-vert">
+  <tr class="tripal_pub-table-even-row tripal-table-even-row">
+    <th>Title</th>
+    <td><?php
+      if ($url) {
+        print l(htmlspecialchars($pub->title), $url, array('attributes' => array('target' => '_blank')));          
+      }
+      elseif ($dbxref->db_id->urlprefix) { 
+        print l(htmlspecialchars($pub->title), $dbxref->db_id->urlprefix . $dbxref->accession, array('attributes' => array('target' => '_blank')));             
+      } 
+      else {
+        print htmlspecialchars($pub->title); 
+      }?>
+    </td>
+  </tr>
+  <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+    <th>Authors</th>
+    <td><?php print $authors->value ? $authors->value : 'N/A'; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-even-row tripal-table-even-row">
+    <th>Type</th>
+    <td><?php print $pub->type_id->name; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+    <th nowrap>Conference Name</th>
+    <td><?php print $pub->series_name; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-even-row tripal-table-even-row">
+    <th>Volume</th>
+    <td><?php print $pub->volume ? $pub->volume : 'N/A'; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+    <th>Issue</th>
+    <td><?php print $pub->issue ? $pub->issue : 'N/A'; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-even-row tripal-table-even-row">    
+    <th>Year</th>
+    <td><?php print $pub->pyear; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+    <th>Page(s)</th>
+    <td><?php print $pub->pages ? $pub->pages : 'N/A'; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-even-row tripal-table-even-row">
+    <th>Citation</th>
+    <td><?php print htmlspecialchars($citation->value); ?></td>
+  </tr>
+  <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+    <th>Abstract</th>
+    <td style="text-align:justify;"><?php print htmlspecialchars($abstract->value) ? $abstract->value : 'N/A'; ?></td>
+  </tr>
+</table>

+ 52 - 0
tripal_pub/theme/tripal_pub/pub_types/journal_article.inc

@@ -0,0 +1,52 @@
+<table id="tripal_pub-table-base" class="tripal_pub-table tripal-table tripal-table-vert">
+  <tr class="tripal_pub-table-even-row tripal-table-even-row">
+    <th>Title</th>
+    <td><?php
+      if ($url) {
+        print l(htmlspecialchars($pub->title), $url, array('attributes' => array('target' => '_blank')));          
+      }
+      elseif ($dbxref->db_id->urlprefix) { 
+        print l(htmlspecialchars($pub->title), $dbxref->db_id->urlprefix . $dbxref->accession, array('attributes' => array('target' => '_blank')));             
+      } 
+      else {
+        print htmlspecialchars($pub->title); 
+      }?>
+    </td>
+  </tr>
+  <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+    <th>Authors</th>
+    <td><?php print $authors->value ? $authors->value : 'N/A'; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-even-row tripal-table-even-row">
+    <th>Type</th>
+    <td><?php print $pub->type_id->name; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+    <th nowrap>Journal Name</th>
+    <td><?php print $pub->series_name; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-even-row tripal-table-even-row">
+    <th>Volume</th>
+    <td><?php print $pub->volume ? $pub->volume : 'N/A'; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+    <th>Issue</th>
+    <td><?php print $pub->issue ? $pub->issue : 'N/A'; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-even-row tripal-table-even-row">    
+    <th>Year</th>
+    <td><?php print $pub->pyear; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+    <th>Page(s)</th>
+    <td><?php print $pub->pages ? $pub->pages : 'N/A'; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-even-row tripal-table-even-row">
+    <th>Citation</th>
+    <td><?php print htmlspecialchars($citation->value); ?></td>
+  </tr>
+  <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+    <th>Abstract</th>
+    <td style="text-align:justify;"><?php print htmlspecialchars($abstract->value) ? $abstract->value : 'N/A'; ?></td>
+  </tr>
+</table>

+ 36 - 0
tripal_pub/theme/tripal_pub/pub_types/patent.inc

@@ -0,0 +1,36 @@
+<table id="tripal_pub-table-base" class="tripal_pub-table tripal-table tripal-table-vert">
+  <tr class="tripal_pub-table-even-row tripal-table-even-row">
+    <th>Title</th>
+    <td><?php
+      if ($url) {
+        print l(htmlspecialchars($pub->title), $url, array('attributes' => array('target' => '_blank')));          
+      }
+      elseif ($dbxref->db_id->urlprefix) { 
+        print l(htmlspecialchars($pub->title), $dbxref->db_id->urlprefix . $dbxref->accession, array('attributes' => array('target' => '_blank')));             
+      } 
+      else {
+        print htmlspecialchars($pub->title); 
+      }?>
+    </td>
+  </tr>
+  <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+    <th>Authors</th>
+    <td><?php print $authors->value ? $authors->value : 'N/A'; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-even-row tripal-table-even-row">
+    <th>Type</th>
+    <td><?php print $pub->type_id->name; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-odd-row tripal-table-odd-row">    
+    <th>Year</th>
+    <td><?php print $pub->pyear; ?></td>
+  </tr>
+  <tr class="tripal_pub-table-even-row tripal-table-even-row">
+    <th>Citation</th>
+    <td><?php print htmlspecialchars($citation->value); ?></td>
+  </tr>
+  <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+    <th>Abstract</th>
+    <td style="text-align:justify;"><?php print htmlspecialchars($abstract->value) ? $abstract->value : 'N/A'; ?></td>
+  </tr>
+</table>

+ 94 - 0
tripal_pub/theme/tripal_pub/tripal_pub_authors.tpl.php

@@ -0,0 +1,94 @@
+<?php
+$pub = $node->pub;
+
+// expand the pub to include the pubauthors.
+$options = array(
+  'return_array' => 1,
+  'order_by' => array('rank' => 'ASC'),
+);
+$pub = tripal_core_expand_chado_vars($pub, 'table', 'pubauthor', $options);
+
+// see if we have authors as contacts if so then we'll add this resource
+$authors = $pub->pubauthor;
+$has_contacts = FALSE;
+if (count($authors) > 0) { 
+  foreach ($authors as $author) {
+    // expand the author to include the pubauthor_contact table records
+    $options = array(
+      'return_array' => 1,
+      'include_fk' => array(
+        'contact_id' => array(
+          'type_id' => 1,
+        ),
+      ),
+    );
+    $author = tripal_core_expand_chado_vars($author, 'table', 'pubauthor_contact', $options);
+    if ($author->pubauthor_contact) {
+      $has_contacts = TRUE;
+    }
+  }
+}
+
+if ($has_contacts) { ?>
+  <div id="tripal_pub-pubauthors-box" class="tripal_pub-info-box tripal-info-box">
+    <div class="tripal_pub-info-box-title tripal-info-box-title">Authors</div>
+    <div class="tripal_pub-info-box-desc tripal-info-box-desc">Additional information about authors:</div>
+    <table id="tripal_pubauthor_<?php print $rank?>-table" class="tripal_pub-table tripal-table tripal-table-horz"><?php 
+      $rank = 1;
+      foreach ($authors as $author) {
+         
+        // expand the author to include the contact information linked via the pubauthor_contact table
+        $contact = $author->pubauthor_contact[0]->contact_id;
+        $options = array(
+          'return_array' => 1,
+          'include_fk' => array(
+            'type_id' => 1,       
+          ),      
+        );
+        $contact = tripal_core_expand_chado_vars($contact, 'table', 'contactprop', $options);
+        $properties = $contact->contactprop;
+        $options = array('order_by' => array('rank' => 'ASC'));
+        $properties = tripal_core_expand_chado_vars($properties, 'field', 'contactprop.value', $options); 
+        
+        $class = 'tripal_pub-table-odd-row tripal-table-odd-row';
+        if($rank % 2 == 0 ){
+           $class = 'tripal_pub-table-even-row tripal-table-even-row';
+        } ?>            
+        <tr class="<?php print $class?>">
+          <td><?php print $rank?></td>
+          <?php
+          // now build the table for display the authors and their information 
+          if ($contact->nid) {?>
+            <td><?php print l($author->givennames . " " . $author->surname, 'node/' . $contact->nid) ?></td><?php
+          }
+          else {?>
+            <td><?php print $author->givennames . " " . $author->surname ?></td><?php
+          } ?>
+          <td> 
+            <table class="tripal-subtable"><?php 
+              if (is_array($properties)) {          
+                foreach ($properties as $property) {
+                  // skip the description and name properties
+                  if ($property->type_id->name == "contact_description" or
+                      $property->type_id->name == "Surname" or
+                      $property->type_id->name == "Given Name" or
+                      $property->type_id->name == "First Initials" or
+                      $property->type_id->name == "Suffix") {
+                    continue;
+                  }?>
+                  <tr>
+                    <td><?php print $property->type_id->name ?></td>
+                    <td>:</td>
+                    <td><?php print $property->value ?></td>
+                  </tr><?php
+                  $i++; 
+                } 
+              }?> 
+            </table>
+          </td>
+        </tr><?php 
+        $rank++;
+      }?>
+    </table>
+  </div><?php      
+}

+ 135 - 0
tripal_pub/theme/tripal_pub/tripal_pub_base.tpl.php

@@ -0,0 +1,135 @@
+<?php
+$node = $variables['node'];
+$pub = $variables['node']->pub;
+
+// expand the title
+$pub = tripal_core_expand_chado_vars($pub, 'field', 'pub.title');
+$pub = tripal_core_expand_chado_vars($pub, 'field', 'pub.volumetitle');
+
+// get the citation
+$values = array(
+  'pub_id' => $pub->pub_id, 
+  'type_id' => array(
+    'name' => 'Citation',
+  ),
+);
+$citation = tripal_core_generate_chado_var('pubprop', $values); 
+$citation = tripal_core_expand_chado_vars($citation, 'field', 'pubprop.value');
+
+// get the abstract
+$values = array(
+  'pub_id' => $pub->pub_id, 
+  'type_id' => array(
+    'name' => 'Abstract',
+  ),
+);
+$abstract = tripal_core_generate_chado_var('pubprop', $values); 
+$abstract = tripal_core_expand_chado_vars($abstract, 'field', 'pubprop.value');
+
+// get the author list
+$values = array(
+  'pub_id' => $pub->pub_id, 
+  'type_id' => array(
+    'name' => 'Authors',
+  ),
+);
+$authors = tripal_core_generate_chado_var('pubprop', $values); 
+$authors = tripal_core_expand_chado_vars($authors, 'field', 'pubprop.value');
+
+// get the first database cross-reference with a url
+$options = array('return_array' => 1);
+$pub = tripal_core_expand_chado_vars($pub, 'table', 'pub_dbxref', $options);
+if ($pub->pub_dbxref) { 
+  foreach ($pub->pub_dbxref as $index => $pub_dbxref) {
+    if ($pub_dbxref->dbxref_id->db_id->urlprefix) {
+      $dbxref = $pub_dbxref->dbxref_id;
+    }
+  }
+}
+
+// get the URL
+// get the author list
+$values = array(
+  'pub_id' => $pub->pub_id, 
+  'type_id' => array(
+    'name' => 'URL',
+  ),
+);
+$options = array('return_array' => 1);
+$urls = tripal_core_generate_chado_var('pubprop', $values, $options); 
+$urls = tripal_core_expand_chado_vars($urls, 'field', 'pubprop.value');
+$url = $urls[0]->value;
+
+?>
+<div id="tripal_pub-base-box" class="tripal_pub-info-box tripal-info-box">
+  <div class="tripal_pub-info-box-title tripal-info-box-title"><?php print $pub->type_id->name ?> Details</div>
+  <!-- <div class="tripal_pub-info-box-desc tripal-info-box-desc"></div> -->
+  <?php 
+  if ($pub->is_obsolete == 't') { ?>
+    <div class="tripal_pub-obsolete">This publication is obsolete</div> <?php 
+  }  
+
+  // to simplify the template, we have a subdirectory named 'pub_types'.  This directory
+  // should have include files each specific to a publication type. If the type is 
+  // not present then the base template will be used, otherwise the template in the
+  // include file is used.
+  $inc_name = strtolower(preg_replace('/ /', '_', $pub->type_id->name)) . '.inc';
+  $inc_path = realpath('./') . '/' . drupal_get_path('theme', 'tripal') . "/tripal_pub/pub_types/$inc_name";
+  if (file_exists($inc_path)) {
+    require_once "pub_types/$inc_name";  
+  } 
+  else { ?>
+    <table id="tripal_pub-table-base" class="tripal_pub-table tripal-table tripal-table-vert">
+      <tr class="tripal_pub-table-even-row tripal-table-even-row">
+        <th>Title</th>
+        <td><?php
+          if ($url) {
+            print l(htmlspecialchars($pub->title), $url, array('attributes' => array('target' => '_blank')));          
+          }
+          elseif ($dbxref->db_id->urlprefix) { 
+            print l(htmlspecialchars($pub->title), $dbxref->db_id->urlprefix . $dbxref->accession, array('attributes' => array('target' => '_blank')));             
+          } 
+          else {
+            print htmlspecialchars($pub->title); 
+          }?>
+        </td>
+      </tr>
+      <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+        <th>Authors</th>
+        <td><?php print $authors->value ? $authors->value : 'N/A'; ?></td>
+      </tr>
+      <tr class="tripal_pub-table-even-row tripal-table-even-row">
+        <th>Type</th>
+        <td><?php print $pub->type_id->name; ?></td>
+      </tr>
+      <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+        <th nowrap>Media Title</th>
+        <td><?php print $pub->series_name; ?></td>
+      </tr>
+      <tr class="tripal_pub-table-even-row tripal-table-even-row">
+        <th>Volume</th>
+        <td><?php print $pub->volume ? $pub->volume : 'N/A'; ?></td>
+      </tr>
+      <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+        <th>Issue</th>
+        <td><?php print $pub->issue ? $pub->issue : 'N/A'; ?></td>
+      </tr>
+      <tr class="tripal_pub-table-even-row tripal-table-even-row">    
+        <th>Year</th>
+        <td><?php print $pub->pyear; ?></td>
+      </tr>
+      <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+        <th>Page(s)</th>
+        <td><?php print $pub->pages ? $pub->pages : 'N/A'; ?></td>
+      </tr>
+      <tr class="tripal_pub-table-even-row tripal-table-even-row">
+        <th>Citation</th>
+        <td><?php print htmlspecialchars($citation->value); ?></td>
+      </tr>
+      <tr class="tripal_pub-table-odd-row tripal-table-odd-row">
+        <th>Abstract</th>
+        <td style="text-align:justify;"><?php print htmlspecialchars($abstract->value) ? $abstract->value : 'N/A'; ?></td>
+      </tr>
+    </table> <?php
+  } ?>
+</div>

+ 60 - 0
tripal_pub/theme/tripal_pub/tripal_pub_featuremaps.tpl.php

@@ -0,0 +1,60 @@
+<?php
+$pub = $variables['node']->pub;
+$featuremaps = array();
+
+// expand the pub object to include the records from the pub_dbxref table
+// specify the number of genotypes to show by default and the unique pager ID
+$num_results_per_page = 25; 
+$featuremap_pager_id = 5;
+
+// get the genotypes from the featuremap_genotype table
+$options = array(  
+  'return_array' => 1,
+  'pager' => array('limit' => $num_results_per_page, 'element' => $featuremap_pager_id),
+);
+
+$pub = tripal_core_expand_chado_vars($pub, 'table', 'featuremap_pub', $options);
+$featuremap_pubs = $pub->featuremap_pub;
+if (count($featuremap_pubs) > 0 ) {
+  foreach ($featuremap_pubs as $featuremap_pub) {    
+    $featuremaps[] = $featuremap_pub->featuremap_id;
+  }
+}
+
+// create the pager.  
+global $pager_total_items;
+$featuremap_pager = theme('pager', array(), $num_results_per_page, $featuremap_pager_id, array('block' => 'featuremaps'));
+$total_featuremaps = $pager_total_items[$featuremap_pager_id];
+
+
+if(count($featuremaps) > 0){ ?>
+  <div id="tripal_pub-featuremaps-box" class="tripal_pub-info-box tripal-info-box">
+    <div class="tripal_pub-info-box-title tripal-info-box-title">Maps</div>
+    <div class="tripal_pub-info-box-desc tripal-info-box-desc">This publication contains information about <?php print number_format($total_featuremaps) ?> map(s):</div>
+    <table id="tripal_pub-featuremap-table" class="tripal_pub-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Map Name</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($featuremaps as $featuremap){         
+        $class = 'tripal_pub-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_pub-table-even-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td> <?php 
+            if ($featuremap->nid) { 
+              print l($featuremap->name, 'node/' . $featuremap->nid, array('attributes' => array('target' => '_blank')));
+            } 
+            else { 
+              print $featuremap->name;
+            } ?>
+          </td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table> <?php 
+    print $featuremap_pager ?>
+  </div><?php 
+}?>
+

+ 62 - 0
tripal_pub/theme/tripal_pub/tripal_pub_features.tpl.php

@@ -0,0 +1,62 @@
+<?php
+$pub = $variables['node']->pub;
+$features = array();
+
+// expand the pub object to include the records from the pub_dbxref table
+// specify the number of genotypes to show by default and the unique pager ID
+$num_results_per_page = 25; 
+$feature_pager_id = 5;
+
+// get the genotypes from the feature_genotype table
+$options = array(  
+  'return_array' => 1,
+  'pager' => array('limit' => $num_results_per_page, 'element' => $feature_pager_id),
+);
+
+$pub = tripal_core_expand_chado_vars($pub, 'table', 'feature_pub', $options);
+$feature_pubs = $pub->feature_pub;
+if (count($feature_pubs) > 0 ) {
+  foreach ($feature_pubs as $feature_pub) {    
+    $features[] = $feature_pub->feature_id;
+  }
+}
+
+// create the pager.  
+global $pager_total_items;
+$feature_pager = theme('pager', array(), $num_results_per_page, $feature_pager_id, array('block' => 'features'));
+$total_features = $pager_total_items[$feature_pager_id];
+
+
+if(count($features) > 0){ ?>
+  <div id="tripal_pub-features-box" class="tripal_pub-info-box tripal-info-box">
+    <div class="tripal_pub-info-box-title tripal-info-box-title">Features</div>
+    <div class="tripal_pub-info-box-desc tripal-info-box-desc">This publication contains information about <?php print number_format($total_features) ?> features:</div>
+    <table id="tripal_pub-feature-table" class="tripal_pub-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Feature Name</th>
+        <th>Type</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($features as $feature){         
+        $class = 'tripal_pub-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_pub-table-even-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td> <?php 
+            if ($feature->nid) { 
+              print l($feature->name, 'node/' . $feature->nid, array('attributes' => array('target' => '_blank')));
+            } 
+            else { 
+              print $feature->name;
+            } ?>
+          </td>
+          <td><?php print $feature->type_id->name ?></td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table> <?php 
+    print $feature_pager ?>
+  </div><?php 
+}?>
+

+ 64 - 0
tripal_pub/theme/tripal_pub/tripal_pub_libraries.tpl.php

@@ -0,0 +1,64 @@
+<?php
+$pub = $variables['node']->pub;
+$libraries = array();
+
+// expand the pub object to include the records from the pub_dbxref table
+// specify the number of genotypes to show by default and the unique pager ID
+$num_results_per_page = 25; 
+$library_pager_id = 5;
+
+// get the genotypes from the library_genotype table
+$options = array(  
+  'return_array' => 1,
+  'pager' => array('limit' => $num_results_per_page, 'element' => $library_pager_id),
+);
+
+$pub = tripal_core_expand_chado_vars($pub, 'table', 'library_pub', $options);
+$library_pubs = $pub->library_pub;
+if (count($library_pubs) > 0 ) {
+  foreach ($library_pubs as $library_pub) {    
+    $libraries[] = $library_pub->library_id;
+  }
+}
+
+// create the pager.  
+global $pager_total_items;
+$library_pager = theme('pager', array(), $num_results_per_page, $library_pager_id, array('block' => 'libraries'));
+$total_libraries = $pager_total_items[$library_pager_id];
+
+
+if(count($libraries) > 0){ ?>
+  <div id="tripal_pub-libraries-box" class="tripal_pub-info-box tripal-info-box">
+    <div class="tripal_pub-info-box-title tripal-info-box-title">Libraries</div>
+    <div class="tripal_pub-info-box-desc tripal-info-box-desc">This publication contains information about <?php print number_format($total_libraries) ?> libraries:</div>
+    <table id="tripal_pub-library-table" class="tripal_pub-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Library Name</th>
+        <th>Species</th>
+        <th>Type</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($libraries as $library){         
+        $class = 'tripal_pub-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_pub-table-even-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td> <?php 
+            if ($library->nid) { 
+              print l($library->name, 'node/' . $library->nid, array('attributes' => array('target' => '_blank')));
+            } 
+            else { 
+              print $library->name;
+            } ?>
+          </td>
+          <td><?php print $library->type_id->name ?></td>
+          <td><?php print $library->organism_id->genus ?> <?php print $library->organism_id->species ?></td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table> <?php 
+    print $library_pager ?>
+  </div><?php 
+}?>
+

+ 60 - 0
tripal_pub/theme/tripal_pub/tripal_pub_projects.tpl.php

@@ -0,0 +1,60 @@
+<?php
+$pub = $variables['node']->pub;
+$projects = array();
+
+// expand the pub object to include the records from the pub_dbxref table
+// specify the number of genotypes to show by default and the unique pager ID
+$num_results_per_page = 25; 
+$project_pager_id = 5;
+
+// get the genotypes from the project_genotype table
+$options = array(  
+  'return_array' => 1,
+  'pager' => array('limit' => $num_results_per_page, 'element' => $project_pager_id),
+);
+
+$pub = tripal_core_expand_chado_vars($pub, 'table', 'project_pub', $options);
+$project_pubs = $pub->project_pub;
+if (count($project_pubs) > 0 ) {
+  foreach ($project_pubs as $project_pub) {    
+    $projects[] = $project_pub->project_id;
+  }
+}
+
+// create the pager.  
+global $pager_total_items;
+$project_pager = theme('pager', array(), $num_results_per_page, $project_pager_id, array('block' => 'projects'));
+$total_projects = $pager_total_items[$project_pager_id];
+
+
+if(count($projects) > 0){ ?>
+  <div id="tripal_pub-projects-box" class="tripal_pub-info-box tripal-info-box">
+    <div class="tripal_pub-info-box-title tripal-info-box-title">Projects</div>
+    <div class="tripal_pub-info-box-desc tripal-info-box-desc">This publication contains information about <?php print number_format($total_projects) ?> projects:</div>
+    <table id="tripal_pub-project-table" class="tripal_pub-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Project Name</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($projects as $project){         
+        $class = 'tripal_pub-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_pub-table-even-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td> <?php 
+            if ($project->nid) { 
+              print l($project->name, 'node/' . $project->nid, array('attributes' => array('target' => '_blank')));
+            } 
+            else { 
+              print $project->name;
+            } ?>
+          </td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table> <?php 
+    print $project_pager ?>
+  </div><?php 
+}?>
+

+ 77 - 0
tripal_pub/theme/tripal_pub/tripal_pub_properties.tpl.php

@@ -0,0 +1,77 @@
+<?php
+$pub = $node->pub;
+
+// expand the pub to include the properties.
+$options = array(
+  'return_array' => 1,
+  'order_by' => array('rank' => 'ASC'),
+);
+$pub = tripal_core_expand_chado_vars($pub,'table', 'pubprop', $options);
+$pubprops = $pub->pubprop;
+$properties = array();
+if (is_array($pubprops)) {
+  foreach ($pubprops as $property) {
+    // skip the following properties as those are already on other templates
+    if ($property->type_id->name == 'Abstract' or
+        $property->type_id->name == 'Citation' or
+        $property->type_id->name == 'Publication Dbxref' or
+        $property->type_id->name == 'Authors' or
+        $property->type_id->name == 'Structured Abstract Part')  {
+      continue;
+    }
+    $property = tripal_core_expand_chado_vars($property,'field','pubprop.value');
+    $properties[] = $property;
+  }
+}
+// we'll keep track of the keywords so we can lump them into a single row
+$keywords = array(); ?>
+  <div id="tripal_pub-properties-box" class="tripal_pub-info-box tripal-info-box">
+    <div class="tripal_pub-info-box-title tripal-info-box-title">More Details</div>
+    <div class="tripal_pub-info-box-desc tripal-info-box-desc">Additional details for this publication include:</div>
+    <table class="tripal_pub-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Property Name</th>
+        <th>Value</th>
+      </tr> <?php
+      if (count($properties) > 0) {
+        $i = 0;
+        foreach ($properties as $property) {
+          if ($property->type_id->name == 'Keywords') {
+            $keywords[] = $property->value;
+            continue;
+          }
+          $class = 'tripal_pub-table-odd-row tripal-table-odd-row';
+          if ($i % 2 == 0 ) {
+             $class = 'tripal_pub-table-odd-row tripal-table-even-row';
+          }
+          $i++; 
+          ?>
+          <tr class="<?php print $class ?>">
+            <td nowrap><?php print $property->type_id->name ?></td>
+            <td><?php print $property->value ?></td>
+          </tr><?php 
+        } 
+        if (count($keywords) > 0) {
+          $class = 'tripal_pub-table-odd-row tripal-table-odd-row';
+          if ($i % 2 == 0 ) {
+             $class = 'tripal_pub-table-odd-row tripal-table-even-row';
+          }
+          $i++; 
+          ?>
+          <tr class="<?php print $class ?>">
+            <td nowrap>Keywords</td>
+            <td><?php print implode(', ', $keywords) ?></td>
+          </tr><?php   
+        }
+        $class = 'tripal_pub-table-odd-row tripal-table-odd-row';
+        if ($i % 2 == 0 ) {
+           $class = 'tripal_pub-table-odd-row tripal-table-even-row';
+        }
+      } ?>
+    <tr class="<?php print $class ?>">
+      <td>Internal ID</td>
+      <td style="text-align:justify;"><?php print $pub->pub_id; ?></td>
+    </tr>
+  </table> 
+</div> <?php
+

+ 56 - 0
tripal_pub/theme/tripal_pub/tripal_pub_references.tpl.php

@@ -0,0 +1,56 @@
+<?php
+$pub = $variables['node']->pub;
+$references = array();
+
+// expand the pub object to include the records from the pub_dbxref table
+$options = array('return_array' => 1);
+$pub = tripal_core_expand_chado_vars($pub, 'table', 'pub_dbxref', $options);
+$pub_dbxrefs = $pub->pub_dbxref;
+if (count($pub_dbxrefs) > 0 ) {
+  foreach ($pub_dbxrefs as $pub_dbxref) {    
+    $references[] = $pub_dbxref->dbxref_id;
+  }
+}
+
+if(count($references) > 0){ ?>
+  <div id="tripal_pub-references-box" class="tripal_pub-info-box tripal-info-box">
+    <div class="tripal_pub-info-box-title tripal-info-box-title">Cross References</div>
+    <div class="tripal_pub-info-box-desc tripal-info-box-desc">This publication is also available in the following databases:</div>
+    <table id="tripal_pub-references-table" class="tripal_pub-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Dababase</th>
+        <th>Accession</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($references as $dbxref){         
+        $class = 'tripal_pub-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_pub-table-even-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td> <?php 
+            if ($dbxref->db_id->url) { 
+              print l($dbxref->db_id->name, $dbxref->db_id->url, array('attributes' => array('target' => '_blank'))) . '<br>' . $dbxref->db_id->description;             
+            } 
+            else { 
+              print $dbxref->db_id->name . '<br>' . $dbxref->db_id->description;
+            } ?>
+          </td>
+          <td> <?php 
+            if ($dbxref->db_id->urlprefix) { 
+              print l($dbxref->db_id->name . ':' . $dbxref->accession, $dbxref->db_id->urlprefix . $dbxref->accession, array('attributes' => array('target' => '_blank')));
+            } 
+            else { 
+              print $dbxref->db_id->name . ':' . $dbxref->accession; 
+            }
+            if ($dbxref->is_primary) {
+              print " <i>(primary cross-reference)</i>";
+            } ?>
+          </td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table>
+  </div><?php 
+}?>
+

+ 81 - 0
tripal_pub/theme/tripal_pub/tripal_pub_relationships.tpl.php

@@ -0,0 +1,81 @@
+<?php
+// this template does not follow the typical Tripal API. Normally
+// variables are expanded using the tripal_core_expand_chado_vars API
+// function call, but expanding the relationships table does not yeild
+// a meaningful order to the data.  Therefore, relationships are preprocessed
+// into an array named 'all_relationships', which is used in the template below.
+
+$pub = $variables['node']->pub;
+
+$all_relationships = $pub->all_relationships;
+$object_rels = $all_relationships['object'];
+$subject_rels = $all_relationships['subject'];
+
+// make the pub type a bit more human readable
+$pub_type =  preg_replace("/_/", ' ', $pub->type_id->name);
+
+if (count($object_rels) > 0 or count($subject_rels) > 0) {
+?>
+  <div id="tripal_pub-relationships-box" class="tripal_pub-info-box tripal-info-box">
+    <div class="tripal_pub-info-box-title tripal-info-box-title">Relationships</div>
+    <!--  <div class="tripal_pub-info-box-desc tripal-info-box-desc"></div> --><?php
+    
+      // first add in the subject relationships.  
+      foreach ($subject_rels as $rel_type => $rels){
+         // make the type a bit more human readable
+         $rel_type = preg_replace("/_/", ' ', $rel_type);
+         $rel_type = preg_replace("/^is/", '', $rel_type);
+         // iterate through each parent   
+         foreach ($rels as $obj_type => $objects){?>
+           <p>This pub is a <b><?php print $rel_type ?></b> of the following pub(s):
+           <table id="tripal_pub-relationships_as_object-table" class="tripal_pub-table tripal-table tripal-table-horz">
+             <tr>
+               <th>pub Name</th>
+             </tr> <?php
+             foreach ($objects as $object){ ?>
+               <tr>
+                 <td><?php 
+                    if ($object->nid) {
+                      print "<a href=\"" . url("node/" . $object->nid) . "\" target=\"_blank\">" . $object->title . "</a>";
+                    }
+                    else {
+                      print $object->name;
+                    } ?>
+                 </td>
+               </tr> <?php
+             } ?>
+             </table>
+             </p><br><?php
+         }
+      }
+      
+      // second add in the object relationships.  
+      foreach ($object_rels as $rel_type => $rels){
+         // make the type more human readable
+         $rel_type = preg_replace('/_/', ' ', $rel_type);
+         $rel_type = preg_replace("/^is/", '', $rel_type);
+         // iterate through the children         
+         foreach ($rels as $subject_type => $subjects){?>
+           <p>The following pubs are a <b><?php print $rel_type ?></b> of this pub:
+           <table id="tripal_pub-relationships_as_object-table" class="tripal_pub-table tripal-table tripal-table-horz">
+             <tr>
+               <th>Title</th>
+             </tr> <?php
+             foreach ($subjects as $subject){ ?>
+               <tr>
+                 <td><?php 
+                    if ($subject->nid) {
+                      print "<a href=\"" . url("node/" . $subject->nid) . "\" target=\"_blank\">" . $subject->title . "</a>";
+                    }
+                    else {
+                      print $subject->name;
+                    } ?>
+                 </td>
+               </tr> <?php
+             } ?>
+             </table>
+             </p><br><?php
+         }
+      } ?>
+  </div> <?php
+}

+ 62 - 0
tripal_pub/theme/tripal_pub/tripal_pub_stocks.tpl.php

@@ -0,0 +1,62 @@
+<?php
+$pub = $variables['node']->pub;
+$stocks = array();
+
+// expand the pub object to include the records from the pub_dbxref table
+// specify the number of genotypes to show by default and the unique pager ID
+$num_results_per_page = 25; 
+$stock_pager_id = 5;
+
+// get the genotypes from the stock_genotype table
+$options = array(  
+  'return_array' => 1,
+  'pager' => array('limit' => $num_results_per_page, 'element' => $stock_pager_id),
+);
+
+$pub = tripal_core_expand_chado_vars($pub, 'table', 'stock_pub', $options);
+$stock_pubs = $pub->stock_pub;
+if (count($stock_pubs) > 0 ) {
+  foreach ($stock_pubs as $stock_pub) {    
+    $stocks[] = $stock_pub->stock_id;
+  }
+}
+
+// create the pager.  
+global $pager_total_items;
+$stock_pager = theme('pager', array(), $num_results_per_page, $stock_pager_id, array('block' => 'stocks'));
+$total_stocks = $pager_total_items[$stock_pager_id];
+
+
+if(count($stocks) > 0){ ?>
+  <div id="tripal_pub-stocks-box" class="tripal_pub-info-box tripal-info-box">
+    <div class="tripal_pub-info-box-title tripal-info-box-title">Stocks</div>
+    <div class="tripal_pub-info-box-desc tripal-info-box-desc">This publication contains information about <?php print number_format($total_stocks) ?> stocks:</div>
+    <table id="tripal_pub-stock-table" class="tripal_pub-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Stock Name</th>
+        <th>Type</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($stocks as $stock){         
+        $class = 'tripal_pub-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal_pub-table-even-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td> <?php 
+            if ($stock->nid) { 
+              print l($stock->name, 'node/' . $stock->nid, array('attributes' => array('target' => '_blank')));
+            } 
+            else { 
+              print $stock->name;
+            } ?>
+          </td>
+          <td><?php print $stock->type_id->name ?></td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table> <?php 
+    print $stock_pager ?>
+  </div><?php 
+}?>
+

+ 147 - 0
tripal_stock/theme/node--chado-stock.tpl.php

@@ -0,0 +1,147 @@
+<?php
+// Purpose: This template provides the layout of the stock node (page)
+//   using the same templates used for the various stock content blocks.
+//
+// To Customize the Stock Node Page:
+//   - This Template: customize basic layout and which elements are included
+//   - Using Panels: Override the node page using Panels3 and place the blocks
+//       of content as you please. This method requires no programming. See
+//       the Tripal User Guide for more details
+//   - Block Templates: customize the content/layout of each block of stock 
+//       content. These templates are found in the tripal_stock subdirectory
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+
+$stock = $variables['node']->stock;
+
+// get the template settings
+$template_settings = theme_get_setting('tripal');
+
+// toggle the sidebar if desired
+$no_sidebar = 0;
+if (is_array($template_settings['tripal_no_sidebar']) and 
+   $template_settings['tripal_no_sidebar']['stock']) {
+  $no_sidebar = 1;
+}
+
+if ($teaser) { 
+  print theme('tripal_stock_teaser',$node); 
+} 
+else { ?>
+
+<script type="text/javascript">
+(function ($) {
+  Drupal.behaviors.stockBehavior = {
+    attach: function (context, settings){ <?php 
+      if ($no_sidebar) { ?>    
+        // hide the resource side bar and strech the details section    
+        $(".tripal_toc").hide();
+        $(".tripal_details").addClass("tripal_details_full");
+        $(".tripal_details_full").removeClass("tripal_details"); <?php
+      } else { ?>
+        // use default resource sidebar
+        $(".tripal-info-box").hide(); <?php
+      } ?>
+ 
+      // iterate through all of the info boxes and add their titles
+      // to the table of contents
+      $(".tripal-info-box-title").each(function(){
+        var parent = $(this).parent();
+        var id = $(parent).attr('id');
+        var title = $(this).text();
+        $('#tripal_stock_toc_list').append('<li><a href="#'+id+'" class="tripal_stock_toc_item">'+title+'</a></li>');
+      });
+
+      // when a title in the table of contents is clicked, then
+      // show the corresponding item in the details box
+      $(".tripal_stock_toc_item").click(function(){
+         $(".tripal-info-box").hide();
+         href = $(this).attr('href');
+         $(href).fadeIn('slow');
+         // we want to make sure our table of contents and the details
+         // box stay the same height
+         $("#tripal_stock_toc").height($(href).parent().height());
+         return false;
+      }); 
+
+      // we want the base details to show up when the page is first shown 
+      // unless the user specified a specific block
+      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
+      if(block == null){
+         block = window.location.href.match(/[\?|\&]block=(.+)/)
+      }
+      if(block != null){
+         $("#tripal_stock-"+block[1]+"-box").show();
+      } else {
+         $("#tripal_stock-base-box").show();
+      }
+
+      $("#tripal_stock_toc").height($("#tripal_stock-base-box").parent().height());
+    }     
+  };
+})(jQuery);
+</script>
+
+<div id="tripal_stock_details" class="tripal_details">
+
+  <!-- Base Theme -->
+  <?php print theme('tripal_stock_base',$node); ?>
+
+  <!-- Cross References -->
+  <?php print theme('tripal_stock_references',$node); ?>
+
+  <!-- Properties -->
+  <?php print theme('tripal_stock_properties',$node); ?>
+
+  <!-- Synonyms -->
+  <?php print theme('tripal_stock_synonyms',$node); ?>
+
+  <!-- Relationships -->
+  <?php print theme('tripal_stock_relationships',$node); ?>
+  
+  <!-- Stock Collections -->
+  <?php print theme('tripal_stock_collections',$node); ?>
+
+  <!-- Stock Genotypes -->
+  <?php print theme('tripal_stock_genotypes',$node); ?>
+
+  <!-- Resource Blocks CCK elements --><?php
+  for($i = 0; $i < count($node->field_resource_titles); $i++){
+    if($node->field_resource_titles[$i]['value']){ ?>
+      <div id="tripal_stock-resource_<?php print $i?>-box" class="tripal_stock-info-box tripal-info-box">
+        <div class="tripal_stock-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
+        <?php print $node->field_resource_blocks[$i]['value']; ?>
+      </div><?php
+    }
+  }?>
+   
+  <!-- Let modules add more content -->
+	<?php print $content; ?>
+</div>
+
+<!-- Table of contents -->
+<div id="tripal_stock_toc" class="tripal_toc">
+   <div id="tripal_stock_toc_title" class="tripal_toc_title">Resources</div>
+   <span id="tripal_stock_toc_desc" class="tripal_toc_desc"></span>
+   <ul id="tripal_stock_toc_list" class="tripal_toc_list">
+   
+     <!-- Resource Links CCK elements --><?php
+     for($i = 0; $i < count($node->field_resource_links); $i++){
+       if($node->field_resource_links[$i]['value']){
+         $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
+         <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
+       }
+     }?>
+     
+     <?php // ADD CUSTOMIZED <li> LINKS HERE ?>
+   </ul>
+</div>
+<?php } ?>

+ 52 - 0
tripal_stock/theme/tripal_stock/tripal_stock_base.tpl.php

@@ -0,0 +1,52 @@
+<?php
+$stock = $node->stock;
+$organism = $node->stock->organism_id; 
+$main_db_reference = $stock->dbxref_id;
+
+// expand the text fields
+$stock = tripal_core_expand_chado_vars($stock, 'field', 'stock.description');
+$stock = tripal_core_expand_chado_vars($stock, 'field', 'stock.uniquename');
+
+?>
+<div id="tripal_stock-base-box" class="tripal_stock-info-box tripal-info-box">
+  <div class="tripal_stock-info-box-title tripal-info-box-title">Details</div>
+  <!-- <div class="tripal_stock-info-box-desc tripal-info-box-desc"></div> -->
+
+   <?php if($stock->is_obsolete == 't'){ ?>
+      <div class="tripal_stock-obsolete">This stock is obsolete and no longer used in analysis, but is here for reference</div>
+   <?php }?>
+   <table class="tripal_stock-table tripal-table tripal-table-vert">
+      <tr class="tripal_stock-table-even-row tripal-table-even-row">
+        <th>Name</th>
+        <td><?php print $stock->name; ?></td>
+      </tr>
+      <tr class="tripal_stock-table-odd-row tripal-table-odd-row">
+        <th nowrap>Unique Name</th>
+        <td><?php print $stock->uniquename ?></td>
+      </tr>
+      <tr class="tripal_stock-table-even-row tripal-table-even-row">
+        <th>Type</th>
+        <td><?php print ucwords(preg_replace('/_/', ' ', $stock->type_id->name)) ?></td>
+      </tr>
+      <tr class="tripal_stock-table-odd-row tripal-table-odd-row">
+        <th>Organism</th>
+        <td><?php 
+          if ($organism->nid) { ?>
+      	   <a href="<?php print url("node/$organism->nid") ?>"><?php print "<i>" . $organism->genus . 
+            " " . $organism->species . "</i> (" . $organism->common_name . " )"?></a><?php 
+          } else { 
+            print "<i>" . $organism->genus . " " . $organism->species . "</i> (" . $organism->common_name . ")";
+          } ?>
+        </td>
+     	</tr>   
+      <tr class="tripal_stock-table-even-row tripal-table-even-row">
+        <th>Description</th>
+        <td><?php print $stock->description ?></td>      
+      </tr>   
+      <!--  
+      <tr class="tripal_stock-table-odd-row tripal-table-odd-row">
+        <th>Internal ID</th>
+        <td><?php print $stock->stock_id ?></td>
+      </tr>     -->	                                
+   </table>
+</div>

+ 47 - 0
tripal_stock/theme/tripal_stock/tripal_stock_collections.tpl.php

@@ -0,0 +1,47 @@
+<?php
+$stock = $variables['node']->stock;
+
+// expand the stock object to include the stockcollections associated with this stock
+$options = array('return_array' => 1);
+$stock = tripal_core_expand_chado_vars($stock, 'table', 'stockcollection_stock', $options);
+$collections = $stock->stockcollection_stock;
+
+if (count($collections) > 0) {?>
+  <div id="tripal_stock-collections-box" class="tripal_stock-info-box tripal-info-box">
+    <div class="tripal_stock-info-box-title tripal-info-box-title">Stock Collections</div>
+    <div class="tripal_stock-info-box-desc tripal-info-box-desc">This stock is found in the following collections.</div>
+    <table id="tripal_stock-table-collection" class="tripal_stock-table tripal-table tripal-table-horz">     
+      <tr class="tripal_stock-table-odd-row tripal-table-even-row">
+        <th>Collection Name</th>
+        <th>Type</th>
+        <th>Contact</th>
+      </tr> <?php
+      foreach ($collections as $collection_stock){ 
+        // get the stock collection details
+        $collection = $collection_stock->stockcollection_id;
+        
+        $class = 'tripal_stock-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+          $class = 'tripal_stock-table-odd-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td><?php 
+            if($collection->nid){    
+              $link =  url("node/$collection->nid");        
+              print "<a href=\"$link\">$collection->name</a>";
+            } 
+            else {
+              print $collection->name;
+            } ?>
+          </td>
+          <td><?php print ucwords(preg_replace('/_/', ' ', $collection->type_id->name)) ?> </td>
+          <td><?php 
+            $contact = $collection->contact_id; 
+            print $contact->name . "<br>" .  $contact->description ?>              
+          </td>
+        </tr> <?php
+        $i++; 
+      }?>  
+    </table> 
+  </div><?php
+}

+ 125 - 0
tripal_stock/theme/tripal_stock/tripal_stock_genotypes.tpl.php

@@ -0,0 +1,125 @@
+<?php
+/*
+ * There are two ways that stock genotypes can be housed in Chado.  The first, more simple
+ * method, is via the stock_genotype table.  This is simply a linker table between the
+ * stock and genotype tables of Chado.  A more complex method is via the Natural Diversity
+ * tables.  In these tables, the genotypes are in the nd_experiment_genotype table 
+ * and there may be an associated project, contact info, etc. This template is for the simple
+ * stock_genotype linker table.
+ */
+$stock = $variables['node']->stock;
+
+// specify the number of genotypes to show by default and the unique pager ID
+$num_results_per_page = 25; 
+$stock_pager_id = 0;
+
+// get the genotypes from the stock_genotype table
+$options = array(
+  'return_array' => 1, 
+  'pager' => array('limit' => $num_results_per_page, 'element' => $stock_pager_id),
+);
+$stock = tripal_core_expand_chado_vars($stock, 'table', 'stock_genotype', $options); 
+$stock_genotypes = $stock->stock_genotype;
+
+// create the pager.  
+$stock_pager = theme('pager', array(), $num_results_per_page, $stock_pager_id, array('block' => 'genotypes'));
+
+
+// now iterate through the stock genotypes and print a paged table.
+if (count($stock_genotypes) > 0) {?>
+  <div id="tripal_stock-genotypes-box" class="tripal_stock-info-box tripal-info-box">
+    <div class="tripal_stock-info-box-title tripal-info-box-title">Genotypes</div>
+    <div class="tripal_stock-info-box-desc tripal-info-box-desc">This following genotypes have been recorded for this stock.</div>
+    <table id="tripal_stock-table-stock_genotypes_exp" class="tripal_stock-table tripal-table tripal-table-horz">     
+      <tr class="tripal_stock-table-odd-row tripal-table-even-row">
+        <th>Name</th>
+        <th>Type</th>
+        <th>Genotype</th>
+        <th>Details</th>
+        <th>Markers</th>
+      </tr> <?php       
+      $i = 0;   
+      foreach($stock_genotypes as $stock_genotype) {
+        $class = 'tripal_stock-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+          $class = 'tripal_stock-table-odd-row tripal-table-even-row';
+        }         
+        $genotype = $stock_genotype->genotype_id;
+        
+        // get the genotype properties
+        $options = array('return_array' => 1);
+        $genotype = tripal_core_expand_chado_vars($genotype, 'table', 'genotypeprop', $options);
+        $properties = $genotype->genotypeprop; 
+        
+        // add in markers associated with this genotype if any
+        $options = array(
+          'return_array' => 1,
+          'inlude_fk' => array(
+            'feature_id' => array(
+              'type_id' => 1
+            )
+          ),
+        );
+        $genotype = tripal_core_expand_chado_vars($genotype, 'table', 'feature_genotype', $options);
+        $feature_genotypes = $genotype->feature_genotype; ?>
+        <tr class="<?php print $class ?>">
+          <td><?php
+          if($genotype->name){
+             print $genotype->name;
+          } 
+          else {
+             print $genotype->uniquename;
+          } ?>
+          </td>
+          <td><?php
+            // Chado versions < v1.2 did not have a type_id field
+            if ($genotype->type_id) {
+              print ucwords(preg_replace('/_/', ' ', $genotype->type_id->name));
+            } 
+            else {
+              print 'N/A';
+            } ?>
+          </td>
+          <td><?php print $genotype->description ?></td>
+          <td><?php 
+            if(count($properties) > 0) { ?>           
+              <table class="tripal-subtable"> <?php
+                foreach ($properties as $property){ ?>
+                  <tr> 
+                    <td><?php print ucwords(preg_replace('/_/', ' ', $property->type_id->name)) ?></td>
+                    <td>:</td>                  
+                    <td><?php print $property->value ?>
+                    </td>
+                  </tr> <?php                 
+                } ?>
+              </table><?php 
+            } ?>
+          </td>
+          <td><?php 
+            if(count($feature_genotypes) > 0) { ?>                      
+              <table class="tripal-subtable"> <?php
+                foreach ($feature_genotypes as $feature_genotype){ 
+                  $feature = $feature_genotype->feature_id; ?>
+                  <tr> 
+                    <td><?php print ucwords(preg_replace('/_/', ' ', $feature->type_id->name)) ?></td>
+                    <td>:</td>                  
+                    <td><?php 
+                      if($feature->nid) {
+                        print l($feature->name, 'node/' . $feature->nid);
+                      }
+                      else {
+                        print $feature->name;
+                      }?>
+                    </td>
+                  </tr> <?php                 
+                } ?>
+              </table><?php 
+            } ?>
+          </td>
+        </tr> <?php
+        $i++;
+      } ?>  
+    </table> <?php 
+    print $stock_pager ?>
+  </div><?php
+} 

+ 100 - 0
tripal_stock/theme/tripal_stock/tripal_stock_nd_genotypes.tpl.php

@@ -0,0 +1,100 @@
+<?php
+/*
+ * There are two ways that stock genotypes can be housed in Chado.  The first, more simple
+ * method, is via the stock_genotype table.  This is simply a linker table between the
+ * stock and genotype tables of Chado.  A more complex method is via the Natural Diversity
+ * tables.  In these tables, the genotypes are in the nd_experiment_genotype table
+ * and there may be an associated project, contact info, etc.  This template handles
+ * stocks that are stored via the ND method.
+ */
+$stock = $variables['node']->stock;
+
+// specify the number of genotypes to show by default and the unique pager ID
+$num_results_per_page = 25;
+$pager_id = 500;
+
+// expand the stock object to include the nd_experiment_stock table
+$options = array(
+  'return_array' => 1,
+  'pager' => array (
+    'limit' => $num_results_per_page,
+    'element' => $pager_id,
+  ),
+);
+$stock = tripal_core_expand_chado_vars($stock, 'table', 'nd_experiment_stock', $options);
+$nd_experiment_stocks = $stock->nd_experiment_stock;
+
+// create the pager.  
+global $pager_total_items;
+$pager = theme('pager', array(), $num_results_per_page, $pager_id, array('block' => 'nd_genotypes'));
+$total_features = $pager_total_items[$pager_id];
+
+
+// now iterate through the experiments and create a paged table for each experiment
+if (count($nd_experiment_stocks) > 0) {?>
+  <div id="tripal_stock-nd_genotypes-box" class="tripal_stock-info-box tripal-info-box">
+    <div class="tripal_stock-info-box-title tripal-info-box-title">Genotypes</div>
+    <div class="tripal_stock-info-box-desc tripal-info-box-desc">This <?php print $stock->type_id->name ?> has <?php print number_format($total_features) ?> associated genotypes: </div>
+
+    <table id="tripal_stock-table-nd_stock_genotypes" class="tripal_stock-table tripal-table tripal-table-horz">
+        <tr class="tripal_stock-table-odd-row tripal-table-even-row">
+          <th>Project</th>
+          <th>Marker (Type)</th>
+          <th>Details</th>
+        </tr>
+
+    <?php
+    foreach ($nd_experiment_stocks as $nd_experiment_stock) {
+
+      // get the nd experiment
+      $values = array('nd_experiment_id' => $nd_experiment_stock->nd_experiment_id->nd_experiment_id);
+      $options = array('include_fk' => array('nd_geolocation_id' => 1)); 
+      $nd_experiment = tripal_core_generate_chado_var('nd_experiment', $values, $options);
+ 
+      // add in the project
+      $options = array('include_fk' => array('project_id' => 1)); 
+      $nd_experiment = tripal_core_expand_chado_vars($nd_experiment, 'table', 'nd_experiment_project', $options);
+      $project = $nd_experiment->nd_experiment_project->project_id;
+
+      // add in the nd_experiment_genotype table
+      $options = array('include_fk' => array('genotype_id' => 1)); 
+      $nd_experiment = tripal_core_expand_chado_vars($nd_experiment, 'table', 'nd_experiment_genotype', $options);
+
+      // add in the feature_genotype table
+      $genotype = $nd_experiment->nd_experiment_genotype->genotype_id;
+      $options = array('include_fk' => array('feature_id' => array('type_id' => 1))); 
+      $genotype = tripal_core_expand_chado_vars($genotype, 'table', 'feature_genotype', $options);
+
+      // add in the node for the feature
+      $marker = $genotype->feature_genotype->feature_id;
+      $marker = tripal_core_expand_chado_vars($marker, 'node', 'feature'); ?>
+      <tr class="tripal_stock-table-odd-row tripal-table-even-row">
+        <td><?php 
+          if ($project->nid) {
+            print l($project->name, 'node/' . $project->nid);
+          }
+          else {
+            print $project->name; 
+          } ?>
+        </td>
+        <td><?php
+          if ($marker->name != $marker->uniquename) {
+            $name = $marker->name . ', ' . $marker->uniquename . ' (' . $marker->type_id->name . ')';
+          } 
+          else {
+            $name = $marker->name . ' (' . $marker->type_id->name . ')';
+          }
+          if ($marker->nid) {
+            print l($name, 'node/' . $marker->nid);
+          }
+          else {         
+            print $name;
+          } ?>
+        </td>
+        <td><?php print $genotype->description; ?></td>
+      </tr> <?php
+    }?>
+  </table> <?php
+  print $pager; ?>
+  </div><?php
+}

+ 110 - 0
tripal_stock/theme/tripal_stock/tripal_stock_nd_phenotypes.tpl.php

@@ -0,0 +1,110 @@
+<?php
+$stock = $variables['node']->stock;
+
+// expand the stock object to include the nd_experiment_stock table
+$options = array('return_array' => 1);
+$stock = tripal_core_expand_chado_vars($stock, 'table', 'nd_experiment_stock', $options);
+$nd_experiment_stocks = $stock->nd_experiment_stock;
+
+// Get the experiments to which this stock belongs that have a phenotype
+// associated.  Store those in the phenotypes array indexed by the experiment_id
+$all_phenotypes = array();
+if (count($nd_experiment_stocks) > 0) {
+  foreach ($nd_experiment_stocks as $nd_experiment_stock){      
+    $values = array('nd_experiment_id' => $nd_experiment_stock->nd_experiment_id->nd_experiment_id);
+    $nd_experiment_phenotypes = tripal_core_generate_chado_var('nd_experiment_phenotype', $values, $options);
+    if ($nd_experiment_phenotypes) {
+    	foreach ($nd_experiment_phenotypes as $nd_exp_phenotype){
+        $phenotype = $nd_exp_phenotype->phenotype_id;
+        $all_phenotypes[$nd_experiment_stock->nd_experiment_id->nd_experiment_id][] = $phenotype;
+    	}
+    }
+  }
+}
+if (count($all_phenotypes) > 0) {?>
+  <div id="tripal_stock-phenotypes-box" class="tripal_stock-info-box tripal-info-box">
+    <div class="tripal_stock-info-box-title tripal-info-box-title">Phenotypes</div>
+    <div class="tripal_stock-info-box-desc tripal-info-box-desc">This following phenotypes have been recorded for this stock.</div>
+ 
+    <table id="tripal_stock-table-phenotypes_exp" class="tripal_stock-table tripal-table tripal-table-horz">     
+      <tr class="tripal_stock-table-odd-row tripal-table-even-row">
+        <th>Phenotypes</th>
+        <th>Project</th>
+      </tr> <?php
+      
+      // iterate through the nd_experiment_stock records and get 
+      // each experiment and the associated phenotypes
+      foreach ($nd_experiment_stocks as $nd_experiment_stock){      
+        // Get the project for this experiment. For each nd_experiment_id there can only be one project
+        $values = array('nd_experiment_id' => $nd_experiment_stock->nd_experiment_id->nd_experiment_id);
+        $nd_experiment_project = tripal_core_generate_chado_var('nd_experiment_project', $values, $options);
+        $project = $nd_experiment_project[0]->project_id;
+
+        // get the phenotypes
+        $phenotypes = $all_phenotypes[$nd_experiment_stock->nd_experiment_id->nd_experiment_id];
+        if(!$phenotypes){
+          $phenotypes = array();
+        }
+                
+        $class = 'tripal_stock-table-odd-row tripal-table-odd-row';
+        if($i % 2 == 0 ){
+          $class = 'tripal_stock-table-odd-row tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td>           
+            <table class="tripal-subtable"> <?php
+              foreach ($phenotypes as $phenotype){
+                if ($phenotype->name) { ?>
+	                <tr> 
+	                  <td>Name</td>
+	                  <td>:</td>
+	                  <td><?php print $phenotype->name ?></td>
+	                </tr> <?php 
+                }?>
+                <tr> 
+                  <td><?php print ucwords(preg_replace('/_/', ' ', $phenotype->attr_id->name)) ?></td>
+                  <td>:</td>                  
+                  <td><?php 
+	                  // pheonotypes values are stored qualitatively or quantitatively.  If
+	                  // qualitatively the cvalue_id will link to a type. If quantitative we
+	                  // us ethe value column                  
+	                  if ($phenotype->cvalue_id) { 
+	                  	print ucwords(preg_replace('/_/', ' ', $phenotype->cvalue_id->name));
+	                  }
+	                  else { 
+	                    print $phenotype->value;
+	                  } ?>
+                  </td>
+                </tr> <?php 
+                if ($phenotype->observable_id) { ?>
+	                <tr>
+	                  <td>Observable Unit</td>
+	                  <td>:</td>
+	                  <td><?php print ucwords(preg_replace('/_/', ' ', $phenotype->observable_id->name)) ?></td>
+	                </tr> <?php 
+                }
+                if ($phenotype->assay_id) { ?>
+	                <tr>
+	                  <td>Evidence</td>
+	                  <td>:</td>
+	                  <td><?php print ucwords(preg_replace('/_/', ' ', $phenotype->assay_id->name)) ?></td>
+	                </tr><?php
+                }
+              } ?>
+            </table>
+          </td>
+          <td><?php 
+            if($project->nid){    
+              $link =  url("node/$project->name");        
+              print "<a href=\"$link\">$project->name</a>";
+            } 
+            else {
+              print $project->name;
+            } ?>
+          </td>
+        </tr> <?php
+        $i++; 
+      }?>  
+    </table> 
+  </div><?php
+}

+ 47 - 0
tripal_stock/theme/tripal_stock/tripal_stock_properties.tpl.php

@@ -0,0 +1,47 @@
+<?php
+
+$stock = $node->stock;
+$properties = array();
+
+// expand the stock object to include the stockprop records
+$options = array('return_array' => 1);
+$stock = tripal_core_expand_chado_vars($stock, 'table', 'stockprop', $options);
+$stockprops = $stock->stockprop;
+
+// iterate through all of the properties and pull out only the synonyms
+if ($stockprops) {
+  foreach ($stockprops as $stockprop){    
+    if($stockprop->type_id->name == 'synonym' or $stockprop->type_id->name == 'alias'){
+      // there is no stock_synonym table, analogous to the feature_synonym table.
+      // Therefore, synonyms have been stored in the stockprop table with a type 
+      // of 'synonym' or 'alias'. Synonyms are shown in the tripal_stock_synonyms.tpl.php
+      // template, so we exclude those types of properties for this template    
+    } 
+    else {
+      $properties[] = $stockprop;  
+    }
+  }
+}
+
+if(count($properties) > 0){ ?>
+	<div id="tripal_stock-properties-box" class="tripal_stock-info-box tripal-info-box">
+	  <div class="tripal_stock-info-box-title tripal-info-box-title">Properties</div>
+	  <div class="tripal_stock-info-box-desc tripal-info-box-desc">Properties for the stock '<?php print $node->stock->name ?>' include:</div>
+	  <table class="tripal_stock-table tripal-table tripal-table-horz">
+	    <tr><th>Type</th><th>Value</th></tr> <?php	
+			$i = 0;
+			// iterate through each property
+			foreach ($properties as $property){
+			  $class = 'tripal_stock-table-odd-row tripal-table-odd-row';
+	      if($i % 2 == 0 ){
+	         $class = 'tripal_stock-table-even-row tripal-table-even-row';
+	      }?>   
+        <tr class="<?php print $class ?>">
+          <td><?php print ucwords(preg_replace('/_/', ' ', $property->type_id->name)) ?></td>
+          <td><?php print $property->value?></td>
+        </tr> <?php	      
+				$i++;
+			} ?>
+	  </table>
+	</div><?php  
+}

+ 61 - 0
tripal_stock/theme/tripal_stock/tripal_stock_references.tpl.php

@@ -0,0 +1,61 @@
+<?php
+$stock = $variables['node']->stock;
+$references = array();
+
+// First, get the dbxref record from stock recrod itself if one exists
+if ($stock->dbxref_id) {
+  $stock->dbxref_id->is_primary = 1;  // add this new property so we know it's the primary reference
+  $references[] = $stock->dbxref_id;
+}
+
+// Second, expand the stock object to include the records from the stock_dbxref table
+$options = array('return_array' => 1);
+$stock = tripal_core_expand_chado_vars($stock, 'table', 'stock_dbxref', $options);
+$stock_dbxrefs = $stock->stock_dbxref;
+if (count($stock_dbxrefs) > 0 ) {
+  foreach ($stock_dbxrefs as $stock_dbxref) {
+    $references[] = $stock_dbxref->dbxref_id;
+  }
+}
+
+if(count($references) > 0){ ?>
+	<div id="tripal_stock-references-box" class="tripal_stock-info-box tripal-info-box">
+	  <div class="tripal_stock-info-box-title tripal-info-box-title">Cross References</div>
+	  <div class="tripal_stock-info-box-desc tripal-info-box-desc">The stock '<?php print $node->stock->name ?>' is also available at these locations</div>
+	  <table class="tripal_stock-table tripal-table tripal-table-horz">
+	    <tr>
+	      <th>Dababase</th>
+	      <th>Accession</th>
+	    </tr> <?php
+	    $i = 0; 
+	    foreach ($references as $dbxref){ 
+	      $class = 'tripal_stock-table-odd-row tripal-table-odd-row';
+	      if($i % 2 == 0 ){
+	         $class = 'tripal_stock-table-odd-row tripal-table-even-row';
+	      } ?>
+	      <tr class="<?php print $class ?>">
+	        <td> <?php 
+	          if ($dbxref->db_id->url) { 
+              print l($dbxref->db_id->name, $dbxref->db_id->url);
+            } 
+            else { 
+              print $dbxref->db_id->name; 
+            } ?>
+	        </td>
+	        <td> <?php 
+	          if ($dbxref->db_id->urlprefix) { 
+	           	print l($dbxref->accession, $dbxref->db_id->urlprefix.$dbxref->accession);
+	          } 
+	          else { 
+	            print $dbxref->accession; 
+	          }
+	          if ($dbxref->is_primary) {
+	            print " <i>(primary cross-reference)</i>";
+	          } ?>
+	        </td>
+	      </tr> <?php
+	      $i++;  
+	    } ?>
+	  </table> 
+	</div><?php 
+}

+ 101 - 0
tripal_stock/theme/tripal_stock/tripal_stock_relationships.tpl.php

@@ -0,0 +1,101 @@
+<?php
+/* Typically in a Tripal template, the data needed is retrieved using a call to
+ * tripal_core_expand_chado_vars function.  For example, to retrieve all 
+ * of the stock relationships for this node, the following function call would be made:
+ * 
+ *   $stock = tripal_core_expand_chado_vars($stock,'table','stock_relationship');
+ * 
+ * However, this function call can be extremely slow when there are numerous relationships.
+ * This is because the tripal_core_expand_chado_vars function is recursive and expands 
+ * all data following the foreign key relationships tree.  Therefore, to speed retrieval
+ * of data, a special variable is provided to this template:
+ * 
+ *   $stock->all_relationships;
+ *   
+ * This variable is an array with two sub arrays with the keys 'object' and 'subject'.  The array with
+ * key 'object' contains relationships where the stock is the object, and the array with
+ * the key 'subject' contains relationships where the stock is the subject
+ */
+
+$stock = $variables['node']->stock;
+
+$all_relationships = $stock->all_relationships;
+$object_rels = $all_relationships['object'];
+$subject_rels = $all_relationships['subject'];
+
+// make the stock type a bit more human readable
+$stock_type =  preg_replace("/_/", ' ', $stock->type_id->name);
+
+if (count($object_rels) > 0 or count($subject_rels) > 0) {
+?>
+  <div id="tripal_stock-relationships-box" class="tripal_stock-info-box tripal-info-box">
+    <div class="tripal_stock-info-box-title tripal-info-box-title">Relationships</div>
+    <!--  <div class="tripal_stock-info-box-desc tripal-info-box-desc"></div> --><?php
+    
+      // first add in the subject relationships.  
+      foreach ($subject_rels as $rel_type => $rels){
+         // make the type a bit more human readable
+         $rel_type = preg_replace("/_/", ' ', $rel_type);
+         $rel_type = preg_replace("/^is/", '', $rel_type);
+         // iterate through each parent   
+         foreach ($rels as $obj_type => $objects){?>
+           <p>This stock is a <b><?php print $rel_type ?></b> of the following <?php print $obj_type ?> stock(s):
+           <table id="tripal_stock-relationships_as_object-table" class="tripal_stock-table tripal-table tripal-table-horz">
+             <tr>
+               <th>Stock Name</th>
+               <th>Type</th>
+               <th>Description</th>
+             </tr> <?php
+             foreach ($objects as $object){ ?>
+               <tr>
+                 <td><?php 
+                    if ($object->nid) {
+                      print "<a href=\"" . url("node/" . $object->nid) . "\" target=\"_blank\">" . $object->name . "</a>";
+                    }
+                    else {
+                      print $object->name;
+                    } ?>
+                 </td>
+                 <td><?php print ucwords(preg_replace('/_/', ' ', $object->obj_type)) ?></td> 
+                 <td><?php print $object->value ?></td>                
+               </tr> <?php
+             } ?>
+             </table>
+             </p><br><?php
+         }
+      }
+      
+      // second add in the object relationships.  
+      foreach ($object_rels as $rel_type => $rels){
+         // make the type more human readable
+         $rel_type = preg_replace('/_/', ' ', $rel_type);
+         $rel_type = preg_replace("/^is/", '', $rel_type);
+         // iterate through the children         
+         foreach ($rels as $subject_type => $subjects){?>
+           <p>The following <?php print $subject_type ?> stocks are a <b><?php print $rel_type ?></b> of this stock:
+           <table id="tripal_stock-relationships_as_object-table" class="tripal_stock-table tripal-table tripal-table-horz">
+             <tr>
+               <th>Stock Name</th>
+               <th>Type</th>
+               <th>Description</th>
+             </tr> <?php
+             foreach ($subjects as $subject){ ?>
+               <tr>
+                 <td><?php 
+                    if ($subject->nid) {
+                      print "<a href=\"" . url("node/" . $subject->nid) . "\" target=\"_blank\">" . $subject->name . "</a>";
+                    }
+                    else {
+                      print $subject->name;
+                    } ?>
+                 </td>
+                 <td><?php print ucwords(preg_replace('/_/', ' ', $subject->sub_type)) ?></td>   
+                 <td><?php print $subject->value ?></td>              
+               </tr> <?php
+             } ?>
+             </table>
+             </p><br><?php
+         }
+      } ?>
+  </div> <?php
+}

+ 44 - 0
tripal_stock/theme/tripal_stock/tripal_stock_synonyms.tpl.php

@@ -0,0 +1,44 @@
+<?php
+// there is no stock_synonym table, analogous to the feature_synonym table.
+// Therefore, synonyms have been stored in the stockprop table with a type 
+// of 'synonym' or 'alias'.
+$stock = $node->stock;
+$synonyms = array();
+
+// expand the stock object to include the stockprop records
+$options = array('return_array' => 1);
+$stock = tripal_core_expand_chado_vars($stock, 'table', 'stockprop', $options);
+$stockprops = $stock->stockprop;
+
+// iterate through all of the properties and pull out only the synonyms
+if ($stockprops) {
+  foreach ($stockprops as $stockprop){    
+    if($stockprop->type_id->name == 'synonym' or $stockprop->type_id->name == 'alias'){
+      $synonyms[] = $stockprop;
+    }
+  }
+}
+
+if(count($synonyms) > 0){ ?>
+	<div id="tripal_stock-synonyms-box" class="tripal_stock-info-box tripal-info-box">
+	  <div class="tripal_stock-info-box-title tripal-info-box-title">Synonyms</div>
+	  <div class="tripal_stock-info-box-desc tripal-info-box-desc">The feature '<?php print $stock->name ?>' has the following synonyms</div> 
+	  		
+	  <table id="tripal_stock-synonyms-table" class="tripal_stock-table tripal-table tripal-table-horz">
+      <tr>
+        <th>Name</th>
+      </tr> <?php
+      $i = 0; 
+      foreach ($synonyms as $synonym){
+        $class = 'tripal-table-odd-row';
+        if($i % 2 == 0 ){
+           $class = 'tripal-table-even-row';
+        } ?>
+        <tr class="<?php print $class ?>">
+          <td><?php print $synonym->value?></td>
+        </tr> <?php
+        $i++;  
+      } ?>
+    </table>
+	</div><?php
+}

+ 85 - 0
tripal_stock/theme/tripal_stock/tripal_stock_teaser.tpl.php

@@ -0,0 +1,85 @@
+<?php
+// Purpose: Provide layout and content for the basic stock details. This
+//   includes all fields in the chado stock table supplemented with extra
+//   details for each foreign key to provide human-readable output
+//
+// Note: This template controls the layout/content for the default stock node
+//   template (node-chado_stock.tpl.php) and the Stock Details Block
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes stock
+//       specific fields such as stock_name, uniquename, stock_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+?>
+
+<?php
+ //uncomment this line to see a full listing of the fields avail. to $node
+ //print '<pre>'.print_r($node,TRUE).'</pre>';
+?>
+
+<?php 
+  $stock = $node->stock;
+  $organism = $node->stock->organism_id; 
+  $main_db_reference = $stock->dbxref_id;
+?>
+
+<div id="tripal_stock-base-box" class="tripal_stock-info-box tripal-info-box">
+  <div class="tripal_stock-info-box-title tripal-info-box-title">
+    <?php print l($node->stock->name, 'node/'.$node->nid); ?>
+  </div>
+  <div class="tripal_stock-info-box-desc tripal-info-box-desc"></div>
+  
+   <?php if($stock->is_obsolete == 't'){ ?>
+      <div class="tripal_stock-obsolete">This stock is obsolete and no longer used in analysis, but is here for reference</div>
+   <?php }?>
+   <table class="tripal_stock-table tripal-table tripal-table-vert">
+      <tr class="tripal_stock-table-odd-row tripal-table-even-row">
+        <th>Name</th>
+        <td><?php print $stock->name; ?></td>
+      </tr>
+      <tr class="tripal_stock-table-odd-row tripal-table-odd-row">
+        <th nowrap>Unique Name</th>
+        <td><?php print $stock->uniquename; ?></td>
+      </tr>
+      <tr class="tripal_stock-table-odd-row tripal-table-even-row">
+        <th>Internal ID</th>
+        <?php if (!empty($main_db_reference->dbxref_id)) { ?>
+        	<?php 
+        		if ($main_db_reference->db_id->urlprefix) {
+        			$accession = l($main_db_reference->accession, $main_db_reference->db_id->urlprefix.$main_db_reference->accession);
+        		} else {
+        			$accession = $main_db_reference->accession;
+        		}
+        		if ($main_db_reference->db_id->url) {
+        			$accession .= ' ('.l($main_db_reference->db_id->name, $main_db_reference->db_id->url).')';
+        		} else {
+        			$accession .= ' ('.$main_db_reference->db_id->name.')';
+        		}
+        	?>
+        	<td><?php print $accession; ?></td>
+        <?php } else { ?>
+        	<td></td>
+        <?php } ?>
+      </tr>
+      <tr class="tripal_stock-table-odd-row tripal-table-odd-row">
+        <th>Type</th>
+        <td><?php print $stock->type_id->name; ?></td>
+      </tr>
+      <tr class="tripal_stock-table-odd-row tripal-table-even-row">
+        <th>Organism</th>
+        <td>
+          <?php if ($organism->nid) { ?>
+      	   <a href="<?php print url("node/$organism->nid") ?>"><?php print $organism->genus ." " . $organism->species ." (" .$organism->common_name ." )"?></a>
+      	 <?php 
+          } else { 
+            print $organism->genus ." " . $organism->species ." (" .$organism->common_name ." )";
+          } ?>
+        </td>
+     	</tr>           	                                
+   </table>
+</div>