tripal_library_base.tpl.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. $library = $variables['node']->library;
  3. // get the library description. IT uses a tern name of 'Library Description'
  4. $record = [
  5. 'table' => 'library',
  6. 'id' => $library->library_id,
  7. ];
  8. $property = [
  9. 'type_name' => 'Library Description',
  10. 'cv_name' => 'library_property',
  11. ];
  12. $libprop = chado_get_property($record, $property);
  13. $description = isset($libprop->value) ? $libprop->value : ''; ?>
  14. <div class="tripal_library-data-block-desc tripal-data-block-desc"></div> <?php
  15. // the $headers array is an array of fields to use as the colum headers.
  16. // additional documentation can be found here
  17. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  18. // This table for the library has a vertical header (down the first column)
  19. // so we do not provide headers here, but specify them in the $rows array below.
  20. $headers = [];
  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 = [];
  26. // Name row
  27. $rows[] = [
  28. [
  29. 'data' => 'Library Name',
  30. 'header' => TRUE,
  31. 'width' => '20%',
  32. ],
  33. $library->name,
  34. ];
  35. // Unique row
  36. $rows[] = [
  37. [
  38. 'data' => 'Unique Name',
  39. 'header' => TRUE,
  40. ],
  41. $library->uniquename,
  42. ];
  43. // Organism row
  44. $organism = $library->organism_id->genus . " " . $library->organism_id->species . " (" . $library->organism_id->common_name . ")";
  45. if (property_exists($library->organism_id, 'nid')) {
  46. $organism = l("<i>" . $library->organism_id->genus . " " . $library->organism_id->species . "</i> (" . $library->organism_id->common_name . ")", "node/" . $library->organism_id->nid, ['html' => TRUE]);
  47. }
  48. $rows[] = [
  49. [
  50. 'data' => 'Organism',
  51. 'header' => TRUE,
  52. ],
  53. $organism,
  54. ];
  55. // Library Type row
  56. $rows[] = [
  57. [
  58. 'data' => 'Type',
  59. 'header' => TRUE,
  60. ],
  61. $library->type_id->name,
  62. ];
  63. // allow site admins to see the library ID
  64. if (user_access('view ids')) {
  65. // Library ID
  66. $rows[] = [
  67. [
  68. 'data' => 'Library ID',
  69. 'header' => TRUE,
  70. 'class' => 'tripal-site-admin-only-table-row',
  71. ],
  72. $library->library_id,
  73. ];
  74. }
  75. // the $table array contains the headers and rows array as well as other
  76. // options for controlling the display of the table. Additional
  77. // documentation can be found here:
  78. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  79. $table = [
  80. 'header' => $headers,
  81. 'rows' => $rows,
  82. 'attributes' => [
  83. 'id' => 'tripal_library-table-base',
  84. 'class' => 'tripal-data-table',
  85. ],
  86. 'sticky' => FALSE,
  87. 'caption' => '',
  88. 'colgroups' => [],
  89. 'empty' => '',
  90. ];
  91. // once we have our table array structure defined, we call Drupal's theme_table()
  92. // function to generate the table.
  93. print theme_table($table);
  94. // now add in the description below the table if one exists
  95. if ($description) { ?>
  96. <div style="text-align: justify"><?php print $description; ?></div> <?php
  97. }