1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of views_handler_field_file_uri.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Field handler to add rendering file paths as file URLs instead of as internal
|
10
|
* file URIs.
|
11
|
*/
|
12
|
class views_handler_field_file_uri extends views_handler_field_file {
|
13
|
|
14
|
/**
|
15
|
* {@inheritdoc}
|
16
|
*/
|
17
|
public function option_definition() {
|
18
|
$options = parent::option_definition();
|
19
|
$options['file_download_path'] = array('default' => FALSE, 'bool' => TRUE);
|
20
|
return $options;
|
21
|
}
|
22
|
|
23
|
/**
|
24
|
* {@inheritdoc}
|
25
|
*/
|
26
|
public function options_form(&$form, &$form_state) {
|
27
|
$form['file_download_path'] = array(
|
28
|
'#title' => t('Display download path instead of file storage URI'),
|
29
|
'#description' => t('This will provide the full download URL rather than the internal filestream address.'),
|
30
|
'#type' => 'checkbox',
|
31
|
'#default_value' => !empty($this->options['file_download_path']),
|
32
|
);
|
33
|
parent::options_form($form, $form_state);
|
34
|
}
|
35
|
|
36
|
/**
|
37
|
* {@inheritdoc}
|
38
|
*/
|
39
|
public function render($values) {
|
40
|
$data = $values->{$this->field_alias};
|
41
|
if (!empty($this->options['file_download_path']) && $data !== NULL && $data !== '') {
|
42
|
$data = file_create_url($data);
|
43
|
}
|
44
|
return $this->render_link($data, $values);
|
45
|
}
|
46
|
|
47
|
}
|