tripal_stock_relationships_as_object.tpl.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. <div id="tripal_stock-object_relationships-box" class="tripal_stock-info-box tripal-info-box">
  33. <div class="tripal_stock-info-box-title tripal-info-box-title">Object Relationships</div>
  34. <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>
  35. <?php if(count($node->object_relationships) > 0){ ?>
  36. <table class="tripal_stock-table tripal-table tripal-table-horz">
  37. <tr>
  38. <th>Current Stock (Subject)</th>
  39. <th>Type</th>
  40. <th>Object</th>
  41. </tr>
  42. <?php
  43. $i = 0;
  44. foreach ($node->object_relationships as $result){
  45. $class = 'tripal_stock-table-odd-row tripal-table-odd-row';
  46. if($i % 2 == 0 ){
  47. $class = 'tripal_stock-table-odd-row tripal-table-even-row';
  48. } ?>
  49. <tr class="<?php print $class ?>">
  50. <td><?php print $node->stock_name; ?></td>
  51. <td><?php print $result->type; ?></td>
  52. <?php $object = $result->object;
  53. if ($object->nid) {?>
  54. <td><?php print l($object->stock_name.' ('.$object->uniquename.')', 'node/'.$object->nid); ?></td>
  55. <?php } else { ?>
  56. <td><?php print $object->stock_name.' ('.$object->uniquename.')'; ?></td>
  57. <?php } ?>
  58. </tr>
  59. <?php } //end of foreach?>
  60. </table>
  61. <?php } //end of if there are object relationships ?>
  62. </div>