tripal_feature.views.inc.orig 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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. function tripal_feature_views_data() {
  30. $data = array();
  31. <<<<<<< HEAD
  32. if (module_exists('tripal_views')) {
  33. $tables = array(
  34. 'feature',
  35. );
  36. foreach ($tables as $tablename) {
  37. if (!tripal_views_is_integrated($tablename, 10)) {
  38. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,TRUE);
  39. tripal_views_integration_add_entry($table_integration_array);
  40. }
  41. }
  42. $tables = array(
  43. 'feature_cvterm',
  44. 'feature_cvterm_dbxref',
  45. 'feature_cvterm_pub',
  46. 'feature_cvtermprop',
  47. 'feature_dbxref',
  48. 'feature_pub',
  49. 'feature_pubprop',
  50. 'feature_relationship',
  51. 'feature_relationship_pub',
  52. 'feature_relationshipprop',
  53. 'feature_relationshipprop_pub',
  54. 'feature_synonym',
  55. 'featureloc',
  56. 'featureloc_pub',
  57. 'featureprop',
  58. 'featureprop_pub',
  59. 'featuremap',
  60. 'featuremap_pub',
  61. 'featurepos',
  62. 'featurerange'
  63. );
  64. foreach ($tables as $tablename) {
  65. if (!tripal_views_is_integrated($tablename, 10)) {
  66. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,FALSE);
  67. tripal_views_integration_add_entry($table_integration_array);
  68. }
  69. }
  70. }
  71. =======
  72. $data = array_merge($data, retrieve_feature_views_data());
  73. $data = array_merge($data, retrieve_chado_feature_views_data());
  74. $data = array_merge($data, retrieve_feature_misc_tables_views_data());
  75. >>>>>>> 6.x-0.4-dev
  76. return $data;
  77. }
  78. /**
  79. * Implements hook_views_handlers()
  80. *
  81. * Purpose: Register all custom handlers with views
  82. * where a handler describes either "the type of field",
  83. * "how a field should be filtered", "how a field should be sorted"
  84. *
  85. * @return: An array of handler definitions
  86. *
  87. * @ingroup tripal_feature_views
  88. */
  89. function tripal_feature_views_handlers() {
  90. return array(
  91. 'info' => array(
  92. 'path' => drupal_get_path('module', 'tripal_feature') . '/views_handlers',
  93. ),
  94. 'handlers' => array(
  95. 'views_handler_field_residues' => array(
  96. 'parent' => 'views_handler_field',
  97. ),
  98. ),
  99. );
  100. }
  101. /**
  102. * Implementation of hook_views_data_alter().
  103. */
  104. function tripal_feature_views_data_alter(&$data) {
  105. if ( !(is_array($db_url) and array_key_exists('chado', $db_url)) ) {
  106. // Add featuer relationship to node
  107. $data['node']['feature_chado_nid'] = array(
  108. 'group' => 'Feature',
  109. 'title' => 'Feature Node',
  110. 'help' => 'Links Chado Feature Fields/Data to the Nodes in the current View.',
  111. 'real field' => 'nid',
  112. 'relationship' => array(
  113. 'handler' => 'views_handler_relationship',
  114. 'title' => t('Node => Chado'),
  115. 'label' => t('Node => Chado'),
  116. 'real field' => 'nid',
  117. 'base' => 'chado_feature',
  118. 'base field' => 'nid'
  119. ),
  120. );
  121. }
  122. }
  123. /**
  124. *
  125. * @ingroup tripal_feature_views
  126. */
  127. function tripal_feature_views_default_views() {
  128. $views = array();
  129. // Main default view
  130. // List all cvterms based on cv
  131. $view = new view;
  132. $view->name = 'all_features';
  133. $view->description = 'A listing of all Sequence FEatures';
  134. $view->tag = 'chado';
  135. $view->view_php = '';
  136. $view->base_table = 'feature';
  137. $view->is_cacheable = FALSE;
  138. $view->api_version = 2;
  139. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  140. $handler = $view->new_display('default', 'Defaults', 'default');
  141. $handler->override_option('fields', array(
  142. 'uniquename' => array(
  143. 'label' => 'Unique Name',
  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. 'link_to_node' => 1,
  166. 'exclude' => 0,
  167. 'id' => 'uniquename',
  168. 'table' => 'feature',
  169. 'field' => 'uniquename',
  170. 'relationship' => 'none',
  171. ),
  172. 'name' => array(
  173. 'label' => 'Name',
  174. 'alter' => array(
  175. 'alter_text' => 0,
  176. 'text' => '',
  177. 'make_link' => 0,
  178. 'path' => '',
  179. 'link_class' => '',
  180. 'alt' => '',
  181. 'prefix' => '',
  182. 'suffix' => '',
  183. 'target' => '',
  184. 'help' => '',
  185. 'trim' => 0,
  186. 'max_length' => '',
  187. 'word_boundary' => 1,
  188. 'ellipsis' => 1,
  189. 'html' => 0,
  190. 'strip_tags' => 0,
  191. ),
  192. 'empty' => '',
  193. 'hide_empty' => 0,
  194. 'empty_zero' => 0,
  195. 'link_to_node' => 1,
  196. 'exclude' => 0,
  197. 'id' => 'name',
  198. 'table' => 'feature',
  199. 'field' => 'name',
  200. 'relationship' => 'none',
  201. ),
  202. 'common_name' => array(
  203. 'label' => 'Organism',
  204. 'alter' => array(
  205. 'alter_text' => 0,
  206. 'text' => '',
  207. 'make_link' => 0,
  208. 'path' => '',
  209. 'link_class' => '',
  210. 'alt' => '',
  211. 'prefix' => '',
  212. 'suffix' => '',
  213. 'target' => '',
  214. 'help' => '',
  215. 'trim' => 0,
  216. 'max_length' => '',
  217. 'word_boundary' => 1,
  218. 'ellipsis' => 1,
  219. 'html' => 0,
  220. 'strip_tags' => 0,
  221. ),
  222. 'empty' => '',
  223. 'hide_empty' => 0,
  224. 'empty_zero' => 0,
  225. 'link_to_node' => 1,
  226. 'exclude' => 0,
  227. 'id' => 'common_name',
  228. 'table' => 'organism',
  229. 'field' => 'common_name',
  230. 'relationship' => 'none',
  231. ),
  232. 'name_3' => array(
  233. 'label' => 'Type',
  234. 'alter' => array(
  235. 'alter_text' => 0,
  236. 'text' => '',
  237. 'make_link' => 0,
  238. 'path' => '',
  239. 'link_class' => '',
  240. 'alt' => '',
  241. 'prefix' => '',
  242. 'suffix' => '',
  243. 'target' => '',
  244. 'help' => '',
  245. 'trim' => 0,
  246. 'max_length' => '',
  247. 'word_boundary' => 1,
  248. 'ellipsis' => 1,
  249. 'html' => 0,
  250. 'strip_tags' => 0,
  251. ),
  252. 'empty' => '',
  253. 'hide_empty' => 0,
  254. 'empty_zero' => 0,
  255. 'exclude' => 0,
  256. 'id' => 'name_3',
  257. 'table' => 'cvterm',
  258. 'field' => 'name',
  259. 'relationship' => 'none',
  260. ),
  261. 'accession_link' => array(
  262. 'label' => 'External Reference',
  263. 'alter' => array(
  264. 'alter_text' => 0,
  265. 'text' => '',
  266. 'make_link' => 0,
  267. 'path' => '',
  268. 'link_class' => '',
  269. 'alt' => '',
  270. 'prefix' => '',
  271. 'suffix' => '',
  272. 'target' => '',
  273. 'help' => '',
  274. 'trim' => 0,
  275. 'max_length' => '',
  276. 'word_boundary' => 1,
  277. 'ellipsis' => 1,
  278. 'html' => 0,
  279. 'strip_tags' => 0,
  280. ),
  281. 'empty' => '',
  282. 'hide_empty' => 0,
  283. 'empty_zero' => 0,
  284. 'exclude' => 0,
  285. 'id' => 'accession_link',
  286. 'table' => 'dbxref',
  287. 'field' => 'accession_link',
  288. 'relationship' => 'none',
  289. ),
  290. 'name_1' => array(
  291. 'label' => 'Library',
  292. 'alter' => array(
  293. 'alter_text' => 0,
  294. 'text' => '',
  295. 'make_link' => 0,
  296. 'path' => '',
  297. 'link_class' => '',
  298. 'alt' => '',
  299. 'prefix' => '',
  300. 'suffix' => '',
  301. 'target' => '',
  302. 'help' => '',
  303. 'trim' => 0,
  304. 'max_length' => '',
  305. 'word_boundary' => 1,
  306. 'ellipsis' => 1,
  307. 'html' => 0,
  308. 'strip_tags' => 0,
  309. ),
  310. 'empty' => '',
  311. 'hide_empty' => 0,
  312. 'empty_zero' => 0,
  313. 'link_to_node' => 1,
  314. 'exclude' => 0,
  315. 'id' => 'name_1',
  316. 'table' => 'library',
  317. 'field' => 'name',
  318. 'relationship' => 'none',
  319. ),
  320. 'name_2' => array(
  321. 'label' => 'Analysis',
  322. 'alter' => array(
  323. 'alter_text' => 0,
  324. 'text' => '',
  325. 'make_link' => 0,
  326. 'path' => '',
  327. 'link_class' => '',
  328. 'alt' => '',
  329. 'prefix' => '',
  330. 'suffix' => '',
  331. 'target' => '',
  332. 'help' => '',
  333. 'trim' => 0,
  334. 'max_length' => '',
  335. 'word_boundary' => 1,
  336. 'ellipsis' => 1,
  337. 'html' => 0,
  338. 'strip_tags' => 0,
  339. ),
  340. 'empty' => '',
  341. 'hide_empty' => 0,
  342. 'empty_zero' => 0,
  343. 'link_to_node' => 1,
  344. 'exclude' => 0,
  345. 'id' => 'name_2',
  346. 'table' => 'analysis',
  347. 'field' => 'name',
  348. 'relationship' => 'none',
  349. ),
  350. ));
  351. $handler->override_option('filters', array(
  352. 'common_name' => array(
  353. 'operator' => '=',
  354. 'value' => '<select organism>',
  355. 'group' => '0',
  356. 'exposed' => TRUE,
  357. 'expose' => array(
  358. 'use_operator' => 0,
  359. 'operator' => 'common_name_op',
  360. 'identifier' => 'organism',
  361. 'label' => 'Organism',
  362. 'optional' => 1,
  363. 'remember' => 0,
  364. ),
  365. 'case' => 1,
  366. 'id' => 'common_name',
  367. 'table' => 'organism',
  368. 'field' => 'common_name',
  369. 'relationship' => 'none',
  370. ),
  371. 'name' => array(
  372. 'operator' => 'contains',
  373. 'value' => '',
  374. 'group' => '0',
  375. 'exposed' => TRUE,
  376. 'expose' => array(
  377. 'use_operator' => 0,
  378. 'operator' => 'name_op',
  379. 'identifier' => 'name',
  380. 'label' => 'Name Contains',
  381. 'optional' => 1,
  382. 'remember' => 0,
  383. ),
  384. 'case' => 0,
  385. 'id' => 'name',
  386. 'table' => 'feature',
  387. 'field' => 'name',
  388. 'relationship' => 'none',
  389. ),
  390. 'name_1' => array(
  391. 'operator' => 'contains',
  392. 'value' => '',
  393. 'group' => '0',
  394. 'exposed' => TRUE,
  395. 'expose' => array(
  396. 'use_operator' => 0,
  397. 'operator' => 'name_1_op',
  398. 'identifier' => 'library',
  399. 'label' => 'Library Name Contains',
  400. 'optional' => 1,
  401. 'remember' => 0,
  402. ),
  403. 'case' => 0,
  404. 'id' => 'name_1',
  405. 'table' => 'library',
  406. 'field' => 'name',
  407. 'relationship' => 'none',
  408. ),
  409. 'name_2' => array(
  410. 'operator' => 'contains',
  411. 'value' => '',
  412. 'group' => '0',
  413. 'exposed' => TRUE,
  414. 'expose' => array(
  415. 'use_operator' => 0,
  416. 'operator' => 'name_2_op',
  417. 'identifier' => 'analysis',
  418. 'label' => 'Analysis Name Contains',
  419. 'optional' => 1,
  420. 'remember' => 0,
  421. ),
  422. 'case' => 0,
  423. 'id' => 'name_2',
  424. 'table' => 'analysis',
  425. 'field' => 'name',
  426. 'relationship' => 'none',
  427. ),
  428. ));
  429. $handler->override_option('access', array(
  430. 'type' => 'perm',
  431. 'perm' => 'access chado_feature content',
  432. ));
  433. $handler->override_option('cache', array(
  434. 'type' => 'none',
  435. ));
  436. $handler->override_option('title', 'Sequence Features');
  437. $handler->override_option('empty', 'There are no features matching that criteria. Please select a different organism above.');
  438. $handler->override_option('empty_format', '1');
  439. $handler->override_option('items_per_page', 50);
  440. $handler->override_option('style_plugin', 'table');
  441. $handler = $view->new_display('page', 'Page', 'page_1');
  442. $handler->override_option('path', 'features');
  443. $handler->override_option('menu', array(
  444. 'type' => 'normal',
  445. 'title' => 'Sequence Features',
  446. 'description' => '',
  447. 'weight' => '0',
  448. 'name' => 'primary-links',
  449. ));
  450. $handler->override_option('tab_options', array(
  451. 'type' => 'none',
  452. 'title' => '',
  453. 'description' => '',
  454. 'weight' => 0,
  455. 'name' => 'navigation',
  456. ));
  457. $views[$view->name] = $view;
  458. return $views;
  459. }