chado_organism.views.inc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Purpose: this function returns the portion of the data array
  4. * which describes the chado_organism drupal table, it's fields and any joins between it and other tables
  5. * @see tripal_organism_views_data() --in tripal_organism.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. function retrieve_chado_organism_views_data () {
  11. global $db_url;
  12. $data = array();
  13. // if the chado database is not local to the drupal database
  14. // then we need to set the database name. This should always
  15. // be 'chado'.
  16. if(is_array($db_url) and array_key_exists('chado',$db_url)){
  17. // return empty data array b/c if chado is external then no join to the nodetable can be made
  18. return $data;
  19. }
  20. // Basic table definition
  21. $data['chado_organism']['table'] = array(
  22. 'field' => 'nid',
  23. );
  24. // Note: No joins need to be made from $data['organism']['table']
  25. // Join the chado organism table to organism
  26. $data['chado_organism']['table']['join']['organism'] = array(
  27. 'left_field' => 'organism_id',
  28. 'field' => 'organism_id',
  29. );
  30. // Join the node table to chado organism
  31. $data['node']['table']['join']['chado_organism'] = array(
  32. 'left_field' => 'nid',
  33. 'field' => 'nid',
  34. );
  35. // Join the node table to organism
  36. $data['node']['table']['join']['organism'] = array(
  37. 'left_table' => 'chado_organism',
  38. 'left_field' => 'nid',
  39. 'field' => 'nid',
  40. );
  41. return $data;
  42. }