tripal_organism_base.tpl.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. $organism = $variables['node']->organism;
  3. $organism = chado_expand_var($organism, 'field', 'organism.comment'); ?>
  4. <div class="tripal_organism-data-block-desc tripal-data-block-desc"></div><?php
  5. // generate the image tag
  6. $image = '';
  7. $image_url = tripal_get_organism_image_url($organism);
  8. if ($image_url) {
  9. $image = "<img class=\"tripal-organism-img img-fluid\" src=\"$image_url\">";
  10. }
  11. // the $headers array is an array of fields to use as the colum headers.
  12. // additional documentation can be found here
  13. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  14. // This table for the organism has a vertical header (down the first column)
  15. // so we do not provide headers here, but specify them in the $rows array below.
  16. $headers = array();
  17. // the $rows array contains an array of rows where each row is an array
  18. // of values for each column of the table in that row. Additional documentation
  19. // can be found here:
  20. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  21. $rows = array();
  22. // genus row
  23. $rows[] = array(
  24. array(
  25. 'data' => 'Genus',
  26. 'header' => TRUE
  27. ),
  28. '<i>' . $organism->genus . '</i>'
  29. );
  30. // species row
  31. $rows[] = array(
  32. array(
  33. 'data' => 'Species',
  34. 'header' => TRUE
  35. ),
  36. '<i>' . $organism->species . '</i>'
  37. );
  38. // common name row
  39. $rows[] = array(
  40. array(
  41. 'data' => 'Common Name',
  42. 'header' => TRUE
  43. ),
  44. $organism->common_name,
  45. );
  46. // abbreviation row
  47. $rows[] = array(
  48. array(
  49. 'data' => 'Abbreviation',
  50. 'header' => TRUE
  51. ),
  52. $organism->abbreviation
  53. );
  54. // allow site admins to see the organism ID
  55. if (user_access('view ids')) {
  56. // Organism ID
  57. $rows[] = array(
  58. array(
  59. 'data' => 'Organism ID',
  60. 'header' => TRUE,
  61. 'class' => 'tripal-site-admin-only-table-row',
  62. ),
  63. array(
  64. 'data' => $organism->organism_id,
  65. 'class' => 'tripal-site-admin-only-table-row',
  66. ),
  67. );
  68. }
  69. // the $table array contains the headers and rows array as well as other
  70. // options for controlling the display of the table. Additional
  71. // documentation can be found here:
  72. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  73. $table = array(
  74. 'header' => $headers,
  75. 'rows' => $rows,
  76. 'attributes' => array(
  77. 'id' => 'tripal_organism-table-base',
  78. 'class' => 'tripal-organism-data-table tripal-data-table table table-striped',
  79. ),
  80. 'sticky' => FALSE,
  81. 'caption' => '',
  82. 'colgroups' => array(),
  83. 'empty' => '',
  84. );
  85. // once we have our table array structure defined, we call Drupal's theme_table()
  86. // function to generate the table.
  87. if (empty($image)) {
  88. print theme_table($table);
  89. print $organism->comment;
  90. }
  91. else {
  92. ?>
  93. <div class="row">
  94. <div class="col-lg-8">
  95. <?php print theme_table($table); ?>
  96. <?php print $organism->comment; ?>
  97. </div>
  98. <div class="col-lg-4">
  99. <?php print $image; ?>
  100. </div>
  101. </div>
  102. <?php } ?>