chado_stock.views.inc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Purpose: this function returns the portion of the data array which describes the chado_stock
  4. * drupal table, it's fields and any joins between it and other tables
  5. *
  6. * The main need for description of this table to views is to join chado data with drupal nodes
  7. *
  8. * @see tripal_stock_views_data() --in tripal_stock.views.inc
  9. *
  10. * @ingroup tripal_stock
  11. */
  12. function retrieve_chado_stock_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_stock']['table'] = array(
  24. 'field' => 'nid',
  25. );
  26. // Note: No joins need to be made from $data['stock']['table']
  27. // Join the chado stock table to stock
  28. $data['chado_stock']['table']['join']['stock'] = array(
  29. 'left_field' => 'stock_id',
  30. 'field' => 'stock_id',
  31. );
  32. // Join the node table to chado stock
  33. $data['node']['table']['join']['chado_stock'] = array(
  34. 'left_field' => 'nid',
  35. 'field' => 'nid',
  36. );
  37. // Join the node table to stock
  38. $data['node']['table']['join']['stock'] = array(
  39. 'left_table' => 'chado_stock',
  40. 'left_field' => 'nid',
  41. 'field' => 'nid',
  42. );
  43. return $data;
  44. }