tripal_db.views.inc 8.8 KB

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