![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/webtrees/app/Http/RequestHandlers/ |
Upload File : |
<?php /** * webtrees: online genealogy * Copyright (C) 2023 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fisharebest\Webtrees\Http\ViewResponseTrait; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Services\TreeService; use Fisharebest\Webtrees\Services\UpgradeService; use Fisharebest\Webtrees\Validator; use Fisharebest\Webtrees\Webtrees; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function basename; use function e; use function route; use function version_compare; /** * Upgrade to a new version of webtrees. */ class UpgradeWizardPage implements RequestHandlerInterface { use ViewResponseTrait; // We make the upgrade in a number of small steps to keep within server time limits. private const STEP_CHECK = 'Check'; private const STEP_PREPARE = 'Prepare'; private const STEP_PENDING = 'Pending'; private const STEP_EXPORT = 'Export'; private const STEP_DOWNLOAD = 'Download'; private const STEP_UNZIP = 'Unzip'; private const STEP_COPY = 'Copy'; private TreeService $tree_service; private UpgradeService $upgrade_service; /** * @param TreeService $tree_service * @param UpgradeService $upgrade_service */ public function __construct(TreeService $tree_service, UpgradeService $upgrade_service) { $this->tree_service = $tree_service; $this->upgrade_service = $upgrade_service; } /** * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $this->layout = 'layouts/administration'; $continue = Validator::queryParams($request)->string('continue', ''); $title = I18N::translate('Upgrade wizard'); $latest_version = $this->upgrade_service->latestVersion(); $upgrade_available = version_compare($latest_version, Webtrees::VERSION) > 0; if ($upgrade_available && $continue === '1') { return $this->viewResponse('admin/upgrade/steps', [ 'steps' => $this->wizardSteps(), 'title' => $title, ]); } return $this->viewResponse('admin/upgrade/wizard', [ 'current_version' => Webtrees::VERSION, 'latest_version' => $latest_version, 'title' => $title, ]); } /** * @return array<string> */ private function wizardSteps(): array { $download_url = $this->upgrade_service->downloadUrl(); $export_steps = []; foreach ($this->tree_service->all() as $tree) { $route = route(UpgradeWizardStep::class, [ 'step' => self::STEP_EXPORT, 'tree' => $tree->name(), ]); $export_steps[$route] = I18N::translate('Export all the family trees to GEDCOM files…') . ' ' . e($tree->title()); } return [ route(UpgradeWizardStep::class, ['step' => self::STEP_CHECK]) => I18N::translate('Upgrade wizard'), route(UpgradeWizardStep::class, ['step' => self::STEP_PREPARE]) => I18N::translate('Create a temporary folder…'), route(UpgradeWizardStep::class, ['step' => self::STEP_PENDING]) => I18N::translate('Check for pending changes…'), ] + $export_steps + [ route(UpgradeWizardStep::class, ['step' => self::STEP_DOWNLOAD]) => I18N::translate('Download %s…', e($download_url)), route(UpgradeWizardStep::class, ['step' => self::STEP_UNZIP]) => I18N::translate('Unzip %s to a temporary folder…', e(basename($download_url))), route(UpgradeWizardStep::class, ['step' => self::STEP_COPY]) => I18N::translate('Copy files…'), ]; } }