nd_reagent.views.inc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * @file
  4. * This file defines the data array for a given chado table. This array
  5. * is merged into a larger array containing definitions of all tables associated
  6. * with this module in:
  7. * @see tripal_natural_diversity.views.inc --in tripal_natural_diversity_views_data()
  8. *
  9. * Documentation on views integration can be found at
  10. * http://views2.logrus.com/doc/html/index.html.
  11. */
  12. /*************************************************************************
  13. * Purpose: this function returns the portion of the data array
  14. * which describes the nd_reagent table, it's fields and any joins between it and other tables
  15. * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  16. *
  17. * Table: nd_reagent
  18. * @code
  19. CREATE TABLE nd_reagent (
  20. nd_reagent_id serial PRIMARY KEY NOT NULL,
  21. name character varying(80) NOT NULL,
  22. type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
  23. feature_id integer
  24. );
  25. * @endcode
  26. */
  27. function retrieve_nd_reagent_views_data() {
  28. global $db_url;
  29. $data = array();
  30. // if the chado database is not local to the drupal database
  31. // then we need to set the database name. This should always
  32. // be 'chado'.
  33. if(is_array($db_url) and array_key_exists('chado',$db_url)){
  34. $database = 'chado';
  35. }
  36. //Basic table definition-----------------------------------
  37. $data['nd_reagent']['table']['group'] = t('Chado ND Reagent');
  38. $data['nd_reagent']['table']['base'] = array(
  39. 'field' => 'nd_reagent_id',
  40. 'title' => t('Chado Natural Diversity Reagent'),
  41. 'help' => t('Reagents used in Natural Diversity Experiments.'),
  42. );
  43. if($database){
  44. $data['nd_reagent']['table']['base']['database'] = $database;
  45. }
  46. //Table Field Definitions----------------------------------
  47. //Field: nd_reagent_id (primary key)
  48. $data['nd_reagent']['nd_reagent_id'] = array(
  49. 'title' => t('ND Reagent Primary Key'),
  50. 'help' => t('A unique index for every ND Reagent.'),
  51. 'field' => array(
  52. 'handler' => 'views_handler_field_numeric',
  53. 'click sortable' => TRUE,
  54. ),
  55. 'sort' => array(
  56. 'handler' => 'views_handler_sort',
  57. ),
  58. 'filter' => array(
  59. 'handler' => 'views_handler_filter_numeric',
  60. ),
  61. );
  62. //Field: name (varchar 255)
  63. $data['nd_reagent']['name'] = array(
  64. 'title' => t('Name'),
  65. 'help' => t('The name of the reagent.'),
  66. 'field' => array(
  67. 'handler' => 'views_handler_field',
  68. 'click sortable' => TRUE,
  69. ),
  70. 'sort' => array(
  71. 'handler' => 'views_handler_sort',
  72. ),
  73. 'filter' => array(
  74. 'handler' => 'views_handler_filter_string',
  75. ),
  76. 'argument' => array(
  77. 'handler' => 'views_handler_argument_string',
  78. ),
  79. );
  80. //Field: type_id (foreign key)
  81. // Join described in cvterm.views.inc
  82. //Field: feature_id (foreign key)
  83. // Join described in feature.views.inc
  84. //Calculated Field: stock relationships (ALL)
  85. // uses a custom field handler which pulls results from the view
  86. // actual query performed in chado_stock_views_views_pre_render (&$view) -file:tripal_stock.views.inc
  87. $data['nd_reagent']['all_relationships'] = array(
  88. 'title' => t('All Reagent Relationships'),
  89. 'help' => t('Relationships including the current reagent.'),
  90. 'field' => array(
  91. 'title' => t('All Relationships'),
  92. 'help' => t('Display all relationships including the current reagent.'),
  93. 'handler' => 'views_handler_field_chado_relationship_all',
  94. ),
  95. );
  96. //Calculated Field: stock relationships
  97. // uses a custom field handler which pulls results from the view
  98. // actual query performed in chado_stock_views_views_pre_render (&$view) -file:tripal_stock.views.inc
  99. $data['nd_reagent']['relationships'] = array(
  100. 'title' => t('ND Reagent Relationships'),
  101. 'help' => t('Relationships including the current reagent.'),
  102. 'field' => array(
  103. 'title' => t('Relationships'),
  104. 'help' => t('Display a given type of relationships including the current reagent.'),
  105. 'handler' => 'views_handler_field_chado_relationship_by_type',
  106. ),
  107. );
  108. return $data;
  109. }