1*8ce3bd73SGreg Roach<?php 2*8ce3bd73SGreg Roach 3*8ce3bd73SGreg Roach/** 4*8ce3bd73SGreg Roach * webtrees: online genealogy 5*8ce3bd73SGreg Roach * Copyright (C) 2020 webtrees development team 6*8ce3bd73SGreg Roach * This program is free software: you can redistribute it and/or modify 7*8ce3bd73SGreg Roach * it under the terms of the GNU General Public License as published by 8*8ce3bd73SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9*8ce3bd73SGreg Roach * (at your option) any later version. 10*8ce3bd73SGreg Roach * This program is distributed in the hope that it will be useful, 11*8ce3bd73SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12*8ce3bd73SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*8ce3bd73SGreg Roach * GNU General Public License for more details. 14*8ce3bd73SGreg Roach * You should have received a copy of the GNU General Public License 15*8ce3bd73SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 16*8ce3bd73SGreg Roach */ 17*8ce3bd73SGreg Roach 18*8ce3bd73SGreg Roachdeclare(strict_types=1); 19*8ce3bd73SGreg Roach 20*8ce3bd73SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers; 21*8ce3bd73SGreg Roach 22*8ce3bd73SGreg Roachuse Fisharebest\Webtrees\Http\ViewResponseTrait; 23*8ce3bd73SGreg Roachuse Fisharebest\Webtrees\I18N; 24*8ce3bd73SGreg Roachuse Fisharebest\Webtrees\Registry; 25*8ce3bd73SGreg Roachuse Fisharebest\Webtrees\Services\MediaFileService; 26*8ce3bd73SGreg Roachuse Psr\Http\Message\ResponseInterface; 27*8ce3bd73SGreg Roachuse Psr\Http\Message\ServerRequestInterface; 28*8ce3bd73SGreg Roachuse Psr\Http\Server\RequestHandlerInterface; 29*8ce3bd73SGreg Roach 30*8ce3bd73SGreg Roachuse function ini_get; 31*8ce3bd73SGreg Roach 32*8ce3bd73SGreg Roach/** 33*8ce3bd73SGreg Roach * Manage media from the control panel. 34*8ce3bd73SGreg Roach */ 35*8ce3bd73SGreg Roachclass UploadMediaPage implements RequestHandlerInterface 36*8ce3bd73SGreg Roach{ 37*8ce3bd73SGreg Roach use ViewResponseTrait; 38*8ce3bd73SGreg Roach 39*8ce3bd73SGreg Roach // How many files to upload on one form. 40*8ce3bd73SGreg Roach private const MAX_UPLOAD_FILES = 10; 41*8ce3bd73SGreg Roach 42*8ce3bd73SGreg Roach /** @var MediaFileService */ 43*8ce3bd73SGreg Roach private $media_file_service; 44*8ce3bd73SGreg Roach 45*8ce3bd73SGreg Roach /** 46*8ce3bd73SGreg Roach * MediaController constructor. 47*8ce3bd73SGreg Roach * 48*8ce3bd73SGreg Roach * @param MediaFileService $media_file_service 49*8ce3bd73SGreg Roach */ 50*8ce3bd73SGreg Roach public function __construct(MediaFileService $media_file_service) 51*8ce3bd73SGreg Roach { 52*8ce3bd73SGreg Roach $this->media_file_service = $media_file_service; 53*8ce3bd73SGreg Roach } 54*8ce3bd73SGreg Roach 55*8ce3bd73SGreg Roach /** 56*8ce3bd73SGreg Roach * @param ServerRequestInterface $request 57*8ce3bd73SGreg Roach * 58*8ce3bd73SGreg Roach * @return ResponseInterface 59*8ce3bd73SGreg Roach */ 60*8ce3bd73SGreg Roach public function handle(ServerRequestInterface $request): ResponseInterface 61*8ce3bd73SGreg Roach { 62*8ce3bd73SGreg Roach $this->layout = 'layouts/administration'; 63*8ce3bd73SGreg Roach 64*8ce3bd73SGreg Roach $data_filesystem = Registry::filesystem()->data(); 65*8ce3bd73SGreg Roach 66*8ce3bd73SGreg Roach $media_folders = $this->media_file_service->allMediaFolders($data_filesystem); 67*8ce3bd73SGreg Roach 68*8ce3bd73SGreg Roach $filesize = ini_get('upload_max_filesize') ?: '2M'; 69*8ce3bd73SGreg Roach 70*8ce3bd73SGreg Roach $title = I18N::translate('Upload media files'); 71*8ce3bd73SGreg Roach 72*8ce3bd73SGreg Roach return $this->viewResponse('admin/media-upload', [ 73*8ce3bd73SGreg Roach 'max_upload_files' => self::MAX_UPLOAD_FILES, 74*8ce3bd73SGreg Roach 'filesize' => $filesize, 75*8ce3bd73SGreg Roach 'media_folders' => $media_folders, 76*8ce3bd73SGreg Roach 'title' => $title, 77*8ce3bd73SGreg Roach ]); 78*8ce3bd73SGreg Roach } 79*8ce3bd73SGreg Roach} 80