tripal_organism_libraries.tpl.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 = 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 following libraries are associated with this organism.</div> <?php
  10. // the $headers array is an array of fields to use as the colum headers.
  11. // additional documentation can be found here
  12. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  13. // This table for the analysis has a vertical header (down the first column)
  14. // so we do not provide headers here, but specify them in the $rows array below.
  15. $headers = array('Library Name', 'Type');
  16. // the $rows array contains an array of rows where each row is an array
  17. // of values for each column of the table in that row. Additional documentation
  18. // can be found here:
  19. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  20. $rows = array();
  21. foreach ($libraries as $library){
  22. $libname = $library->name;
  23. if (isset($library->nid)) {
  24. $libname = l($libname, "node/".$library->nid, array('attributes' => array('target' => '_blank')));
  25. }
  26. $typename = $library->type_id->name;
  27. if ($typename == 'cdna_library') {
  28. $typename = 'cDNA';
  29. }
  30. else if ($typename == 'bac_library') {
  31. $typename = 'BAC';
  32. }
  33. $rows[] = array(
  34. $libname,
  35. $typename
  36. );
  37. }
  38. // the $table array contains the headers and rows array as well as other
  39. // options for controlling the display of the table. Additional
  40. // documentation can be found here:
  41. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  42. $table = array(
  43. 'header' => $headers,
  44. 'rows' => $rows,
  45. 'attributes' => array(
  46. 'id' => 'tripal_organism-table-libraries',
  47. 'class' => 'tripal-data-table'
  48. ),
  49. 'sticky' => FALSE,
  50. 'caption' => '',
  51. 'colgroups' => array(),
  52. 'empty' => '',
  53. );
  54. // once we have our table array structure defined, we call Drupal's theme_table()
  55. // function to generate the table.
  56. print theme_table($table);
  57. }