tripal_db.views.inc 9.1 KB

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