tripal_stock_base.tpl.php 3.1 KB

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