Issues (2510)

app/Http/RequestHandlers/UploadMediaPage.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * webtrees: online genealogy
5
 * Copyright (C) 2025 webtrees development team
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU General Public License for more details.
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
 */
17
18
declare(strict_types=1);
19
20
namespace Fisharebest\Webtrees\Http\RequestHandlers;
21
22
use Fisharebest\Webtrees\Http\ViewResponseTrait;
23
use Fisharebest\Webtrees\I18N;
24
use Fisharebest\Webtrees\Registry;
25
use Fisharebest\Webtrees\Services\MediaFileService;
26
use Fisharebest\Webtrees\Services\PhpService;
27
use Psr\Http\Message\ResponseInterface;
28
use Psr\Http\Message\ServerRequestInterface;
29
use Psr\Http\Server\RequestHandlerInterface;
30
31
use function intdiv;
32
33
final class UploadMediaPage implements RequestHandlerInterface
34
{
35
    use ViewResponseTrait;
36
37
    // How many files to upload on one form.
38
    private const int MAX_UPLOAD_FILES = 10;
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 38 at column 22
Loading history...
39
40
    public function __construct(
41
        private readonly MediaFileService $media_file_service,
42
        private readonly PhpService $php_service,
43
    ) {
44
    }
45
46
    public function handle(ServerRequestInterface $request): ResponseInterface
47
    {
48
        $this->layout = 'layouts/administration';
49
50
        $data_filesystem = Registry::filesystem()->data();
51
        $media_folders   = $this->media_file_service->allMediaFolders($data_filesystem);
52
        $kb              = intdiv(num1: $this->php_service->uploadMaxFilesize() + 1023, num2: 1024);
53
        $filesize        = I18N::translate('%s KB', I18N::number($kb));
54
        $title           = I18N::translate('Upload media files');
55
56
        return $this->viewResponse('admin/media-upload', [
57
            'max_upload_files' => self::MAX_UPLOAD_FILES,
58
            'filesize'         => $filesize,
59
            'media_folders'    => $media_folders,
60
            'title'            => $title,
61
        ]);
62
    }
63
}
64