tripal_natural_diversity.views.inc 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * @file
  4. * This file contains the basic functions for views integration of
  5. * chado/tripal_natural_diversity 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. * Purpose: Describe chado/tripal tables & fields to views
  14. *
  15. * @return: a data array which follows the structure outlined in the
  16. * views2 documentation for this hook. Essentially, it's an array of table
  17. * definitions keyed by chado/tripal table name. Each table definition
  18. * includes basic details about the table, fields in that table and
  19. * relationships between that table and others (joins)
  20. */
  21. function tripal_natural_diversity_views_data() {
  22. $data = array();
  23. if (module_exists('tripal_views')) {
  24. $tables = array(
  25. 'nd_experiment',
  26. 'nd_geolocation',
  27. 'nd_protocol',
  28. 'nd_reagent'
  29. );
  30. foreach ($tables as $tablename) {
  31. if (!tripal_views_is_integrated($tablename, 9)) {
  32. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE);
  33. tripal_views_integration_add_entry($table_integration_array);
  34. }
  35. }
  36. $tables = array(
  37. 'nd_experiment_contact',
  38. 'nd_experiment_dbxref',
  39. 'nd_experiment_genotype',
  40. 'nd_experiment_phenotype',
  41. 'nd_experiment_project',
  42. 'nd_experiment_protocol',
  43. 'nd_experiment_pub',
  44. 'nd_experiment_stock',
  45. 'nd_experiment_stock_dbxref',
  46. 'nd_experiment_stockprop',
  47. 'nd_experimentprop',
  48. 'nd_geolocationprop',
  49. 'nd_protocol_reagent',
  50. 'nd_protocolprop',
  51. 'nd_reagent_relationship',
  52. 'nd_reagentprop'
  53. );
  54. foreach ($tables as $tablename) {
  55. if (!tripal_views_is_integrated($tablename, 9)) {
  56. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE);
  57. tripal_views_integration_add_entry($table_integration_array);
  58. }
  59. }
  60. }
  61. return $data;
  62. }
  63. /*************************************************************************
  64. * Implements hook_views_handlers()
  65. * Purpose: Register all custom handlers with views
  66. * where a handler describes either "the type of field",
  67. * "how a field should be filtered", "how a field should be sorted"
  68. *
  69. * @return: An array of handler definitions
  70. */
  71. function tripal_natural_diversity_views_handlers() {
  72. return array(
  73. 'info' => array(
  74. 'path' => drupal_get_path('module', 'tripal_natural_diversity') . '/views/handlers',
  75. ),
  76. 'handlers' => array(
  77. 'views_handler_field_chado_relationship_all' => array(
  78. 'parent' => 'views_handler_field_prerender_list',
  79. ),
  80. 'views_handler_field_chado_relationship_by_type' => array(
  81. 'parent' => 'views_handler_field_prerender_list',
  82. ),
  83. ),
  84. );
  85. }