class download_count_views_handler_field_file in Download Count 6.2
Same name and namespace in other branches
- 7.2 includes/download_count_views_handler_field_file.inc \download_count_views_handler_field_file
Fix node title field to reflect correct private_upload path.
Hierarchy
- class \download_count_views_handler_field_file extends \views_handler_field_file
Expanded class hierarchy of download_count_views_handler_field_file
1 string reference to 'download_count_views_handler_field_file'
- download_count_views_data_alter in includes/
download_count.views.inc - Implementation of hook_views_data_alter().
File
- includes/
download_count_views_handler_field_file.inc, line 13 - 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…
View source
class download_count_views_handler_field_file extends views_handler_field_file {
/**
* Constructor to provide additional field info.
*/
function init(&$view, &$options) {
parent::init($view, $options);
if (!empty($options['link_to_file'])) {
$this->additional_fields['filename'] = 'filename';
$this->additional_fields['fid'] = 'fid';
}
}
/**
* Render whatever the data is as a link to the file.
*
* Data should be made XSS safe prior to calling this function.
*/
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;
}
function render($values) {
return $this
->render_private(check_plain($values->{$this->field_alias}), $values);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
download_count_views_handler_field_file:: |
function | Constructor to provide additional field info. | ||
download_count_views_handler_field_file:: |
function | |||
download_count_views_handler_field_file:: |
function | Render whatever the data is as a link to the file. |