tripal_feature_analyses.tpl.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. $feature = $variables['node']->feature;
  3. $options = ['return_array' => 1];
  4. $feature = chado_expand_var($feature, 'table', 'analysisfeature', $options);
  5. $analyses = $feature->analysisfeature;
  6. // don't show this page if there are no analyses
  7. if (count($analyses) > 0) { ?>
  8. <div class="tripal_feature-data-block-desc tripal-data-block-desc">
  9. This <?php print $feature->type_id->name ?> is derived from or has
  10. results from the following analyses
  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. $headers = ['Analysis Name', 'Date Performed'];
  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 = [];
  21. foreach ($analyses as $analysis) {
  22. $analysis_name = $analysis->analysis_id->name;
  23. if (property_exists($analysis->analysis_id, 'nid')) {
  24. $analysis_name = l($analysis_name, "node/" . $analysis->analysis_id->nid);
  25. }
  26. $rows[] = [
  27. $analysis_name,
  28. preg_replace('/\d\d:\d\d:\d\d/', '', $analysis->analysis_id->timeexecuted),
  29. ];
  30. }
  31. // the $table array contains the headers and rows array as well as other
  32. // options for controlling the display of the table. Additional
  33. // documentation can be found here:
  34. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  35. $table = [
  36. 'header' => $headers,
  37. 'rows' => $rows,
  38. 'attributes' => [
  39. 'id' => 'tripal_feature-table-analyses',
  40. 'class' => 'tripal-data-table',
  41. ],
  42. 'sticky' => FALSE,
  43. 'caption' => '',
  44. 'colgroups' => [],
  45. 'empty' => '',
  46. ];
  47. // once we have our table array structure defined, we call Drupal's theme_table()
  48. // function to generate the table.
  49. print theme_table($table);
  50. }