tripal_feature_references.tpl.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. $feature = $variables['node']->feature;
  3. // get the references. if only one reference exists then we want to convert
  4. // the object into an array, otherwise the value is an array
  5. $references = $feature->feature_dbxref;
  6. if (!$references) {
  7. $references = array();
  8. } elseif (!is_array($references)) {
  9. $references = array($references);
  10. }
  11. // check to see if the reference 'GFF_source' is there. This reference is
  12. // used to help the GBrowse chado adapter find features. We don't need to show
  13. // it
  14. if($references[0]->dbxref_id->db_id->name == 'GFF_source' and count($references)==1){
  15. $references = array();
  16. }
  17. ?>
  18. <div id="tripal_feature-references-box" class="tripal_feature-info-box tripal-info-box">
  19. <div class="tripal_feature-info-box-title tripal-info-box-title">References</div>
  20. <div class="tripal_feature-info-box-desc tripal-info-box-desc">External references for this <?php print $feature->type_id->name ?></div>
  21. <?php if(count($references) > 0){ ?>
  22. <table id="tripal_feature-references-table" class="tripal_feature-table tripal-table tripal-table-horz">
  23. <tr>
  24. <th>Dababase</th>
  25. <th>Accession</th>
  26. </tr>
  27. <?php
  28. $i = 0;
  29. foreach ($references as $feature_dbxref){
  30. if($feature_dbxref->dbxref_id->db_id->name == 'GFF_source'){
  31. continue; // skip the GFF_source entry as this is just needed for the GBrowse chado adapter
  32. }
  33. $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
  34. if($i % 2 == 0 ){
  35. $class = 'tripal_feature-table-odd-row tripal-table-even-row';
  36. }
  37. ?>
  38. <tr class="<?php print $class ?>">
  39. <td><?php print $feature_dbxref->dbxref_id->db_id->name?></td>
  40. <td><?php
  41. if($feature_dbxref->db_id->urlprefix){
  42. ?><a href="<?php print $feature_dbxref->db_id->urlprefix.$feature_dbxref->dbxref_id->accession?>" target="_blank"><?php print $feature_dbxref->dbxref_id->accession?></a><?php
  43. } else {
  44. print $feature_dbxref->dbxref_id->accession;
  45. }
  46. ?>
  47. </td>
  48. </tr>
  49. <?php
  50. $i++;
  51. } ?>
  52. </table>
  53. <?php } else { ?>
  54. <div class="tripal-no-results">There are no external references</div>
  55. <?php }?>
  56. </div>