1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Epesi\FileStorage; |
4
|
|
|
|
5
|
|
|
use Epesi\FileStorage\Models\File; |
6
|
|
|
use Epesi\Core\Helpers\Utils; |
7
|
|
|
|
8
|
|
|
class FileStorageUI |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
public static function fileLabel($id, $nolink = false, $icon = true, $action_urls = null, $label = null, $inline = false) |
12
|
|
|
{ |
13
|
|
|
$fileExists = File::exists($id); |
14
|
|
|
|
15
|
|
|
if ($icon) { |
16
|
|
|
$icon_file = $fileExists ? 'z-attach.png': 'z-attach-off.png'; |
17
|
|
|
$img_src = Base_ThemeCommon::get_template_file(self::module_name(), $icon_file); |
|
|
|
|
18
|
|
|
$icon_img = '<img src="' . $img_src . '" style="vertical-align:bottom">'; |
19
|
|
|
} |
20
|
|
|
else { |
21
|
|
|
$icon_img = ''; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
$file = File::get($id); |
|
|
|
|
25
|
|
|
|
26
|
|
|
if (! $fileName = $label) { |
27
|
|
|
$fileName = ($file['name']?? '') ?: '[' . __('missing file name') . ']'; |
|
|
|
|
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
if ($nolink || ! $file) { |
31
|
|
|
return $fileName . ($fileExists ? '': ' [' . __('missing file') . ']'); |
|
|
|
|
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
$link_href = ''; |
35
|
|
|
if ($fileExists) { |
36
|
|
|
$filesize = filesize_hr($file['file']); |
|
|
|
|
37
|
|
|
$filetooltip = __('File size: %s', array($filesize)) . '<hr>' . |
|
|
|
|
38
|
|
|
__('Uploaded by: %s', array(Base_UserCommon::get_user_label($file['created_by'], true))) . '<br/>' . |
|
|
|
|
39
|
|
|
__('Uploaded on: %s', array(Base_RegionalSettingsCommon::time2reg($file['created_on']))) . '<br/>' . |
|
|
|
|
40
|
|
|
__('Number of downloads: %d', array(self::get_downloads_count($id))); |
|
|
|
|
41
|
|
|
$link_href = Utils_TooltipCommon::open_tag_attrs($filetooltip) . ' ' |
|
|
|
|
42
|
|
|
. Utils_FileStorage_FileLeightbox::get_file_leightbox($file, $action_urls); |
|
|
|
|
43
|
|
|
} else { |
44
|
|
|
if (isset($file['hash'])) { |
45
|
|
|
$tooltip_text = __('Missing file: %s', array(substr($file['hash'], 0, 32) . '...')); |
46
|
|
|
$link_href = Utils_TooltipCommon::open_tag_attrs($tooltip_text); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$ret = '<a ' . $link_href . '>' . $icon_img . '<span class="file_name">' . $fileName . '</span></a>'; |
51
|
|
|
|
52
|
|
|
return $inline? $ret: '<div class="file_link">'.$ret.'</div>'; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.