views_handler_field_file_uri.inc

Definition of views_handler_field_file_uri.

File

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