-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconvertfile.theme.inc
64 lines (59 loc) · 1.66 KB
/
convertfile.theme.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* Implements hook_theme().
*/
function convertfile_theme() {
return array(
'convertfile_link' => array(
'variables' => array(
'file' => NULL,
'icon_directory' => NULL,
),
),
);
}
/**
* Returns HTML for a link to a file.
*
* @param $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.
*
* @return string
* HTML to display.
*
* @ingroup themeable
*/
function theme_convertfile_link($variables) {
$file = $variables['file'];
$icon_directory = $variables['icon_directory'];
$html = '';
$files = array($file);
$fids = convertfile_db_conversion_get_backups($file->fid);
foreach ($fids as $fid) {
$files[] = file_load($fid);
}
foreach($files as $file) {
$url = file_create_url($file->uri);
$icon = theme('file_icon', array('file' => $file, 'icon_directory' => $icon_directory));
// Set options as per anchor format described at
// http://microformats.org/wiki/file-format-examples
$options = array(
'attributes' => array(
'type' => $file->filemime . '; length=' . $file->filesize,
),
);
// Use the description as the link text if available.
if (empty($file->description)) {
$link_text = $file->filename;
}
else {
$link_text = $file->description;
$options['attributes']['title'] = check_plain($file->filename);
}
$html .= '<span class="file">' . $icon . ' ' . l($link_text, $url, $options) . '</span> ';
}
return $html;
}