tripal.term_lookup.inc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?php
  2. /**
  3. *
  4. * @param $form
  5. * @param string $form_state
  6. */
  7. function tripal_vocabulary_lookup_form($form, &$form_state = NULL) {
  8. }
  9. /**
  10. *
  11. * @param $form
  12. * @param $form_state
  13. */
  14. function tripal_vocabulary_lookup_form_validate($form, $form_state) {
  15. }
  16. /**
  17. *
  18. * @param $form
  19. * @param $form_state
  20. */
  21. function tripal_vocabulary_lookup_form_submit($form, $form_state) {
  22. }
  23. function tripal_vocabulary_lookup_page($vocabulary) {
  24. $vocab = tripal_get_vocabulary_details($vocabulary);
  25. // If we can't find the term then just return a message.
  26. if (!$vocab) {
  27. drupal_set_message('The vocabulary cannot be found on this site', 'error');
  28. return '';
  29. }
  30. $headers = array();
  31. $rows = array();
  32. $vocab_name = $vocab['name'];
  33. if ($vocab['url']) {
  34. $vocab_name = l($vocab['name'], $vocab['url'], array('attributes' => array('target' => '_blank')));
  35. }
  36. $short_name = $vocab['short_name'];
  37. $vocab_desc = $vocab['description'];
  38. $rows[] = array(
  39. array(
  40. 'data' => 'Name',
  41. 'header' => TRUE,
  42. 'width' => '20%',
  43. ),
  44. $vocab_name,
  45. );
  46. $rows[] = array(
  47. array(
  48. 'data' => 'Short Name',
  49. 'header' => TRUE,
  50. 'width' => '20%',
  51. ),
  52. $short_name,
  53. );
  54. $rows[] = array(
  55. array(
  56. 'data' => 'Description',
  57. 'header' => TRUE,
  58. 'width' => '20%',
  59. ),
  60. $vocab_desc,
  61. );
  62. $table = array(
  63. 'header' => $headers,
  64. 'rows' => $rows,
  65. 'attributes' => array(),
  66. 'sticky' => FALSE,
  67. 'caption' => 'Vocabulary details',
  68. 'colgroups' => array(),
  69. 'empty' => '',
  70. );
  71. $content = theme_table($table);
  72. return $content;
  73. }
  74. /**
  75. *
  76. * @param $vocabulary
  77. * @param $accession
  78. *
  79. * @return
  80. */
  81. function tripal_vocabulary_lookup_term_page($vocabulary, $accession) {
  82. $term = tripal_get_term_details($vocabulary, $accession);
  83. // If we can't find the term then just return a message.
  84. if (!$term) {
  85. drupal_set_message('The term cannot be found on this site', 'error');
  86. return '';
  87. }
  88. // Build the Term table.
  89. $headers = array();
  90. $rows = array();
  91. $term_name = $term['name'];
  92. $accession = $term['vocabulary']['short_name'] . ':' . $term['accession'];
  93. if ($term['url']) {
  94. $term_name = l($term['name'], $term['url'], array('attributes' => array('target' => '_blank')));
  95. }
  96. $rows[] = array(
  97. array(
  98. 'data' => 'Term',
  99. 'header' => TRUE,
  100. 'width' => '20%',
  101. ),
  102. $accession,
  103. );
  104. $rows[] = array(
  105. array(
  106. 'data' => 'Name',
  107. 'header' => TRUE,
  108. 'width' => '20%',
  109. ),
  110. $term_name,
  111. );
  112. $rows[] = array(
  113. array(
  114. 'data' => 'Definition',
  115. 'header' => TRUE,
  116. 'width' => '20%',
  117. ),
  118. $term['definition'],
  119. );
  120. $table = array(
  121. 'header' => $headers,
  122. 'rows' => $rows,
  123. 'attributes' => array(),
  124. 'sticky' => FALSE,
  125. 'caption' => 'Term Details',
  126. 'colgroups' => array(),
  127. 'empty' => '',
  128. );
  129. $content = theme_table($table);
  130. $rows = array();
  131. $vocab_name = $term['vocabulary']['name'];
  132. if ($term['vocabulary']['url']) {
  133. $vocab_name = l($term['vocabulary']['name'], $term['vocabulary']['url'], array('attributes' => array('target' => '_blank')));
  134. }
  135. $short_name = $term['vocabulary']['short_name'];
  136. $vocab_desc = $term['vocabulary']['description'];
  137. $rows[] = array(
  138. array(
  139. 'data' => 'Name',
  140. 'header' => TRUE,
  141. 'width' => '20%',
  142. ),
  143. $vocab_name,
  144. );
  145. $rows[] = array(
  146. array(
  147. 'data' => 'Short Name',
  148. 'header' => TRUE,
  149. 'width' => '20%',
  150. ),
  151. $short_name,
  152. );
  153. $rows[] = array(
  154. array(
  155. 'data' => 'Description',
  156. 'header' => TRUE,
  157. 'width' => '20%',
  158. ),
  159. $vocab_desc,
  160. );
  161. $table = array(
  162. 'header' => $headers,
  163. 'rows' => $rows,
  164. 'attributes' => array(),
  165. 'sticky' => FALSE,
  166. 'caption' => 'Term Vocabulary details',
  167. 'colgroups' => array(),
  168. 'empty' => '',
  169. );
  170. $content .= theme_table($table);
  171. return $content;
  172. }