tripal_stock_synonyms.tpl.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. // Copyright 2010 University of Saskatchewan (Lacey-Anne Sanderson)
  3. //
  4. // Purpose: Provides layout and content for Synonyms of the Current Stock.
  5. // Stock synonyms are stored in the stockprop table with a type corresponding
  6. // to the cvterm synonym.
  7. //
  8. // Note: This template controls the layout/content for the default stock node
  9. // template (node-chado_stock.tpl.php) and the Stock Synonyms 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->synonyms: an array of stock property objects where each object
  18. // has type=synonyms and the following fields: stockprop_id, type_id,
  19. // type, value, rank
  20. // NOTE: For a full listing of fields available in the node object the
  21. // print_r $node line below or install the Drupal Devel module which
  22. // provides an extra tab at the top of the node page labelled Devel
  23. ?>
  24. <?php
  25. $node->stock->stock_synonyms = tripal_core_generate_chado_var(
  26. 'stockprop',
  27. array(
  28. 'stock_id'=>$node->stock->stock_id,
  29. 'type_id' => array(
  30. 'cv_id' => variable_get('chado_stock_prop_types_cv', 'null'),
  31. 'name' => 'synonym'
  32. ),
  33. )
  34. );
  35. $synonyms = $node->stock->stock_synonyms;
  36. if (!$synonyms) {
  37. $synonyms = array();
  38. } elseif (!is_array($synonyms)) {
  39. $synonyms = array($synonyms);
  40. }
  41. ?>
  42. <?php
  43. //uncomment this line to see a full listing of the fields avail. to $node
  44. //print '<pre>'.print_r($node,TRUE).'</pre>';
  45. ?>
  46. <div id="tripal_stock-synonyms-box" class="tripal_stock-info-box tripal-info-box">
  47. <div class="tripal_stock-info-box-title tripal-info-box-title">Synonyms</div>
  48. <div class="tripal_stock-info-box-desc tripal-info-box-desc">Synonyms for the stock '<?php print $node->stock->name ?>' include:</div>
  49. <?php if(count($synonyms) > 0){
  50. print '<ul>';
  51. // iterate through each synonym
  52. foreach ($synonyms as $result){
  53. print '<li>'.$result->value.'</li>';
  54. }
  55. print '</ul>';
  56. } else {
  57. print '<b>There are no synonyms for the current stock.</b>';
  58. } ?>
  59. </div>