chado_analysis.views.inc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * Purpose: this function returns the portion of the data array
  4. * which describes the chado_analysis drupal table, it's fields and any joins between it and other tables
  5. * @see tripal_analysis_views_data() --in tripal_analysis.views.inc
  6. *
  7. * The main need for description of this table to views is to join chado data with drupal nodes
  8. *
  9. *
  10. * @ingroup tripal_analysis_views
  11. */
  12. function retrieve_chado_analysis_views_data () {
  13. global $db_url;
  14. $data = array();
  15. // if the chado database is not local to the drupal database
  16. // then we need to set the database name. This should always
  17. // be 'chado'.
  18. if(is_array($db_url) and array_key_exists('chado',$db_url)){
  19. // return empty data array b/c if chado is external then no join to the nodetable can be made
  20. return $data;
  21. }
  22. // Basic table definition
  23. $data['chado_analysis']['table'] = array(
  24. 'field' => 'nid',
  25. 'group' => 'Chado Analysis'
  26. );
  27. $data['chado_analysis']['nid'] = array(
  28. 'title' => t('Analysis Node ID'),
  29. 'help' => t('The node ID for this analysis'),
  30. 'field' => array(
  31. 'handler' => 'views_handler_field_numeric',
  32. 'click sortable' => TRUE,
  33. ),
  34. 'filter' => array(
  35. 'handler' => 'views_handler_filter_numeric',
  36. ),
  37. 'sort' => array(
  38. 'handler' => 'views_handler_sort',
  39. ),
  40. );
  41. // Note: No joins need to be made from $data['analysis']['table']
  42. // Join the chado analysis table to analysis
  43. $data['chado_analysis']['table']['join']['analysis'] = array(
  44. 'left_field' => 'analysis_id',
  45. 'field' => 'analysis_id',
  46. );
  47. // Join the node table to chado analysis
  48. $data['node']['table']['join']['chado_analysis'] = array(
  49. 'left_field' => 'nid',
  50. 'field' => 'nid',
  51. );
  52. // Join the node table to analysis
  53. $data['node']['table']['join']['analysis'] = array(
  54. 'left_table' => 'chado_analysis',
  55. 'left_field' => 'nid',
  56. 'field' => 'nid',
  57. );
  58. // Add relationship between chado_analysis and analysis
  59. $data['chado_analysis']['analysis_nid'] = array(
  60. 'group' => 'Analysis',
  61. 'title' => 'Analysis Node',
  62. 'help' => 'Links Chado Analysis Fields/Data to the Nodes in the current View.',
  63. 'real field' => 'analysis_id',
  64. 'relationship' => array(
  65. 'handler' => 'views_handler_relationship',
  66. 'title' => t('Chado => Analysis'),
  67. 'label' => t('Chado => Analysis'),
  68. 'real field' => 'analysis_id',
  69. 'base' => 'analysis',
  70. 'base field' => 'analysis_id'
  71. ),
  72. );
  73. // Add node relationship to analysis
  74. $data['chado_analysis']['analysis_chado_nid'] = array(
  75. 'group' => 'Analysis',
  76. 'title' => 'Analysis Node',
  77. 'help' => 'Links Chado Analysis Fields/Data to the Nodes in the current View.',
  78. 'real field' => 'nid',
  79. 'relationship' => array(
  80. 'handler' => 'views_handler_relationship',
  81. 'title' => t('Chado => Node'),
  82. 'label' => t('Chado => Node'),
  83. 'real field' => 'nid',
  84. 'base' => 'node',
  85. 'base field' => 'nid'
  86. ),
  87. );
  88. return $data;
  89. }