tripal_stock_relationships_as_object.tpl.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. // Copyright 2010 University of Saskatchewan (Lacey-Anne Sanderson)
  3. //
  4. // Purpose: Provides layout and content for Stock Relationships where
  5. // the current stock is the Subject of the relationships. This includes all
  6. // fields in the stock_relationship table.
  7. //
  8. // Note: This template controls the layout/content for the default stock node
  9. // template (node-chado_stock.tpl.php) and the Stock Object Relationships Block
  10. //
  11. // Variables Available:
  12. // - $node: a standard object which contains all the fields associated with
  13. // nodes including nid, type, title, taxonomy. It also includes stock
  14. // specific fields such as stock_name, uniquename, stock_type, synonyms,
  15. // properties, db_references, object_relationships, subject_relationships,
  16. // organism, etc.
  17. // - $node->object_relationships: an array of stock relaionship objects
  18. // where each object has the following fields: stock_relationship_id,
  19. // subject_id (current stock_id), type_id, type, value, rank, object
  20. // - $node->object_relationships->object: a stock object describing the
  21. // object stock with the fields: stock_id, stock_name, uniquename,
  22. // description, stock_type_id, organism(object), man_db_reference(object),
  23. // nid (if sync'd with Drupal)
  24. // NOTE: For a full listing of fields available in the node object the
  25. // print_r $node line below or install the Drupal Devel module which
  26. // provides an extra tab at the top of the node page labelled Devel
  27. ?>
  28. <?php
  29. //uncomment this line to see a full listing of the fields avail. to $node
  30. //print '<pre>'.print_r($node,TRUE).'</pre>';
  31. ?>
  32. <?php
  33. $relationships = $node->stock->stock_object_relationships;
  34. if (!$relationships) {
  35. $relationships = array();
  36. } elseif (!is_array($relationships)) {
  37. $relationships = array($relationships);
  38. }
  39. ?>
  40. <div id="tripal_stock-object_relationships-box" class="tripal_stock-info-box tripal-info-box">
  41. <div class="tripal_stock-info-box-title tripal-info-box-title">Object Relationships</div>
  42. <div class="tripal_stock-info-box-desc tripal-info-box-desc">The stock '<?php print $node->stock->name ?>' is the subject in the following relationships:</div>
  43. <?php if(count($relationships) > 0){ ?>
  44. <table class="tripal_stock-table tripal-table tripal-table-horz">
  45. <tr>
  46. <th>Current Stock (Subject)</th>
  47. <th>Type</th>
  48. <th>Object</th>
  49. </tr>
  50. <?php
  51. $i = 0;
  52. foreach ($relationships as $result){
  53. $class = 'tripal_stock-table-odd-row tripal-table-odd-row';
  54. if($i % 2 == 0 ){
  55. $class = 'tripal_stock-table-odd-row tripal-table-even-row';
  56. } ?>
  57. <tr class="<?php print $class ?>">
  58. <td><?php print $node->stock->name; ?></td>
  59. <td><?php print $result->type_id->name; ?></td>
  60. <?php $object = $result->object_id;
  61. if ($object->nid) {?>
  62. <td><?php print l($object->name.' ('.$object->uniquename.')', 'node/'.$object->nid); ?></td>
  63. <?php } else { ?>
  64. <td><?php print $object->name.' ('.$object->uniquename.')'; ?></td>
  65. <?php } ?>
  66. </tr>
  67. <?php } //end of foreach?>
  68. </table>
  69. <?php } else {
  70. print '<b>There are no relationships where the current stock is the subject</b>';
  71. } //end of if there are object relationships ?>
  72. </div>