Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/modules/system/views_handler_field_file.inc | ||
---|---|---|
11 | 11 |
* @ingroup views_field_handlers |
12 | 12 |
*/ |
13 | 13 |
class views_handler_field_file extends views_handler_field { |
14 |
|
|
14 | 15 |
/** |
15 | 16 |
* Constructor to provide additional field to add. |
16 | 17 |
*/ |
17 |
function init(&$view, &$options) { |
|
18 |
public function init(&$view, &$options) {
|
|
18 | 19 |
parent::init($view, $options); |
19 | 20 |
if (!empty($options['link_to_file'])) { |
20 | 21 |
$this->additional_fields['uri'] = 'uri'; |
21 | 22 |
} |
22 | 23 |
} |
23 | 24 |
|
24 |
function option_definition() { |
|
25 |
/** |
|
26 |
* {@inheritdoc} |
|
27 |
*/ |
|
28 |
public function option_definition() { |
|
25 | 29 |
$options = parent::option_definition(); |
26 | 30 |
$options['link_to_file'] = array('default' => FALSE, 'bool' => TRUE); |
27 | 31 |
return $options; |
28 | 32 |
} |
29 | 33 |
|
30 | 34 |
/** |
31 |
* Provide link to file option |
|
35 |
* Provide link to file option.
|
|
32 | 36 |
*/ |
33 |
function options_form(&$form, &$form_state) { |
|
37 |
public function options_form(&$form, &$form_state) {
|
|
34 | 38 |
$form['link_to_file'] = array( |
35 | 39 |
'#title' => t('Link this field to download the file'), |
36 | 40 |
'#description' => t("Enable to override this field's links."), |
... | ... | |
45 | 49 |
* |
46 | 50 |
* Data should be made XSS safe prior to calling this function. |
47 | 51 |
*/ |
48 |
function render_link($data, $values) { |
|
52 |
public function render_link($data, $values) {
|
|
49 | 53 |
if (!empty($this->options['link_to_file']) && $data !== NULL && $data !== '') { |
50 | 54 |
$this->options['alter']['make_link'] = TRUE; |
51 | 55 |
$this->options['alter']['path'] = file_create_url($this->get_value($values, 'uri')); |
... | ... | |
54 | 58 |
return $data; |
55 | 59 |
} |
56 | 60 |
|
57 |
function render($values) { |
|
61 |
/** |
|
62 |
* {@inheritdoc} |
|
63 |
*/ |
|
64 |
public function render($values) { |
|
58 | 65 |
$value = $this->get_value($values); |
59 | 66 |
return $this->render_link($this->sanitize_value($value), $values); |
60 | 67 |
} |
68 |
|
|
61 | 69 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules