tripal_feature_libraries.tpl.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. $feature = $variables['node']->feature;
  3. // expand the feature object to include the libraries from the library
  4. // table in chado.
  5. $options = ['return_array' => 1];
  6. $feature = chado_expand_var($feature, 'table', 'library_feature', $options);
  7. $library_features = $feature->library_feature;
  8. if (count($library_features) > 0) { ?>
  9. <div class="tripal_feature-data-block-desc tripal-data-block-desc">The
  10. following libraries are associated with this feature.
  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 ($library_features as $library_feature) {
  24. $libname = $library_feature->library_id->name;
  25. if ($library_feature->library_id->nid) {
  26. $libname = l($libname, "node/" . $library_feature->library_id->nid, ['attributes' => ['target' => '_blank']]);
  27. }
  28. $typename = $library_feature->library_id->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_feature-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. }