tripal_library_base.tpl.php 2.9 KB

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