tripal_db.views.inc 8.1 KB

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