tripal_cv.views.inc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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. if (module_exists('tripal_views')) {
  41. // Base Tables
  42. $tables = array(
  43. 'cv',
  44. 'cvterm'
  45. );
  46. foreach ($tables as $tablename) {
  47. if (!tripal_views_is_integrated($tablename, 10)) {
  48. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,TRUE);
  49. tripal_views_integration_add_entry($table_integration_array);
  50. }
  51. }
  52. // Additional Tables
  53. $tables = array(
  54. 'cvterm_dbxref',
  55. 'cvterm_relationship',
  56. 'cvtermpath',
  57. 'cvtermprop',
  58. 'cvtermsynonym'
  59. );
  60. foreach ($tables as $tablename) {
  61. if (!tripal_views_is_integrated($tablename, 10)) {
  62. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,FALSE);
  63. tripal_views_integration_add_entry($table_integration_array);
  64. }
  65. }
  66. }
  67. return $data;
  68. }
  69. /**
  70. * Implements hook_views_handlers()
  71. *
  72. * Purpose: Register all custom handlers with views
  73. * where a handler describes either "the type of field",
  74. * "how a field should be filtered", "how a field should be sorted"
  75. *
  76. * @return: An array of handler definitions
  77. *
  78. * @ingroup tripal_cv_views
  79. */
  80. function tripal_cv_views_handlers() {
  81. return array(
  82. 'info' => array(
  83. 'path' => drupal_get_path('module', 'tripal_cv') . '/views/handlers',
  84. ),
  85. 'handlers' => array(
  86. 'views_handler_field_tf_boolean' => array(
  87. 'parent' => 'views_handler_field',
  88. ),
  89. ),
  90. );
  91. }
  92. /**
  93. *
  94. * @ingroup tripal_cv_views
  95. */
  96. function tripal_cv_views_default_views () {
  97. $views = array();
  98. // Main default view
  99. // List all cvterms based on cv
  100. $view = new view;
  101. $view->name = 'all_cvterms';
  102. $view->description = 'A listing of all controlled vocabulary terms filtered by controlled vocabulary';
  103. $view->tag = 'chado';
  104. $view->view_php = '';
  105. $view->base_table = 'cvterm';
  106. $view->is_cacheable = FALSE;
  107. $view->api_version = 2;
  108. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  109. $handler = $view->new_display('default', 'Defaults', 'default');
  110. $handler->override_option('fields', array(
  111. 'name' => array(
  112. 'label' => 'Name',
  113. 'alter' => array(
  114. 'alter_text' => 0,
  115. 'text' => '',
  116. 'make_link' => 0,
  117. 'path' => '',
  118. 'link_class' => '',
  119. 'alt' => '',
  120. 'prefix' => '',
  121. 'suffix' => '',
  122. 'target' => '',
  123. 'help' => '',
  124. 'trim' => 0,
  125. 'max_length' => '',
  126. 'word_boundary' => 1,
  127. 'ellipsis' => 1,
  128. 'html' => 0,
  129. 'strip_tags' => 0,
  130. ),
  131. 'empty' => '',
  132. 'hide_empty' => 0,
  133. 'empty_zero' => 0,
  134. 'exclude' => 0,
  135. 'id' => 'name',
  136. 'table' => 'cvterm',
  137. 'field' => 'name',
  138. 'relationship' => 'none',
  139. ),
  140. 'definition' => array(
  141. 'label' => 'Definition',
  142. 'alter' => array(
  143. 'alter_text' => 0,
  144. 'text' => '',
  145. 'make_link' => 0,
  146. 'path' => '',
  147. 'link_class' => '',
  148. 'alt' => '',
  149. 'prefix' => '',
  150. 'suffix' => '',
  151. 'target' => '',
  152. 'help' => '',
  153. 'trim' => 0,
  154. 'max_length' => '',
  155. 'word_boundary' => 1,
  156. 'ellipsis' => 1,
  157. 'html' => 0,
  158. 'strip_tags' => 0,
  159. ),
  160. 'empty' => '',
  161. 'hide_empty' => 0,
  162. 'empty_zero' => 0,
  163. 'exclude' => 0,
  164. 'id' => 'definition',
  165. 'table' => 'cvterm',
  166. 'field' => 'definition',
  167. 'relationship' => 'none',
  168. ),
  169. 'is_obsolete' => array(
  170. 'label' => 'Is Obsolete',
  171. 'alter' => array(
  172. 'alter_text' => 0,
  173. 'text' => '',
  174. 'make_link' => 0,
  175. 'path' => '',
  176. 'link_class' => '',
  177. 'alt' => '',
  178. 'prefix' => '',
  179. 'suffix' => '',
  180. 'target' => '',
  181. 'help' => '',
  182. 'trim' => 0,
  183. 'max_length' => '',
  184. 'word_boundary' => 1,
  185. 'ellipsis' => 1,
  186. 'html' => 0,
  187. 'strip_tags' => 0,
  188. ),
  189. 'empty' => '',
  190. 'hide_empty' => 0,
  191. 'empty_zero' => 0,
  192. 'type' => 'yes-no',
  193. 'not' => 0,
  194. 'exclude' => 0,
  195. 'id' => 'is_obsolete',
  196. 'table' => 'cvterm',
  197. 'field' => 'is_obsolete',
  198. 'relationship' => 'none',
  199. ),
  200. 'is_relationshiptype' => array(
  201. 'label' => 'Is Relationship',
  202. 'alter' => array(
  203. 'alter_text' => 0,
  204. 'text' => '',
  205. 'make_link' => 0,
  206. 'path' => '',
  207. 'link_class' => '',
  208. 'alt' => '',
  209. 'prefix' => '',
  210. 'suffix' => '',
  211. 'target' => '',
  212. 'help' => '',
  213. 'trim' => 0,
  214. 'max_length' => '',
  215. 'word_boundary' => 1,
  216. 'ellipsis' => 1,
  217. 'html' => 0,
  218. 'strip_tags' => 0,
  219. ),
  220. 'empty' => '',
  221. 'hide_empty' => 0,
  222. 'empty_zero' => 0,
  223. 'type' => 'yes-no',
  224. 'not' => 0,
  225. 'exclude' => 0,
  226. 'id' => 'is_relationshiptype',
  227. 'table' => 'cvterm',
  228. 'field' => 'is_relationshiptype',
  229. 'relationship' => 'none',
  230. ),
  231. 'accession_link' => array(
  232. 'label' => 'Accession Link',
  233. 'alter' => array(
  234. 'alter_text' => 0,
  235. 'text' => '',
  236. 'make_link' => 0,
  237. 'path' => '',
  238. 'link_class' => '',
  239. 'alt' => '',
  240. 'prefix' => '',
  241. 'suffix' => '',
  242. 'target' => '',
  243. 'help' => '',
  244. 'trim' => 0,
  245. 'max_length' => '',
  246. 'word_boundary' => 1,
  247. 'ellipsis' => 1,
  248. 'html' => 0,
  249. 'strip_tags' => 0,
  250. ),
  251. 'empty' => '',
  252. 'hide_empty' => 0,
  253. 'empty_zero' => 0,
  254. 'exclude' => 0,
  255. 'id' => 'accession_link',
  256. 'table' => 'dbxref',
  257. 'field' => 'accession_link',
  258. 'relationship' => 'none',
  259. ),
  260. ));
  261. $handler->override_option('filters', array(
  262. 'name' => array(
  263. 'operator' => '=',
  264. 'value' => '<select cv>',
  265. 'group' => '0',
  266. 'exposed' => TRUE,
  267. 'expose' => array(
  268. 'use_operator' => 0,
  269. 'operator' => 'name_op',
  270. 'identifier' => 'cv',
  271. 'label' => 'Vocabulary',
  272. 'optional' => 0,
  273. 'remember' => 0,
  274. ),
  275. 'case' => 1,
  276. 'id' => 'name',
  277. 'table' => 'cv',
  278. 'field' => 'name',
  279. 'relationship' => 'none',
  280. ),
  281. 'name_1' => array(
  282. 'operator' => '~',
  283. 'value' => '',
  284. 'group' => '0',
  285. 'exposed' => TRUE,
  286. 'expose' => array(
  287. 'use_operator' => 0,
  288. 'operator' => '',
  289. 'identifier' => 'name',
  290. 'label' => 'Name Contains',
  291. 'optional' => 1,
  292. 'remember' => 0,
  293. ),
  294. 'case' => 0,
  295. 'id' => 'name_1',
  296. 'table' => 'cvterm',
  297. 'field' => 'name',
  298. 'relationship' => 'none',
  299. 'values_form_type' => 'textfield',
  300. ),
  301. 'definition' => array(
  302. 'operator' => 'contains',
  303. 'value' => '',
  304. 'group' => '0',
  305. 'exposed' => TRUE,
  306. 'expose' => array(
  307. 'use_operator' => 0,
  308. 'operator' => 'definition_op',
  309. 'identifier' => 'definition',
  310. 'label' => 'Definition Contains',
  311. 'optional' => 1,
  312. 'remember' => 0,
  313. ),
  314. 'case' => 0,
  315. 'id' => 'definition',
  316. 'table' => 'cvterm',
  317. 'field' => 'definition',
  318. 'relationship' => 'none',
  319. ),
  320. ));
  321. $handler->override_option('access', array(
  322. 'type' => 'perm',
  323. 'perm' => 'access chado_cv content',
  324. ));
  325. $handler->override_option('cache', array(
  326. 'type' => 'none',
  327. ));
  328. $handler->override_option('title', 'Controlled Vocabulary Terms');
  329. $handler->override_option('empty', 'There are no terms associated with the selected controlled vocabulary. Please select a different vocabulary from the list above.');
  330. $handler->override_option('empty_format', '1');
  331. $handler->override_option('items_per_page', 50);
  332. $handler->override_option('use_pager', '1');
  333. $handler->override_option('style_plugin', 'table');
  334. $handler->override_option('style_options', array(
  335. 'grouping' => '',
  336. 'override' => 1,
  337. 'sticky' => 0,
  338. 'order' => 'asc',
  339. 'columns' => array(
  340. 'definition' => 'definition',
  341. 'is_obsolete' => 'is_obsolete',
  342. 'is_relationshiptype' => 'is_relationshiptype',
  343. 'name' => 'name',
  344. 'accession_link' => 'accession_link',
  345. ),
  346. 'info' => array(
  347. 'definition' => array(
  348. 'sortable' => 0,
  349. 'separator' => '',
  350. ),
  351. 'is_obsolete' => array(
  352. 'sortable' => 1,
  353. 'separator' => '',
  354. ),
  355. 'is_relationshiptype' => array(
  356. 'sortable' => 1,
  357. 'separator' => '',
  358. ),
  359. 'name' => array(
  360. 'sortable' => 1,
  361. 'separator' => '',
  362. ),
  363. 'accession_link' => array(
  364. 'sortable' => 1,
  365. 'separator' => '',
  366. ),
  367. ),
  368. 'default' => '-1',
  369. ));
  370. $handler = $view->new_display('page', 'Page', 'page_1');
  371. $handler->override_option('path', 'admin/tripal/tripal_cv/list_cvterms');
  372. $handler->override_option('menu', array(
  373. 'type' => 'normal',
  374. 'title' => 'Term Listing',
  375. 'description' => 'A listing of a controlled vocabulary terms for a given vocabulary',
  376. 'weight' => '0',
  377. 'name' => 'navigation',
  378. ));
  379. $handler->override_option('tab_options', array(
  380. 'type' => 'none',
  381. 'title' => '',
  382. 'description' => '',
  383. 'weight' => 0,
  384. 'name' => 'navigation',
  385. ));
  386. $views[$view->name] = $view;
  387. return $views;
  388. }