mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 14:30:32 +02:00
[ticket/14039] Revamp updater
PHPBB3-14039
This commit is contained in:
92
phpBB/phpbb/install/controller/archive_download.php
Normal file
92
phpBB/phpbb/install/controller/archive_download.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\controller;
|
||||
|
||||
use phpbb\install\helper\config;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
||||
|
||||
class archive_download
|
||||
{
|
||||
/**
|
||||
* @var config
|
||||
*/
|
||||
protected $installer_config;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param config $config
|
||||
*/
|
||||
public function __construct(config $config)
|
||||
{
|
||||
$this->installer_config = $config;
|
||||
$this->installer_config->load_config();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends response with the merge conflict archive
|
||||
*
|
||||
* Merge conflicts are always have to be resolved manually,
|
||||
* so we use a different archive for that.
|
||||
*
|
||||
* @return BinaryFileResponse
|
||||
*/
|
||||
public function conflict_archive()
|
||||
{
|
||||
$filename = $this->installer_config->get('update_file_conflict_archive', false);
|
||||
|
||||
if (!$filename)
|
||||
{
|
||||
die ('The requested file is not exist.');
|
||||
}
|
||||
|
||||
return $this->send_response($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends response with the updated files' archive
|
||||
*
|
||||
* @return BinaryFileResponse
|
||||
*/
|
||||
public function update_archive()
|
||||
{
|
||||
$filename = $this->installer_config->get('update_file_archive', '');
|
||||
|
||||
if (!$filename)
|
||||
{
|
||||
die ('The requested file is not exist.');
|
||||
}
|
||||
|
||||
return $this->send_response($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a download response
|
||||
*
|
||||
* @param string $filename Path to the file to download
|
||||
*
|
||||
* @return BinaryFileResponse Response object
|
||||
*/
|
||||
private function send_response($filename)
|
||||
{
|
||||
$response = new BinaryFileResponse($filename);
|
||||
$response->setContentDisposition(
|
||||
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
|
||||
basename($filename)
|
||||
);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
@@ -13,6 +13,7 @@
|
||||
|
||||
namespace phpbb\install\controller;
|
||||
|
||||
use phpbb\install\helper\config;
|
||||
use phpbb\install\helper\navigation\navigation_provider;
|
||||
use phpbb\language\language;
|
||||
use phpbb\language\language_file_helper;
|
||||
@@ -33,6 +34,11 @@ use Symfony\Component\HttpFoundation\Cookie;
|
||||
*/
|
||||
class helper
|
||||
{
|
||||
/**
|
||||
* @var config
|
||||
*/
|
||||
protected $installer_config;
|
||||
|
||||
/**
|
||||
* @var \phpbb\language\language
|
||||
*/
|
||||
@@ -91,6 +97,7 @@ class helper
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param config $config
|
||||
* @param language $language
|
||||
* @param language_file_helper $lang_helper
|
||||
* @param navigation_provider $nav
|
||||
@@ -101,8 +108,9 @@ class helper
|
||||
* @param router $router
|
||||
* @param string $phpbb_root_path
|
||||
*/
|
||||
public function __construct(language $language, language_file_helper $lang_helper, navigation_provider $nav, template $template, path_helper $path_helper, request $phpbb_request, symfony_request $request, router $router, $phpbb_root_path)
|
||||
public function __construct(config $config, language $language, language_file_helper $lang_helper, navigation_provider $nav, template $template, path_helper $path_helper, request $phpbb_request, symfony_request $request, router $router, $phpbb_root_path)
|
||||
{
|
||||
$this->installer_config = $config;
|
||||
$this->language = $language;
|
||||
$this->language_cookie = false;
|
||||
$this->lang_helper = $lang_helper;
|
||||
@@ -199,6 +207,47 @@ class helper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process navigation data to reflect active/completed stages
|
||||
*
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface|null $iohandler
|
||||
*/
|
||||
public function handle_navigation($iohandler = null)
|
||||
{
|
||||
$nav_data = $this->installer_config->get_navigation_data();
|
||||
|
||||
// Set active navigation stage
|
||||
if (isset($nav_data['active']) && is_array($nav_data['active']))
|
||||
{
|
||||
if ($iohandler !== null)
|
||||
{
|
||||
$iohandler->set_active_stage_menu($nav_data['active']);
|
||||
}
|
||||
|
||||
$this->navigation_provider->set_nav_property($nav_data['active'], array(
|
||||
'selected' => true,
|
||||
'completed' => false,
|
||||
));
|
||||
}
|
||||
|
||||
// Set finished navigation stages
|
||||
if (isset($nav_data['finished']) && is_array($nav_data['finished']))
|
||||
{
|
||||
foreach ($nav_data['finished'] as $finished_stage)
|
||||
{
|
||||
if ($iohandler !== null)
|
||||
{
|
||||
$iohandler->set_finished_stage_menu($finished_stage);
|
||||
}
|
||||
|
||||
$this->navigation_provider->set_nav_property($finished_stage, array(
|
||||
'selected' => false,
|
||||
'completed' => true,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default template variables
|
||||
*
|
||||
@@ -207,27 +256,32 @@ class helper
|
||||
*/
|
||||
protected function page_header($page_title, $selected_language = false)
|
||||
{
|
||||
// Path to templates
|
||||
$paths = array($this->phpbb_root_path . 'install/update/new/adm/', $this->phpbb_admin_path);
|
||||
$paths = array_filter($paths, 'is_dir');
|
||||
$path = array_shift($paths);
|
||||
$path = substr($path, strlen($this->phpbb_root_path));
|
||||
|
||||
$this->template->assign_vars(array(
|
||||
'L_CHANGE' => $this->language->lang('CHANGE'),
|
||||
'L_COLON' => $this->language->lang('COLON'),
|
||||
'L_INSTALL_PANEL' => $this->language->lang('INSTALL_PANEL'),
|
||||
'L_SELECT_LANG' => $this->language->lang('SELECT_LANG'),
|
||||
'L_SKIP' => $this->language->lang('SKIP'),
|
||||
'PAGE_TITLE' => $this->language->lang($page_title),
|
||||
'T_IMAGE_PATH' => htmlspecialchars($this->phpbb_admin_path) . 'images/',
|
||||
'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . 'assets/javascript/jquery.min.js',
|
||||
'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . 'adm/style',
|
||||
'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . 'assets/',
|
||||
'L_CHANGE' => $this->language->lang('CHANGE'),
|
||||
'L_COLON' => $this->language->lang('COLON'),
|
||||
'L_INSTALL_PANEL' => $this->language->lang('INSTALL_PANEL'),
|
||||
'L_SELECT_LANG' => $this->language->lang('SELECT_LANG'),
|
||||
'L_SKIP' => $this->language->lang('SKIP'),
|
||||
'PAGE_TITLE' => $this->language->lang($page_title),
|
||||
'T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . $path . 'images/',
|
||||
'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . $path . '../assets/javascript/jquery.min.js',
|
||||
'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . $path . 'style',
|
||||
'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . $path . '../assets/',
|
||||
|
||||
'S_CONTENT_DIRECTION' => $this->language->lang('DIRECTION'),
|
||||
'S_CONTENT_FLOW_BEGIN' => ($this->language->lang('DIRECTION') === 'ltr') ? 'left' : 'right',
|
||||
'S_CONTENT_FLOW_END' => ($this->language->lang('DIRECTION') === 'ltr') ? 'right' : 'left',
|
||||
'S_CONTENT_ENCODING' => 'UTF-8',
|
||||
'S_LANG_SELECT' => $selected_language,
|
||||
'S_CONTENT_DIRECTION' => $this->language->lang('DIRECTION'),
|
||||
'S_CONTENT_FLOW_BEGIN' => ($this->language->lang('DIRECTION') === 'ltr') ? 'left' : 'right',
|
||||
'S_CONTENT_FLOW_END' => ($this->language->lang('DIRECTION') === 'ltr') ? 'right' : 'left',
|
||||
'S_CONTENT_ENCODING' => 'UTF-8',
|
||||
'S_LANG_SELECT' => $selected_language,
|
||||
|
||||
'S_USER_LANG' => $this->language->lang('USER_LANG'),
|
||||
)
|
||||
);
|
||||
'S_USER_LANG' => $this->language->lang('USER_LANG'),
|
||||
));
|
||||
|
||||
$this->render_navigation();
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@
|
||||
|
||||
namespace phpbb\install\controller;
|
||||
|
||||
use phpbb\install\helper\config;
|
||||
use phpbb\install\helper\install_helper;
|
||||
use phpbb\install\helper\navigation\navigation_provider;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
@@ -35,11 +34,6 @@ class install
|
||||
*/
|
||||
protected $controller_helper;
|
||||
|
||||
/**
|
||||
* @var config
|
||||
*/
|
||||
protected $installer_config;
|
||||
|
||||
/**
|
||||
* @var factory
|
||||
*/
|
||||
@@ -79,7 +73,6 @@ class install
|
||||
* Constructor
|
||||
*
|
||||
* @param helper $helper
|
||||
* @param config $install_config
|
||||
* @param factory $factory
|
||||
* @param navigation_provider $nav_provider
|
||||
* @param language $language
|
||||
@@ -88,10 +81,9 @@ class install
|
||||
* @param installer $installer
|
||||
* @param install_helper $install_helper
|
||||
*/
|
||||
public function __construct(helper $helper, config $install_config, factory $factory, navigation_provider $nav_provider, language $language, template $template, request_interface $request, installer $installer, install_helper $install_helper)
|
||||
public function __construct(helper $helper, factory $factory, navigation_provider $nav_provider, language $language, template $template, request_interface $request, installer $installer, install_helper $install_helper)
|
||||
{
|
||||
$this->controller_helper = $helper;
|
||||
$this->installer_config = $install_config;
|
||||
$this->iohandler_factory = $factory;
|
||||
$this->menu_provider = $nav_provider;
|
||||
$this->language = $language;
|
||||
@@ -130,34 +122,6 @@ class install
|
||||
// Set the appropriate input-output handler
|
||||
$this->installer->set_iohandler($this->iohandler_factory->get());
|
||||
|
||||
// Set up navigation
|
||||
$nav_data = $this->installer_config->get_navigation_data();
|
||||
/** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */
|
||||
$iohandler = $this->iohandler_factory->get();
|
||||
|
||||
// Set active navigation stage
|
||||
if (isset($nav_data['active']) && is_array($nav_data['active']))
|
||||
{
|
||||
$iohandler->set_active_stage_menu($nav_data['active']);
|
||||
$this->menu_provider->set_nav_property($nav_data['active'], array(
|
||||
'selected' => true,
|
||||
'completed' => false,
|
||||
));
|
||||
}
|
||||
|
||||
// Set finished navigation stages
|
||||
if (isset($nav_data['finished']) && is_array($nav_data['finished']))
|
||||
{
|
||||
foreach ($nav_data['finished'] as $finished_stage)
|
||||
{
|
||||
$iohandler->set_finished_stage_menu($finished_stage);
|
||||
$this->menu_provider->set_nav_property($finished_stage, array(
|
||||
'selected' => false,
|
||||
'completed' => true,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->request->is_ajax())
|
||||
{
|
||||
$installer = $this->installer;
|
||||
@@ -193,6 +157,11 @@ class install
|
||||
'TITLE' => $this->language->lang('INSTALL_INTRO'),
|
||||
'CONTENT' => $this->language->lang('INSTALL_INTRO_BODY'),
|
||||
));
|
||||
|
||||
/** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */
|
||||
$iohandler = $this->iohandler_factory->get();
|
||||
$this->controller_helper->handle_navigation($iohandler);
|
||||
|
||||
return $this->controller_helper->render('installer_install.html', 'INSTALL', true);
|
||||
}
|
||||
|
||||
|
162
phpBB/phpbb/install/controller/update.php
Normal file
162
phpBB/phpbb/install/controller/update.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\controller;
|
||||
|
||||
use phpbb\install\helper\install_helper;
|
||||
use phpbb\install\helper\iohandler\factory;
|
||||
use phpbb\install\helper\navigation\navigation_provider;
|
||||
use phpbb\install\installer;
|
||||
use phpbb\language\language;
|
||||
use phpbb\request\request_interface;
|
||||
use phpbb\template\template;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
/**
|
||||
* Updater controller
|
||||
*/
|
||||
class update
|
||||
{
|
||||
/**
|
||||
* @var helper
|
||||
*/
|
||||
protected $controller_helper;
|
||||
|
||||
/**
|
||||
* @var installer
|
||||
*/
|
||||
protected $installer;
|
||||
|
||||
/**
|
||||
* @var install_helper
|
||||
*/
|
||||
protected $install_helper;
|
||||
|
||||
/**
|
||||
* @var factory
|
||||
*/
|
||||
protected $iohandler_factory;
|
||||
|
||||
/**
|
||||
* @var language
|
||||
*/
|
||||
protected $language;
|
||||
|
||||
/**
|
||||
* @var navigation_provider
|
||||
*/
|
||||
protected $menu_provider;
|
||||
|
||||
/**
|
||||
* @var request_interface
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var template
|
||||
*/
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param helper $controller_helper
|
||||
* @param installer $installer
|
||||
* @param install_helper $install_helper
|
||||
* @param factory $iohandler
|
||||
* @param language $language
|
||||
* @param navigation_provider $menu_provider
|
||||
* @param request_interface $request
|
||||
* @param template $template
|
||||
*/
|
||||
public function __construct(helper $controller_helper, installer $installer, install_helper $install_helper, factory $iohandler, language $language, navigation_provider $menu_provider, request_interface $request, template $template)
|
||||
{
|
||||
$this->controller_helper = $controller_helper;
|
||||
$this->installer = $installer;
|
||||
$this->install_helper = $install_helper;
|
||||
$this->iohandler_factory = $iohandler;
|
||||
$this->language = $language;
|
||||
$this->menu_provider = $menu_provider;
|
||||
$this->request = $request;
|
||||
$this->template = $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller entry point
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if (!$this->install_helper->is_phpbb_installed())
|
||||
{
|
||||
die ('phpBB is not installed');
|
||||
}
|
||||
|
||||
$this->template->assign_vars(array(
|
||||
'U_ACTION' => $this->controller_helper->route('phpbb_installer_update'),
|
||||
));
|
||||
|
||||
// Set up input-output handler
|
||||
if ($this->request->is_ajax())
|
||||
{
|
||||
$this->iohandler_factory->set_environment('ajax');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->iohandler_factory->set_environment('nojs');
|
||||
}
|
||||
|
||||
// Set the appropriate input-output handler
|
||||
$this->installer->set_iohandler($this->iohandler_factory->get());
|
||||
|
||||
// Render the intro page
|
||||
if ($this->request->is_ajax())
|
||||
{
|
||||
$installer = $this->installer;
|
||||
$response = new StreamedResponse();
|
||||
$response->setCallback(function() use ($installer) {
|
||||
$installer->run();
|
||||
});
|
||||
|
||||
// Try to bypass any server output buffers
|
||||
$response->headers->set('X-Accel-Buffering', 'no');
|
||||
$response->headers->set('Content-type', 'application/json');
|
||||
|
||||
return $response;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->controller_helper->handle_language_select();
|
||||
|
||||
// Set active stage
|
||||
$this->menu_provider->set_nav_property(
|
||||
array('update', 0, 'introduction'),
|
||||
array(
|
||||
'selected' => true,
|
||||
'completed' => false,
|
||||
)
|
||||
);
|
||||
|
||||
$this->template->assign_vars(array(
|
||||
'SHOW_INSTALL_START_FORM' => true,
|
||||
'TITLE' => $this->language->lang('UPDATE_INSTALLATION'),
|
||||
'CONTENT' => $this->language->lang('UPDATE_INSTALLATION_EXPLAIN'),
|
||||
));
|
||||
|
||||
/** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */
|
||||
$iohandler = $this->iohandler_factory->get();
|
||||
$this->controller_helper->handle_navigation($iohandler);
|
||||
|
||||
return $this->controller_helper->render('installer_update.html', 'UPDATE_INSTALLATION', true);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user