Projet

Général

Profil

Paste
Télécharger (1,09 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / system / views_handler_field_file_uri.inc @ b08fce64

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 file URIs.
10
 */
11
class views_handler_field_file_uri extends views_handler_field_file {
12
  function option_definition() {
13
    $options = parent::option_definition();
14
    $options['file_download_path'] = array('default' => FALSE, 'bool' => TRUE);
15
    return $options;
16
  }
17

    
18
  function options_form(&$form, &$form_state) {
19
    $form['file_download_path'] = array(
20
      '#title' => t('Display download path instead of file storage URI'),
21
      '#description' => t('This will provide the full download URL rather than the internal filestream address.'),
22
      '#type' => 'checkbox',
23
      '#default_value' => !empty($this->options['file_download_path']),
24
    );
25
    parent::options_form($form, $form_state);
26
  }
27

    
28
  function render($values) {
29
    $data = $values->{$this->field_alias};
30
    if (!empty($this->options['file_download_path']) && $data !== NULL && $data !== '') {
31
      $data = file_create_url($data);
32
    }
33
    return $this->render_link($data, $values);
34
  }
35
}