tripal_cv.views.inc 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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_cv_views Controlled Vocabulary Views Integration
  13. * @ingroup views
  14. * @ingroup tripal_cv
  15. */
  16. require_once('views/cvterm.views.inc');
  17. require_once('views/cv.views.inc');
  18. /**
  19. * Implements hook_views_data()
  20. *
  21. * Purpose: Describe chado/tripal tables & fields to views
  22. *
  23. * @return
  24. * a data array which follows the structure outlined in the
  25. * views2 documentation for this hook. Essentially, it's an array of table
  26. * definitions keyed by chado/tripal table name. Each table definition
  27. * includes basic details about the table, fields in that table and
  28. * relationships between that table and others (joins)
  29. *
  30. * @ingroup tripal_cv_views
  31. */
  32. function tripal_cv_views_data() {
  33. $data = array();
  34. //Function is contained in includes/cvterm.views.inc
  35. //Returns the data array for the chado cvterm table
  36. $data = array_merge($data, retrieve_cvterm_views_data());
  37. //Function is contained in includes/cv.views.inc
  38. //Returns the data array for the chado cv table
  39. $data = array_merge($data, retrieve_cv_views_data());
  40. return $data;
  41. }
  42. /**
  43. * Implements hook_views_handlers()
  44. *
  45. * Purpose: Register all custom handlers with views
  46. * where a handler describes either "the type of field",
  47. * "how a field should be filtered", "how a field should be sorted"
  48. *
  49. * @return: An array of handler definitions
  50. *
  51. * @ingroup tripal_cv_views
  52. */
  53. function tripal_cv_views_handlers() {
  54. return array(
  55. 'info' => array(
  56. 'path' => drupal_get_path('module', 'tripal_cv') . '/views/handlers',
  57. ),
  58. 'handlers' => array(
  59. 'views_handler_field_tf_boolean' => array(
  60. 'parent' => 'views_handler_field',
  61. ),
  62. ),
  63. );
  64. }
  65. /**
  66. *
  67. * @ingroup tripal_cv_views
  68. */
  69. function tripal_cv_views_default_views () {
  70. $views = array();
  71. // Main default view
  72. // List all cvterms based on cv
  73. $view = new view;
  74. $view->name = 'all_cvterms';
  75. $view->description = 'A listing of all controlled vocabulary terms filtered by controlled vocabulary';
  76. $view->tag = 'chado';
  77. $view->view_php = '';
  78. $view->base_table = 'cvterm';
  79. $view->is_cacheable = FALSE;
  80. $view->api_version = 2;
  81. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  82. $handler = $view->new_display('default', 'Defaults', 'default');
  83. $handler->override_option('fields', array(
  84. 'name' => array(
  85. 'label' => 'Name',
  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' => 'name',
  109. 'table' => 'cvterm',
  110. 'field' => 'name',
  111. 'relationship' => 'none',
  112. ),
  113. 'definition' => array(
  114. 'label' => 'Definition',
  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' => 'definition',
  138. 'table' => 'cvterm',
  139. 'field' => 'definition',
  140. 'relationship' => 'none',
  141. ),
  142. 'is_obsolete' => array(
  143. 'label' => 'Is Obsolete',
  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. 'type' => 'yes-no',
  166. 'not' => 0,
  167. 'exclude' => 0,
  168. 'id' => 'is_obsolete',
  169. 'table' => 'cvterm',
  170. 'field' => 'is_obsolete',
  171. 'relationship' => 'none',
  172. ),
  173. 'is_relationshiptype' => array(
  174. 'label' => 'Is Relationship',
  175. 'alter' => array(
  176. 'alter_text' => 0,
  177. 'text' => '',
  178. 'make_link' => 0,
  179. 'path' => '',
  180. 'link_class' => '',
  181. 'alt' => '',
  182. 'prefix' => '',
  183. 'suffix' => '',
  184. 'target' => '',
  185. 'help' => '',
  186. 'trim' => 0,
  187. 'max_length' => '',
  188. 'word_boundary' => 1,
  189. 'ellipsis' => 1,
  190. 'html' => 0,
  191. 'strip_tags' => 0,
  192. ),
  193. 'empty' => '',
  194. 'hide_empty' => 0,
  195. 'empty_zero' => 0,
  196. 'type' => 'yes-no',
  197. 'not' => 0,
  198. 'exclude' => 0,
  199. 'id' => 'is_relationshiptype',
  200. 'table' => 'cvterm',
  201. 'field' => 'is_relationshiptype',
  202. 'relationship' => 'none',
  203. ),
  204. 'accession_link' => array(
  205. 'label' => 'Accession Link',
  206. 'alter' => array(
  207. 'alter_text' => 0,
  208. 'text' => '',
  209. 'make_link' => 0,
  210. 'path' => '',
  211. 'link_class' => '',
  212. 'alt' => '',
  213. 'prefix' => '',
  214. 'suffix' => '',
  215. 'target' => '',
  216. 'help' => '',
  217. 'trim' => 0,
  218. 'max_length' => '',
  219. 'word_boundary' => 1,
  220. 'ellipsis' => 1,
  221. 'html' => 0,
  222. 'strip_tags' => 0,
  223. ),
  224. 'empty' => '',
  225. 'hide_empty' => 0,
  226. 'empty_zero' => 0,
  227. 'exclude' => 0,
  228. 'id' => 'accession_link',
  229. 'table' => 'dbxref',
  230. 'field' => 'accession_link',
  231. 'relationship' => 'none',
  232. ),
  233. ));
  234. $handler->override_option('filters', array(
  235. 'name' => array(
  236. 'operator' => '=',
  237. 'value' => '<select cv>',
  238. 'group' => '0',
  239. 'exposed' => TRUE,
  240. 'expose' => array(
  241. 'use_operator' => 0,
  242. 'operator' => 'name_op',
  243. 'identifier' => 'cv',
  244. 'label' => 'Vocabulary',
  245. 'optional' => 0,
  246. 'remember' => 0,
  247. ),
  248. 'case' => 1,
  249. 'id' => 'name',
  250. 'table' => 'cv',
  251. 'field' => 'name',
  252. 'relationship' => 'none',
  253. ),
  254. 'name_1' => array(
  255. 'operator' => '~',
  256. 'value' => '',
  257. 'group' => '0',
  258. 'exposed' => TRUE,
  259. 'expose' => array(
  260. 'use_operator' => 0,
  261. 'operator' => '',
  262. 'identifier' => 'name',
  263. 'label' => 'Name Contains',
  264. 'optional' => 1,
  265. 'remember' => 0,
  266. ),
  267. 'case' => 0,
  268. 'id' => 'name_1',
  269. 'table' => 'cvterm',
  270. 'field' => 'name',
  271. 'relationship' => 'none',
  272. 'values_form_type' => 'textfield',
  273. ),
  274. 'definition' => array(
  275. 'operator' => 'contains',
  276. 'value' => '',
  277. 'group' => '0',
  278. 'exposed' => TRUE,
  279. 'expose' => array(
  280. 'use_operator' => 0,
  281. 'operator' => 'definition_op',
  282. 'identifier' => 'definition',
  283. 'label' => 'Definition Contains',
  284. 'optional' => 1,
  285. 'remember' => 0,
  286. ),
  287. 'case' => 0,
  288. 'id' => 'definition',
  289. 'table' => 'cvterm',
  290. 'field' => 'definition',
  291. 'relationship' => 'none',
  292. ),
  293. ));
  294. $handler->override_option('access', array(
  295. 'type' => 'perm',
  296. 'perm' => 'access chado_cv content',
  297. ));
  298. $handler->override_option('cache', array(
  299. 'type' => 'none',
  300. ));
  301. $handler->override_option('title', 'Controlled Vocabulary Terms');
  302. $handler->override_option('empty', 'There are no terms associated with the selected controlled vocabulary. Please select a different vocabulary from the list above.');
  303. $handler->override_option('empty_format', '1');
  304. $handler->override_option('items_per_page', 50);
  305. $handler->override_option('use_pager', '1');
  306. $handler->override_option('style_plugin', 'table');
  307. $handler->override_option('style_options', array(
  308. 'grouping' => '',
  309. 'override' => 1,
  310. 'sticky' => 0,
  311. 'order' => 'asc',
  312. 'columns' => array(
  313. 'definition' => 'definition',
  314. 'is_obsolete' => 'is_obsolete',
  315. 'is_relationshiptype' => 'is_relationshiptype',
  316. 'name' => 'name',
  317. 'accession_link' => 'accession_link',
  318. ),
  319. 'info' => array(
  320. 'definition' => array(
  321. 'sortable' => 0,
  322. 'separator' => '',
  323. ),
  324. 'is_obsolete' => array(
  325. 'sortable' => 1,
  326. 'separator' => '',
  327. ),
  328. 'is_relationshiptype' => array(
  329. 'sortable' => 1,
  330. 'separator' => '',
  331. ),
  332. 'name' => array(
  333. 'sortable' => 1,
  334. 'separator' => '',
  335. ),
  336. 'accession_link' => array(
  337. 'sortable' => 1,
  338. 'separator' => '',
  339. ),
  340. ),
  341. 'default' => '-1',
  342. ));
  343. $handler = $view->new_display('page', 'Page', 'page_1');
  344. $handler->override_option('path', 'admin/tripal/tripal_cv/list_cvterms');
  345. $handler->override_option('menu', array(
  346. 'type' => 'normal',
  347. 'title' => 'Term Listing',
  348. 'description' => 'A listing of a controlled vocabulary terms for a given vocabulary',
  349. 'weight' => '0',
  350. 'name' => 'navigation',
  351. ));
  352. $handler->override_option('tab_options', array(
  353. 'type' => 'none',
  354. 'title' => '',
  355. 'description' => '',
  356. 'weight' => 0,
  357. 'name' => 'navigation',
  358. ));
  359. $views[$view->name] = $view;
  360. return $views;
  361. }