tripal_phenotype.views.inc 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <?php
  2. /**
  3. * @file
  4. * This file contains the basic functions for views integration of
  5. * chado/tripal_phenotype tables. Supplementary functions can be found in
  6. * ./views/
  7. *
  8. * Documentation on views integration can be found at
  9. * http://views2.logrus.com/doc/html/index.html.
  10. */
  11. /*************************************************************************
  12. * Implements hook_views_data()
  13. * Purpose: Describe chado/tripal tables & fields to views
  14. *
  15. * @return: a data array which follows the structure outlined in the
  16. * views2 documentation for this hook. Essentially, it's an array of table
  17. * definitions keyed by chado/tripal table name. Each table definition
  18. * includes basic details about the table, fields in that table and
  19. * relationships between that table and others (joins)
  20. */
  21. function tripal_phenotype_views_data() {
  22. $data = array();
  23. if (module_exists('tripal_views')) {
  24. $tables = array(
  25. 'phenotype'
  26. );
  27. foreach ($tables as $tablename) {
  28. if (!tripal_views_is_integrated($tablename, 9)) {
  29. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE);
  30. tripal_views_integration_add_entry($table_integration_array);
  31. }
  32. }
  33. $tables = array(
  34. 'feature_phenotype',
  35. 'phenotype_cvterm'
  36. );
  37. foreach ($tables as $tablename) {
  38. if (!tripal_views_is_integrated($tablename, 9)) {
  39. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE);
  40. tripal_views_integration_add_entry($table_integration_array);
  41. }
  42. }
  43. }
  44. return $data;
  45. }
  46. /*************************************************************************
  47. * Implements hook_views_handlers()
  48. * Purpose: Register all custom handlers with views
  49. * where a handler describes either "the type of field",
  50. * "how a field should be filtered", "how a field should be sorted"
  51. *
  52. * @return: An array of handler definitions
  53. */
  54. function tripal_phenotype_views_handlers() {
  55. return array(
  56. 'info' => array(
  57. 'path' => drupal_get_path('module', 'tripal_phenotype') . '/views/handlers',
  58. ),
  59. 'handlers' => array(
  60. ),
  61. );
  62. }
  63. /**
  64. *
  65. * @ingroup tripal_feature_views
  66. */
  67. function tripal_phenotype_views_default_views() {
  68. $views = array();
  69. // Main default view
  70. $view = new view;
  71. $view->name = 'phenotype_listing';
  72. $view->description = 'A listing of chado phenotypes';
  73. $view->tag = 'chado default';
  74. $view->base_table = 'phenotype';
  75. $view->core = 6;
  76. $view->api_version = '2';
  77. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  78. $handler = $view->new_display('default', 'Defaults', 'default');
  79. $handler->override_option('fields', array(
  80. 'uniquename' => array(
  81. 'label' => 'Unique Name',
  82. 'alter' => array(
  83. 'alter_text' => 0,
  84. 'text' => '',
  85. 'make_link' => 0,
  86. 'path' => '',
  87. 'absolute' => 0,
  88. 'link_class' => '',
  89. 'alt' => '',
  90. 'rel' => '',
  91. 'prefix' => '',
  92. 'suffix' => '',
  93. 'target' => '',
  94. 'help' => '',
  95. 'trim' => 0,
  96. 'max_length' => '',
  97. 'word_boundary' => 1,
  98. 'ellipsis' => 1,
  99. 'html' => 0,
  100. 'strip_tags' => 0,
  101. ),
  102. 'empty' => '',
  103. 'hide_empty' => 0,
  104. 'empty_zero' => 0,
  105. 'hide_alter_empty' => 1,
  106. 'type' => 'separator',
  107. 'separator' => ', ',
  108. 'exclude' => 0,
  109. 'id' => 'uniquename',
  110. 'table' => 'phenotype',
  111. 'field' => 'uniquename',
  112. 'relationship' => 'none',
  113. ),
  114. 'value' => array(
  115. 'label' => 'Value',
  116. 'alter' => array(
  117. 'alter_text' => 0,
  118. 'text' => '',
  119. 'make_link' => 0,
  120. 'path' => '',
  121. 'absolute' => 0,
  122. 'link_class' => '',
  123. 'alt' => '',
  124. 'rel' => '',
  125. 'prefix' => '',
  126. 'suffix' => '',
  127. 'target' => '',
  128. 'help' => '',
  129. 'trim' => 0,
  130. 'max_length' => '',
  131. 'word_boundary' => 1,
  132. 'ellipsis' => 1,
  133. 'html' => 0,
  134. 'strip_tags' => 0,
  135. ),
  136. 'empty' => '',
  137. 'hide_empty' => 0,
  138. 'empty_zero' => 0,
  139. 'hide_alter_empty' => 1,
  140. 'type' => 'separator',
  141. 'separator' => ', ',
  142. 'exclude' => 0,
  143. 'id' => 'value',
  144. 'table' => 'phenotype',
  145. 'field' => 'value',
  146. 'relationship' => 'none',
  147. ),
  148. ));
  149. $handler->override_option('filters', array(
  150. 'uniquename' => array(
  151. 'operator' => 'contains',
  152. 'value' => '',
  153. 'group' => '0',
  154. 'exposed' => TRUE,
  155. 'expose' => array(
  156. 'use_operator' => 0,
  157. 'operator' => 'uniquename_op',
  158. 'identifier' => 'uniquename',
  159. 'label' => 'Unique Name Contains',
  160. 'remember' => 0,
  161. ),
  162. 'case' => 0,
  163. 'id' => 'uniquename',
  164. 'table' => 'phenotype',
  165. 'field' => 'uniquename',
  166. 'relationship' => 'none',
  167. 'agg' => array(
  168. 'records_with' => 1,
  169. 'aggregates_with' => 1,
  170. ),
  171. ),
  172. 'value' => array(
  173. 'operator' => 'contains',
  174. 'value' => '',
  175. 'group' => '0',
  176. 'exposed' => TRUE,
  177. 'expose' => array(
  178. 'use_operator' => 0,
  179. 'operator' => 'value_op',
  180. 'identifier' => 'phen_value',
  181. 'label' => 'Value Contains',
  182. 'remember' => 0,
  183. ),
  184. 'case' => 0,
  185. 'id' => 'value',
  186. 'table' => 'phenotype',
  187. 'field' => 'value',
  188. 'relationship' => 'none',
  189. 'agg' => array(
  190. 'records_with' => 1,
  191. 'aggregates_with' => 1,
  192. ),
  193. ),
  194. 'search_results' => array(
  195. 'operator' => '=',
  196. 'value' => '',
  197. 'group' => '0',
  198. 'exposed' => FALSE,
  199. 'expose' => array(
  200. 'operator' => FALSE,
  201. 'label' => '',
  202. ),
  203. 'id' => 'search_results',
  204. 'table' => 'views',
  205. 'field' => 'search_results',
  206. 'relationship' => 'none',
  207. 'apply_button' => 'Show',
  208. 'no_results_text' => 'Click "Show" to see a list of all phenotypes matching the entered criteria. If you leave a any of the criteria blank then the phenotypes will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all phenotypes will be listed.',
  209. ),
  210. ));
  211. $handler->override_option('access', array(
  212. 'type' => 'perm',
  213. 'perm' => 'access content',
  214. ));
  215. $handler->override_option('cache', array(
  216. 'type' => 'none',
  217. ));
  218. $handler->override_option('title', 'Phenotypes');
  219. $handler->override_option('header', 'Click "Show" to see a list of all phenotypes matching the entered criteria. If you leave a any of the criteria blank then the phenotypes will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all phenotypes will be listed.');
  220. $handler->override_option('header_format', '2');
  221. $handler->override_option('header_empty', 0);
  222. $handler->override_option('empty', 'No phenotypes match the current criteria.');
  223. $handler->override_option('empty_format', '2');
  224. $handler->override_option('items_per_page', 50);
  225. $handler->override_option('use_pager', '1');
  226. $handler->override_option('style_plugin', 'table');
  227. $handler->override_option('style_options', array(
  228. 'grouping' => '',
  229. 'override' => 1,
  230. 'sticky' => 0,
  231. 'order' => 'asc',
  232. 'summary' => '',
  233. 'columns' => array(
  234. 'uniquename' => 'uniquename',
  235. 'value' => 'value',
  236. ),
  237. 'info' => array(
  238. 'uniquename' => array(
  239. 'sortable' => 1,
  240. 'separator' => '',
  241. ),
  242. 'value' => array(
  243. 'sortable' => 1,
  244. 'separator' => '',
  245. ),
  246. ),
  247. 'default' => 'uniquename',
  248. ));
  249. $handler = $view->new_display('page', 'Page', 'page_1');
  250. $handler->override_option('path', 'phenotypes');
  251. $handler->override_option('menu', array(
  252. 'type' => 'normal',
  253. 'title' => 'Phenotypes',
  254. 'description' => '',
  255. 'weight' => '0',
  256. 'name' => 'primary-links',
  257. ));
  258. $handler->override_option('tab_options', array(
  259. 'type' => 'none',
  260. 'title' => '',
  261. 'description' => '',
  262. 'weight' => 0,
  263. 'name' => 'navigation',
  264. ));
  265. $views[$view->name] = $view;
  266. return $views;
  267. }