/[drupal]/contributions/modules/views/modules/system.views.inc
ViewVC logotype

Contents of /contributions/modules/views/modules/system.views.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Wed Sep 3 19:21:29 2008 UTC (14 months, 3 weeks ago) by merlinofchaos
Branch: MAIN
CVS Tags: DRUPAL-6--2-0-RC5, DRUPAL-6--2-0-RC4, DRUPAL-6--2-0-RC3, DRUPAL-6--2-0-RC2, DRUPAL-6--2-7, DRUPAL-6--2-6, DRUPAL-6--2-5, DRUPAL-6--2-4, DRUPAL-6--2-3, DRUPAL-6--2-2, DRUPAL-6--2-1, DRUPAL-6--2-0, DRUPAL-6--3-0-ALPHA1, HEAD
Branch point for: DRUPAL-6--2, DRUPAL-6--3, DRUPAL-7--3
Changes since 1.6: +23 -84 lines
File MIME type: text/x-php
Major re-organization of handlers. PLEASE NOTE: This drastically affected the Views module API and until modules are updated to match, they will stop working. Efforts have been made to ensure that this won't cause your site to crash, but that's partly up to the individual module as well.
1 <?php
2 // $Id: system.views.inc,v 1.6 2008/06/26 00:58:29 merlinofchaos Exp $
3 /**
4 * @file
5 *
6 * Provide views data and handlers for system tables that are not represented by
7 * their own module.
8 */
9
10 /**
11 * @defgroup views_system_module system.module handlers
12 *
13 * @{
14 */
15
16 /**
17 * Implementation of hook_views_data()
18 */
19 function system_views_data() {
20 $data = array();
21
22 // ----------------------------------------------------------------------
23 // files table
24
25 $data['files']['table']['group'] = t('File');
26
27 // Advertise this table as a possible base table
28 $data['files']['table']['base'] = array(
29 'field' => 'fid',
30 'title' => t('File'),
31 'help' => t("Files maintained by Drupal and various modules."),
32 );
33
34 // The files table does not inherently join to the node table,
35 // but may things (such as upload.module) can add relationships
36 // that allow file fields to be used.
37
38 // For other base tables, explain how we join
39 $data['files']['table']['join'] = array(
40 'users' => array(
41 // direct join to the users table via 'uid' field.
42 'left_field' => 'uid',
43 'field' => 'uid',
44 ),
45 );
46
47 // fid
48 $data['files']['fid'] = array(
49 'title' => t('File ID'),
50 'help' => t('The ID of the file.'),
51 'field' => array(
52 'handler' => 'views_handler_field_file',
53 'click sortable' => TRUE,
54 ),
55 'argument' => array(
56 'handler' => 'views_handler_argument_file_fid',
57 'name field' => 'filename', // the field to display in the summary.
58 ),
59 'filter' => array(
60 'handler' => 'views_handler_filter_numeric',
61 ),
62 'sort' => array(
63 'handler' => 'views_handler_sort',
64 ),
65 );
66
67 // filename
68 $data['files']['filename'] = array(
69 'title' => t('Name'),
70 'help' => t('The name of the file.'),
71 'field' => array(
72 'handler' => 'views_handler_field_file',
73 'click sortable' => TRUE,
74 ),
75 'sort' => array(
76 'handler' => 'views_handler_sort',
77 ),
78 'filter' => array(
79 'handler' => 'views_handler_filter_string',
80 ),
81 'argument' => array(
82 'handler' => 'views_handler_argument_string',
83 ),
84 );
85
86 // filepath
87 $data['files']['filepath'] = array(
88 'title' => t('Path'),
89 'help' => t('The path of the file.'),
90 'field' => array(
91 'handler' => 'views_handler_field_file',
92 'click sortable' => TRUE,
93 ),
94 'sort' => array(
95 'handler' => 'views_handler_sort',
96 ),
97 'filter' => array(
98 'handler' => 'views_handler_filter_string',
99 ),
100 'argument' => array(
101 'handler' => 'views_handler_argument_string',
102 ),
103 );
104
105 // filemime
106 $data['files']['filemime'] = array(
107 'title' => t('Mime type'),
108 'help' => t('The mime type of the file.'),
109 'field' => array(
110 'handler' => 'views_handler_field_file',
111 'click sortable' => TRUE,
112 ),
113 'sort' => array(
114 'handler' => 'views_handler_sort',
115 ),
116 'filter' => array(
117 'handler' => 'views_handler_filter_string',
118 ),
119 'argument' => array(
120 'handler' => 'views_handler_argument_string',
121 ),
122 );
123
124 // filesize
125 $data['files']['filesize'] = array(
126 'title' => t('Size'),
127 'help' => t('The size of the file.'),
128 'field' => array(
129 'handler' => 'views_handler_field_file_size',
130 'click sortable' => TRUE,
131 ),
132 'sort' => array(
133 'handler' => 'views_handler_sort',
134 ),
135 'filter' => array(
136 'handler' => 'views_handler_filter_numeric',
137 ),
138 );
139
140 // status
141 $data['files']['status'] = array(
142 'title' => t('Status'),
143 'help' => t('The status of the file.'),
144 'field' => array(
145 'handler' => 'views_handler_field_file_status',
146 'click sortable' => TRUE,
147 ),
148 'sort' => array(
149 'handler' => 'views_handler_sort',
150 ),
151 'filter' => array(
152 'handler' => 'views_handler_filter_file_status',
153 ),
154 );
155
156 // timestamp field
157 $data['files']['timestamp'] = array(
158 'title' => t('Upload date'),
159 'help' => t('The date the file was uploaded.'),
160 'field' => array(
161 'handler' => 'views_handler_field_date',
162 'click sortable' => TRUE,
163 ),
164 'sort' => array(
165 'handler' => 'views_handler_sort_date',
166 ),
167 'filter' => array(
168 'handler' => 'views_handler_filter_date',
169 ),
170 );
171
172
173 return $data;
174 }
175
176 /**
177 * Implementation of hook_views_handlers() to register all of the basic handlers
178 * views uses.
179 */
180 function system_views_handlers() {
181 return array(
182 'info' => array(
183 'path' => drupal_get_path('module', 'views') . '/modules/system',
184 ),
185 'handlers' => array(
186 'views_handler_field_file' => array(
187 'parent' => 'views_handler_field',
188 ),
189 'views_handler_field_file_status' => array(
190 'parent' => 'views_handler_field',
191 ),
192 'views_handler_filter_file_status' => array(
193 'parent' => 'views_handler_filter_in_operator',
194 ),
195 'views_handler_argument_file_fid' => array(
196 'parent' => 'views_handler_argument',
197 ),
198 ),
199 );
200 }
201
202 function _views_file_status($choice = NULL) {
203 $status = array(
204 FILE_STATUS_TEMPORARY => t('Temporary'),
205 FILE_STATUS_PERMANENT => t('Permanent'),
206 );
207
208 if (isset($choice)) {
209 return isset($status[$choice]) ? $status[$choice] : t('Unknown');
210 }
211
212 return $status;
213 }
214
215
216 /**
217 * @}
218 */

  ViewVC Help
Powered by ViewVC 1.1.2