tripal_cv.views.inc 10 KB

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