tripal_stock_references.tpl.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. // Copyright 2010 University of Saskatchewan (Lacey-Anne Sanderson)
  3. //
  4. // Purpose: Provides the layout and content for stock external database
  5. // references (this doesn't include the main database reference from the
  6. // stock table). This includes all fields from the dbxref and db chado tables
  7. // where each dbxref is associated with the current stock through the
  8. // stock_dbxref table
  9. //
  10. // Note: This template controls the layout/content for the default stock node
  11. // template (node-chado_stock.tpl.php) and the Stock Database References Block
  12. //
  13. // Variables Available:
  14. // - $node: a standard object which contains all the fields associated with
  15. // nodes including nid, type, title, taxonomy. It also includes stock
  16. // specific fields such as stock_name, uniquename, stock_type, synonyms,
  17. // properties, db_references, object_relationships, subject_relationships,
  18. // organism, etc.
  19. // - $node->db_references: an array of stock database reference objects
  20. // where each object has the following fields: dbxref_id, accession,
  21. // version, description, db_id, db_name, db_description, db_url,
  22. // db_urlprefix
  23. // NOTE: For a full listing of fields available in the node object the
  24. // print_r $node line below or install the Drupal Devel module which
  25. // provides an extra tab at the top of the node page labelled Devel
  26. ?>
  27. <?php
  28. //uncomment this line to see a full listing of the fields avail. to $node
  29. //print '<pre>'.print_r($node,TRUE).'</pre>';
  30. ?>
  31. <?php
  32. $db_references = $node->stock->stock_dbxref;
  33. if (!$db_references) {
  34. $db_references = array();
  35. } elseif (!is_array($db_references)) {
  36. $db_references = array($db_references);
  37. }
  38. ?>
  39. <div id="tripal_stock-references-box" class="tripal_stock-info-box tripal-info-box">
  40. <div class="tripal_stock-info-box-title tripal-info-box-title">References</div>
  41. <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>
  42. <?php if(count($db_references) > 0){ ?>
  43. <table class="tripal_stock-table tripal-table tripal-table-horz">
  44. <tr>
  45. <th>Dababase</th>
  46. <th>Accession</th>
  47. </tr>
  48. <?php
  49. $i = 0;
  50. foreach ($db_references as $result){
  51. $dbxref = $result->dbxref_id;
  52. $class = 'tripal_stock-table-odd-row tripal-table-odd-row';
  53. if($i % 2 == 0 ){
  54. $class = 'tripal_stock-table-odd-row tripal-table-even-row';
  55. }
  56. ?>
  57. <tr class="<?php print $class ?>">
  58. <td><?php print $dbxref->db_id->name?></td>
  59. <td><?php
  60. if($dbxref->db_id->urlprefix){
  61. print l($dbxref->accession, $dbxref->db_id->urlprefix.$dbxref->accession);
  62. } else {
  63. print $dbxref->accession;
  64. }
  65. ?>
  66. </td>
  67. </tr>
  68. <?php
  69. $i++;
  70. } ?>
  71. </table>
  72. <?php } else {
  73. print '<b>There are no external database references for the current stock.</b>';
  74. }?>
  75. </div>