Skip to content

Commit 7612ee6

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 2ed2b01 + fec9d71 commit 7612ee6

File tree

6 files changed

+36
-5
lines changed

6 files changed

+36
-5
lines changed

app/Helpers/Helper.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,19 +1197,30 @@ public static function filetype_icon($filename)
11971197
'webp' => 'far fa-image',
11981198
'avif' => 'far fa-image',
11991199
'svg' => 'fas fa-vector-square',
1200+
12001201
// word
12011202
'doc' => 'far fa-file-word',
12021203
'docx' => 'far fa-file-word',
1204+
12031205
// Excel
12041206
'xls' => 'far fa-file-excel',
12051207
'xlsx' => 'far fa-file-excel',
1208+
'ods' => 'far fa-file-excel',
1209+
1210+
// Presentation
1211+
'ppt' => 'far fa-file-powerpoint',
1212+
'odp' => 'far fa-file-powerpoint',
1213+
12061214
// archive
12071215
'zip' => 'fas fa-file-archive',
12081216
'rar' => 'fas fa-file-archive',
1217+
12091218
//Text
1219+
'odt' => 'far fa-file-alt',
12101220
'txt' => 'far fa-file-alt',
12111221
'rtf' => 'far fa-file-alt',
12121222
'xml' => 'fas fa-code',
1223+
12131224
// Misc
12141225
'pdf' => 'far fa-file-pdf',
12151226
'lic' => 'far fa-save',

app/Helpers/StorageHelper.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static function downloader($filename, $disk = 'default') : BinaryFileResp
2929

3030
public static function getMediaType($file_with_path) {
3131

32-
// The file exists and is allowed to be displayed inline
32+
// Get the file extension and determine the media type
3333
if (Storage::exists($file_with_path)) {
3434
$fileinfo = pathinfo($file_with_path);
3535
$extension = strtolower($fileinfo['extension']);
@@ -51,6 +51,15 @@ public static function getMediaType($file_with_path) {
5151
case 'webm':
5252
case 'mov':
5353
return 'video';
54+
case 'doc':
55+
case 'docx':
56+
return 'document';
57+
case 'txt':
58+
return 'text';
59+
case 'xls':
60+
case 'xlsx':
61+
case 'ods':
62+
return 'spreadsheet';
5463
default:
5564
return $extension; // Default for unknown types
5665
}

app/Http/Transformers/UploadedFilesTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function transformFile(Actionlog $file)
4545
] : null,
4646
'created_at' => Helper::getFormattedDateObject($file->created_at, 'datetime'),
4747
'deleted_at' => Helper::getFormattedDateObject($file->deleted_at, 'datetime'),
48-
'inlineable' => StorageHelper::allowSafeInline($file->uploads_file_path()),
48+
'inlineable' => StorageHelper::allowSafeInline($file->uploads_file_path()) ?? false,
4949
'exists_on_disk' => (Storage::exists($file->uploads_file_path()) ? true : false),
5050
];
5151

config/filesystems.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@
123123
'mov',
124124
'mp3',
125125
'mp4',
126+
'odp',
127+
'ods',
128+
'odt',
126129
'ogg',
127130
'pdf',
128131
'png',
@@ -140,12 +143,15 @@
140143
];
141144

142145

143-
146+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types/Common_types
144147
$config['allowed_upload_mimetypes_array'] = [
145148
'application/json',
146149
'application/msword',
147150
'application/pdf',
148151
'application/vnd.ms-excel',
152+
'application/vnd.oasis.opendocument.presentation',
153+
'application/vnd.oasis.opendocument.spreadsheet',
154+
'application/vnd.oasis.opendocument.text',
149155
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
150156
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
151157
'application/x-rar-compressed',

resources/lang/en-US/general.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@
337337
'zip' => 'Zip',
338338
'noimage' => 'No image uploaded or image not found.',
339339
'file_does_not_exist' => 'The requested file does not exist on the server.',
340+
'file_not_inlineable' => 'The requested file cannot be opened inline in your browser. You can download it instead.',
340341
'open_new_window' => 'Open this file in a new window',
341342
'file_upload_success' => 'File upload success!',
342343
'no_files_uploaded' => 'File upload success!',

resources/views/partials/bootstrap-table.blade.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,10 +966,14 @@ function fileDownloadButtonsFormatter(row, value) {
966966
var download_button = '<a href="' + download_url + '" class="btn btn-sm btn-default" data-tooltip="true" title="{{ trans('general.download') }}"><x-icon type="download" /></a>';
967967
var download_button_disabled = '<span data-tooltip="true" title="{{ trans('general.file_does_not_exist') }}"><a class="btn btn-sm btn-default disabled"><x-icon type="download" /></a></span>';
968968
var inline_button = '<a href="'+ download_url +'?inline=true" class="btn btn-sm btn-default" target="_blank" data-tooltip="true" title="{{ trans('general.open_new_window') }}"><x-icon type="external-link" /></a>';
969-
var inline_button_disabled = '<span data-tooltip="true" title="{{ trans('general.file_does_not_exist') }}"><a class="btn btn-sm btn-default disabled" target="_blank" data-tooltip="true" title="{{ trans('general.file_does_not_exist') }}"><x-icon type="external-link" /></a></span>';
969+
var inline_button_disabled = '<span data-tooltip="true" title="{{ trans('general.file_not_inlineable') }}"><a class="btn btn-sm btn-default disabled" target="_blank" data-tooltip="true" title="{{ trans('general.file_does_not_exist') }}"><x-icon type="external-link" /></a></span>';
970970
971971
if (exists_on_disk === true) {
972-
return '<span style="white-space: nowrap;">' + download_button + ' ' + inline_button + '</span>';
972+
if (inlinable === true) {
973+
return '<span style="white-space: nowrap;">' + download_button + ' ' + inline_button + '</span>';
974+
} else {
975+
return '<span style="white-space: nowrap;">' + download_button + ' ' + inline_button_disabled + '</span>';
976+
}
973977
} else {
974978
return '<span style="white-space: nowrap;">' + download_button_disabled + ' ' + inline_button_disabled + '</span>';
975979
}

0 commit comments

Comments
 (0)