tripal_db.views.inc 8.6 KB

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