chado_analysis.views.inc 3.0 KB

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