chado_analysis.views.inc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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
  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. return $data;
  44. }