xref: /webtrees/app/Http/RequestHandlers/SitePreferencesPage.php (revision e93a8df2f8d797005750082cc3766c0e80799688)
1c7aa856bSGreg Roach<?php
2c7aa856bSGreg Roach
3c7aa856bSGreg Roach/**
4c7aa856bSGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6c7aa856bSGreg Roach * This program is free software: you can redistribute it and/or modify
7c7aa856bSGreg Roach * it under the terms of the GNU General Public License as published by
8c7aa856bSGreg Roach * the Free Software Foundation, either version 3 of the License, or
9c7aa856bSGreg Roach * (at your option) any later version.
10c7aa856bSGreg Roach * This program is distributed in the hope that it will be useful,
11c7aa856bSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12c7aa856bSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13c7aa856bSGreg Roach * GNU General Public License for more details.
14c7aa856bSGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
16c7aa856bSGreg Roach */
17c7aa856bSGreg Roach
18c7aa856bSGreg Roachdeclare(strict_types=1);
19c7aa856bSGreg Roach
20c7aa856bSGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
21c7aa856bSGreg Roach
22c7aa856bSGreg Roachuse Fisharebest\Webtrees\Http\ViewResponseTrait;
23c7aa856bSGreg Roachuse Fisharebest\Webtrees\I18N;
24c7aa856bSGreg Roachuse Fisharebest\Webtrees\Module\ModuleThemeInterface;
25*3f17da1aSGreg Roachuse Fisharebest\Webtrees\Registry;
26c7aa856bSGreg Roachuse Fisharebest\Webtrees\Services\ModuleService;
27c7aa856bSGreg Roachuse Psr\Http\Message\ResponseInterface;
28c7aa856bSGreg Roachuse Psr\Http\Message\ServerRequestInterface;
29c7aa856bSGreg Roachuse Psr\Http\Server\RequestHandlerInterface;
30c7aa856bSGreg Roach
31d8809d62SGreg Roachuse function ini_get;
32d8809d62SGreg Roach
33c7aa856bSGreg Roach/**
34c7aa856bSGreg Roach * Edit the site preferences.
35c7aa856bSGreg Roach */
36c7aa856bSGreg Roachclass SitePreferencesPage implements RequestHandlerInterface
37c7aa856bSGreg Roach{
38c7aa856bSGreg Roach    use ViewResponseTrait;
39c7aa856bSGreg Roach
40c4943cffSGreg Roach    private ModuleService $module_service;
41c7aa856bSGreg Roach
42c7aa856bSGreg Roach    /**
43c7aa856bSGreg Roach     * @param ModuleService $module_service
44c7aa856bSGreg Roach     */
45c7aa856bSGreg Roach    public function __construct(ModuleService $module_service)
46c7aa856bSGreg Roach    {
47c7aa856bSGreg Roach        $this->module_service = $module_service;
48c7aa856bSGreg Roach    }
49c7aa856bSGreg Roach
50c7aa856bSGreg Roach    /**
51c7aa856bSGreg Roach     * @param ServerRequestInterface $request
52c7aa856bSGreg Roach     *
53c7aa856bSGreg Roach     * @return ResponseInterface
54c7aa856bSGreg Roach     */
55c7aa856bSGreg Roach    public function handle(ServerRequestInterface $request): ResponseInterface
56c7aa856bSGreg Roach    {
57c7aa856bSGreg Roach        $this->layout = 'layouts/administration';
58c7aa856bSGreg Roach
59c7aa856bSGreg Roach        $all_themes = $this->module_service
6071cfb8d6SGreg Roach            ->findByInterface(ModuleThemeInterface::class, true, true)
61c7aa856bSGreg Roach            ->map($this->module_service->titleMapper());
62c7aa856bSGreg Roach
63d8809d62SGreg Roach        $max_execution_time = (int) ini_get('max_execution_time');
64c7aa856bSGreg Roach
65c7aa856bSGreg Roach        $title = I18N::translate('Website preferences');
66c7aa856bSGreg Roach
67c7aa856bSGreg Roach        return $this->viewResponse('admin/site-preferences', [
68c7aa856bSGreg Roach            'all_themes'         => $all_themes,
69*3f17da1aSGreg Roach            'data_folder'        => Registry::filesystem()->dataName(),
70c7aa856bSGreg Roach            'max_execution_time' => $max_execution_time,
71c7aa856bSGreg Roach            'title'              => $title,
72c7aa856bSGreg Roach        ]);
73c7aa856bSGreg Roach    }
74c7aa856bSGreg Roach}
75