tripal_feature.libraries.tpl.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 = array('return_array' => 1);
  6. $feature = tripal_core_expand_chado_vars($feature, 'table', 'library_feature', $options);
  7. $library_features = $feature->library_feature;
  8. if (count($library_features) > 0) {?>
  9. <div id="tripal_feature-library_list-box" class="tripal_feature-info-box tripal-info-box">
  10. <div class="tripal_feature-info-box-title tripal-info-box-title">Libraries</div>
  11. <div class="tripal_feature-info-box-desc tripal-info-box-desc">The following libraries are associated with this feature.</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 ($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, array('attributes' => array('target' => '_blank')));
  27. }
  28. $typename = $library_feature->library_id->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_feature-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. }