tripal_feature_libraries.tpl.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 = 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 following libraries are associated with this feature.</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 ($library_features as $library_feature){
  22. $libname = $library_feature->library_id->name;
  23. if ($library_feature->library_id->nid) {
  24. $libname = l($libname, "node/" . $library_feature->library_id->nid, array('attributes' => array('target' => '_blank')));
  25. }
  26. $typename = $library_feature->library_id->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_feature-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. }