function theme_track_da_files_file_link in Track da files 7
Same name and namespace in other branches
- 8 includes/track_da_files_formatter.inc \theme_track_da_files_file_link()
Returns HTML for a link to a file.
Parameters
array $variables: An associative array containing:
- file: A file object to which the link will be created.
- icon_directory: (optional) A path to a directory of icons to be used for files. Defaults to the value of the "file_icon_directory" variable.
2 theme calls to theme_track_da_files_file_link()
- theme_track_da_files_file_formatter_table in includes/
track_da_files_formatter.inc - Returns HTML for a file attachments table.
- track_da_files_field_formatter_view in ./
track_da_files.module - Implements hook_field_formatter_view().
File
- includes/
track_da_files_formatter.inc, line 19 - format_custom_link_text This file contains the specialized field formatters.
Code
function theme_track_da_files_file_link($variables) {
$track_da_files_file_field_links_show_enabled = variable_get('track_da_files_file_field_links_show_enabled', 1);
// Load related CSS.
if ($track_da_files_file_field_links_show_enabled) {
drupal_add_css(drupal_get_path('module', 'track_da_files') . '/includes/track_da_files.css');
}
$output = '';
$file = $variables['file'];
$icon_directory = $variables['icon_directory'];
$url = track_da_files_create_url($file->uri);
$icon = theme('file_icon', array(
'file' => $file,
'icon_directory' => $icon_directory,
));
$options = array(
'attributes' => array(
'type' => $file->filemime . '; length=' . $file->filesize,
),
);
// Use custom link text if available, else use description or file name
if (isset($file->custom_link_text) && !empty($file->custom_link_text)) {
$link_text = $file->custom_link_text;
}
elseif (empty($file->description)) {
$link_text = $file->filename;
}
else {
$link_text = $file->description;
$options['attributes']['title'] = check_plain($file->filename);
}
$options['query']['file'] = '1';
if (isset($file->type)) {
$options['query']['type'] = $file->type;
}
if (isset($file->id)) {
$options['query']['id'] = $file->id;
}
if (isset($file->force_download)) {
$options['query']['force'] = $file->force_download;
}
$output = '<span class="file">' . $icon . ' ' . l($link_text, $url, $options) . '</span>';
if (isset($file->displays) && ($file->displays > 0 && isset($track_da_files_file_field_links_show_enabled))) {
$output .= '<span class="file-displayed-counter">' . format_plural($file->displays, 'displayed 1 time', 'displayed @count times') . '</span>';
}
return $output;
}