tripal_stock_base.tpl.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 = tripal_core_expand_chado_vars($stock, 'field', 'stock.description');
  7. $stock = tripal_core_expand_chado_vars($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 = array();
  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 = array();
  20. // Stock Name
  21. $rows[] = array(
  22. array(
  23. 'data' => 'Name',
  24. 'header' => TRUE,
  25. ),
  26. $stock->name
  27. );
  28. // Stock Unique Name
  29. $rows[] = array(
  30. array(
  31. 'data' => 'Stock Name',
  32. 'header' => TRUE,
  33. ),
  34. $stock->uniquename
  35. );
  36. // Stock Type
  37. $rows[] = array(
  38. array(
  39. 'data' => 'Type',
  40. 'header' => TRUE,
  41. ),
  42. ucwords(preg_replace('/_/', ' ', $stock->type_id->name))
  43. );
  44. // Organism
  45. $organism = $stock->organism_id->genus ." " . $stock->organism_id->species ." (" . $stock->organism_id->common_name .")";
  46. if (property_exists($stock->organism_id, 'nid')) {
  47. $organism = l("<i>" . $stock->organism_id->genus . " " . $stock->organism_id->species . "</i> (" . $stock->organism_id->common_name .")", "node/".$stock->organism_id->nid, array('html' => TRUE));
  48. }
  49. $rows[] = array(
  50. array(
  51. 'data' => 'Organism',
  52. 'header' => TRUE
  53. ),
  54. $organism
  55. );
  56. // allow site admins to see the stock ID
  57. if (user_access('access administration pages')) {
  58. // stock ID
  59. $rows[] = array(
  60. array(
  61. 'data' => 'Stock ID',
  62. 'header' => TRUE,
  63. 'class' => 'tripal-site-admin-only-table-row',
  64. ),
  65. array(
  66. 'data' => $stock->stock_id,
  67. 'class' => 'tripal-site-admin-only-table-row',
  68. ),
  69. );
  70. }
  71. // Is Obsolete Row
  72. if($stock->is_obsolete == TRUE){
  73. $rows[] = array(
  74. array(
  75. 'data' => '<div class="tripal_stock-obsolete">This stock is obsolete</div>',
  76. 'colspan' => 2
  77. ),
  78. );
  79. }
  80. // the $table array contains the headers and rows array as well as other
  81. // options for controlling the display of the table. Additional
  82. // documentation can be found here:
  83. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  84. $table = array(
  85. 'header' => $headers,
  86. 'rows' => $rows,
  87. 'attributes' => array(
  88. 'id' => 'tripal_stock-table-base',
  89. ),
  90. 'sticky' => FALSE,
  91. 'caption' => '',
  92. 'colgroups' => array(),
  93. 'empty' => '',
  94. );
  95. // once we have our table array structure defined, we call Drupal's theme_table()
  96. // function to generate the table.
  97. print theme_table($table);
  98. // add in the description if there is one
  99. if (property_exists($stock, 'description')) { ?>
  100. <div style="text-align: justify"><?php print $stock->description; ?></div> <?php
  101. }