tripal_feature.views.inc 10 KB

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