chado_library.views.inc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Purpose: this function returns the portion of the data array
  4. * which describes the chado_library drupal table, it's fields and any joins between it and other tables
  5. * @see tripal_library_views_data() --in tripal_library.views.inc
  6. *
  7. * The main need for description of this table to views is to join chado data with drupal nodes
  8. *
  9. * @ingroup tripal_library_views
  10. */
  11. function retrieve_chado_library_views_data () {
  12. global $db_url;
  13. $data = array();
  14. // if the chado database is not local to the drupal database
  15. // then we need to set the database name. This should always
  16. // be 'chado'.
  17. if(is_array($db_url) and array_key_exists('chado',$db_url)){
  18. // return empty data array b/c if chado is external then no join to the nodetable can be made
  19. return $data;
  20. }
  21. // Basic table definition
  22. $data['chado_library']['table'] = array(
  23. 'field' => 'nid',
  24. );
  25. // Note: No joins need to be made from $data['library']['table']
  26. // Join the chado library table to library
  27. $data['chado_library']['table']['join']['library'] = array(
  28. 'left_field' => 'library_id',
  29. 'field' => 'library_id',
  30. );
  31. // Join the node table to chado library
  32. $data['node']['table']['join']['chado_library'] = array(
  33. 'left_field' => 'nid',
  34. 'field' => 'nid',
  35. );
  36. // Join the node table to library
  37. $data['node']['table']['join']['library'] = array(
  38. 'left_table' => 'chado_library',
  39. 'left_field' => 'nid',
  40. 'field' => 'nid',
  41. );
  42. return $data;
  43. }