Projet

Général

Profil

Paste
Télécharger (4,01 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / file_entity / file_entity.views.inc @ a2baadd1

1
<?php
2

    
3
/**
4
 * @file
5
 * Views integration for the file_entity module.
6
 */
7

    
8
/**
9
 * Implements hook_views_data().
10
 */
11
function file_entity_views_data() {
12
  // File type.
13
  $data['file_managed']['type'] = array(
14
    'title' => t('Type'),
15
    'help' => t('The type of the file (for example, "audio", "image", "video", etc).'),
16
    'field' => array(
17
      'handler' => 'views_handler_field_file_type',
18
      'click sortable' => TRUE,
19
    ),
20
    'sort' => array(
21
      'handler' => 'views_handler_sort',
22
    ),
23
    'filter' => array(
24
      'handler' => 'views_handler_filter_file_type',
25
    ),
26
    'argument' => array(
27
      'handler' => 'views_handler_argument_file_type',
28
    ),
29
  );
30
  // Rendered file.
31
  $data['file_managed']['rendered'] = array(
32
    'title' => t('Rendered'),
33
    'help' => t('Display the file in a specific view mode.'),
34
    'field' => array(
35
      'handler' => 'views_handler_field_file_rendered',
36
      'click sortable' => TRUE,
37
      'real field' => 'fid',
38
      'additional fields' => array(
39
        'fid',
40
      ),
41
    ),
42
  );
43

    
44
  // View link.
45
  $data['file_managed']['link'] = array(
46
    'title' => t('Link'),
47
    'help' => t('Provide a simple link to the file entity.'),
48
    'field' => array(
49
      'handler' => 'views_handler_field_file_link',
50
      'real field' => 'fid',
51
      'additional fields' => array(
52
        'fid',
53
      ),
54
    ),
55
  );
56

    
57
  // Edit link.
58
  $data['file_managed']['edit'] = array(
59
    'title' => t('Edit link'),
60
    'help' => t('Provide a simple link to edit the file entity.'),
61
    'field' => array(
62
      'handler' => 'views_handler_field_file_link_edit',
63
      'real field' => 'fid',
64
      'additional fields' => array(
65
        'fid',
66
      ),
67
    ),
68
  );
69

    
70
  // Delete link.
71
  $data['file_managed']['delete'] = array(
72
    'title' => t('Delete link'),
73
    'help' => t('Provide a simple link to delete the file entity.'),
74
    'field' => array(
75
      'handler' => 'views_handler_field_file_link_delete',
76
      'real field' => 'fid',
77
      'additional fields' => array(
78
        'fid',
79
      ),
80
    ),
81
  );
82

    
83
  // Download link.
84
  $data['file_managed']['download'] = array(
85
    'title' => t('Download link'),
86
    'help' => t('Provide a simple link to download the file entity.'),
87
    'field' => array(
88
      'handler' => 'views_handler_field_file_link_download',
89
      'real field' => 'fid',
90
      'additional fields' => array(
91
        'fid',
92
      ),
93
    ),
94
  );
95

    
96
  // Usage link.
97
  $data['file_managed']['usage'] = array(
98
    'title' => t('Usage link'),
99
    'help' => t('Provide a simple link to view the usage of the file entity.'),
100
    'field' => array(
101
      'handler' => 'views_handler_field_file_link_usage',
102
      'real field' => 'fid',
103
      'additional fields' => array(
104
        'fid',
105
      ),
106
    ),
107
  );
108

    
109
  return $data;
110
}
111

    
112
/**
113
 * Implements hook_views_data_alter().
114
 */
115
function file_entity_views_data_alter(&$data) {
116
  // Add access tag for all queries against file_managed.
117
  $data['file_managed']['table']['base']['access query tag'] = 'file_access';
118
  // Override the filename field handler.
119
  $data['file_managed']['filename']['field']['handler'] = 'views_handler_field_file_filename';
120
}
121

    
122
/**
123
 * Implements hook_views_plugins().
124
 */
125
function file_entity_views_plugins() {
126
  return array(
127
    'module' => 'views', // This just tells our themes are elsewhere.
128
    'row' => array(
129
      'file' => array(
130
        'title' => t('File'),
131
        'help' => t('Display the file with standard file view.'),
132
        'handler' => 'views_plugin_row_file_view',
133
        'base' => array('file_managed'), // only works with 'file' as base.
134
        'uses options' => TRUE,
135
        'type' => 'normal',
136
        'help topic' => 'style-file',
137
      ),
138
      'file_rss' => array(
139
        'title' => t('File'),
140
        'help' => t('Display the file with standard file view.'),
141
        'handler' => 'views_plugin_row_file_rss',
142
        'theme' => 'views_view_row_rss',
143
        'base' => array('file_managed'), // only works with 'file' as base.
144
        'uses options' => TRUE,
145
        'type' => 'feed',
146
        'help topic' => 'style-file-rss',
147
      ),
148
    ),
149
  );
150
}