Projet

Général

Profil

Paste
Télécharger (19,5 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / system.views.inc @ 7547bb19

1
<?php
2

    
3
/**
4
 * @file
5
 * Provide views data and handlers for system.module.
6
 *
7
 * @ingroup views_module_handlers
8
 */
9

    
10
/**
11
 * Implements hook_views_data().
12
 */
13
function system_views_data() {
14
  $data = array();
15

    
16
  // ----------------------------------------------------------------------
17
  // file_managed table
18

    
19
  $data['files']['moved to'] = 'file_managed';
20
  $data['file_managed']['table']['group']  = t('File');
21

    
22
  // Advertise this table as a possible base table
23
  $data['file_managed']['table']['base'] = array(
24
    'field' => 'fid',
25
    'title' => t('File'),
26
    'help' => t("Files maintained by Drupal and various modules."),
27
    'defaults' => array(
28
      'field' => 'filename'
29
    ),
30
  );
31
  $data['file_managed']['table']['entity type'] = 'file';
32

    
33
  // fid
34
  $data['file_managed']['fid'] = array(
35
    'title' => t('File ID'),
36
    'help' => t('The ID of the file.'),
37
    'field' => array(
38
      'handler' => 'views_handler_field_file',
39
      'click sortable' => TRUE,
40
    ),
41
    'argument' => array(
42
      'handler' => 'views_handler_argument_file_fid',
43
      'name field' => 'filename', // the field to display in the summary.
44
      'numeric' => TRUE,
45
    ),
46
    'filter' => array(
47
      'handler' => 'views_handler_filter_numeric',
48
    ),
49
    'sort' => array(
50
      'handler' => 'views_handler_sort',
51
    ),
52
  );
53

    
54
  // filename
55
  $data['file_managed']['filename'] = array(
56
    'title' => t('Name'),
57
    'help' => t('The name of the file.'),
58
    'field' => array(
59
      'handler' => 'views_handler_field_file',
60
      'click sortable' => TRUE,
61
     ),
62
    'sort' => array(
63
      'handler' => 'views_handler_sort',
64
    ),
65
    'filter' => array(
66
      'handler' => 'views_handler_filter_string',
67
    ),
68
    'argument' => array(
69
      'handler' => 'views_handler_argument_string',
70
    ),
71
  );
72

    
73
  // uri
74
  $data['file_managed']['uri'] = array(
75
    'title' => t('Path'),
76
    'help' => t('The path of the file.'),
77
    'field' => array(
78
      'handler' => 'views_handler_field_file_uri',
79
      'click sortable' => TRUE,
80
     ),
81
    'sort' => array(
82
      'handler' => 'views_handler_sort',
83
    ),
84
    'filter' => array(
85
      'handler' => 'views_handler_filter_string',
86
    ),
87
    'argument' => array(
88
      'handler' => 'views_handler_argument_string',
89
    ),
90
  );
91

    
92
  // filemime
93
  $data['file_managed']['filemime'] = array(
94
    'title' => t('Mime type'),
95
    'help' => t('The mime type of the file.'),
96
    'field' => array(
97
      'handler' => 'views_handler_field_file_filemime',
98
      'click sortable' => TRUE,
99
     ),
100
    'sort' => array(
101
      'handler' => 'views_handler_sort',
102
    ),
103
    'filter' => array(
104
      'handler' => 'views_handler_filter_string',
105
    ),
106
    'argument' => array(
107
      'handler' => 'views_handler_argument_string',
108
    ),
109
  );
110

    
111
  // extension
112
  $data['file_managed']['extension'] = array(
113
    'title' => t('Extension'),
114
    'help' => t('The extension of the file.'),
115
    'real field' => 'filename',
116
    'field' => array(
117
      'handler' => 'views_handler_field_file_extension',
118
      'click sortable' => FALSE,
119
     ),
120
  );
121

    
122
  // filesize
123
  $data['file_managed']['filesize'] = array(
124
    'title' => t('Size'),
125
    'help' => t('The size of the file.'),
126
    'field' => array(
127
      'handler' => 'views_handler_field_file_size',
128
      'click sortable' => TRUE,
129
     ),
130
    'sort' => array(
131
      'handler' => 'views_handler_sort',
132
    ),
133
    'filter' => array(
134
      'handler' => 'views_handler_filter_numeric',
135
    ),
136
  );
137

    
138
  // status
139
  $data['file_managed']['status'] = array(
140
    'title' => t('Status'),
141
    'help' => t('The status of the file.'),
142
    'field' => array(
143
      'handler' => 'views_handler_field_file_status',
144
      'click sortable' => TRUE,
145
     ),
146
    'sort' => array(
147
      'handler' => 'views_handler_sort',
148
    ),
149
    'filter' => array(
150
      'handler' => 'views_handler_filter_file_status',
151
    ),
152
  );
153

    
154
  // timestamp field
155
  $data['file_managed']['timestamp'] = array(
156
    'title' => t('Upload date'),
157
    'help' => t('The date the file was uploaded.'),
158
    'field' => array(
159
      'handler' => 'views_handler_field_date',
160
      'click sortable' => TRUE,
161
    ),
162
    'sort' => array(
163
      'handler' => 'views_handler_sort_date',
164
    ),
165
    'filter' => array(
166
      'handler' => 'views_handler_filter_date',
167
    ),
168
  );
169

    
170
  // uid
171
  $data['file_managed']['uid'] = array(
172
    'title' => t('User who uploaded'),
173
    'help' => t('The user that uploaded the file.'),
174
    'relationship' => array(
175
      'title' => t('User who uploaded'),
176
      'label' => t('User who uploaded'),
177
      'base' => 'users',
178
      'base field' => 'uid',
179
    ),
180
  );
181

    
182
  // ----------------------------------------------------------------------
183
  // file_usage table
184

    
185
  $data['file_usage']['table']['group']  = t('File Usage');
186

    
187
  // Provide field-type-things to several base tables; on the core files table ("file_managed") so
188
  // that we can create relationships from files to entities, and then on each core entity type base
189
  // table so that we can provide general relationships between entities and files.
190
  $data['file_usage']['table']['join'] = array(
191
    // Link ourself to the {file_managed} table so we can provide file->entity relationships.
192
    'file_managed' => array(
193
      'field' => 'fid',
194
      'left_field' => 'fid',
195
    ),
196
    // Link ourself to the {node} table so we can provide node->file relationships.
197
    'node' => array(
198
      'field' => 'id',
199
      'left_field' => 'nid',
200
      'extra' => array(array('field' => 'type', 'value' => 'node')),
201
    ),
202
    // Link ourself to the {users} table so we can provide user->file relationships.
203
    'users' => array(
204
      'field' => 'id',
205
      'left_field' => 'uid',
206
      'extra' => array(array('field' => 'type', 'value' => 'user')),
207
    ),
208
    // Link ourself to the {comment} table so we can provide comment->file relationships.
209
    'comment' => array(
210
      'field' => 'id',
211
      'left_field' => 'cid',
212
      'extra' => array(array('field' => 'type', 'value' => 'comment')),
213
    ),
214
    // Link ourself to the {taxonomy_term_data} table so we can provide taxonomy_term->file relationships.
215
    'taxonomy_term_data' => array(
216
      'field' => 'id',
217
      'left_field' => 'tid',
218
      'extra' => array(array('field' => 'type', 'value' => 'taxonomy_term')),
219
    ),
220
    // Link ourself to the {taxonomy_vocabulary} table so we can provide taxonomy_vocabulary->file relationships.
221
    'taxonomy_vocabulary' => array(
222
      'field' => 'id',
223
      'left_field' => 'vid',
224
      'extra' => array(array('field' => 'type', 'value' => 'taxonomy_vocabulary')),
225
    ),
226
  );
227

    
228
  // Provide a relationship between the files table and each entity type, and between each entity
229
  // type and the files table. Entity->file relationships are type-restricted in the joins
230
  // declared above, and file->entity relationships are type-restricted in the relationship
231
  // declarations below.
232

    
233
  // Relationships between files and nodes.
234
  $data['file_usage']['file_to_node'] = array(
235
    'title' => t('Content'),
236
    'help' => t('Content that is associated with this file, usually because this file is in a field on the content.'),
237
    // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
238
    'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
239
    'real field' => 'id',
240
    'relationship' => array(
241
      'title' => t('Content'),
242
      'label' => t('Content'),
243
      'base' => 'node',
244
      'base field' => 'nid',
245
      'relationship field' => 'id',
246
      'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'node')),
247
    ),
248
  );
249
  $data['file_usage']['node_to_file'] = array(
250
    'title' => t('File'),
251
    'help' => t('A file that is associated with this node, usually because it is in a field on the node.'),
252
    // Only provide this field/relationship/etc. when the 'node' base table is present.
253
    'skip base' => array('file_managed', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
254
    'real field' => 'fid',
255
    'relationship' => array(
256
      'title' => t('File'),
257
      'label' => t('File'),
258
      'base' => 'file_managed',
259
      'base field' => 'fid',
260
      'relationship field' => 'fid',
261
    ),
262
  );
263

    
264
  // Relationships between files and users.
265
  $data['file_usage']['file_to_user'] = array(
266
    'title' => t('User'),
267
    'help' => t('A user that is associated with this file, usually because this file is in a field on the user.'),
268
    // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
269
    'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
270
    'real field' => 'id',
271
    'relationship' => array(
272
      'title' => t('User'),
273
      'label' => t('User'),
274
      'base' => 'users',
275
      'base field' => 'uid',
276
      'relationship field' => 'id',
277
      'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'user')),
278
    ),
279
  );
280
  $data['file_usage']['user_to_file'] = array(
281
    'title' => t('File'),
282
    'help' => t('A file that is associated with this user, usually because it is in a field on the user.'),
283
    // Only provide this field/relationship/etc. when the 'users' base table is present.
284
    'skip base' => array('file_managed', 'node', 'node_revision', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
285
    'real field' => 'fid',
286
    'relationship' => array(
287
      'title' => t('File'),
288
      'label' => t('File'),
289
      'base' => 'file_managed',
290
      'base field' => 'fid',
291
      'relationship field' => 'fid',
292
    ),
293
  );
294

    
295
  // Relationships between files and comments.
296
  $data['file_usage']['file_to_comment'] = array(
297
    'title' => t('Comment'),
298
    'help' => t('A comment that is associated with this file, usually because this file is in a field on the comment.'),
299
    // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
300
    'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
301
    'real field' => 'id',
302
    'relationship' => array(
303
      'title' => t('Comment'),
304
      'label' => t('Comment'),
305
      'base' => 'comment',
306
      'base field' => 'cid',
307
      'relationship field' => 'id',
308
      'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'comment')),
309
    ),
310
  );
311
  $data['file_usage']['comment_to_file'] = array(
312
    'title' => t('File'),
313
    'help' => t('A file that is associated with this comment, usually because it is in a field on the comment.'),
314
    // Only provide this field/relationship/etc. when the 'comment' base table is present.
315
    'skip base' => array('file_managed', 'node', 'node_revision', 'users', 'taxonomy_term_data', 'taxonomy_vocabulary'),
316
    'real field' => 'fid',
317
    'relationship' => array(
318
      'title' => t('File'),
319
      'label' => t('File'),
320
      'base' => 'file_managed',
321
      'base field' => 'fid',
322
      'relationship field' => 'fid',
323
    ),
324
  );
325

    
326
  // Relationships between files and taxonomy_terms.
327
  $data['file_usage']['file_to_taxonomy_term'] = array(
328
    'title' => t('Taxonomy Term'),
329
    'help' => t('A taxonomy term that is associated with this file, usually because this file is in a field on the taxonomy term.'),
330
    // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
331
    'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
332
    'real field' => 'id',
333
    'relationship' => array(
334
      'title' => t('Taxonomy Term'),
335
      'label' => t('Taxonomy Term'),
336
      'base' => 'taxonomy_term_data',
337
      'base field' => 'tid',
338
      'relationship field' => 'id',
339
      'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'taxonomy_term')),
340
    ),
341
  );
342
  $data['file_usage']['taxonomy_term_to_file'] = array(
343
    'title' => t('File'),
344
    'help' => t('A file that is associated with this taxonomy term, usually because it is in a field on the taxonomy term.'),
345
    // Only provide this field/relationship/etc. when the 'taxonomy_term_data' base table is present.
346
    'skip base' => array('file_managed', 'node', 'node_revision', 'users', 'comment', 'taxonomy_vocabulary'),
347
    'real field' => 'fid',
348
    'relationship' => array(
349
      'title' => t('File'),
350
      'label' => t('File'),
351
      'base' => 'file_managed',
352
      'base field' => 'fid',
353
      'relationship field' => 'fid',
354
    ),
355
  );
356

    
357
  // Relationships between files and taxonomy_vocabulary items.
358
  $data['file_usage']['file_to_taxonomy_vocabulary'] = array(
359
    'title' => t('Taxonomy Vocabulary'),
360
    'help' => t('A taxonomy vocabulary that is associated with this file, usually because this file is in a field on the taxonomy vocabulary.'),
361
    // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
362
    'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
363
    'real field' => 'id',
364
    'relationship' => array(
365
      'title' => t('Taxonomy Vocabulary'),
366
      'label' => t('Taxonomy Vocabulary'),
367
      'base' => 'taxonomy_vocabulary',
368
      'base field' => 'vid',
369
      'relationship field' => 'id',
370
      'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'taxonomy_vocabulary')),
371
    ),
372
  );
373
  $data['file_usage']['taxonomy_vocabulary_to_file'] = array(
374
    'title' => t('File'),
375
    'help' => t('A file that is associated with this taxonomy vocabulary, usually because it is in a field on the taxonomy vocabulary.'),
376
    // Only provide this field/relationship/etc. when the 'taxonomy_vocabulary' base table is present.
377
    'skip base' => array('file_managed', 'node', 'node_revision', 'users', 'comment', 'taxonomy_term_data'),
378
    'real field' => 'fid',
379
    'relationship' => array(
380
      'title' => t('File'),
381
      'label' => t('File'),
382
      'base' => 'file_managed',
383
      'base field' => 'fid',
384
      'relationship field' => 'fid',
385
    ),
386
  );
387

    
388
  // Provide basic fields from the {file_usage} table to all of the base tables we've declared
389
  // joins to (because there is no 'skip base' property on these fields).
390
  $data['file_usage']['module'] = array(
391
    'title' => t('Module'),
392
    'help' => t('The module managing this file relationship.'),
393
    'field' => array(
394
      'handler' => 'views_handler_field',
395
      'click sortable' => TRUE,
396
     ),
397
    'filter' => array(
398
      'handler' => 'views_handler_filter_string',
399
    ),
400
    'argument' => array(
401
      'handler' => 'views_handler_argument_string',
402
    ),
403
    'sort' => array(
404
      'handler' => 'views_handler_sort',
405
    ),
406
  );
407
  $data['file_usage']['type'] = array(
408
    'title' => t('Entity type'),
409
    'help' => t('The type of entity that is related to the file.'),
410
    'field' => array(
411
      'handler' => 'views_handler_field',
412
      'click sortable' => TRUE,
413
     ),
414
    'filter' => array(
415
      'handler' => 'views_handler_filter_string',
416
    ),
417
    'argument' => array(
418
      'handler' => 'views_handler_argument_string',
419
    ),
420
    'sort' => array(
421
      'handler' => 'views_handler_sort',
422
    ),
423
  );
424
  $data['file_usage']['id'] = array(
425
    'title' => t('Entity ID'),
426
    'help' => t('The ID of the entity that is related to the file.'),
427
    'field' => array(
428
      'handler' => 'views_handler_field_numeric',
429
      'click sortable' => TRUE,
430
    ),
431
    'argument' => array(
432
      'handler' => 'views_handler_argument_numeric',
433
    ),
434
    'filter' => array(
435
      'handler' => 'views_handler_filter_numeric',
436
    ),
437
    'sort' => array(
438
      'handler' => 'views_handler_sort',
439
    ),
440
  );
441
  $data['file_usage']['count'] = array(
442
    'title' => t('Use count'),
443
    'help' => t('The number of times the file is used by this entity.'),
444
    'field' => array(
445
      'handler' => 'views_handler_field_numeric',
446
      'click sortable' => TRUE,
447
     ),
448
    'filter' => array(
449
      'handler' => 'views_handler_filter_numeric',
450
    ),
451
    'sort' => array(
452
      'handler' => 'views_handler_sort',
453
    ),
454
  );
455

    
456
  // ----------------------------------------------------------------------
457
  // system table
458
  $data['system']['table']['group']  = t('System');
459

    
460
  // Advertise this table as a possible base table
461
  $data['system']['table']['base'] = array(
462
    'field' => 'filename',
463
    'title' => t('Module/Theme/Theme engine'),
464
    'help' => t('Modules/Themes/Theme engines in your codebase.'),
465
  );
466

    
467
  // fields
468
  // - filename
469
  $data['system']['filename'] = array(
470
    'title' => t('Module/Theme/Theme engine filename'),
471
    'help' => t('The path of the primary file for this item, relative to the Drupal root; e.g. modules/node/node.module.'),
472
    'field' => array(
473
      'handler' => 'views_handler_field',
474
      'click sortable' => TRUE,
475
    ),
476
    'argument' => array(
477
      'handler' => 'views_handler_argument_string',
478
      'name field' => 'filename', // the field to display in the summary.
479
    ),
480
    'filter' => array(
481
      'handler' => 'views_handler_filter_string',
482
    ),
483
    'sort' => array(
484
      'handler' => 'views_handler_sort',
485
    ),
486
  );
487
  // - name
488
  $data['system']['name'] = array(
489
    'title' => t('Module/Theme/Theme engine name'),
490
    'help' => t('The name of the item; e.g. node.'),
491
    'field' => array(
492
      'handler' => 'views_handler_field',
493
      'click sortable' => TRUE,
494
    ),
495
    'argument' => array(
496
      'handler' => 'views_handler_argument_string',
497
      'name field' => 'name', // the field to display in the summary.
498
    ),
499
    'filter' => array(
500
      'handler' => 'views_handler_filter_string',
501
    ),
502
    'sort' => array(
503
      'handler' => 'views_handler_sort',
504
    ),
505
  );
506
  // - type
507
  $data['system']['type'] = array(
508
    'title' => t('Type'),
509
    'help' => t('The type of the item, either module, theme, or theme_engine.'),
510
    'field' => array(
511
      'handler' => 'views_handler_field',
512
      'click sortable' => TRUE,
513
    ),
514
    'argument' => array(
515
      'handler' => 'views_handler_argument_string',
516
      'name field' => 'type', // the field to display in the summary.
517
    ),
518
    'filter' => array(
519
      'handler' => 'views_handler_filter_system_type',
520
    ),
521
    'sort' => array(
522
      'handler' => 'views_handler_sort',
523
    ),
524
  );
525
  // - status
526
  $data['system']['status'] = array(
527
    'title' => t('Status'),
528
    'help' => t('Boolean indicating whether or not this item is enabled.'),
529
    'field' => array(
530
      'handler' => 'views_handler_field_boolean',
531
      'click sortable' => TRUE,
532
    ),
533
    'argument' => array(
534
      'handler' => 'views_handler_argument_numeric',
535
      'name field' => 'status', // the field to display in the summary.
536
    ),
537
    'filter' => array(
538
      'handler' => 'views_handler_filter_boolean_operator',
539
    ),
540
    'sort' => array(
541
      'handler' => 'views_handler_sort',
542
    ),
543
  );
544
  // - schema version
545
  $data['system']['schema_version'] = array(
546
    'title' => t('Schema version'),
547
    'help' => t("The module's database schema version number. -1 if the module is not installed (its tables do not exist); 0 or the largest N of the module's hook_update_N() function that has either been run or existed when the module was first installed."),
548
    'field' => array(
549
      'handler' => 'views_handler_field_numeric',
550
      'click sortable' => TRUE,
551
    ),
552
    'argument' => array(
553
      'handler' => 'views_handler_argument_numeric',
554
      'name field' => 'schema_version', // the field to display in the summary.
555
    ),
556
    'filter' => array(
557
      'handler' => 'views_handler_filter_numeric',
558
    ),
559
    'sort' => array(
560
      'handler' => 'views_handler_sort',
561
    ),
562
  );
563

    
564
  return $data;
565
}
566

    
567
function _views_file_status($choice = NULL) {
568
  $status = array(
569
    0 => t('Temporary'),
570
    FILE_STATUS_PERMANENT => t('Permanent'),
571
  );
572

    
573
  if (isset($choice)) {
574
    return isset($status[$choice]) ? $status[$choice] : t('Unknown');
575
  }
576

    
577
  return $status;
578
}