Projet

Général

Profil

Paste
Télécharger (819 octets) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / file_entity / views / views_handler_field_file_link_download.inc @ ca0757b9

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_handler_field_file_link_download.
6
 */
7

    
8
/**
9
 * Field handler to present a link to download a file.
10
 *
11
 * @ingroup views_field_handlers
12
 */
13
class views_handler_field_file_link_download extends views_handler_field_file_link {
14

    
15
  /**
16
   * Renders the link.
17
   */
18
  function render_link($file, $values) {
19
    // Ensure user has access to download this file.
20
    if (!file_entity_access('download', $file)) {
21
      return;
22
    }
23

    
24
    $this->options['alter']['make_link'] = TRUE;
25
    $uri = file_entity_download_uri($file);
26
    $this->options['alter']['path'] = $uri['path'];
27
    $this->options['alter'] = drupal_array_merge_deep($this->options['alter'], $uri['options']);
28

    
29
    $text = !empty($this->options['text']) ? $this->options['text'] : t('Download');
30
    return $text;
31
  }
32
}