tripal_stock_base.tpl.php 3.5 KB

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