tripal_cv.views.inc 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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/cvterm.views.inc');
  21. require_once('views/cv.views.inc');
  22. function tripal_cv_views_data() {
  23. $data = array();
  24. //Function is contained in includes/cvterm.views.inc
  25. //Returns the data array for the chado cvterm table
  26. $data = array_merge($data, retrieve_cvterm_views_data());
  27. //Function is contained in includes/cv.views.inc
  28. //Returns the data array for the chado cv table
  29. $data = array_merge($data, retrieve_cv_views_data());
  30. return $data;
  31. }
  32. /*************************************************************************
  33. * Implements hook_views_handlers()
  34. * Purpose: Register all custom handlers with views
  35. * where a handler describes either "the type of field",
  36. * "how a field should be filtered", "how a field should be sorted"
  37. * @return: An array of handler definitions
  38. */
  39. function tripal_cv_views_handlers() {
  40. return array(
  41. 'info' => array(
  42. 'path' => drupal_get_path('module', 'tripal_cv') . '/views/handlers',
  43. ),
  44. 'handlers' => array(
  45. 'views_handler_field_tf_boolean' => array(
  46. 'parent' => 'views_handler_field',
  47. ),
  48. ),
  49. );
  50. }
  51. function tripal_genetic_views_default_views () {
  52. $views = array();
  53. // Main default view
  54. // List all cvterms based on cv
  55. $view = new view;
  56. $view->name = 'all_cvterms';
  57. $view->description = 'A listing of all controlled vocabulary terms filtered by controlled vocabulary';
  58. $view->tag = 'chado';
  59. $view->view_php = '';
  60. $view->base_table = 'cvterm';
  61. $view->is_cacheable = FALSE;
  62. $view->api_version = 2;
  63. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  64. $handler = $view->new_display('default', 'Defaults', 'default');
  65. $handler->override_option('fields', array(
  66. 'name' => array(
  67. 'label' => 'Name',
  68. 'alter' => array(
  69. 'alter_text' => 0,
  70. 'text' => '',
  71. 'make_link' => 0,
  72. 'path' => '',
  73. 'link_class' => '',
  74. 'alt' => '',
  75. 'prefix' => '',
  76. 'suffix' => '',
  77. 'target' => '',
  78. 'help' => '',
  79. 'trim' => 0,
  80. 'max_length' => '',
  81. 'word_boundary' => 1,
  82. 'ellipsis' => 1,
  83. 'html' => 0,
  84. 'strip_tags' => 0,
  85. ),
  86. 'empty' => '',
  87. 'hide_empty' => 0,
  88. 'empty_zero' => 0,
  89. 'exclude' => 0,
  90. 'id' => 'name',
  91. 'table' => 'cvterm',
  92. 'field' => 'name',
  93. 'relationship' => 'none',
  94. ),
  95. 'definition' => array(
  96. 'label' => 'Definition',
  97. 'alter' => array(
  98. 'alter_text' => 0,
  99. 'text' => '',
  100. 'make_link' => 0,
  101. 'path' => '',
  102. 'link_class' => '',
  103. 'alt' => '',
  104. 'prefix' => '',
  105. 'suffix' => '',
  106. 'target' => '',
  107. 'help' => '',
  108. 'trim' => 0,
  109. 'max_length' => '',
  110. 'word_boundary' => 1,
  111. 'ellipsis' => 1,
  112. 'html' => 0,
  113. 'strip_tags' => 0,
  114. ),
  115. 'empty' => '',
  116. 'hide_empty' => 0,
  117. 'empty_zero' => 0,
  118. 'exclude' => 0,
  119. 'id' => 'definition',
  120. 'table' => 'cvterm',
  121. 'field' => 'definition',
  122. 'relationship' => 'none',
  123. ),
  124. 'is_obsolete' => array(
  125. 'label' => 'Is Obsolete',
  126. 'alter' => array(
  127. 'alter_text' => 0,
  128. 'text' => '',
  129. 'make_link' => 0,
  130. 'path' => '',
  131. 'link_class' => '',
  132. 'alt' => '',
  133. 'prefix' => '',
  134. 'suffix' => '',
  135. 'target' => '',
  136. 'help' => '',
  137. 'trim' => 0,
  138. 'max_length' => '',
  139. 'word_boundary' => 1,
  140. 'ellipsis' => 1,
  141. 'html' => 0,
  142. 'strip_tags' => 0,
  143. ),
  144. 'empty' => '',
  145. 'hide_empty' => 0,
  146. 'empty_zero' => 0,
  147. 'type' => 'yes-no',
  148. 'not' => 0,
  149. 'exclude' => 0,
  150. 'id' => 'is_obsolete',
  151. 'table' => 'cvterm',
  152. 'field' => 'is_obsolete',
  153. 'relationship' => 'none',
  154. ),
  155. 'is_relationshiptype' => array(
  156. 'label' => 'Is Relationship',
  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. 'type' => 'yes-no',
  179. 'not' => 0,
  180. 'exclude' => 0,
  181. 'id' => 'is_relationshiptype',
  182. 'table' => 'cvterm',
  183. 'field' => 'is_relationshiptype',
  184. 'relationship' => 'none',
  185. ),
  186. 'accession_link' => array(
  187. 'label' => 'Accession Link',
  188. 'alter' => array(
  189. 'alter_text' => 0,
  190. 'text' => '',
  191. 'make_link' => 0,
  192. 'path' => '',
  193. 'link_class' => '',
  194. 'alt' => '',
  195. 'prefix' => '',
  196. 'suffix' => '',
  197. 'target' => '',
  198. 'help' => '',
  199. 'trim' => 0,
  200. 'max_length' => '',
  201. 'word_boundary' => 1,
  202. 'ellipsis' => 1,
  203. 'html' => 0,
  204. 'strip_tags' => 0,
  205. ),
  206. 'empty' => '',
  207. 'hide_empty' => 0,
  208. 'empty_zero' => 0,
  209. 'exclude' => 0,
  210. 'id' => 'accession_link',
  211. 'table' => 'dbxref',
  212. 'field' => 'accession_link',
  213. 'relationship' => 'none',
  214. ),
  215. ));
  216. $handler->override_option('filters', array(
  217. 'name' => array(
  218. 'operator' => '=',
  219. 'value' => '<select cv>',
  220. 'group' => '0',
  221. 'exposed' => TRUE,
  222. 'expose' => array(
  223. 'use_operator' => 0,
  224. 'operator' => 'name_op',
  225. 'identifier' => 'cv',
  226. 'label' => 'Vocabulary',
  227. 'optional' => 0,
  228. 'remember' => 0,
  229. ),
  230. 'case' => 1,
  231. 'id' => 'name',
  232. 'table' => 'cv',
  233. 'field' => 'name',
  234. 'relationship' => 'none',
  235. ),
  236. 'name_1' => array(
  237. 'operator' => '~',
  238. 'value' => '',
  239. 'group' => '0',
  240. 'exposed' => TRUE,
  241. 'expose' => array(
  242. 'use_operator' => 0,
  243. 'operator' => '',
  244. 'identifier' => 'name',
  245. 'label' => 'Name Contains',
  246. 'optional' => 1,
  247. 'remember' => 0,
  248. ),
  249. 'case' => 0,
  250. 'id' => 'name_1',
  251. 'table' => 'cvterm',
  252. 'field' => 'name',
  253. 'relationship' => 'none',
  254. 'values_form_type' => 'textfield',
  255. ),
  256. 'definition' => array(
  257. 'operator' => 'contains',
  258. 'value' => '',
  259. 'group' => '0',
  260. 'exposed' => TRUE,
  261. 'expose' => array(
  262. 'use_operator' => 0,
  263. 'operator' => 'definition_op',
  264. 'identifier' => 'definition',
  265. 'label' => 'Definition Contains',
  266. 'optional' => 1,
  267. 'remember' => 0,
  268. ),
  269. 'case' => 0,
  270. 'id' => 'definition',
  271. 'table' => 'cvterm',
  272. 'field' => 'definition',
  273. 'relationship' => 'none',
  274. ),
  275. ));
  276. $handler->override_option('access', array(
  277. 'type' => 'perm',
  278. 'perm' => 'access chado_cv content',
  279. ));
  280. $handler->override_option('cache', array(
  281. 'type' => 'none',
  282. ));
  283. $handler->override_option('title', 'Controlled Vocabulary Terms');
  284. $handler->override_option('empty', 'There are no terms associated with the selected controlled vocabulary. Please select a different vocabulary from the list above.');
  285. $handler->override_option('empty_format', '1');
  286. $handler->override_option('items_per_page', 50);
  287. $handler->override_option('use_pager', '1');
  288. $handler->override_option('style_plugin', 'table');
  289. $handler->override_option('style_options', array(
  290. 'grouping' => '',
  291. 'override' => 1,
  292. 'sticky' => 0,
  293. 'order' => 'asc',
  294. 'columns' => array(
  295. 'definition' => 'definition',
  296. 'is_obsolete' => 'is_obsolete',
  297. 'is_relationshiptype' => 'is_relationshiptype',
  298. 'name' => 'name',
  299. 'accession_link' => 'accession_link',
  300. ),
  301. 'info' => array(
  302. 'definition' => array(
  303. 'sortable' => 0,
  304. 'separator' => '',
  305. ),
  306. 'is_obsolete' => array(
  307. 'sortable' => 1,
  308. 'separator' => '',
  309. ),
  310. 'is_relationshiptype' => array(
  311. 'sortable' => 1,
  312. 'separator' => '',
  313. ),
  314. 'name' => array(
  315. 'sortable' => 1,
  316. 'separator' => '',
  317. ),
  318. 'accession_link' => array(
  319. 'sortable' => 1,
  320. 'separator' => '',
  321. ),
  322. ),
  323. 'default' => '-1',
  324. ));
  325. $handler = $view->new_display('page', 'Page', 'page_1');
  326. $handler->override_option('path', 'admin/tripal/tripal_cv/list_cvterms');
  327. $handler->override_option('menu', array(
  328. 'type' => 'normal',
  329. 'title' => 'Term Listing',
  330. 'description' => 'A listing of a controlled vocabulary terms for a given vocabulary',
  331. 'weight' => '0',
  332. 'name' => 'navigation',
  333. ));
  334. $handler->override_option('tab_options', array(
  335. 'type' => 'none',
  336. 'title' => '',
  337. 'description' => '',
  338. 'weight' => 0,
  339. 'name' => 'navigation',
  340. ));
  341. $views[$view->name] = $view;
  342. return $views;
  343. }