tripal_organism_libraries.tpl.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. $organism = $variables['node']->organism;
  3. // expand the organism object to include the libraries from the library
  4. // table in chado.
  5. $options = ['return_array' => 1];
  6. $organism = chado_expand_var($organism, 'table', 'library', $options);
  7. $libraries = $organism->library;
  8. if (count($libraries) > 0) { ?>
  9. <div class="tripal_organism-data-block-desc tripal-data-block-desc">The
  10. following libraries are associated with this organism.
  11. </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 analysis 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 = ['Library Name', 'Type'];
  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 = [];
  23. foreach ($libraries as $library) {
  24. $libname = $library->name;
  25. if (isset($library->nid)) {
  26. $libname = l($libname, "node/" . $library->nid, ['attributes' => ['target' => '_blank']]);
  27. }
  28. $typename = $library->type_id->name;
  29. if ($typename == 'cdna_library') {
  30. $typename = 'cDNA';
  31. }
  32. else {
  33. if ($typename == 'bac_library') {
  34. $typename = 'BAC';
  35. }
  36. }
  37. $rows[] = [
  38. $libname,
  39. $typename,
  40. ];
  41. }
  42. // the $table array contains the headers and rows array as well as other
  43. // options for controlling the display of the table. Additional
  44. // documentation can be found here:
  45. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  46. $table = [
  47. 'header' => $headers,
  48. 'rows' => $rows,
  49. 'attributes' => [
  50. 'id' => 'tripal_organism-table-libraries',
  51. 'class' => 'tripal-data-table',
  52. ],
  53. 'sticky' => FALSE,
  54. 'caption' => '',
  55. 'colgroups' => [],
  56. 'empty' => '',
  57. ];
  58. // once we have our table array structure defined, we call Drupal's theme_table()
  59. // function to generate the table.
  60. print theme_table($table);
  61. }