tripal_organism_feature_counts.tpl.php

  1. 2.x tripal_feature/theme/templates/tripal_organism_feature_counts.tpl.php
  2. 3.x legacy/tripal_feature/theme/templates/tripal_organism_feature_counts.tpl.php
1 theme call to tripal_organism_feature_counts.tpl.php
tripal_feature_node_view in tripal_feature/includes/tripal_feature.chado_node.inc
Implements hook_node_view(). Acts on all content types.

File

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