function theme_download_count_file_field_formatter in Download Count 7.3
Theme function for file fields with download counts. Mostly copied from the core file module.
1 theme call to theme_download_count_file_field_formatter()
- download_count_field_formatter_view in includes/
download_count.field.inc - Implements hook_field_formatter_view().
File
- includes/
download_count.field.inc, line 46 - Implement a file field formatter that includes download count.
Code
function theme_download_count_file_field_formatter($variables) {
$file = $variables['file'];
$url = file_create_url($file->uri);
$icon = theme('file_icon', array(
'file' => $file,
));
$options = array(
'attributes' => array(
'type' => $file->filemime . '; length=' . $file->filesize,
),
);
if (empty($file->description)) {
$link_text = $file->filename;
}
else {
$link_text = $file->description;
$options['attributes']['title'] = check_plain($file->filename);
}
$output = '<span class="file">' . $icon . ' ' . l($link_text, $url, $options) . '</span><span class="download-count"> — ';
if (isset($file->downloads) && $file->downloads > 0) {
$output .= format_plural($file->downloads, 'Downloaded 1 time', 'Downloaded @count times');
}
else {
$output .= t('Never downloaded');
}
$output .= '</span>';
return $output;
}