tripal_phylogeny_references.tpl.php 2.1 KB

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