tripal_feature_base.tpl.php 2.9 KB

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