tripal_stock_base.tpl.php

  1. 2.x tripal_stock/theme/templates/tripal_stock_base.tpl.php
  2. 3.x legacy/tripal_stock/theme/templates/tripal_stock_base.tpl.php
1 theme call to tripal_stock_base.tpl.php
tripal_stock_node_view in tripal_stock/includes/tripal_stock.chado_node.inc
Implements hook_node_view(). Acts on all content types.

File

tripal_stock/theme/templates/tripal_stock_base.tpl.php
View source
  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 = 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. 'width' => '20%',
  26. ),
  27. $stock->name
  28. );
  29. // Stock Unique Name
  30. $rows[] = array(
  31. array(
  32. 'data' => 'Stock Name',
  33. 'header' => TRUE,
  34. ),
  35. $stock->uniquename
  36. );
  37. // Stock Type
  38. $rows[] = array(
  39. array(
  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, array('html' => TRUE));
  49. }
  50. $rows[] = array(
  51. array(
  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[] = array(
  61. array(
  62. 'data' => 'Stock ID',
  63. 'header' => TRUE,
  64. 'class' => 'tripal-site-admin-only-table-row',
  65. ),
  66. array(
  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[] = array(
  75. array(
  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 = array(
  86. 'header' => $headers,
  87. 'rows' => $rows,
  88. 'attributes' => array(
  89. 'id' => 'tripal_stock-table-base',
  90. 'class' => 'tripal-data-table'
  91. ),
  92. 'sticky' => FALSE,
  93. 'caption' => '',
  94. 'colgroups' => array(),
  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. }