File.php 2.2 KB
Newer Older
merlinofchaos's avatar
merlinofchaos committed
1
2
3
4
<?php

/**
 * @file
5
 * Definition of Drupal\file\Plugin\views\wizard\File.
merlinofchaos's avatar
merlinofchaos committed
6
7
 */

8
namespace Drupal\file\Plugin\views\wizard;
9

10
use Drupal\views\Plugin\views\wizard\WizardPluginBase;
11

merlinofchaos's avatar
merlinofchaos committed
12
13
/**
 * Tests creating managed files views with the wizard.
14
 *
15
 * @ViewsWizard(
aspilicious's avatar
aspilicious committed
16
 *   id = "file_managed",
17
 *   base_table = "file_managed",
18
 *   title = @Translation("Files")
19
 * )
merlinofchaos's avatar
merlinofchaos committed
20
 */
21
class File extends WizardPluginBase {
22

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  /**
   * Set the created column.
   */
  protected $createdColumn = 'timestamp';

  /**
   * Set default values for the path field options.
   */
  protected $pathField = array(
    'id' => 'uri',
    'table' => 'file_managed',
    'field' => 'uri',
    'exclude' => TRUE,
    'file_download_path' => TRUE
  );

39
  /**
40
   * Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayOptions().
41
   */
42
43
  protected function defaultDisplayOptions() {
    $display_options = parent::defaultDisplayOptions();
merlinofchaos's avatar
merlinofchaos committed
44
45
46
47
48
49
50
51
52
53
54

    // Add permission-based access control.
    $display_options['access']['type'] = 'perm';

    // Remove the default fields, since we are customizing them here.
    unset($display_options['fields']);

    /* Field: File: Name */
    $display_options['fields']['filename']['id'] = 'filename';
    $display_options['fields']['filename']['table'] = 'file_managed';
    $display_options['fields']['filename']['field'] = 'filename';
55
    $display_options['fields']['filename']['provider'] = 'file';
merlinofchaos's avatar
merlinofchaos committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
    $display_options['fields']['filename']['label'] = '';
    $display_options['fields']['filename']['alter']['alter_text'] = 0;
    $display_options['fields']['filename']['alter']['make_link'] = 0;
    $display_options['fields']['filename']['alter']['absolute'] = 0;
    $display_options['fields']['filename']['alter']['trim'] = 0;
    $display_options['fields']['filename']['alter']['word_boundary'] = 0;
    $display_options['fields']['filename']['alter']['ellipsis'] = 0;
    $display_options['fields']['filename']['alter']['strip_tags'] = 0;
    $display_options['fields']['filename']['alter']['html'] = 0;
    $display_options['fields']['filename']['hide_empty'] = 0;
    $display_options['fields']['filename']['empty_zero'] = 0;
    $display_options['fields']['filename']['link_to_file'] = 1;

    return $display_options;
  }
71

merlinofchaos's avatar
merlinofchaos committed
72
}