tripal_organism_libraries.tpl.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. $organism = $variables['node']->organism;
  3. // expand the organism object to include the libraries from the library
  4. // table in chado.
  5. $organism = tripal_core_expand_chado_vars($organism,'table','library');
  6. // get the references. if only one reference exists then we want to convert
  7. // the object into an array, otherwise the value is an array
  8. $libraries = $organism->library;
  9. if (!$libraries) {
  10. $libraries = array();
  11. }
  12. elseif (!is_array($libraries)) {
  13. $libraries = array($libraries);
  14. }
  15. if (count($libraries) > 0) {?>
  16. <div id="tripal_organism-library_list-box" class="tripal_organism-info-box tripal-info-box">
  17. <div class="tripal_organism-info-box-title tripal-info-box-title">Libraries</div>
  18. <div class="tripal_organism-info-box-desc tripal-info-box-desc">The following libraries are associated with this organism.</div>
  19. <table id="tripal_organism-table-library_list" class="tripal_organism-table tripal-table tripal-table-horz">
  20. <tr class="tripal_organism-table-odd-row tripal-table-even-row">
  21. <th>Library Name</th>
  22. <th>Description</th>
  23. <th>Type</th>
  24. </tr> <?php
  25. foreach ($libraries as $library){
  26. // expand the library to include the properties.
  27. $library = tripal_core_expand_chado_vars($library,'table','libraryprop');
  28. $library = tripal_core_expand_chado_vars($library,'field','libraryprop.value');
  29. $class = 'tripal_organism-table-odd-row tripal-table-odd-row';
  30. if($i % 2 == 0 ){
  31. $class = 'tripal_organism-table-odd-row tripal-table-even-row';
  32. } ?>
  33. <tr class="<?php print $class ?>">
  34. <td><?php
  35. if($library->nid){
  36. $link = url("node/$library->nid");
  37. print "<a href=\"$link\">$library->name</a>";
  38. }
  39. else {
  40. print $library->name;
  41. } ?>
  42. </td>
  43. <td><?php
  44. // right now we only have one property for libraries. So we can just
  45. // refernece it directly. If we had more than one property
  46. // we would need to convert this to an if statment and loop
  47. // until we found the right one.
  48. print $library->libraryprop->value?>
  49. </td>
  50. <td> <?php
  51. if ($library->type_id->name == 'cdna_library') {
  52. print 'cDNA';
  53. }
  54. else if ($library->type_id->name == 'bac_library') {
  55. print 'BAC';
  56. }
  57. else {
  58. print $library->type_id->name;
  59. }?>
  60. </td>
  61. </tr> <?php
  62. $i++;
  63. }?>
  64. </table>
  65. </div><?php
  66. }