tripal_organism_base.tpl.php 3.3 KB

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