draggableviews.views.inc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * @file
  4. * Views hooks implementations.
  5. */
  6. /**
  7. * Implements hook_views_data_alter().
  8. */
  9. function draggableviews_views_data_alter(&$data) {
  10. $data['draggableviews_structure']['weight'] = array(
  11. 'title' => t('Weight'),
  12. 'help' => t('Sort entities by the draggableviews weight table field.'),
  13. 'group' => t('Draggableviews'),
  14. 'sort' => array(
  15. 'handler' => 'draggableviews_handler_sort',
  16. ),
  17. );
  18. foreach (entity_get_info() as $entity_type => $info) {
  19. if (isset($info['base table']) && isset($data[$info['base table']]['table'])) {
  20. $data[$info['base table']]['draggableviews'] = array(
  21. 'title' => $data[$info['base table']]['table']['group'],
  22. 'group' => t('Draggableviews'),
  23. 'help' => t('Provide a draggable functionality.'),
  24. 'real field' => $info['entity keys']['id'],
  25. 'field' => array(
  26. 'handler' => 'draggableviews_handler_field_draggable',
  27. 'click sortable' => FALSE,
  28. ),
  29. );
  30. // Explain to every entity how to join with draggableviews structure table.
  31. $data['draggableviews_structure']['table']['join'][$info['base table']] = array(
  32. 'handler' => 'draggableviews_join_handler',
  33. 'left_table' => $info['base table'], // Because this is a direct link it could be left out.
  34. 'left_field' => $info['entity keys']['id'],
  35. 'field' => 'entity_id',
  36. );
  37. }
  38. }
  39. }