tripal_feature_references.tpl.php 2.4 KB

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