tripal_db.views.inc 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <?php
  2. /**
  3. * @file
  4. * This file contains the basic functions for views integration of
  5. * chado/tripal db 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_db_views External Database Views Integration
  13. * @ingroup views
  14. * @ingroup tripal_db
  15. */
  16. /**
  17. * Implements hook_views_data()
  18. * Purpose: Describe chado/tripal tables & fields to views
  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_db_views
  26. */
  27. function tripal_db_views_data() {
  28. $data = array();
  29. if (module_exists('tripal_views')) {
  30. // Base Tables
  31. $tables = array(
  32. 'db',
  33. 'dbxref'
  34. );
  35. foreach ($tables as $tablename) {
  36. if (!tripal_views_is_integrated($tablename, 10)) {
  37. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE);
  38. tripal_views_integration_add_entry($table_integration_array);
  39. }
  40. }
  41. // Additional Tables
  42. $tables = array(
  43. 'dbxrefprop'
  44. );
  45. foreach ($tables as $tablename) {
  46. if (!tripal_views_is_integrated($tablename, 10)) {
  47. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE);
  48. tripal_views_integration_add_entry($table_integration_array);
  49. }
  50. }
  51. }
  52. return $data;
  53. }
  54. /**
  55. *
  56. * @ingroup tripal_db_views
  57. */
  58. function tripal_db_views_default_views() {
  59. $views = array();
  60. // Main default view
  61. // List all cvterms based on cv
  62. $view = new view;
  63. $view = new view;
  64. $view->name = 'all_dbxrefs';
  65. $view->description = 'A listing of all database references filtered by database';
  66. $view->tag = 'chado';
  67. $view->view_php = '';
  68. $view->base_table = 'dbxref';
  69. $view->is_cacheable = FALSE;
  70. $view->api_version = 2;
  71. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  72. $handler = $view->new_display('default', 'Defaults', 'default');
  73. $handler->override_option('fields', array(
  74. 'name' => array(
  75. 'label' => 'Database',
  76. 'alter' => array(
  77. 'alter_text' => 0,
  78. 'text' => '',
  79. 'make_link' => 0,
  80. 'path' => '',
  81. 'link_class' => '',
  82. 'alt' => '',
  83. 'prefix' => '',
  84. 'suffix' => '',
  85. 'target' => '',
  86. 'help' => '',
  87. 'trim' => 0,
  88. 'max_length' => '',
  89. 'word_boundary' => 1,
  90. 'ellipsis' => 1,
  91. 'html' => 0,
  92. 'strip_tags' => 0,
  93. ),
  94. 'empty' => '',
  95. 'hide_empty' => 0,
  96. 'empty_zero' => 0,
  97. 'exclude' => 0,
  98. 'id' => 'name',
  99. 'table' => 'db',
  100. 'field' => 'name',
  101. 'relationship' => 'none',
  102. ),
  103. 'accession' => array(
  104. 'label' => 'Accession',
  105. 'alter' => array(
  106. 'alter_text' => 0,
  107. 'text' => '',
  108. 'make_link' => 0,
  109. 'path' => '',
  110. 'link_class' => '',
  111. 'alt' => '',
  112. 'prefix' => '',
  113. 'suffix' => '',
  114. 'target' => '',
  115. 'help' => '',
  116. 'trim' => 0,
  117. 'max_length' => '',
  118. 'word_boundary' => 1,
  119. 'ellipsis' => 1,
  120. 'html' => 0,
  121. 'strip_tags' => 0,
  122. ),
  123. 'empty' => '',
  124. 'hide_empty' => 0,
  125. 'empty_zero' => 0,
  126. 'exclude' => 0,
  127. 'id' => 'accession',
  128. 'table' => 'dbxref',
  129. 'field' => 'accession',
  130. 'relationship' => 'none',
  131. ),
  132. 'description' => array(
  133. 'label' => 'Description',
  134. 'alter' => array(
  135. 'alter_text' => 0,
  136. 'text' => '',
  137. 'make_link' => 0,
  138. 'path' => '',
  139. 'link_class' => '',
  140. 'alt' => '',
  141. 'prefix' => '',
  142. 'suffix' => '',
  143. 'target' => '',
  144. 'help' => '',
  145. 'trim' => 0,
  146. 'max_length' => '',
  147. 'word_boundary' => 1,
  148. 'ellipsis' => 1,
  149. 'html' => 0,
  150. 'strip_tags' => 0,
  151. ),
  152. 'empty' => '',
  153. 'hide_empty' => 0,
  154. 'empty_zero' => 0,
  155. 'exclude' => 0,
  156. 'id' => 'description',
  157. 'table' => 'dbxref',
  158. 'field' => 'description',
  159. 'relationship' => 'none',
  160. ),
  161. 'version' => array(
  162. 'label' => 'Version',
  163. 'alter' => array(
  164. 'alter_text' => 0,
  165. 'text' => '',
  166. 'make_link' => 0,
  167. 'path' => '',
  168. 'link_class' => '',
  169. 'alt' => '',
  170. 'prefix' => '',
  171. 'suffix' => '',
  172. 'target' => '',
  173. 'help' => '',
  174. 'trim' => 0,
  175. 'max_length' => '',
  176. 'word_boundary' => 1,
  177. 'ellipsis' => 1,
  178. 'html' => 0,
  179. 'strip_tags' => 0,
  180. ),
  181. 'empty' => '',
  182. 'hide_empty' => 0,
  183. 'empty_zero' => 0,
  184. 'exclude' => 0,
  185. 'id' => 'version',
  186. 'table' => 'dbxref',
  187. 'field' => 'version',
  188. 'relationship' => 'none',
  189. ),
  190. 'accession_link' => array(
  191. 'label' => 'External Link',
  192. 'alter' => array(
  193. 'alter_text' => 1,
  194. 'text' => 'link',
  195. 'make_link' => 1,
  196. 'path' => '[accession_link]',
  197. 'link_class' => '',
  198. 'alt' => '',
  199. 'prefix' => '',
  200. 'suffix' => '',
  201. 'target' => '',
  202. 'help' => '',
  203. 'trim' => 0,
  204. 'max_length' => '',
  205. 'word_boundary' => 1,
  206. 'ellipsis' => 1,
  207. 'html' => 0,
  208. 'strip_tags' => 0,
  209. ),
  210. 'empty' => '',
  211. 'hide_empty' => 1,
  212. 'empty_zero' => 0,
  213. 'exclude' => 0,
  214. 'id' => 'accession_link',
  215. 'table' => 'dbxref',
  216. 'field' => 'accession_link',
  217. 'relationship' => 'none',
  218. ),
  219. ));
  220. $handler->override_option('filters', array(
  221. 'name' => array(
  222. 'operator' => '=',
  223. 'value' => '<select db>',
  224. 'group' => '0',
  225. 'exposed' => TRUE,
  226. 'expose' => array(
  227. 'use_operator' => 0,
  228. 'operator' => 'name_op',
  229. 'identifier' => 'db',
  230. 'label' => 'Database',
  231. 'optional' => 1,
  232. 'remember' => 0,
  233. ),
  234. 'case' => 1,
  235. 'id' => 'name',
  236. 'table' => 'db',
  237. 'field' => 'name',
  238. 'relationship' => 'none',
  239. ),
  240. 'accession' => array(
  241. 'operator' => 'contains',
  242. 'value' => '',
  243. 'group' => '0',
  244. 'exposed' => TRUE,
  245. 'expose' => array(
  246. 'use_operator' => 0,
  247. 'operator' => 'accession_op',
  248. 'identifier' => 'accession',
  249. 'label' => 'Accession Contains',
  250. 'optional' => 1,
  251. 'remember' => 0,
  252. ),
  253. 'case' => 0,
  254. 'id' => 'accession',
  255. 'table' => 'dbxref',
  256. 'field' => 'accession',
  257. 'relationship' => 'none',
  258. ),
  259. ));
  260. $handler->override_option('access', array(
  261. 'type' => 'perm',
  262. 'perm' => 'access chado_db content',
  263. ));
  264. $handler->override_option('cache', array(
  265. 'type' => 'none',
  266. ));
  267. $handler->override_option('title', 'Database References');
  268. $handler->override_option('empty', 'There are no database references matching the above criteria. Please select a database in order to display all references to that database.');
  269. $handler->override_option('empty_format', '1');
  270. $handler->override_option('items_per_page', 50);
  271. $handler->override_option('use_pager', '1');
  272. $handler->override_option('style_plugin', 'table');
  273. $handler->override_option('style_options', array(
  274. 'grouping' => '',
  275. 'override' => 1,
  276. 'sticky' => 0,
  277. 'order' => 'asc',
  278. 'columns' => array(
  279. 'name' => 'name',
  280. 'accession' => 'accession',
  281. 'description' => 'description',
  282. 'version' => 'version',
  283. ),
  284. 'info' => array(
  285. 'name' => array(
  286. 'sortable' => 1,
  287. 'separator' => '',
  288. ),
  289. 'accession' => array(
  290. 'sortable' => 1,
  291. 'separator' => '',
  292. ),
  293. 'description' => array(
  294. 'sortable' => 1,
  295. 'separator' => '',
  296. ),
  297. 'version' => array(
  298. 'sortable' => 1,
  299. 'separator' => '',
  300. ),
  301. ),
  302. 'default' => '-1',
  303. ));
  304. $handler = $view->new_display('page', 'Page', 'page_1');
  305. $handler->override_option('path', 'admin/tripal/tripal_db/list_dbxrefs');
  306. $handler->override_option('menu', array(
  307. 'type' => 'normal',
  308. 'title' => 'DB Reference Listing',
  309. 'description' => 'A listing of all database references associated with a given database',
  310. 'weight' => '0',
  311. 'name' => 'navigation',
  312. ));
  313. $handler->override_option('tab_options', array(
  314. 'type' => 'none',
  315. 'title' => '',
  316. 'description' => '',
  317. 'weight' => 0,
  318. 'name' => 'navigation',
  319. ));
  320. $views[$view->name] = $view;
  321. return $views;
  322. }