tripal_organism_feature_counts.tpl.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. $organism = $variables['node']->organism;
  3. $types = [];
  4. if (property_exists($organism, 'feature_counts')) {
  5. $types = $organism->feature_counts['types'];
  6. $names = $organism->feature_counts['names'];
  7. } ?>
  8. <div class="tripal_organism-data-block-desc tripal-data-block-desc">The
  9. following features are currently present for this organism
  10. </div> <?php
  11. // let admins know they can customize the terms that appear in the list
  12. print tripal_set_message("
  13. Administrators, you can customize the types of terms that appear in this report by navigating to the " .
  14. l('Tripal feature configuration page', 'admin/tripal/legacy/tripal_feature/configuration', ['attributes' => ['target' => '_blank']]) . "
  15. opening the section \"Feature Summary Report\" and adding the list of
  16. terms you want to appear in the list. You can rename terms as well. To refresh the data,re-populate the " .
  17. l('organism_feature_count', 'admin/tripal/storage/legacy/mviews', ['attributes' => ['target' => '_blank']]) . "
  18. materialized view.",
  19. TRIPAL_INFO,
  20. ['return_html' => 1]
  21. );
  22. // the $headers array is an array of fields to use as the colum headers.
  23. // additional documentation can be found here
  24. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  25. $headers = ['Feature Type', 'Count'];
  26. // the $rows array contains an array of rows where each row is an array
  27. // of values for each column of the table in that row. Additional documentation
  28. // can be found here:
  29. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  30. $rows = [];
  31. for ($j = 0; $j < count($types); $j++) {
  32. $type = $types[$j];
  33. $name = $names[$j];
  34. $rows[] = [
  35. "<span title=\"" . $type->definition . "\">$name</span>",
  36. number_format($type->num_features),
  37. ];
  38. }
  39. // the $table array contains the headers and rows array as well as other
  40. // options for controlling the display of the table. Additional
  41. // documentation can be found here:
  42. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  43. $table = [
  44. 'header' => $headers,
  45. 'rows' => $rows,
  46. 'attributes' => [
  47. 'id' => 'tripal_organism-table-features',
  48. 'class' => 'tripal-data-table',
  49. ],
  50. 'sticky' => FALSE,
  51. 'caption' => '',
  52. 'colgroups' => [],
  53. 'empty' => 'There are no feature counts to report. If you have loaded features for this
  54. organism then re-populate the organism_feature_count materialized view.',
  55. ];
  56. // once we have our table array structure defined, we call Drupal's theme_table()
  57. // function to generate the table.
  58. print theme_table($table);