tripal_db.views.inc 8.7 KB

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