tripal_organism_feature_counts.tpl.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. $organism = $variables['node']->organism;
  3. $enabled = 1;
  4. $types = array();
  5. if(property_exists($organism, 'feature_counts')) {
  6. $types = $organism->feature_counts['types'];
  7. $names = $organism->feature_counts['names'];
  8. }
  9. if (count($types) > 0){ ?>
  10. <div class="tripal_organism-data-block-desc tripal-data-block-desc">The following features are currently present for this organism</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/chado/tripal_feature/configuration', array('attributes' => array('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/schema/mviews', array('attributes' => array('target' => '_blank'))) . "
  18. materialized view.",
  19. TRIPAL_INFO,
  20. array('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 = array('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 = array();
  31. for ($j = 0; $j < count($types); $j++) {
  32. $type = $types[$j];
  33. $name = $names[$j];
  34. $rows[] = array(
  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 = array(
  44. 'header' => $headers,
  45. 'rows' => $rows,
  46. 'attributes' => array(
  47. 'id' => 'tripal_organism-table-features',
  48. 'class' => 'tripal-data-table'
  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. }