tripal_stock_references.tpl.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. $stock = $variables['node']->stock;
  3. $references = array();
  4. // First, get the dbxref record from stock recrod 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 = tripal_core_expand_chado_vars($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. $references[] = $stock_dbxref->dbxref_id;
  16. }
  17. }
  18. if(count($references) > 0){ ?>
  19. <div id="tripal_stock-references-box" class="tripal_stock-info-box tripal-info-box">
  20. <div class="tripal_stock-info-box-title tripal-info-box-title">Cross References</div>
  21. <div class="tripal_stock-info-box-desc tripal-info-box-desc">The stock '<?php print $node->stock->name ?>' is also available at these locations</div>
  22. <table class="tripal_stock-table tripal-table tripal-table-horz">
  23. <tr>
  24. <th>Dababase</th>
  25. <th>Accession</th>
  26. </tr> <?php
  27. $i = 0;
  28. foreach ($references as $dbxref){
  29. $class = 'tripal_stock-table-odd-row tripal-table-odd-row';
  30. if($i % 2 == 0 ){
  31. $class = 'tripal_stock-table-odd-row tripal-table-even-row';
  32. } ?>
  33. <tr class="<?php print $class ?>">
  34. <td> <?php
  35. if ($dbxref->db_id->url) {
  36. print l($dbxref->db_id->name, $dbxref->db_id->url);
  37. }
  38. else {
  39. print $dbxref->db_id->name;
  40. } ?>
  41. </td>
  42. <td> <?php
  43. if ($dbxref->db_id->urlprefix) {
  44. print l($dbxref->accession, $dbxref->db_id->urlprefix.$dbxref->accession);
  45. }
  46. else {
  47. print $dbxref->accession;
  48. }
  49. if ($dbxref->is_primary) {
  50. print " <i>(primary cross-reference)</i>";
  51. } ?>
  52. </td>
  53. </tr> <?php
  54. $i++;
  55. } ?>
  56. </table>
  57. </div><?php
  58. }