tripal_featuremap.references.tpl.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. $featuremap = $variables['node']->featuremap;
  3. $references = array();
  4. // expand the featuremap object to include the records from the featuremap_dbxref table
  5. $options = array('return_array' => 1);
  6. $featuremap = tripal_core_expand_chado_vars($featuremap, 'table', 'featuremap_dbxref', $options);
  7. $featuremap_dbxrefs = $featuremap->featuremap_dbxref;
  8. if (count($featuremap_dbxrefs) > 0 ) {
  9. foreach ($featuremap_dbxrefs as $featuremap_dbxref) {
  10. $references[] = $featuremap_dbxref->dbxref_id;
  11. }
  12. }
  13. if(count($references) > 0){ ?>
  14. <div id="tripal_featuremap-references-box" class="tripal_featuremap-info-box tripal-info-box">
  15. <div class="tripal_featuremap-info-box-title tripal-info-box-title">Cross References</div>
  16. <div class="tripal_featuremap-info-box-desc tripal-info-box-desc">External references for this map</div><?php
  17. // the $headers array is an array of fields to use as the colum headers.
  18. // additional documentation can be found here
  19. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  20. $headers = array('Dababase', 'Accession');
  21. // the $rows array contains an array of rows where each row is an array
  22. // of values for each column of the table in that row. Additional documentation
  23. // can be found here:
  24. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  25. $rows = array();
  26. foreach ($references as $dbxref){
  27. $dbname = $dbxref->db_id->name;
  28. if ($dbxref->db_id->url) {
  29. $dbname = l($dbname, $dbxref->db_id->url, array('attributes' => array('target' => '_blank')));
  30. }
  31. $accession = $dbxref->accession;
  32. if ($dbxref->db_id->urlprefix) {
  33. $accession = l($accession, $dbxref->db_id->urlprefix . $dbxref->accession, array('attributes' => array('target' => '_blank')));
  34. }
  35. $rows[] = array(
  36. $dbname,
  37. $accession
  38. );
  39. }
  40. // the $table array contains the headers and rows array as well as other
  41. // options for controlling the display of the table. Additional
  42. // documentation can be found here:
  43. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  44. $table = array(
  45. 'header' => $headers,
  46. 'rows' => $rows,
  47. 'attributes' => array(
  48. 'id' => 'tripal_featuremap-table-references',
  49. ),
  50. 'sticky' => FALSE,
  51. 'caption' => '',
  52. 'colgroups' => array(),
  53. 'empty' => '',
  54. );
  55. // once we have our table array structure defined, we call Drupal's theme_table()
  56. // function to generate the table.
  57. print theme_table($table); ?>
  58. </div><?php
  59. }?>