tripal_organism.libraries.tpl.php 2.6 KB

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