tripal_phylogeny_references.tpl.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. $phylotree = $variables['node']->phylotree;
  3. $dbxref = $phylotree->dbxref_id;
  4. // Make sure the dbxref isn't the null database. If not, then show this pane.
  5. if ($dbxref and $dbxref->db_id->name != 'null') { ?>
  6. <div class="tripal_phylogeny-data-block-desc tripal-data-block-desc">This tree is also available in the following databases:</div><?php
  7. // the $headers array is an array of fields to use as the colum headers.
  8. // additional documentation can be found here
  9. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  10. $headers = array('Database', 'Accession');
  11. // the $rows array contains an array of rows where each row is an array
  12. // of values for each column of the table in that row. Additional documentation
  13. // can be found here:
  14. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  15. $rows = array();
  16. $database = $dbxref->db_id->name . ': ' . $dbxref->db_id->description;
  17. if ($dbxref->db_id->url) {
  18. $database = l($dbxref->db_id->name, $dbxref->db_id->url, array('attributes' => array('target' => '_blank'))) . ': ' . $dbxref->db_id->description;
  19. }
  20. $accession = $dbxref->db_id->name . ':' . $dbxref->accession;
  21. if ($dbxref->db_id->urlprefix) {
  22. $accession = l($accession, $dbxref->db_id->urlprefix . $dbxref->accession, array('attributes' => array('target' => '_blank')));
  23. }
  24. $rows[] = array(
  25. $database,
  26. $accession
  27. );
  28. // the $table array contains the headers and rows array as well as other
  29. // options for controlling the display of the table. Additional
  30. // documentation can be found here:
  31. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  32. $table = array(
  33. 'header' => $headers,
  34. 'rows' => $rows,
  35. 'attributes' => array(
  36. 'id' => 'tripal_phylogeny-table-references',
  37. 'class' => 'tripal-data-table'
  38. ),
  39. 'sticky' => FALSE,
  40. 'caption' => '',
  41. 'colgroups' => array(),
  42. 'empty' => t('There are no database cross-references for this tree'),
  43. );
  44. // once we have our table array structure defined, we call Drupal's theme_table()
  45. // function to generate the table.
  46. print theme_table($table);
  47. }