tripal_natural_diversity.views.inc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. //require_once('views/nd_experiment.views.inc');
  22. //require_once('views/nd_experimentprop.views.inc');
  23. //require_once('views/nd_geolocation.views.inc');
  24. //require_once('views/nd_geolocationprop.views.inc');
  25. //require_once('views/nd_reagent.views.inc');
  26. //require_once('views/nd_reagentprop.views.inc');
  27. function tripal_natural_diversity_views_data() {
  28. $data = array();
  29. //EXPERIMENT
  30. //$data = array_merge($data, retrieve_nd_experiment_views_data());
  31. //$data = array_merge($data, retrieve_nd_experimentprop_views_data());
  32. // GEOLOCATION
  33. //$data = array_merge($data, retrieve_nd_geolocation_views_data());
  34. //$data = array_merge($data, retrieve_nd_geolocationprop_views_data());
  35. // REAGENTS
  36. //$data = array_merge($data, retrieve_nd_reagent_views_data());
  37. //$data = array_merge($data, retrieve_nd_reagentprop_views_data());
  38. if (module_exists('tripal_views')) {
  39. $tables = array(
  40. 'nd_experiment',
  41. 'nd_geolocation',
  42. 'nd_protocol',
  43. 'nd_reagent'
  44. );
  45. foreach ($tables as $tablename) {
  46. if (!tripal_views_is_integrated($tablename, 10)) {
  47. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,TRUE);
  48. tripal_views_integration_add_entry($table_integration_array);
  49. }
  50. }
  51. $tables = array(
  52. 'nd_experiment_contact',
  53. 'nd_experiment_dbxref',
  54. 'nd_experiment_genotype',
  55. 'nd_experiment_phenotype',
  56. 'nd_experiment_project',
  57. 'nd_experiment_protocol',
  58. 'nd_experiment_pub',
  59. 'nd_experiment_stock',
  60. 'nd_experiment_stock_dbxref',
  61. 'nd_experiment_stockprop',
  62. 'nd_experimentprop',
  63. 'nd_geolocationprop',
  64. 'nd_protocol_reagent',
  65. 'nd_protocolprop',
  66. 'nd_reagent_relationship',
  67. 'nd_reagentprop'
  68. );
  69. foreach ($tables as $tablename) {
  70. if (!tripal_views_is_integrated($tablename, 10)) {
  71. $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,FALSE);
  72. tripal_views_integration_add_entry($table_integration_array);
  73. }
  74. }
  75. }
  76. return $data;
  77. }
  78. /*************************************************************************
  79. * Implements hook_views_handlers()
  80. * Purpose: Register all custom handlers with views
  81. * where a handler describes either "the type of field",
  82. * "how a field should be filtered", "how a field should be sorted"
  83. *
  84. * @return: An array of handler definitions
  85. */
  86. function tripal_natural_diversity_views_handlers() {
  87. return array(
  88. 'info' => array(
  89. 'path' => drupal_get_path('module', 'tripal_natural_diversity') . '/views/handlers',
  90. ),
  91. 'handlers' => array(
  92. 'views_handler_field_chado_relationship_all' => array(
  93. 'parent' => 'views_handler_field_prerender_list',
  94. ),
  95. 'views_handler_field_chado_relationship_by_type' => array(
  96. 'parent' => 'views_handler_field_prerender_list',
  97. ),
  98. ),
  99. );
  100. }