tripal_organism_references.tpl.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. $organism = $variables['node']->organism;
  3. $references = array();
  4. // expand the organism object to include the records from the organism_dbxref table
  5. $options = array('return_array' => 1);
  6. $organism = chado_expand_var($organism, 'table', 'organism_dbxref', $options);
  7. $organism_dbxrefs = $organism->organism_dbxref;
  8. if (count($organism_dbxrefs) > 0 ) {
  9. foreach ($organism_dbxrefs as $organism_dbxref) {
  10. if($organism_dbxref->dbxref_id->db_id->name == 'GFF_source'){
  11. // check to see if the reference 'GFF_source' is there. This reference is
  12. // used to if the Chado Perl GFF loader was used to load the organisms
  13. }
  14. else {
  15. $references[] = $organism_dbxref->dbxref_id;
  16. }
  17. }
  18. }
  19. if(count($references) > 0){ ?>
  20. <div class="tripal_organism-data-block-desc tripal-data-block-desc">External references for this organism</div><?php
  21. // the $headers array is an array of fields to use as the colum headers.
  22. // additional documentation can be found here
  23. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  24. $headers = array('Database', 'Accession');
  25. // the $rows array contains an array of rows where each row is an array
  26. // of values for each column of the table in that row. Additional documentation
  27. // can be found here:
  28. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  29. $rows = array();
  30. foreach ($references as $dbxref){
  31. // skip the GFF_source entry as this is just needed for the GBrowse chado adapter
  32. if ($dbxref->db_id->name == 'GFF_source'){
  33. continue;
  34. }
  35. $dbname = $dbxref->db_id->name;
  36. if ($dbxref->db_id->url) {
  37. $dbname = l($dbname, $dbxref->db_id->url, array('attributes' => array('target' => '_blank')));
  38. }
  39. $accession = $dbxref->accession;
  40. if ($dbxref->db_id->urlprefix) {
  41. $accession = l($accession, $dbxref->db_id->urlprefix . $dbxref->accession, array('attributes' => array('target' => '_blank')));
  42. }
  43. if (property_exists($dbxref, 'is_primary')) {
  44. $accession .= " <i>(primary cross-reference)</i>";
  45. }
  46. $rows[] = array(
  47. $dbname,
  48. $accession
  49. );
  50. }
  51. // the $table array contains the headers and rows array as well as other
  52. // options for controlling the display of the table. Additional
  53. // documentation can be found here:
  54. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  55. $table = array(
  56. 'header' => $headers,
  57. 'rows' => $rows,
  58. 'attributes' => array(
  59. 'id' => 'tripal_organism-table-references',
  60. 'class' => 'tripal-data-table'
  61. ),
  62. 'sticky' => FALSE,
  63. 'caption' => '',
  64. 'colgroups' => array(),
  65. 'empty' => '',
  66. );
  67. // once we have our table array structure defined, we call Drupal's theme_table()
  68. // function to generate the table.
  69. print theme_table($table);
  70. }?>