tripal_db.views.inc 8.5 KB

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