| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/business/sites/all/modules/views/modules/system/ |
Upload File : |
<?php
/**
* @file
* Definition of views_handler_field_file.
*/
/**
* Field handler to provide simple renderer that allows linking to a file.
*
* @ingroup views_field_handlers
*/
class views_handler_field_file extends views_handler_field {
/**
* Constructor to provide additional field to add.
*/
public function init(&$view, &$options) {
parent::init($view, $options);
if (!empty($options['link_to_file'])) {
$this->additional_fields['uri'] = 'uri';
}
}
/**
* {@inheritdoc}
*/
public function option_definition() {
$options = parent::option_definition();
$options['link_to_file'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
/**
* Provide link to file option.
*/
public function options_form(&$form, &$form_state) {
$form['link_to_file'] = array(
'#title' => t('Link this field to download the file'),
'#description' => t("Enable to override this field's links."),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_file']),
);
parent::options_form($form, $form_state);
}
/**
* Render whatever the data is as a link to the file.
*
* Data should be made XSS safe prior to calling this function.
*/
public function render_link($data, $values) {
if (!empty($this->options['link_to_file']) && $data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = file_create_url($this->get_value($values, 'uri'));
}
return $data;
}
/**
* {@inheritdoc}
*/
public function render($values) {
$value = $this->get_value($values);
return $this->render_link($this->sanitize_value($value), $values);
}
}