tripal_phylogeny_analysis.tpl.php

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

File

tripal_phylogeny/theme/templates/tripal_phylogeny_analysis.tpl.php
View source
  1. <?php
  2. $node = $variables['node'];
  3. $phylotree = $node->phylotree;
  4. if ($phylotree->analysis_id) {
  5. // the $headers array is an array of fields to use as the colum headers.
  6. // additional documentation can be found here
  7. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  8. $header = array(
  9. 'Name',
  10. 'Description',
  11. array(
  12. 'data' => 'Metadata',
  13. 'width' => '50%',
  14. ),
  15. );
  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. $analysis = $phylotree->analysis_id;
  22. if ($analysis) {
  23. $analysis = chado_expand_var($analysis, 'field', 'analysis.description');
  24. // Source row
  25. $source = '';
  26. if($analysis->sourceuri){
  27. $source = "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>";
  28. }
  29. else {
  30. $source = $analysis->sourcename;
  31. }
  32. if($analysis->sourceversion){
  33. $source = " (" . $analysis->sourceversion . ")";
  34. }
  35. $software = $analysis->program;
  36. if($analysis->programversion != 'n/a'){
  37. $software .= " (" . $analysis->programversion . ")";
  38. }
  39. if($analysis->algorithm){
  40. $software .= ". " . $analysis->algorithm;
  41. }
  42. $date = preg_replace("/^(\d+-\d+-\d+) .*/","$1", $analysis->timeexecuted);
  43. $metadata = "
  44. <dl class=\"tripal-dl\">
  45. <dt>Method</dt> <dd>: $software</dd>
  46. <dt>Source</dt> <dd>: $source</dd>
  47. <dt>Date</dt> <dd>: $date</dd>
  48. </dl>
  49. ";
  50. $analysis_name = $analysis->name;
  51. if (property_exists($analysis, 'nid')) {
  52. $analysis_name = l($analysis_name, "node/" . $analysis->nid);
  53. }
  54. $rows[] = array($analysis_name, $analysis->description, $metadata);
  55. }
  56. // the $table array contains the headers and rows array as well as other
  57. // options for controlling the display of the table. Additional
  58. // documentation can be found here:
  59. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  60. $table = array(
  61. 'header' => $header,
  62. 'rows' => $rows,
  63. 'attributes' => array(
  64. 'id' => 'tripal_phylogeny-table-analysis',
  65. 'class' => 'tripal-data-table'
  66. ),
  67. 'sticky' => FALSE,
  68. 'caption' => '',
  69. 'colgroups' => array(),
  70. 'empty' => t('This tree is not associated with an analysis'),
  71. );
  72. print theme_table($table);
  73. }