chado_analysis.views.inc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. );
  26. // Note: No joins need to be made from $data['analysis']['table']
  27. // Join the chado analysis table to analysis
  28. $data['chado_analysis']['table']['join']['analysis'] = array(
  29. 'left_field' => 'analysis_id',
  30. 'field' => 'analysis_id',
  31. );
  32. // Join the node table to chado analysis
  33. $data['node']['table']['join']['chado_analysis'] = array(
  34. 'left_field' => 'nid',
  35. 'field' => 'nid',
  36. );
  37. // Join the node table to analysis
  38. $data['node']['table']['join']['analysis'] = array(
  39. 'left_table' => 'chado_analysis',
  40. 'left_field' => 'nid',
  41. 'field' => 'nid',
  42. );
  43. // Add relationship between chado_analysis and analysis
  44. $data['chado_analysis']['analysis_nid'] = array(
  45. 'group' => 'Analysis',
  46. 'title' => 'Analysis Node',
  47. 'help' => 'Links Chado Analysis Fields/Data to the Nodes in the current View.',
  48. 'real field' => 'analysis_id',
  49. 'relationship' => array(
  50. 'handler' => 'views_handler_relationship',
  51. 'title' => t('Chado => Analysis'),
  52. 'label' => t('Chado => Analysis'),
  53. 'real field' => 'analysis_id',
  54. 'base' => 'analysis',
  55. 'base field' => 'analysis_id'
  56. ),
  57. );
  58. // Add node relationship to analysis
  59. $data['chado_analysis']['analysis_chado_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' => 'nid',
  64. 'relationship' => array(
  65. 'handler' => 'views_handler_relationship',
  66. 'title' => t('Chado => Node'),
  67. 'label' => t('Chado => Node'),
  68. 'real field' => 'nid',
  69. 'base' => 'node',
  70. 'base field' => 'nid'
  71. ),
  72. );
  73. return $data;
  74. }