1 |
85ad3d82
|
Assos Assos
|
<?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 |
ca0757b9
|
Assos Assos
|
|
31 |
|
|
// File schema type.
|
32 |
|
|
$data['file_managed']['schema_type'] = array(
|
33 |
|
|
'title' => t('Schema type'),
|
34 |
|
|
'help' => t('Filter files by schema, such as public or private.'),
|
35 |
|
|
'filter' => array(
|
36 |
|
|
'handler' => 'views_handler_filter_schema_type',
|
37 |
|
|
),
|
38 |
|
|
);
|
39 |
|
|
|
40 |
85ad3d82
|
Assos Assos
|
// Rendered file.
|
41 |
|
|
$data['file_managed']['rendered'] = array(
|
42 |
|
|
'title' => t('Rendered'),
|
43 |
|
|
'help' => t('Display the file in a specific view mode.'),
|
44 |
|
|
'field' => array(
|
45 |
|
|
'handler' => 'views_handler_field_file_rendered',
|
46 |
|
|
'click sortable' => TRUE,
|
47 |
|
|
'real field' => 'fid',
|
48 |
|
|
'additional fields' => array(
|
49 |
|
|
'fid',
|
50 |
|
|
),
|
51 |
|
|
),
|
52 |
|
|
);
|
53 |
|
|
|
54 |
|
|
// View link.
|
55 |
|
|
$data['file_managed']['link'] = array(
|
56 |
|
|
'title' => t('Link'),
|
57 |
|
|
'help' => t('Provide a simple link to the file entity.'),
|
58 |
|
|
'field' => array(
|
59 |
|
|
'handler' => 'views_handler_field_file_link',
|
60 |
|
|
'real field' => 'fid',
|
61 |
|
|
'additional fields' => array(
|
62 |
|
|
'fid',
|
63 |
|
|
),
|
64 |
|
|
),
|
65 |
|
|
);
|
66 |
|
|
|
67 |
|
|
// Edit link.
|
68 |
|
|
$data['file_managed']['edit'] = array(
|
69 |
|
|
'title' => t('Edit link'),
|
70 |
|
|
'help' => t('Provide a simple link to edit the file entity.'),
|
71 |
|
|
'field' => array(
|
72 |
|
|
'handler' => 'views_handler_field_file_link_edit',
|
73 |
|
|
'real field' => 'fid',
|
74 |
|
|
'additional fields' => array(
|
75 |
|
|
'fid',
|
76 |
|
|
),
|
77 |
|
|
),
|
78 |
|
|
);
|
79 |
|
|
|
80 |
|
|
// Delete link.
|
81 |
|
|
$data['file_managed']['delete'] = array(
|
82 |
|
|
'title' => t('Delete link'),
|
83 |
|
|
'help' => t('Provide a simple link to delete the file entity.'),
|
84 |
|
|
'field' => array(
|
85 |
|
|
'handler' => 'views_handler_field_file_link_delete',
|
86 |
|
|
'real field' => 'fid',
|
87 |
|
|
'additional fields' => array(
|
88 |
|
|
'fid',
|
89 |
|
|
),
|
90 |
|
|
),
|
91 |
|
|
);
|
92 |
|
|
|
93 |
|
|
// Download link.
|
94 |
|
|
$data['file_managed']['download'] = array(
|
95 |
|
|
'title' => t('Download link'),
|
96 |
|
|
'help' => t('Provide a simple link to download the file entity.'),
|
97 |
|
|
'field' => array(
|
98 |
|
|
'handler' => 'views_handler_field_file_link_download',
|
99 |
|
|
'real field' => 'fid',
|
100 |
|
|
'additional fields' => array(
|
101 |
|
|
'fid',
|
102 |
|
|
),
|
103 |
|
|
),
|
104 |
|
|
);
|
105 |
|
|
|
106 |
|
|
// Usage link.
|
107 |
|
|
$data['file_managed']['usage'] = array(
|
108 |
|
|
'title' => t('Usage link'),
|
109 |
|
|
'help' => t('Provide a simple link to view the usage of the file entity.'),
|
110 |
|
|
'field' => array(
|
111 |
|
|
'handler' => 'views_handler_field_file_link_usage',
|
112 |
ca0757b9
|
Assos Assos
|
'click sortable' => TRUE,
|
113 |
85ad3d82
|
Assos Assos
|
'real field' => 'fid',
|
114 |
|
|
'additional fields' => array(
|
115 |
|
|
'fid',
|
116 |
|
|
),
|
117 |
|
|
),
|
118 |
ca0757b9
|
Assos Assos
|
'sort' => array(
|
119 |
|
|
'handler' => 'views_handler_sort',
|
120 |
|
|
),
|
121 |
85ad3d82
|
Assos Assos
|
);
|
122 |
|
|
|
123 |
|
|
return $data;
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
/**
|
127 |
|
|
* Implements hook_views_data_alter().
|
128 |
|
|
*/
|
129 |
|
|
function file_entity_views_data_alter(&$data) {
|
130 |
|
|
// Add access tag for all queries against file_managed.
|
131 |
|
|
$data['file_managed']['table']['base']['access query tag'] = 'file_access';
|
132 |
|
|
// Override the filename field handler.
|
133 |
|
|
$data['file_managed']['filename']['field']['handler'] = 'views_handler_field_file_filename';
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
/**
|
137 |
|
|
* Implements hook_views_plugins().
|
138 |
|
|
*/
|
139 |
|
|
function file_entity_views_plugins() {
|
140 |
|
|
return array(
|
141 |
|
|
'module' => 'views', // This just tells our themes are elsewhere.
|
142 |
|
|
'row' => array(
|
143 |
|
|
'file' => array(
|
144 |
|
|
'title' => t('File'),
|
145 |
|
|
'help' => t('Display the file with standard file view.'),
|
146 |
|
|
'handler' => 'views_plugin_row_file_view',
|
147 |
|
|
'base' => array('file_managed'), // only works with 'file' as base.
|
148 |
|
|
'uses options' => TRUE,
|
149 |
|
|
'type' => 'normal',
|
150 |
|
|
'help topic' => 'style-file',
|
151 |
|
|
),
|
152 |
|
|
'file_rss' => array(
|
153 |
|
|
'title' => t('File'),
|
154 |
|
|
'help' => t('Display the file with standard file view.'),
|
155 |
|
|
'handler' => 'views_plugin_row_file_rss',
|
156 |
|
|
'theme' => 'views_view_row_rss',
|
157 |
|
|
'base' => array('file_managed'), // only works with 'file' as base.
|
158 |
|
|
'uses options' => TRUE,
|
159 |
|
|
'type' => 'feed',
|
160 |
|
|
'help topic' => 'style-file-rss',
|
161 |
|
|
),
|
162 |
|
|
),
|
163 |
|
|
);
|
164 |
|
|
}
|
165 |
1f142f4f
|
Florent Torregrosa
|
|
166 |
|
|
/**
|
167 |
|
|
* Implements hook_views_query_substitutions().
|
168 |
|
|
*/
|
169 |
|
|
function file_entity_views_query_substitutions() {
|
170 |
|
|
return array(
|
171 |
|
|
'***ADMINISTER_FILES***' => intval(user_access('administer files')),
|
172 |
|
|
'***BYPASS_FILE_ACCESS***' => intval(user_access('bypass file access')),
|
173 |
|
|
);
|
174 |
|
|
} |