tripal_genetic.views.inc 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <?php
  2. /**
  3. * @file
  4. * This file contains the basic functions for views integration of
  5. * chado/tripal_genetic 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. * @defgroup tripal_genetic_views Genetic Views Integration
  13. * @ingroup views
  14. */
  15. /*************************************************************************
  16. * Implements hook_views_data()
  17. * Purpose: Describe chado/tripal tables & fields to views
  18. *
  19. * @return: a data array which follows the structure outlined in the
  20. * views2 documentation for this hook. Essentially, it's an array of table
  21. * definitions keyed by chado/tripal table name. Each table definition
  22. * includes basic details about the table, fields in that table and
  23. * relationships between that table and others (joins)
  24. *
  25. * @ingroup tripal_genetic
  26. */
  27. function tripal_genetic_views_data() {
  28. $data = array();
  29. if (module_exists('tripal_views')) {
  30. $tables = array(
  31. 'environment',
  32. 'genotype',
  33. 'phenstatement'
  34. );
  35. foreach ($tables as $tablename) {
  36. $priority = 9;
  37. // check to see if the table is integrated. If it is then integrate it's
  38. // corresponding 'chado_[table]' table.
  39. if (!tripal_views_is_integrated($tablename, $priority)) {
  40. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority);
  41. $status = tripal_views_integration_add_entry($table_integration_array);
  42. if (!$status) {
  43. drupal_set_message(t('Tripal Genetic is unable to integrate %table', array('%table' => $tablename)), 'error');
  44. }
  45. }
  46. }
  47. $tables = array(
  48. 'environment_cvterm',
  49. 'feature_genotype',
  50. 'phendesc',
  51. 'phenotype_comparison'
  52. );
  53. foreach ($tables as $tablename) {
  54. $priority = 9;
  55. if (!tripal_views_is_integrated($tablename, $priority)) {
  56. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
  57. $status = tripal_views_integration_add_entry($table_integration_array);
  58. if (!$status) {
  59. drupal_set_message(t('Tripal Genetic is unable to integrate %table', array('%table' => $tablename)), 'error');
  60. }
  61. }
  62. }
  63. }
  64. return $data;
  65. }
  66. /*************************************************************************
  67. * Implements hook_views_handlers()
  68. * Purpose: Register all custom handlers with views
  69. * where a handler describes either "the type of field",
  70. * "how a field should be filtered", "how a field should be sorted"
  71. *
  72. * @return: An array of handler definitions
  73. *
  74. * @ingroup tripal_genetic
  75. */
  76. function tripal_genetic_views_handlers() {
  77. return array(
  78. 'info' => array(
  79. 'path' => drupal_get_path('module', 'tripal_genetic') . '/views/handlers',
  80. ),
  81. 'handlers' => array(
  82. ),
  83. );
  84. }
  85. /**
  86. * Implements hook_views_default_views().
  87. *
  88. * @ingroup tripal_genetic
  89. */
  90. function tripal_genetic_views_default_views() {
  91. $views = array();
  92. if (!module_exists('tripal_views')) {
  93. return $views;
  94. }
  95. // Main default view
  96. $view = new view;
  97. $view->name = 'genotype_listing';
  98. $view->description = 'A listing of observed genotypes and the features displaying them';
  99. $view->tag = 'chado default';
  100. $view->base_table = 'genotype';
  101. $view->core = 6;
  102. $view->api_version = '2';
  103. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  104. $handler = $view->new_display('default', 'Defaults', 'default');
  105. $handler->override_option('fields', array(
  106. 'uniquename' => array(
  107. 'label' => 'Uniquename',
  108. 'alter' => array(
  109. 'alter_text' => 0,
  110. 'text' => '',
  111. 'make_link' => 0,
  112. 'path' => '',
  113. 'absolute' => 0,
  114. 'link_class' => '',
  115. 'alt' => '',
  116. 'rel' => '',
  117. 'prefix' => '',
  118. 'suffix' => '',
  119. 'target' => '',
  120. 'help' => '',
  121. 'trim' => 0,
  122. 'max_length' => '',
  123. 'word_boundary' => 1,
  124. 'ellipsis' => 1,
  125. 'html' => 0,
  126. 'strip_tags' => 0,
  127. ),
  128. 'empty' => '',
  129. 'hide_empty' => 0,
  130. 'empty_zero' => 0,
  131. 'hide_alter_empty' => 1,
  132. 'type' => 'separator',
  133. 'separator' => ', ',
  134. 'exclude' => 0,
  135. 'id' => 'uniquename',
  136. 'table' => 'genotype',
  137. 'field' => 'uniquename',
  138. 'relationship' => 'none',
  139. ),
  140. 'name' => array(
  141. 'label' => 'Name',
  142. 'alter' => array(
  143. 'alter_text' => 0,
  144. 'text' => '',
  145. 'make_link' => 0,
  146. 'path' => '',
  147. 'absolute' => 0,
  148. 'link_class' => '',
  149. 'alt' => '',
  150. 'rel' => '',
  151. 'prefix' => '',
  152. 'suffix' => '',
  153. 'target' => '',
  154. 'help' => '',
  155. 'trim' => 0,
  156. 'max_length' => '',
  157. 'word_boundary' => 1,
  158. 'ellipsis' => 1,
  159. 'html' => 0,
  160. 'strip_tags' => 0,
  161. ),
  162. 'empty' => '',
  163. 'hide_empty' => 0,
  164. 'empty_zero' => 0,
  165. 'hide_alter_empty' => 1,
  166. 'type' => 'separator',
  167. 'separator' => ', ',
  168. 'exclude' => 0,
  169. 'id' => 'name',
  170. 'table' => 'genotype',
  171. 'field' => 'name',
  172. 'relationship' => 'none',
  173. ),
  174. 'description' => array(
  175. 'label' => 'Description',
  176. 'alter' => array(
  177. 'alter_text' => 0,
  178. 'text' => '',
  179. 'make_link' => 0,
  180. 'path' => '',
  181. 'absolute' => 0,
  182. 'link_class' => '',
  183. 'alt' => '',
  184. 'rel' => '',
  185. 'prefix' => '',
  186. 'suffix' => '',
  187. 'target' => '',
  188. 'help' => '',
  189. 'trim' => 0,
  190. 'max_length' => '',
  191. 'word_boundary' => 1,
  192. 'ellipsis' => 1,
  193. 'html' => 0,
  194. 'strip_tags' => 0,
  195. ),
  196. 'empty' => '',
  197. 'hide_empty' => 0,
  198. 'empty_zero' => 0,
  199. 'hide_alter_empty' => 1,
  200. 'type' => 'separator',
  201. 'separator' => ', ',
  202. 'exclude' => 0,
  203. 'id' => 'description',
  204. 'table' => 'genotype',
  205. 'field' => 'description',
  206. 'relationship' => 'none',
  207. ),
  208. ));
  209. $handler->override_option('filters', array(
  210. 'uniquename' => array(
  211. 'operator' => '~',
  212. 'value' => '',
  213. 'group' => '0',
  214. 'exposed' => TRUE,
  215. 'expose' => array(
  216. 'use_operator' => 0,
  217. 'operator' => 'uniquename_op',
  218. 'identifier' => 'uniquename',
  219. 'label' => 'Unique Name Contains',
  220. 'remember' => 0,
  221. ),
  222. 'case' => 0,
  223. 'id' => 'uniquename',
  224. 'table' => 'genotype',
  225. 'field' => 'uniquename',
  226. 'relationship' => 'none',
  227. 'agg' => array(
  228. 'records_with' => 1,
  229. 'aggregates_with' => 1,
  230. ),
  231. ),
  232. 'description' => array(
  233. 'operator' => '~',
  234. 'value' => '',
  235. 'group' => '0',
  236. 'exposed' => TRUE,
  237. 'expose' => array(
  238. 'use_operator' => 0,
  239. 'operator' => 'description_op',
  240. 'identifier' => 'description',
  241. 'label' => 'Description Contains',
  242. 'remember' => 0,
  243. ),
  244. 'case' => 0,
  245. 'id' => 'description',
  246. 'table' => 'genotype',
  247. 'field' => 'description',
  248. 'relationship' => 'none',
  249. 'agg' => array(
  250. 'records_with' => 1,
  251. 'aggregates_with' => 1,
  252. ),
  253. ),
  254. 'search_results' => array(
  255. 'operator' => '=',
  256. 'value' => '',
  257. 'group' => '0',
  258. 'exposed' => FALSE,
  259. 'expose' => array(
  260. 'operator' => FALSE,
  261. 'label' => '',
  262. ),
  263. 'id' => 'search_results',
  264. 'table' => 'views',
  265. 'field' => 'search_results',
  266. 'relationship' => 'none',
  267. 'apply_button' => 'Show',
  268. 'no_results_text' => 'Click "Show" to see a list of all genotypes matching the entered criteria. If you leave a any of the criteria blank then the genotypes will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all genotypes will be listed.',
  269. ),
  270. ));
  271. $handler->override_option('access', array(
  272. 'type' => 'perm',
  273. 'perm' => 'access content',
  274. ));
  275. $handler->override_option('cache', array(
  276. 'type' => 'none',
  277. ));
  278. $handler->override_option('title', 'Genotypes Observed');
  279. $handler->override_option('header', 'Click "Show" to see a list of all genotypes matching the entered criteria. If you leave a any of the criteria blank then the genotypes will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all genotypes will be listed.');
  280. $handler->override_option('header_format', '2');
  281. $handler->override_option('header_empty', 0);
  282. $handler->override_option('empty', 'No genotypes match the current criteria.');
  283. $handler->override_option('empty_format', '2');
  284. $handler->override_option('items_per_page', 50);
  285. $handler->override_option('use_pager', '1');
  286. $handler->override_option('style_plugin', 'table');
  287. $handler->override_option('style_options', array(
  288. 'grouping' => '',
  289. 'override' => 1,
  290. 'sticky' => 0,
  291. 'order' => 'asc',
  292. 'summary' => '',
  293. 'columns' => array(
  294. 'uniquename' => 'uniquename',
  295. 'name' => 'name',
  296. 'description' => 'description',
  297. ),
  298. 'info' => array(
  299. 'uniquename' => array(
  300. 'sortable' => 1,
  301. 'separator' => '',
  302. ),
  303. 'name' => array(
  304. 'sortable' => 1,
  305. 'separator' => '',
  306. ),
  307. 'description' => array(
  308. 'sortable' => 1,
  309. 'separator' => '',
  310. ),
  311. ),
  312. 'default' => 'uniquename',
  313. ));
  314. $handler = $view->new_display('page', 'Page', 'page_1');
  315. $handler->override_option('path', 'chado/genotypes');
  316. $handler->override_option('menu', array(
  317. 'type' => 'normal',
  318. 'title' => 'Genotypes',
  319. 'description' => 'A genotype is defined by a collection of features, mutations, balancers, deficiencies, haplotype blocks, or engineered constructs.',
  320. 'weight' => '10',
  321. 'name' => 'navigation',
  322. ));
  323. $handler->override_option('tab_options', array(
  324. 'type' => 'none',
  325. 'title' => '',
  326. 'description' => '',
  327. 'weight' => 0,
  328. 'name' => 'navigation',
  329. ));
  330. $views[$view->name] = $view;
  331. return $views;
  332. }