tripal_stock_synonyms.tpl.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. // there is no stock_synonym table, analogous to the stock_synonym table.
  3. // Therefore, synonyms have been stored in the stockprop table with a type
  4. // of 'synonym' or 'alias'.
  5. $stock = $node->stock;
  6. $synonyms = array();
  7. // expand the stock object to include the stockprop records
  8. $options = array('return_array' => 1);
  9. $stock = chado_expand_var($stock, 'table', 'stockprop', $options);
  10. $stockprops = $stock->stockprop;
  11. // iterate through all of the properties and pull out only the synonyms
  12. if ($stockprops) {
  13. foreach ($stockprops as $stockprop){
  14. if($stockprop->type_id->name == 'synonym' or $stockprop->type_id->name == 'alias'){
  15. $synonyms[] = $stockprop;
  16. }
  17. }
  18. }
  19. if(count($synonyms) > 0){ ?>
  20. <div class="tripal_stock-data-block-desc tripal-data-block-desc">The stock '<?php print $stock->name ?>' has the following synonyms</div> <?php
  21. // the $headers array is an array of fields to use as the colum headers.
  22. // additional documentation can be found here
  23. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  24. // This table for the analysis has a vertical header (down the first column)
  25. // so we do not provide headers here, but specify them in the $rows array below.
  26. $headers = array('Synonym');
  27. // the $rows array contains an array of rows where each row is an array
  28. // of values for each column of the table in that row. Additional documentation
  29. // can be found here:
  30. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  31. $rows = array();
  32. foreach ($synonyms as $property){
  33. $rows[] = array(
  34. $property->value,
  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_stock-table-synonyms',
  46. 'class' => 'tripal-data-table'
  47. ),
  48. 'sticky' => FALSE,
  49. 'caption' => '',
  50. 'colgroups' => array(),
  51. 'empty' => '',
  52. );
  53. // once we have our table array structure defined, we call Drupal's theme_table()
  54. // function to generate the table.
  55. print theme_table($table);
  56. }