chado_views_handler_relationship_to_node.inc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Relationship handler that links a chado table to it's nodes by creating 2 joins.
  4. *
  5. * NOTE: This handler assumes if you are linking TABLEA to it's nodes that there is a
  6. * table named chado_TABLEA in the drupal schema with at least the following two fields:
  7. * nid and TABLEA_id.
  8. *
  9. * Definition items:
  10. * - base: The new base table this relationship will be adding. This does not
  11. * have to be a declared base table, but if there are no tables that
  12. * utilize this base table, it won't be very effective.
  13. * - base field: The field to use in the relationship; if left out this will be
  14. * assumed to be the primary field.
  15. * - label: The default label to provide for this relationship, which is
  16. * shown in parentheses next to any field/sort/filter/argument that uses
  17. * the relationship.
  18. */
  19. class chado_views_handler_relationship_to_node extends views_handler_relationship {
  20. function query() {
  21. $this->ensure_my_table();
  22. // First add base => chado_base join
  23. $def = array();
  24. $def['left_table'] = 'chado_' . $this->table;
  25. $def['left_field'] = $this->field;
  26. $def['table'] = $this->table;
  27. $def['field'] = $this->field;
  28. //$def['handler'] = 'views_handler_join_chado_aggregator';
  29. $def['pre-aggregated'] = TRUE;
  30. $def['table_aggregated'] = 'CURRENT';
  31. dpm($def, 'definition in to node relationship handler');
  32. $join = new views_join();
  33. $join->definition = $def;
  34. $join->construct();
  35. $join->adjusted = TRUE;
  36. $this->alias = $this->query->add_relationship('stock_chado_stock', $join, $def['left_table']);
  37. dpm($this->query, 'query');
  38. }
  39. }