You are here

function download_count_views_handler_field_file::render_private in Download Count 6.2

Same name and namespace in other branches
  1. 7.2 includes/download_count_views_handler_field_file.inc \download_count_views_handler_field_file::render_private()

Render whatever the data is as a link to the file.

Data should be made XSS safe prior to calling this function.

1 call to download_count_views_handler_field_file::render_private()
download_count_views_handler_field_file::render in includes/download_count_views_handler_field_file.inc

File

includes/download_count_views_handler_field_file.inc, line 32
Contains the views handler for download_count to correct file name and filepath links for files protected by the private_upload module. It should really be part of the private_upload module, but private_upload does not currently provide views 2…

Class

download_count_views_handler_field_file
Fix node title field to reflect correct private_upload path.

Code

function render_private($data, $values) {
  if (!empty($this->options['link_to_file']) && $data !== NULL && $data !== '') {
    global $base_url;
    $file->fid = $values->{$this->aliases['fid']};
    $file->filename = $values->{$this->aliases['filename']};
    $file->filepath = $values->{$this->aliases['filepath']};
    $this->options['alter']['make_link'] = TRUE;
    $this->options['alter']['path'] = function_exists('_private_upload_create_url') ? _private_upload_create_url($file) : file_create_url($values->{$this->aliases['filepath']});
    if ($data == $file->filepath) {
      $data = drupal_substr($this->options['alter']['path'], drupal_strlen($base_url) + 1);
    }
  }
  return $data;
}