tripal_stock_references.tpl.php

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

File

tripal_stock/theme/templates/tripal_stock_references.tpl.php
View source
  1. <?php
  2. $stock = $variables['node']->stock;
  3. $references = array();
  4. // First, get the dbxref record from stock record itself if one exists
  5. if ($stock->dbxref_id) {
  6. $stock->dbxref_id->is_primary = 1; // add this new property so we know it's the primary reference
  7. $references[] = $stock->dbxref_id;
  8. }
  9. // Second, expand the stock object to include the records from the stock_dbxref table
  10. $options = array('return_array' => 1);
  11. $stock = chado_expand_var($stock, 'table', 'stock_dbxref', $options);
  12. $stock_dbxrefs = $stock->stock_dbxref;
  13. if (count($stock_dbxrefs) > 0 ) {
  14. foreach ($stock_dbxrefs as $stock_dbxref) {
  15. if($stock_dbxref->dbxref_id->db_id->name == 'GFF_source'){
  16. // check to see if the reference 'GFF_source' is there. This reference is
  17. // used to if the Chado Perl GFF loader was used to load the stocks
  18. }
  19. else {
  20. $references[] = $stock_dbxref->dbxref_id;
  21. }
  22. }
  23. }
  24. if(count($references) > 0){ ?>
  25. <div class="tripal_stock-data-block-desc tripal-data-block-desc">External references for this <?php print $stock->type_id->name ?></div><?php
  26. // the $headers array is an array of fields to use as the colum headers.
  27. // additional documentation can be found here
  28. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  29. $headers = array('Database', 'Accession');
  30. // the $rows array contains an array of rows where each row is an array
  31. // of values for each column of the table in that row. Additional documentation
  32. // can be found here:
  33. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  34. $rows = array();
  35. foreach ($references as $dbxref){
  36. // skip the GFF_source entry as this is just needed for the GBrowse chado adapter
  37. if ($dbxref->db_id->name == 'GFF_source'){
  38. continue;
  39. }
  40. $dbname = $dbxref->db_id->name;
  41. if ($dbxref->db_id->url) {
  42. $dbname = l($dbname, $dbxref->db_id->url, array('attributes' => array('target' => '_blank')));
  43. }
  44. $accession = $dbxref->accession;
  45. if ($dbxref->db_id->urlprefix) {
  46. $accession = l($accession, $dbxref->db_id->urlprefix . $dbxref->accession, array('attributes' => array('target' => '_blank')));
  47. }
  48. if (property_exists($dbxref, 'is_primary')) {
  49. $accession .= " <i>(primary cross-reference)</i>";
  50. }
  51. $rows[] = array(
  52. $dbname,
  53. $accession
  54. );
  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' => $headers,
  62. 'rows' => $rows,
  63. 'attributes' => array(
  64. 'id' => 'tripal_stock-table-references',
  65. 'class' => 'tripal-data-table'
  66. ),
  67. 'sticky' => FALSE,
  68. 'caption' => '',
  69. 'colgroups' => array(),
  70. 'empty' => '',
  71. );
  72. // once we have our table array structure defined, we call Drupal's theme_table()
  73. // function to generate the table.
  74. print theme_table($table);
  75. }?>