tripal_pub_references.tpl.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. $pub = $variables['node']->pub;
  3. // expand the pub object to include the records from the pub_dbxref table
  4. $options = array('return_array' => 1);
  5. $pub = tripal_core_expand_chado_vars($pub, 'table', 'pub_dbxref', $options);
  6. $pub_dbxrefs = $pub->pub_dbxref;
  7. $references = array();
  8. if (count($pub_dbxrefs) > 0 ) {
  9. foreach ($pub_dbxrefs as $pub_dbxref) {
  10. $references[] = $pub_dbxref->dbxref_id;
  11. }
  12. }
  13. if(count($references) > 0){ ?>
  14. <div id="tripal_pub-references-box" class="tripal_pub-info-box tripal-info-box">
  15. <div class="tripal_pub-info-box-title tripal-info-box-title">Cross References</div>
  16. <div class="tripal_pub-info-box-desc tripal-info-box-desc">This publication is also available in the following databases:</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('Database', '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. $database = $dbxref->db_id->name . ': ' . $dbxref->db_id->description;
  28. if ($dbxref->db_id->url) {
  29. $database = l($dbxref->db_id->name, $dbxref->db_id->url, array('attributes' => array('target' => '_blank'))) . ': ' . $dbxref->db_id->description;
  30. }
  31. $accession = $dbxref->db_id->name . ':' . $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. if (property_exists($dbxref, 'is_primary')) {
  36. $accession .= " <i>(primary cross-reference)</i>";
  37. }
  38. $rows[] = array(
  39. $database,
  40. $accession
  41. );
  42. }
  43. // the $table array contains the headers and rows array as well as other
  44. // options for controlling the display of the table. Additional
  45. // documentation can be found here:
  46. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  47. $table = array(
  48. 'header' => $headers,
  49. 'rows' => $rows,
  50. 'attributes' => array(
  51. 'id' => 'tripal_pub-table-references',
  52. ),
  53. 'sticky' => FALSE,
  54. 'caption' => '',
  55. 'colgroups' => array(),
  56. 'empty' => '',
  57. );
  58. // once we have our table array structure defined, we call Drupal's theme_table()
  59. // function to generate the table.
  60. print theme_table($table);?>
  61. </div><?php
  62. }