image.views.inc

  1. cis7 sites/all/modules/ulmus/views/modules/image.views.inc
  2. cle7 sites/all/modules/ulmus/views/modules/image.views.inc
  3. ecd7 sites/all/modules/ulmus/views/modules/image.views.inc
  4. elmsmedia7 sites/all/modules/ulmus/views/modules/image.views.inc
  5. harmony7 sites/all/modules/ulmus/views/modules/image.views.inc
  6. icor7 sites/all/modules/ulmus/views/modules/image.views.inc
  7. meedjum_blog7 sites/all/modules/ulmus/views/modules/image.views.inc
  8. mooc7 sites/all/modules/ulmus/views/modules/image.views.inc

Provide views data and handlers for image.module.

Functions

Namesort descending Description
image_field_views_data Implements hook_field_views_data().
image_field_views_data_views_data_alter Implements hook_field_views_data_views_data_alter().

File

sites/all/modules/ulmus/views/modules/image.views.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Provide views data and handlers for image.module.
  5. *
  6. * @ingroup views_module_handlers
  7. */
  8. /**
  9. * Implements hook_field_views_data().
  10. *
  11. * Views integration for image fields. Adds an image relationship to the default
  12. * field data.
  13. *
  14. * @see field_views_field_default_views_data()
  15. */
  16. function image_field_views_data($field) {
  17. $data = field_views_field_default_views_data($field);
  18. foreach ($data as $table_name => $table_data) {
  19. // Add the relationship only on the fid field.
  20. $data[$table_name][$field['field_name'] . '_fid']['relationship'] = array(
  21. 'handler' => 'views_handler_relationship',
  22. 'base' => 'file_managed',
  23. 'base field' => 'fid',
  24. 'label' => t('image from !field_name', array('!field_name' => $field['field_name'])),
  25. );
  26. }
  27. return $data;
  28. }
  29. /**
  30. * Implements hook_field_views_data_views_data_alter().
  31. *
  32. * Views integration to provide reverse relationships on image fields.
  33. */
  34. function image_field_views_data_views_data_alter(&$data, $field) {
  35. foreach ($field['bundles'] as $entity_type => $bundles) {
  36. $entity_info = entity_get_info($entity_type);
  37. $pseudo_field_name = 'reverse_' . $field['field_name'] . '_' . $entity_type;
  38. list($label, $all_labels) = field_views_field_label($field['field_name']);
  39. $entity = $entity_info['label'];
  40. if ($entity == t('Node')) {
  41. $entity = t('Content');
  42. }
  43. $data['file_managed'][$pseudo_field_name]['relationship'] = array(
  44. 'title' => t('@entity using @field', array('@entity' => $entity, '@field' => $label)),
  45. 'help' => t('Relate each @entity with a @field set to the image.', array('@entity' => $entity, '@field' => $label)),
  46. 'handler' => 'views_handler_relationship_entity_reverse',
  47. 'field_name' => $field['field_name'],
  48. 'field table' => _field_sql_storage_tablename($field),
  49. 'field field' => $field['field_name'] . '_fid',
  50. 'base' => $entity_info['base table'],
  51. 'base field' => $entity_info['entity keys']['id'],
  52. 'label' => t('!field_name', array('!field_name' => $field['field_name'])),
  53. 'join_extra' => array(
  54. 0 => array(
  55. 'field' => 'entity_type',
  56. 'value' => $entity_type,
  57. ),
  58. 1 => array(
  59. 'field' => 'deleted',
  60. 'value' => 0,
  61. 'numeric' => TRUE,
  62. ),
  63. ),
  64. );
  65. }
  66. }

Related topics