File.php 2.24 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
use Drupal\Component\Annotation\Plugin;
12
use Drupal\Core\Annotation\Translation;
13

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

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  /**
   * 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
  );

42
43
44
45
46
  /**
   * Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::default_display_options().
   */
  protected function default_display_options() {
    $display_options = parent::default_display_options();
merlinofchaos's avatar
merlinofchaos committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

    // 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';
    $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;
  }
73

merlinofchaos's avatar
merlinofchaos committed
74
}