tripal_feature.views.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <?php
  2. /**
  3. * @file
  4. * This file contains the basic functions for views integration of
  5. * chado/tripal organism 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_feature_views Feature Views Integration
  13. * @ingroup views
  14. * @ingroup tripal_feature
  15. */
  16. /**
  17. * Implements hook_views_data()
  18. *
  19. * Purpose: Describe chado/tripal tables & fields to views
  20. *
  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_feature_views
  28. */
  29. require_once('views/feature.views.inc');
  30. require_once('views/chado_feature.views.inc');
  31. require_once('views/misc_tables.views.inc');
  32. function tripal_feature_views_data() {
  33. $data = array();
  34. $data = array_merge($data, retrieve_feature_views_data());
  35. $data = array_merge($data, retrieve_chado_feature_views_data());
  36. $data = array_merge($data, retrieve_feature_misc_tables_views_data());
  37. return $data;
  38. }
  39. /**
  40. * Implements hook_views_handlers()
  41. *
  42. * Purpose: Register all custom handlers with views
  43. * where a handler describes either "the type of field",
  44. * "how a field should be filtered", "how a field should be sorted"
  45. *
  46. * @return: An array of handler definitions
  47. *
  48. * @ingroup tripal_feature_views
  49. */
  50. function tripal_feature_views_handlers() {
  51. return array(
  52. 'info' => array(
  53. 'path' => drupal_get_path('module', 'tripal_feature') . '/views/handlers',
  54. ),
  55. 'handlers' => array(
  56. 'views_handler_field_computed_feature_nid' => array(
  57. 'parent' => 'views_handler_field_numeric',
  58. ),
  59. 'views_handler_field_readable_date' => array(
  60. 'parent' => 'views_handler_field',
  61. ),
  62. 'views_handler_field_residues' => array(
  63. 'parent' => 'views_handler_field',
  64. ),
  65. ),
  66. );
  67. }
  68. /**
  69. *
  70. * @ingroup tripal_feature_views
  71. */
  72. function tripal_feature_views_default_views () {
  73. $views = array();
  74. // Main default view
  75. // List all cvterms based on cv
  76. $view = new view;
  77. $view->name = 'all_features';
  78. $view->description = 'A listing of all Sequence FEatures';
  79. $view->tag = 'chado';
  80. $view->view_php = '';
  81. $view->base_table = 'feature';
  82. $view->is_cacheable = FALSE;
  83. $view->api_version = 2;
  84. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  85. $handler = $view->new_display('default', 'Defaults', 'default');
  86. $handler->override_option('fields', array(
  87. 'uniquename' => array(
  88. 'label' => 'Unique Name',
  89. 'alter' => array(
  90. 'alter_text' => 0,
  91. 'text' => '',
  92. 'make_link' => 0,
  93. 'path' => '',
  94. 'link_class' => '',
  95. 'alt' => '',
  96. 'prefix' => '',
  97. 'suffix' => '',
  98. 'target' => '',
  99. 'help' => '',
  100. 'trim' => 0,
  101. 'max_length' => '',
  102. 'word_boundary' => 1,
  103. 'ellipsis' => 1,
  104. 'html' => 0,
  105. 'strip_tags' => 0,
  106. ),
  107. 'empty' => '',
  108. 'hide_empty' => 0,
  109. 'empty_zero' => 0,
  110. 'link_to_node' => 1,
  111. 'exclude' => 0,
  112. 'id' => 'uniquename',
  113. 'table' => 'feature',
  114. 'field' => 'uniquename',
  115. 'relationship' => 'none',
  116. ),
  117. 'name' => array(
  118. 'label' => 'Name',
  119. 'alter' => array(
  120. 'alter_text' => 0,
  121. 'text' => '',
  122. 'make_link' => 0,
  123. 'path' => '',
  124. 'link_class' => '',
  125. 'alt' => '',
  126. 'prefix' => '',
  127. 'suffix' => '',
  128. 'target' => '',
  129. 'help' => '',
  130. 'trim' => 0,
  131. 'max_length' => '',
  132. 'word_boundary' => 1,
  133. 'ellipsis' => 1,
  134. 'html' => 0,
  135. 'strip_tags' => 0,
  136. ),
  137. 'empty' => '',
  138. 'hide_empty' => 0,
  139. 'empty_zero' => 0,
  140. 'link_to_node' => 1,
  141. 'exclude' => 0,
  142. 'id' => 'name',
  143. 'table' => 'feature',
  144. 'field' => 'name',
  145. 'relationship' => 'none',
  146. ),
  147. 'common_name' => array(
  148. 'label' => 'Organism',
  149. 'alter' => array(
  150. 'alter_text' => 0,
  151. 'text' => '',
  152. 'make_link' => 0,
  153. 'path' => '',
  154. 'link_class' => '',
  155. 'alt' => '',
  156. 'prefix' => '',
  157. 'suffix' => '',
  158. 'target' => '',
  159. 'help' => '',
  160. 'trim' => 0,
  161. 'max_length' => '',
  162. 'word_boundary' => 1,
  163. 'ellipsis' => 1,
  164. 'html' => 0,
  165. 'strip_tags' => 0,
  166. ),
  167. 'empty' => '',
  168. 'hide_empty' => 0,
  169. 'empty_zero' => 0,
  170. 'link_to_node' => 1,
  171. 'exclude' => 0,
  172. 'id' => 'common_name',
  173. 'table' => 'organism',
  174. 'field' => 'common_name',
  175. 'relationship' => 'none',
  176. ),
  177. 'name_3' => array(
  178. 'label' => 'Type',
  179. 'alter' => array(
  180. 'alter_text' => 0,
  181. 'text' => '',
  182. 'make_link' => 0,
  183. 'path' => '',
  184. 'link_class' => '',
  185. 'alt' => '',
  186. 'prefix' => '',
  187. 'suffix' => '',
  188. 'target' => '',
  189. 'help' => '',
  190. 'trim' => 0,
  191. 'max_length' => '',
  192. 'word_boundary' => 1,
  193. 'ellipsis' => 1,
  194. 'html' => 0,
  195. 'strip_tags' => 0,
  196. ),
  197. 'empty' => '',
  198. 'hide_empty' => 0,
  199. 'empty_zero' => 0,
  200. 'exclude' => 0,
  201. 'id' => 'name_3',
  202. 'table' => 'cvterm',
  203. 'field' => 'name',
  204. 'relationship' => 'none',
  205. ),
  206. 'accession_link' => array(
  207. 'label' => 'External Reference',
  208. 'alter' => array(
  209. 'alter_text' => 0,
  210. 'text' => '',
  211. 'make_link' => 0,
  212. 'path' => '',
  213. 'link_class' => '',
  214. 'alt' => '',
  215. 'prefix' => '',
  216. 'suffix' => '',
  217. 'target' => '',
  218. 'help' => '',
  219. 'trim' => 0,
  220. 'max_length' => '',
  221. 'word_boundary' => 1,
  222. 'ellipsis' => 1,
  223. 'html' => 0,
  224. 'strip_tags' => 0,
  225. ),
  226. 'empty' => '',
  227. 'hide_empty' => 0,
  228. 'empty_zero' => 0,
  229. 'exclude' => 0,
  230. 'id' => 'accession_link',
  231. 'table' => 'dbxref',
  232. 'field' => 'accession_link',
  233. 'relationship' => 'none',
  234. ),
  235. 'name_1' => array(
  236. 'label' => 'Library',
  237. 'alter' => array(
  238. 'alter_text' => 0,
  239. 'text' => '',
  240. 'make_link' => 0,
  241. 'path' => '',
  242. 'link_class' => '',
  243. 'alt' => '',
  244. 'prefix' => '',
  245. 'suffix' => '',
  246. 'target' => '',
  247. 'help' => '',
  248. 'trim' => 0,
  249. 'max_length' => '',
  250. 'word_boundary' => 1,
  251. 'ellipsis' => 1,
  252. 'html' => 0,
  253. 'strip_tags' => 0,
  254. ),
  255. 'empty' => '',
  256. 'hide_empty' => 0,
  257. 'empty_zero' => 0,
  258. 'link_to_node' => 1,
  259. 'exclude' => 0,
  260. 'id' => 'name_1',
  261. 'table' => 'library',
  262. 'field' => 'name',
  263. 'relationship' => 'none',
  264. ),
  265. 'name_2' => array(
  266. 'label' => 'Analysis',
  267. 'alter' => array(
  268. 'alter_text' => 0,
  269. 'text' => '',
  270. 'make_link' => 0,
  271. 'path' => '',
  272. 'link_class' => '',
  273. 'alt' => '',
  274. 'prefix' => '',
  275. 'suffix' => '',
  276. 'target' => '',
  277. 'help' => '',
  278. 'trim' => 0,
  279. 'max_length' => '',
  280. 'word_boundary' => 1,
  281. 'ellipsis' => 1,
  282. 'html' => 0,
  283. 'strip_tags' => 0,
  284. ),
  285. 'empty' => '',
  286. 'hide_empty' => 0,
  287. 'empty_zero' => 0,
  288. 'link_to_node' => 1,
  289. 'exclude' => 0,
  290. 'id' => 'name_2',
  291. 'table' => 'analysis',
  292. 'field' => 'name',
  293. 'relationship' => 'none',
  294. ),
  295. ));
  296. $handler->override_option('filters', array(
  297. 'common_name' => array(
  298. 'operator' => '=',
  299. 'value' => '<select organism>',
  300. 'group' => '0',
  301. 'exposed' => TRUE,
  302. 'expose' => array(
  303. 'use_operator' => 0,
  304. 'operator' => 'common_name_op',
  305. 'identifier' => 'organism',
  306. 'label' => 'Organism',
  307. 'optional' => 1,
  308. 'remember' => 0,
  309. ),
  310. 'case' => 1,
  311. 'id' => 'common_name',
  312. 'table' => 'organism',
  313. 'field' => 'common_name',
  314. 'relationship' => 'none',
  315. ),
  316. 'name' => array(
  317. 'operator' => 'contains',
  318. 'value' => '',
  319. 'group' => '0',
  320. 'exposed' => TRUE,
  321. 'expose' => array(
  322. 'use_operator' => 0,
  323. 'operator' => 'name_op',
  324. 'identifier' => 'name',
  325. 'label' => 'Name Contains',
  326. 'optional' => 1,
  327. 'remember' => 0,
  328. ),
  329. 'case' => 0,
  330. 'id' => 'name',
  331. 'table' => 'feature',
  332. 'field' => 'name',
  333. 'relationship' => 'none',
  334. ),
  335. 'name_1' => array(
  336. 'operator' => 'contains',
  337. 'value' => '',
  338. 'group' => '0',
  339. 'exposed' => TRUE,
  340. 'expose' => array(
  341. 'use_operator' => 0,
  342. 'operator' => 'name_1_op',
  343. 'identifier' => 'library',
  344. 'label' => 'Library Name Contains',
  345. 'optional' => 1,
  346. 'remember' => 0,
  347. ),
  348. 'case' => 0,
  349. 'id' => 'name_1',
  350. 'table' => 'library',
  351. 'field' => 'name',
  352. 'relationship' => 'none',
  353. ),
  354. 'name_2' => array(
  355. 'operator' => 'contains',
  356. 'value' => '',
  357. 'group' => '0',
  358. 'exposed' => TRUE,
  359. 'expose' => array(
  360. 'use_operator' => 0,
  361. 'operator' => 'name_2_op',
  362. 'identifier' => 'analysis',
  363. 'label' => 'Analysis Name Contains',
  364. 'optional' => 1,
  365. 'remember' => 0,
  366. ),
  367. 'case' => 0,
  368. 'id' => 'name_2',
  369. 'table' => 'analysis',
  370. 'field' => 'name',
  371. 'relationship' => 'none',
  372. ),
  373. ));
  374. $handler->override_option('access', array(
  375. 'type' => 'perm',
  376. 'perm' => 'access chado_feature content',
  377. ));
  378. $handler->override_option('cache', array(
  379. 'type' => 'none',
  380. ));
  381. $handler->override_option('title', 'Sequence Features');
  382. $handler->override_option('empty', 'There are no features matching that criteria. Please select a different organism above.');
  383. $handler->override_option('empty_format', '1');
  384. $handler->override_option('items_per_page', 50);
  385. $handler->override_option('style_plugin', 'table');
  386. $handler = $view->new_display('page', 'Page', 'page_1');
  387. $handler->override_option('path', 'features');
  388. $handler->override_option('menu', array(
  389. 'type' => 'normal',
  390. 'title' => 'Sequence Features',
  391. 'description' => '',
  392. 'weight' => '0',
  393. 'name' => 'primary-links',
  394. ));
  395. $handler->override_option('tab_options', array(
  396. 'type' => 'none',
  397. 'title' => '',
  398. 'description' => '',
  399. 'weight' => 0,
  400. 'name' => 'navigation',
  401. ));
  402. $views[$view->name] = $view;
  403. return $views;
  404. }