tripal_feature_relationships.tpl.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. $feature = $variables['node']->feature;
  3. // get the featurelocs. if only one featureloc exists then we want to convert
  4. // the object into an array, otherwise the value is an array
  5. $orelationships = $feature->feature_relationship->object_id;
  6. if (!$orelationships) {
  7. $orelationships = array();
  8. } elseif (!is_array($orelationships)) {
  9. $orelationships = array($orelationships);
  10. }
  11. // do the same for the subject relationships
  12. $srelationships = $feature->feature_relationship->subject_id;
  13. if (!$srelationships) {
  14. $srelationships = array();
  15. } elseif (!is_array($srelationships)) {
  16. $srelationships = array($srelationships);
  17. }
  18. // now combine the two
  19. $relationships = array_merge($orelationships,$srelationships);
  20. ?>
  21. <div id="tripal_feature-relationships-box" class="tripal_feature-info-box tripal-info-box">
  22. <div class="tripal_feature-info-box-title tripal-info-box-title">Relationships</div>
  23. <div class="tripal_feature-info-box-desc tripal-info-box-desc">Subject relationships</div>
  24. <?php if(count($srelationships) > 0){ ?>
  25. <table id="tripal_feature-subject_relationships-table" class="tripal_feature-table tripal-table tripal-table-horz">
  26. <tr>
  27. <th>Subject</th>
  28. <th>Type</th>
  29. <th>Relationship</th>
  30. <th>Object</th>
  31. <th>Type</th>
  32. </tr>
  33. <?php
  34. $i = 0;
  35. foreach ($srelationships as $relationship){
  36. $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
  37. if($i % 2 == 0 ){
  38. $class = 'tripal_feature-table-odd-row tripal-table-even-row';
  39. }
  40. $subject_name = $relationship->subject_id->name;
  41. if(!$subject_name){
  42. $subject_name = $relationship->subject_id->uniquename;
  43. }
  44. $object_name = $relationship->object_id->name;
  45. if(!$object_name){
  46. $object_name = $relationship->object_id->uniquename;
  47. }?>
  48. <tr class="<?php print $class ?>">
  49. <td><?php print $subject_name?></td>
  50. <td><?php print $relationship->subject_id->type_id->name?></td>
  51. <td><b><?php print $relationship->type_id->name?></b></td>
  52. <td>
  53. <?php if(isset($relationship->object_id->nid)){
  54. print "<a href=\"" . url("node/".$relationship->object_id->nid) . "\">$object_name</a>";
  55. } else {
  56. print "$object_name";
  57. }?>
  58. </td>
  59. <td><?php print $relationship->object_id->type_id->name?></td>
  60. </tr>
  61. <?php } ?>
  62. </table>
  63. <?php } else {?>
  64. <div class="tripal-no-results">There are no subject relationships for this feature</div>
  65. <?php } ?>
  66. <br><br><div class="tripal_feature-info-box-desc tripal-info-box-desc">Object relationships</div>
  67. <?php if(count($orelationships) > 0){ ?>
  68. <table id="tripal_feature-object_relationships-table" class="tripal_feature-table tripal-table tripal-table-horz">
  69. <tr>
  70. <th>Subject</th>
  71. <th>Type</th>
  72. <th>Relationship</th>
  73. <th>Object</th>
  74. <th>Type</th>
  75. </tr>
  76. <?php
  77. $i = 0;
  78. foreach ($orelationships as $relationship){
  79. $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
  80. if($i % 2 == 0 ){
  81. $class = 'tripal_feature-table-odd-row tripal-table-even-row';
  82. }
  83. $subject_name = $relationship->subject_id->name;
  84. if(!$subject_name){
  85. $subject_name = $relationship->subject_id->uniquename;
  86. }
  87. $object_name = $relationship->object_id->name;
  88. if(!$object_name){
  89. $object_name = $relationship->object_id->uniquename;
  90. }?>
  91. <tr class="<?php print $class ?>">
  92. <td>
  93. <?php if(isset($relationship->subject_id->nid)){
  94. print "<a href=\"" . url("node/".$relationship->subject_id->nid) . "\">$subject_name</a>";
  95. } else {
  96. print "$subject_name";
  97. }?>
  98. </td>
  99. <td><?php print $relationship->subject_id->type_id->name?></td>
  100. <td><b><?php print $relationship->type_id->name?></b></td>
  101. <td><?php print "$object_name";?> </td>
  102. <td><?php print $relationship->object_id->type_id->name?></td>
  103. </tr>
  104. <?php } ?>
  105. </table>
  106. <?php } else {?>
  107. <div class="tripal-no-results">There are no object relationships for this feature</div>
  108. <?php } ?>
  109. </div>