From 3dcaa48850bf823b238391fbf9c3f085092010bc Mon Sep 17 00:00:00 2001 From: CHItA Date: Sat, 13 Jun 2015 15:35:19 +0200 Subject: [ticket/13740] Move installer files to phpbb/install directory PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 240 +++++++++++++++++++++ phpBB/phpbb/install/controller/install.php | 185 ++++++++++++++++ phpBB/phpbb/install/controller/installer_index.php | 79 +++++++ 3 files changed, 504 insertions(+) create mode 100644 phpBB/phpbb/install/controller/helper.php create mode 100644 phpBB/phpbb/install/controller/install.php create mode 100644 phpBB/phpbb/install/controller/installer_index.php (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php new file mode 100644 index 0000000000..0df1ae71a4 --- /dev/null +++ b/phpBB/phpbb/install/controller/helper.php @@ -0,0 +1,240 @@ + + * @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 Symfony\Component\HttpFoundation\Response; + +/** + * A duplicate of \phpbb\controller\helper + * + * This class is necessary because of controller\helper's legacy function calls + * to page_header() page_footer() functions which has unavailable dependencies. + */ +class helper +{ + /** + * @var \phpbb\language\language + */ + protected $language; + + /** + * @var \phpbb\language\language_file_helper + */ + protected $lang_helper; + + /** + * @var \phpbb\install\helper\navigation\navigation_provider + */ + protected $navigation_provider; + + /** + * @var \phpbb\template\template + */ + protected $template; + + /** + * @var \phpbb\path_helper + */ + protected $path_helper; + + /** + * @var \phpbb\symfony_request + */ + protected $request; + + /** + * @var \phpbb\routing\router + */ + protected $router; + + /** + * @var string + */ + protected $phpbb_admin_path; + + /** + * @var string + */ + protected $phpbb_root_path; + + public function __construct(\phpbb\language\language $language, \phpbb\language\language_file_helper $lang_helper, \phpbb\install\helper\navigation\navigation_provider $nav, \phpbb\template\template $template, \phpbb\path_helper $path_helper, \phpbb\symfony_request $request, \phpbb\routing\router $router, $phpbb_root_path) + { + $this->language = $language; + $this->lang_helper = $lang_helper; + $this->navigation_provider = $nav; + $this->template = $template; + $this->path_helper = $path_helper; + $this->request = $request; + $this->router = $router; + $this->phpbb_root_path = $phpbb_root_path; + $this->phpbb_admin_path = $phpbb_root_path . 'adm/'; + } + + /** + * Automate setting up the page and creating the response object. + * + * @param string $template_file The template handle to render + * @param string $page_title The title of the page to output + * @param int $status_code The status code to be sent to the page header + * + * @return Response object containing rendered page + */ + public function render($template_file, $page_title = '', $status_code = 200) + { + $this->page_header($page_title); + + $this->template->set_filenames(array( + 'body' => $template_file, + )); + + return new Response($this->template->assign_display('body'), $status_code); + } + + /** + * Set default template variables + * + * @param string $page_title + */ + protected function page_header($page_title) + { + $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/', + + '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_USER_LANG' => $this->language->lang('USER_LANG'), + ) + ); + + $this->render_navigation(); + } + + /** + * Render navigation + */ + protected function render_navigation() + { + // Get navigation items + $nav_array = $this->navigation_provider->get(); + + // @todo Sort navs by order + + $active_main_menu = $this->get_active_main_menu($nav_array); + + // Pass navigation to template + foreach ($nav_array as $key => $entry) + { + $this->template->assign_block_vars('t_block1', array( + 'L_TITLE' => $this->language->lang($entry['label']), + 'S_SELECTED' => ($active_main_menu === $key), + 'U_TITLE' => $this->route($entry['route']), + )); + + if (is_array($entry[0]) && $active_main_menu === $key) + { + // @todo Sort navs by order + + foreach ($entry[0] as $name => $sub_entry) + { + if (isset($sub_entry['stage']) && $sub_entry['stage'] === true) + { + $this->template->assign_block_vars('l_block2', array( + 'L_TITLE' => $this->language->lang($sub_entry['label']), + 'S_SELECTED' => (isset($sub_entry['selected']) && $sub_entry['selected'] === true), + 'S_COMPLETE' => (isset($sub_entry['completed']) && $sub_entry['completed'] === true), + 'STAGE_NAME' => $name, + )); + } + else + { + $this->template->assign_block_vars('l_block1', array( + 'L_TITLE' => $this->language->lang($sub_entry['label']), + 'S_SELECTED' => (isset($sub_entry['route']) && $sub_entry['route'] === $this->request->get('_route')), + 'U_TITLE' => $this->route($sub_entry['route']), + )); + } + } + } + } + } + + /** + * Returns path from route name + * + * @param string $route_name + * + * @return string + */ + public function route($route_name) + { + $url = $this->router->generate($route_name); + + return $url; + } + + /** + * Render language select form + */ + protected function render_language_select() + { + $langs = $this->lang_helper->get_available_languages(); + } + + /** + * Returns the name of the active main menu item + * + * @param array $nav_array + * + * @return string|bool Returns the name of the active main menu element, if the element not found, returns false + */ + protected function get_active_main_menu($nav_array) + { + $active_route = $this->request->get('_route'); + + foreach ($nav_array as $nav_name => $nav_options) + { + $current_menu = $nav_name; + + if (isset($nav_options['route']) && $nav_options['route'] === $active_route) + { + return $nav_name; + } + + if (is_array($nav_options[0])) + { + foreach ($nav_options[0] as $sub_menus) + { + if (isset($sub_menus['route']) &&$sub_menus['route'] === $active_route) + { + return $current_menu; + } + } + } + } + + return false; + } +} diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php new file mode 100644 index 0000000000..c1329b6456 --- /dev/null +++ b/phpBB/phpbb/install/controller/install.php @@ -0,0 +1,185 @@ + + * @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 phpbb\install\helper\navigation\navigation_provider; +use Symfony\Component\HttpFoundation\StreamedResponse; +use Symfony\Component\HttpFoundation\Response; +use phpbb\install\helper\iohandler\factory; +use phpbb\install\controller\helper; +use phpbb\template\template; +use phpbb\request\request_interface; +use phpbb\install\installer; +use phpbb\language\language; + +/** + * Controller for installing phpBB + */ +class install +{ + /** + * @var helper + */ + protected $controller_helper; + + /** + * @var config + */ + protected $installer_config; + + /** + * @var factory + */ + protected $iohandler_factory; + + /** + * @var navigation_provider + */ + protected $menu_provider; + + /** + * @var language + */ + protected $language; + + /** + * @var template + */ + protected $template; + + /** + * @var request_interface + */ + protected $request; + + /** + * @var installer + */ + protected $installer; + + /** + * Constructor + * + * @param helper $helper + * @param config $install_config + * @param factory $factory + * @param navigation_provider $nav_provider + * @param language $language + * @param request_interface $request + * @param installer $installer + */ + public function __construct(helper $helper, config $install_config, factory $factory, navigation_provider $nav_provider, language $language, template $template, request_interface $request, installer $installer) + { + $this->controller_helper = $helper; + $this->installer_config = $install_config; + $this->iohandler_factory = $factory; + $this->menu_provider = $nav_provider; + $this->language = $language; + $this->template = $template; + $this->request = $request; + $this->installer = $installer; + } + + /** + * Controller logic + * + * @return Response|StreamedResponse + */ + public function handle() + { + // @todo check that phpBB is not already installed + + $this->template->assign_vars(array( + 'U_ACTION' => $this->controller_helper->route('phpbb_installer_install'), + )); + + // 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()); + + // 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; + $response = new StreamedResponse(); + $response->setCallback(function() use ($installer) { + $installer->run(); + }); + + return $response; + } + else + { + // Determine whether the installation was started or not + if (true) + { + // Set active stage + $this->menu_provider->set_nav_property( + array('install', 0, 'introduction'), + array( + 'selected' => true, + 'completed' => false, + ) + ); + + // If not, let's render the welcome page + $this->template->assign_vars(array( + 'SHOW_INSTALL_START_FORM' => true, + 'TITLE' => $this->language->lang('INSTALL_INTRO'), + 'CONTENT' => $this->language->lang('INSTALL_INTRO_BODY'), + )); + return $this->controller_helper->render('installer_install.html', 'INSTALL'); + } + + // @todo: implement no js controller logic + } + } +} diff --git a/phpBB/phpbb/install/controller/installer_index.php b/phpBB/phpbb/install/controller/installer_index.php new file mode 100644 index 0000000000..3d5224f1be --- /dev/null +++ b/phpBB/phpbb/install/controller/installer_index.php @@ -0,0 +1,79 @@ + + * @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; + +class installer_index +{ + /** + * @var helper + */ + protected $helper; + + /** + * @var \phpbb\language\language + */ + protected $language; + + /** + * @var \phpbb\template\template + */ + protected $template; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * Constructor + * + * @param helper $helper + * @param \phpbb\language\language $language + * @param \phpbb\template\template $template + * @param string $phpbb_root_path + */ + public function __construct(helper $helper, \phpbb\language\language $language, \phpbb\template\template $template, $phpbb_root_path) + { + $this->helper = $helper; + $this->language = $language; + $this->template = $template; + $this->phpbb_root_path = $phpbb_root_path; + } + + public function handle($mode) + { + switch ($mode) + { + case "intro": + $title = $this->language->lang('INTRODUCTION_TITLE'); + $body = $this->language->lang('INTRODUCTION_BODY'); + break; + case "support": + $title = $this->language->lang('SUPPORT_TITLE'); + $body = $this->language->lang('SUPPORT_BODY'); + break; + case "license": + $title = $this->language->lang('LICENSE_TITLE'); + $body = implode("
\n", file($this->phpbb_root_path . 'docs/LICENSE.txt')); + break; + } + + $this->template->assign_vars(array( + 'TITLE' => $title, + 'BODY' => $body, + )); + + return $this->helper->render('install_main.html', $title); + } +} -- cgit v1.2.1 From c53ce3d5fbfcdc9924426aee74fb1097138a8a42 Mon Sep 17 00:00:00 2001 From: CHItA Date: Wed, 17 Jun 2015 11:00:07 +0200 Subject: [ticket/13740] Fix CS and extend phpbb extensions [ci skip] PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 0df1ae71a4..8445d80a41 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -13,6 +13,13 @@ namespace phpbb\install\controller; +use phpbb\install\helper\navigation\navigation_provider; +use phpbb\language\language; +use phpbb\language\language_file_helper; +use phpbb\path_helper; +use phpbb\routing\router; +use phpbb\symfony_request; +use phpbb\template\template; use Symfony\Component\HttpFoundation\Response; /** @@ -68,7 +75,19 @@ class helper */ protected $phpbb_root_path; - public function __construct(\phpbb\language\language $language, \phpbb\language\language_file_helper $lang_helper, \phpbb\install\helper\navigation\navigation_provider $nav, \phpbb\template\template $template, \phpbb\path_helper $path_helper, \phpbb\symfony_request $request, \phpbb\routing\router $router, $phpbb_root_path) + /** + * Constructor + * + * @param language $language + * @param language_file_helper $lang_helper + * @param navigation_provider $nav + * @param template $template + * @param path_helper $path_helper + * @param symfony_request $request + * @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, symfony_request $request, router $router, $phpbb_root_path) { $this->language = $language; $this->lang_helper = $lang_helper; -- cgit v1.2.1 From c5c98b7ca2dfb85925bc3ec1d6057ec554f9b4f9 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 14 Jul 2015 23:14:35 +0200 Subject: [ticket/13740] Implement navigation sorting PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 35 +++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 8445d80a41..5ef98ac2bb 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -158,8 +158,7 @@ class helper { // Get navigation items $nav_array = $this->navigation_provider->get(); - - // @todo Sort navs by order + $nav_array = $this->sort_navigation_level($nav_array); $active_main_menu = $this->get_active_main_menu($nav_array); @@ -174,7 +173,7 @@ class helper if (is_array($entry[0]) && $active_main_menu === $key) { - // @todo Sort navs by order + $entry[0] = $this->sort_navigation_level($entry[0]); foreach ($entry[0] as $name => $sub_entry) { @@ -220,6 +219,7 @@ class helper protected function render_language_select() { $langs = $this->lang_helper->get_available_languages(); + // @todo } /** @@ -246,7 +246,7 @@ class helper { foreach ($nav_options[0] as $sub_menus) { - if (isset($sub_menus['route']) &&$sub_menus['route'] === $active_route) + if (isset($sub_menus['route']) && $sub_menus['route'] === $active_route) { return $current_menu; } @@ -256,4 +256,31 @@ class helper return false; } + + /** + * Sorts the top level of navigation array + * + * @param array $nav_array Navigation array + * + * @return array + */ + protected function sort_navigation_level($nav_array) + { + $sorted = array(); + foreach ($nav_array as $nav) + { + $order = (isset($nav['order'])) ? $nav['order'] : 0; + $sorted[$order][] = $nav; + } + + // Linearization of navigation array + $nav_array = array(); + ksort($sorted); + foreach ($sorted as $nav) + { + $nav_array = array_merge($nav_array, $nav); + } + + return $nav_array; + } } -- cgit v1.2.1 From 6216007caaa884bdbca8bbb5e098ff231b5a36a6 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 20 Jul 2015 18:47:10 +0200 Subject: [ticket/13740] Fix docblocks and comments PHPBB3-13740 --- phpBB/phpbb/install/controller/install.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index c1329b6456..c742906305 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -77,6 +77,7 @@ class install * @param factory $factory * @param navigation_provider $nav_provider * @param language $language + * @param template $template * @param request_interface $request * @param installer $installer */ -- cgit v1.2.1 From 0488c49116f77de55da3ddf36aa2b08f6a5fd085 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 20 Jul 2015 19:26:07 +0200 Subject: [ticket/13740] Exit from installation if phpBB is already installed PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 2 +- phpBB/phpbb/install/controller/install.php | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 5ef98ac2bb..a16298c525 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -219,7 +219,7 @@ class helper protected function render_language_select() { $langs = $this->lang_helper->get_available_languages(); - // @todo + // @todo Implement language change option } /** diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index c742906305..5cd42fcb84 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -13,7 +13,9 @@ namespace phpbb\install\controller; +use phpbb\exception\http_exception; use phpbb\install\helper\config; +use phpbb\install\helper\install_helper; use phpbb\install\helper\navigation\navigation_provider; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\Response; @@ -69,6 +71,11 @@ class install */ protected $installer; + /** + * @var install_helper + */ + protected $install_helper; + /** * Constructor * @@ -80,8 +87,9 @@ class install * @param template $template * @param request_interface $request * @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) + 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) { $this->controller_helper = $helper; $this->installer_config = $install_config; @@ -91,6 +99,7 @@ class install $this->template = $template; $this->request = $request; $this->installer = $installer; + $this->install_helper = $install_helper; } /** @@ -100,8 +109,6 @@ class install */ public function handle() { - // @todo check that phpBB is not already installed - $this->template->assign_vars(array( 'U_ACTION' => $this->controller_helper->route('phpbb_installer_install'), )); @@ -124,6 +131,11 @@ class install /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */ $iohandler = $this->iohandler_factory->get(); + if ($this->install_helper->is_phpbb_installed()) + { + throw new http_exception(404, 'PAGE_NOT_FOUND'); + } + // Set active navigation stage if (isset($nav_data['active']) && is_array($nav_data['active'])) { -- cgit v1.2.1 From b2b9fb1df2e6d37c8a327b7b6c380f19e1ff6496 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 21 Jul 2015 14:42:15 +0200 Subject: [ticket/13740] Fix CS and docblocks PHPBB3-13740 --- phpBB/phpbb/install/controller/install.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 5cd42fcb84..b3103c8284 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -109,6 +109,11 @@ class install */ public function handle() { + if ($this->install_helper->is_phpbb_installed()) + { + throw new http_exception(404, 'PAGE_NOT_FOUND'); + } + $this->template->assign_vars(array( 'U_ACTION' => $this->controller_helper->route('phpbb_installer_install'), )); @@ -131,11 +136,6 @@ class install /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */ $iohandler = $this->iohandler_factory->get(); - if ($this->install_helper->is_phpbb_installed()) - { - throw new http_exception(404, 'PAGE_NOT_FOUND'); - } - // Set active navigation stage if (isset($nav_data['active']) && is_array($nav_data['active'])) { -- cgit v1.2.1 From 136ec8d7e25efe7b466cb41f80dc5a75a51eaa68 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 21 Jul 2015 15:53:26 +0200 Subject: [ticket/13740] Keep keys when sorting navigation PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index a16298c525..569938be09 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -267,10 +267,10 @@ class helper protected function sort_navigation_level($nav_array) { $sorted = array(); - foreach ($nav_array as $nav) + foreach ($nav_array as $key => $nav) { $order = (isset($nav['order'])) ? $nav['order'] : 0; - $sorted[$order][] = $nav; + $sorted[$order][$key] = $nav; } // Linearization of navigation array -- cgit v1.2.1 From 97d08d6f56cf448fd4def8a4d29c570da91faa89 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 22 Jul 2015 03:16:16 +0200 Subject: [ticket/13740] Allow language change in the installer PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 165 +++++++++++++++------ phpBB/phpbb/install/controller/install.php | 2 +- phpBB/phpbb/install/controller/installer_index.php | 2 +- 3 files changed, 121 insertions(+), 48 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 569938be09..5fd0abf9c7 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -17,10 +17,13 @@ use phpbb\install\helper\navigation\navigation_provider; use phpbb\language\language; use phpbb\language\language_file_helper; use phpbb\path_helper; +use phpbb\request\request; +use phpbb\request\request_interface; use phpbb\routing\router; use phpbb\symfony_request; use phpbb\template\template; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\Cookie; /** * A duplicate of \phpbb\controller\helper @@ -35,6 +38,11 @@ class helper */ protected $language; + /** + * @var bool|string + */ + protected $language_cookie; + /** * @var \phpbb\language\language_file_helper */ @@ -55,6 +63,11 @@ class helper */ protected $path_helper; + /** + * @var \phpbb\request\request + */ + protected $phpbb_request; + /** * @var \phpbb\symfony_request */ @@ -83,49 +96,117 @@ class helper * @param navigation_provider $nav * @param template $template * @param path_helper $path_helper + * @param request $phpbb_request * @param symfony_request $request * @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, symfony_request $request, router $router, $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) { $this->language = $language; + $this->language_cookie = false; $this->lang_helper = $lang_helper; $this->navigation_provider = $nav; $this->template = $template; $this->path_helper = $path_helper; + $this->phpbb_request = $phpbb_request; $this->request = $request; $this->router = $router; $this->phpbb_root_path = $phpbb_root_path; $this->phpbb_admin_path = $phpbb_root_path . 'adm/'; + + $this->handle_language_select(); } /** * Automate setting up the page and creating the response object. * - * @param string $template_file The template handle to render - * @param string $page_title The title of the page to output - * @param int $status_code The status code to be sent to the page header + * @param string $template_file The template handle to render + * @param string $page_title The title of the page to output + * @param bool $selected_language True to enable language selector it, false otherwise + * @param int $status_code The status code to be sent to the page header * * @return Response object containing rendered page */ - public function render($template_file, $page_title = '', $status_code = 200) + public function render($template_file, $page_title = '', $selected_language = false, $status_code = 200) { - $this->page_header($page_title); + $this->page_header($page_title, $selected_language); $this->template->set_filenames(array( 'body' => $template_file, )); - return new Response($this->template->assign_display('body'), $status_code); + $response = new Response($this->template->assign_display('body'), $status_code); + + // Set language cookie + if ($this->language_cookie !== false) + { + $cookie = new Cookie('lang', $this->language_cookie, time() + 3600); + $response->headers->setCookie($cookie); + + $this->language_cookie = false; + } + + return $response; + } + + /** + * Returns path from route name + * + * @param string $route_name + * + * @return string + */ + public function route($route_name) + { + $url = $this->router->generate($route_name); + + return $url; + } + + /** + * Handles language selector form + */ + protected function handle_language_select() + { + $lang = null; + + // Check if language form has been submited + $submit = $this->phpbb_request->variable('change_lang', ''); + if (!empty($submit)) + { + $lang = $this->phpbb_request->variable('language', ''); + + if (!empty($lang)) + { + $this->language_cookie = $lang; + } + } + + // Retrive language from cookie + $lang_cookie = $this->phpbb_request->variable('lang', '', false, request_interface::COOKIE); + if (empty($lang) && !empty($lang_cookie)) + { + $lang = $lang_cookie; + $this->language_cookie = $lang; + } + + $lang = (!empty($lang)) ? $lang : null; + $this->render_language_select($lang); + + if ($lang !== null) + { + $this->language->set_user_language($lang, true); + } } /** * Set default template variables * - * @param string $page_title + * @param string $page_title Title of the page + * @param bool $selected_language True to enable language selector it, false otherwise */ - protected function page_header($page_title) + protected function page_header($page_title, $selected_language = false) { $this->template->assign_vars(array( 'L_CHANGE' => $this->language->lang('CHANGE'), @@ -143,6 +224,7 @@ class helper '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'), ) @@ -151,6 +233,8 @@ class helper $this->render_navigation(); } + + /** * Render navigation */ @@ -163,35 +247,29 @@ class helper $active_main_menu = $this->get_active_main_menu($nav_array); // Pass navigation to template - foreach ($nav_array as $key => $entry) - { + foreach ($nav_array as $key => $entry) { $this->template->assign_block_vars('t_block1', array( - 'L_TITLE' => $this->language->lang($entry['label']), - 'S_SELECTED' => ($active_main_menu === $key), - 'U_TITLE' => $this->route($entry['route']), + 'L_TITLE' => $this->language->lang($entry['label']), + 'S_SELECTED' => ($active_main_menu === $key), + 'U_TITLE' => $this->route($entry['route']), )); - if (is_array($entry[0]) && $active_main_menu === $key) - { + if (is_array($entry[0]) && $active_main_menu === $key) { $entry[0] = $this->sort_navigation_level($entry[0]); - foreach ($entry[0] as $name => $sub_entry) - { - if (isset($sub_entry['stage']) && $sub_entry['stage'] === true) - { + foreach ($entry[0] as $name => $sub_entry) { + if (isset($sub_entry['stage']) && $sub_entry['stage'] === true) { $this->template->assign_block_vars('l_block2', array( - 'L_TITLE' => $this->language->lang($sub_entry['label']), - 'S_SELECTED' => (isset($sub_entry['selected']) && $sub_entry['selected'] === true), - 'S_COMPLETE' => (isset($sub_entry['completed']) && $sub_entry['completed'] === true), - 'STAGE_NAME' => $name, + 'L_TITLE' => $this->language->lang($sub_entry['label']), + 'S_SELECTED' => (isset($sub_entry['selected']) && $sub_entry['selected'] === true), + 'S_COMPLETE' => (isset($sub_entry['completed']) && $sub_entry['completed'] === true), + 'STAGE_NAME' => $name, )); - } - else - { + } else { $this->template->assign_block_vars('l_block1', array( - 'L_TITLE' => $this->language->lang($sub_entry['label']), - 'S_SELECTED' => (isset($sub_entry['route']) && $sub_entry['route'] === $this->request->get('_route')), - 'U_TITLE' => $this->route($sub_entry['route']), + 'L_TITLE' => $this->language->lang($sub_entry['label']), + 'S_SELECTED' => (isset($sub_entry['route']) && $sub_entry['route'] === $this->request->get('_route')), + 'U_TITLE' => $this->route($sub_entry['route']), )); } } @@ -199,27 +277,22 @@ class helper } } - /** - * Returns path from route name - * - * @param string $route_name - * - * @return string - */ - public function route($route_name) - { - $url = $this->router->generate($route_name); - - return $url; - } - /** * Render language select form + * + * @param string $selected_language */ - protected function render_language_select() + protected function render_language_select($selected_language = null) { $langs = $this->lang_helper->get_available_languages(); - // @todo Implement language change option + foreach ($langs as $lang) + { + $this->template->assign_block_vars('language_select_item', array( + 'VALUE' => $lang['iso'], + 'NAME' => $lang['local_name'], + 'SELECTED' => ($lang['iso'] === $selected_language), + )); + } } /** diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index b3103c8284..da806948fb 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -189,7 +189,7 @@ class install 'TITLE' => $this->language->lang('INSTALL_INTRO'), 'CONTENT' => $this->language->lang('INSTALL_INTRO_BODY'), )); - return $this->controller_helper->render('installer_install.html', 'INSTALL'); + return $this->controller_helper->render('installer_install.html', 'INSTALL', true); } // @todo: implement no js controller logic diff --git a/phpBB/phpbb/install/controller/installer_index.php b/phpBB/phpbb/install/controller/installer_index.php index 3d5224f1be..0a1855f4e5 100644 --- a/phpBB/phpbb/install/controller/installer_index.php +++ b/phpBB/phpbb/install/controller/installer_index.php @@ -74,6 +74,6 @@ class installer_index 'BODY' => $body, )); - return $this->helper->render('install_main.html', $title); + return $this->helper->render('install_main.html', $title, true); } } -- cgit v1.2.1 From 0c49b88dde77894a91145314d2d3bf4388082075 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 22 Jul 2015 04:01:52 +0200 Subject: [ticket/13740] Fix CS PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 5fd0abf9c7..f3400e6ef0 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -233,8 +233,6 @@ class helper $this->render_navigation(); } - - /** * Render navigation */ @@ -247,25 +245,31 @@ class helper $active_main_menu = $this->get_active_main_menu($nav_array); // Pass navigation to template - foreach ($nav_array as $key => $entry) { + foreach ($nav_array as $key => $entry) + { $this->template->assign_block_vars('t_block1', array( 'L_TITLE' => $this->language->lang($entry['label']), 'S_SELECTED' => ($active_main_menu === $key), 'U_TITLE' => $this->route($entry['route']), )); - if (is_array($entry[0]) && $active_main_menu === $key) { + if (is_array($entry[0]) && $active_main_menu === $key) + { $entry[0] = $this->sort_navigation_level($entry[0]); - foreach ($entry[0] as $name => $sub_entry) { - if (isset($sub_entry['stage']) && $sub_entry['stage'] === true) { + foreach ($entry[0] as $name => $sub_entry) + { + if (isset($sub_entry['stage']) && $sub_entry['stage'] === true) + { $this->template->assign_block_vars('l_block2', array( 'L_TITLE' => $this->language->lang($sub_entry['label']), 'S_SELECTED' => (isset($sub_entry['selected']) && $sub_entry['selected'] === true), 'S_COMPLETE' => (isset($sub_entry['completed']) && $sub_entry['completed'] === true), 'STAGE_NAME' => $name, )); - } else { + } + else + { $this->template->assign_block_vars('l_block1', array( 'L_TITLE' => $this->language->lang($sub_entry['label']), 'S_SELECTED' => (isset($sub_entry['route']) && $sub_entry['route'] === $this->request->get('_route')), -- cgit v1.2.1 From 3356130ce2adf82248cf64fcaa81a47713ce7987 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 22 Jul 2015 12:43:17 +0200 Subject: [ticket/13740] Separate new installer style templates PHPBB3-13740 --- phpBB/phpbb/install/controller/installer_index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/installer_index.php b/phpBB/phpbb/install/controller/installer_index.php index 0a1855f4e5..8e1874984b 100644 --- a/phpBB/phpbb/install/controller/installer_index.php +++ b/phpBB/phpbb/install/controller/installer_index.php @@ -74,6 +74,6 @@ class installer_index 'BODY' => $body, )); - return $this->helper->render('install_main.html', $title, true); + return $this->helper->render('installer_main.html', $title, true); } } -- cgit v1.2.1 From dd31020fb3dd4ab96b48dd1854f73190900319b1 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 23 Jul 2015 16:43:20 +0200 Subject: [ticket/13740] Enhance server output buffer bypass PHPBB3-13740 --- phpBB/phpbb/install/controller/install.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index da806948fb..469e2608a4 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -167,6 +167,9 @@ class install $installer->run(); }); + // Try to bypass any server output buffers + $response->headers->set('X-Accel-Buffering', 'no'); + return $response; } else -- cgit v1.2.1 From e08f1341127792e378580a10bbb0bdeafe93ff8d Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 23 Jul 2015 22:55:31 +0200 Subject: [ticket/13740] Fix is_phpbb_installed() method PHPBB3-13740 --- phpBB/phpbb/install/controller/install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 469e2608a4..904f5920c2 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -111,7 +111,7 @@ class install { if ($this->install_helper->is_phpbb_installed()) { - throw new http_exception(404, 'PAGE_NOT_FOUND'); + die ('phpBB is already installed'); } $this->template->assign_vars(array( -- cgit v1.2.1 From cb593c0e04fc9f3318443fe42b596d27498729c3 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 24 Jul 2015 00:04:40 +0200 Subject: [ticket/13740] Filter basic directory change attempts in lang change PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index f3400e6ef0..8530a0defe 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -191,7 +191,8 @@ class helper $this->language_cookie = $lang; } - $lang = (!empty($lang)) ? $lang : null; + $lang = (!empty($lang) && strpos($lang, '/')) ? $lang : null; + $this->render_language_select($lang); if ($lang !== null) -- cgit v1.2.1 From 22786a5b6fcdab1610b609ae069065c5d6691496 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 24 Jul 2015 02:37:00 +0200 Subject: [ticket/13740] Fix CS PHPBB3-13740 --- phpBB/phpbb/install/controller/install.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 904f5920c2..c21b0d831b 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -13,7 +13,6 @@ namespace phpbb\install\controller; -use phpbb\exception\http_exception; use phpbb\install\helper\config; use phpbb\install\helper\install_helper; use phpbb\install\helper\navigation\navigation_provider; -- cgit v1.2.1 From 04186e8498c78d16f8eb5402c19d70e9e7795e83 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 25 Jul 2015 14:42:17 +0200 Subject: [ticket/13740] Fix comment PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 8530a0defe..6d591786c4 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -183,7 +183,7 @@ class helper } } - // Retrive language from cookie + // Retrieve language from cookie $lang_cookie = $this->phpbb_request->variable('lang', '', false, request_interface::COOKIE); if (empty($lang) && !empty($lang_cookie)) { -- cgit v1.2.1 From 495c0c6fb32ac0b720fccfeb640a0b3d5a32b98f Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 26 Jul 2015 22:20:32 +0200 Subject: [ticket/13740] Move handle_language_select calls to the controllers PHPBB3-13740 --- phpBB/phpbb/install/controller/helper.php | 4 +--- phpBB/phpbb/install/controller/install.php | 2 ++ phpBB/phpbb/install/controller/installer_index.php | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 6d591786c4..fdfa6821ed 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -114,8 +114,6 @@ class helper $this->router = $router; $this->phpbb_root_path = $phpbb_root_path; $this->phpbb_admin_path = $phpbb_root_path . 'adm/'; - - $this->handle_language_select(); } /** @@ -167,7 +165,7 @@ class helper /** * Handles language selector form */ - protected function handle_language_select() + public function handle_language_select() { $lang = null; diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index c21b0d831b..80f6651a39 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -176,6 +176,8 @@ class install // Determine whether the installation was started or not if (true) { + $this->controller_helper->handle_language_select(); + // Set active stage $this->menu_provider->set_nav_property( array('install', 0, 'introduction'), diff --git a/phpBB/phpbb/install/controller/installer_index.php b/phpBB/phpbb/install/controller/installer_index.php index 8e1874984b..c2d9572284 100644 --- a/phpBB/phpbb/install/controller/installer_index.php +++ b/phpBB/phpbb/install/controller/installer_index.php @@ -53,6 +53,8 @@ class installer_index public function handle($mode) { + $this->helper->handle_language_select(); + switch ($mode) { case "intro": -- cgit v1.2.1 From 8f5a0ad6f73e7b7757b02c827436384c96069b5a Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 24 Jul 2015 09:20:50 +0200 Subject: [ticket/14039] Revamp updater PHPBB3-14039 --- .../phpbb/install/controller/archive_download.php | 92 ++++++++++++ phpBB/phpbb/install/controller/helper.php | 96 +++++++++--- phpBB/phpbb/install/controller/install.php | 43 +----- phpBB/phpbb/install/controller/update.php | 162 +++++++++++++++++++++ 4 files changed, 335 insertions(+), 58 deletions(-) create mode 100644 phpBB/phpbb/install/controller/archive_download.php create mode 100644 phpBB/phpbb/install/controller/update.php (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/archive_download.php b/phpBB/phpbb/install/controller/archive_download.php new file mode 100644 index 0000000000..711e1f2f0c --- /dev/null +++ b/phpBB/phpbb/install/controller/archive_download.php @@ -0,0 +1,92 @@ + + * @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; + } +} diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index fdfa6821ed..ef6b8ba3c2 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -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/', - - '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'), - ) - ); + '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_USER_LANG' => $this->language->lang('USER_LANG'), + )); $this->render_navigation(); } diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 80f6651a39..8d5ff95958 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -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); } diff --git a/phpBB/phpbb/install/controller/update.php b/phpBB/phpbb/install/controller/update.php new file mode 100644 index 0000000000..5212ba7f26 --- /dev/null +++ b/phpBB/phpbb/install/controller/update.php @@ -0,0 +1,162 @@ + + * @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); + } + } +} -- cgit v1.2.1 From 85eb6a0bc0575c687eb43efe61cf206b26b26af8 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 11:21:56 +0200 Subject: [ticket/14039] Fix language constants and comments PHPBB3-14039 --- phpBB/phpbb/install/controller/archive_download.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/archive_download.php b/phpBB/phpbb/install/controller/archive_download.php index 711e1f2f0c..e1f7634963 100644 --- a/phpBB/phpbb/install/controller/archive_download.php +++ b/phpBB/phpbb/install/controller/archive_download.php @@ -38,7 +38,7 @@ class archive_download /** * Sends response with the merge conflict archive * - * Merge conflicts are always have to be resolved manually, + * Merge conflicts always have to be resolved manually, * so we use a different archive for that. * * @return BinaryFileResponse -- cgit v1.2.1 From afe91fa7d3af0d30389c49428b30c9aeb0fe0916 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 11:22:19 +0200 Subject: [ticket/14039] Fix T_TEMPLATE_PATH constant PHPBB3-14039 --- phpBB/phpbb/install/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index ef6b8ba3c2..bfa9ec6238 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -271,7 +271,7 @@ class helper '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_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'), -- cgit v1.2.1 From 100bb8f27c52b2faffddf2a6926c5d7b49faa421 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 11:26:41 +0200 Subject: [ticket/14039] Use http_exception instead of die() PHPBB3-14039 --- phpBB/phpbb/install/controller/archive_download.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/archive_download.php b/phpBB/phpbb/install/controller/archive_download.php index e1f7634963..a0f0ba181d 100644 --- a/phpBB/phpbb/install/controller/archive_download.php +++ b/phpBB/phpbb/install/controller/archive_download.php @@ -13,6 +13,7 @@ namespace phpbb\install\controller; +use phpbb\exception\http_exception; use phpbb\install\helper\config; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\ResponseHeaderBag; @@ -49,7 +50,7 @@ class archive_download if (!$filename) { - die ('The requested file is not exist.'); + throw new http_exception(404, 'URL_NOT_FOUND'); } return $this->send_response($filename); @@ -66,7 +67,7 @@ class archive_download if (!$filename) { - die ('The requested file is not exist.'); + throw new http_exception(404, 'URL_NOT_FOUND'); } return $this->send_response($filename); -- cgit v1.2.1 From 719f42c54a45ab669a983964c1e8a6f75a4d4b02 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 30 Oct 2015 15:46:39 +0100 Subject: [ticket/14044] Fix language selection data loss PHPBB3-14044 --- phpBB/phpbb/install/controller/helper.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index bfa9ec6238..fdb07d9c4a 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -204,6 +204,7 @@ class helper if ($lang !== null) { $this->language->set_user_language($lang, true); + $this->installer_config->set('user_language', $lang); } } -- cgit v1.2.1 From 93b37b24c2d546a2bc80830508d64338a24f9afa Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 4 Nov 2015 14:00:59 +0100 Subject: [ticket/14269] Use http_exceptions in the installer instead of die() PHPBB3-14269 --- phpBB/phpbb/install/controller/install.php | 5 ++++- phpBB/phpbb/install/controller/update.php | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 8d5ff95958..0fd4e8897c 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -13,6 +13,7 @@ namespace phpbb\install\controller; +use phpbb\exception\http_exception; use phpbb\install\helper\install_helper; use phpbb\install\helper\navigation\navigation_provider; use Symfony\Component\HttpFoundation\StreamedResponse; @@ -97,12 +98,14 @@ class install * Controller logic * * @return Response|StreamedResponse + * + * @throws http_exception When phpBB is already installed */ public function handle() { if ($this->install_helper->is_phpbb_installed()) { - die ('phpBB is already installed'); + throw new http_exception(404, 'INSTALL_PHPBB_IS_ALREADY_INSTALLED'); } $this->template->assign_vars(array( diff --git a/phpBB/phpbb/install/controller/update.php b/phpBB/phpbb/install/controller/update.php index 5212ba7f26..6a4341710a 100644 --- a/phpBB/phpbb/install/controller/update.php +++ b/phpBB/phpbb/install/controller/update.php @@ -13,6 +13,7 @@ namespace phpbb\install\controller; +use phpbb\exception\http_exception; use phpbb\install\helper\install_helper; use phpbb\install\helper\iohandler\factory; use phpbb\install\helper\navigation\navigation_provider; @@ -93,12 +94,16 @@ class update /** * Controller entry point + * + * @return Response|StreamedResponse + * + * @throws http_exception When phpBB is not installed */ public function handle() { if (!$this->install_helper->is_phpbb_installed()) { - die ('phpBB is not installed'); + throw new http_exception(404, 'INSTALL_PHPBB_IS_NOT_INSTALLED'); } $this->template->assign_vars(array( -- cgit v1.2.1 From 4aac878ec792cfbae01b708dd3d0336a75704405 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 29 Nov 2015 15:49:18 +0100 Subject: [ticket/14320] Fix language selector in the installer PHPBB3-14320 --- phpBB/phpbb/install/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index fdb07d9c4a..ed817f7396 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -197,7 +197,7 @@ class helper $this->language_cookie = $lang; } - $lang = (!empty($lang) && strpos($lang, '/')) ? $lang : null; + $lang = (!empty($lang) && strpos($lang, '/') === false) ? $lang : null; $this->render_language_select($lang); -- cgit v1.2.1 From 02a9264780f3896cf88b9d793dbf8831aa54e029 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 3 Dec 2015 20:31:49 +0100 Subject: [ticket/14269] Fix comments and language var names PHPBB3-14269 --- phpBB/phpbb/install/controller/install.php | 2 +- phpBB/phpbb/install/controller/update.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 0fd4e8897c..baa4e4807a 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -105,7 +105,7 @@ class install { if ($this->install_helper->is_phpbb_installed()) { - throw new http_exception(404, 'INSTALL_PHPBB_IS_ALREADY_INSTALLED'); + throw new http_exception(404, 'INSTALL_PHPBB_INSTALLED'); } $this->template->assign_vars(array( diff --git a/phpBB/phpbb/install/controller/update.php b/phpBB/phpbb/install/controller/update.php index 6a4341710a..8ecd8b3cb8 100644 --- a/phpBB/phpbb/install/controller/update.php +++ b/phpBB/phpbb/install/controller/update.php @@ -103,7 +103,7 @@ class update { if (!$this->install_helper->is_phpbb_installed()) { - throw new http_exception(404, 'INSTALL_PHPBB_IS_NOT_INSTALLED'); + throw new http_exception(404, 'INSTALL_PHPBB_NOT_INSTALLED'); } $this->template->assign_vars(array( -- cgit v1.2.1 From 44a90c9812c4eff73051e75647362859f9407a5f Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 5 Dec 2015 15:42:22 +0100 Subject: [ticket/14269] Change HTTP status codes to 403 PHPBB3-14269 --- phpBB/phpbb/install/controller/install.php | 2 +- phpBB/phpbb/install/controller/update.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index baa4e4807a..8bf9062b08 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -105,7 +105,7 @@ class install { if ($this->install_helper->is_phpbb_installed()) { - throw new http_exception(404, 'INSTALL_PHPBB_INSTALLED'); + throw new http_exception(403, 'INSTALL_PHPBB_INSTALLED'); } $this->template->assign_vars(array( diff --git a/phpBB/phpbb/install/controller/update.php b/phpBB/phpbb/install/controller/update.php index 8ecd8b3cb8..9fff11cae8 100644 --- a/phpBB/phpbb/install/controller/update.php +++ b/phpBB/phpbb/install/controller/update.php @@ -103,7 +103,7 @@ class update { if (!$this->install_helper->is_phpbb_installed()) { - throw new http_exception(404, 'INSTALL_PHPBB_NOT_INSTALLED'); + throw new http_exception(403, 'INSTALL_PHPBB_NOT_INSTALLED'); } $this->template->assign_vars(array( -- cgit v1.2.1 From c02fc0f63fb8098cd4096481ad27b31f8069d5d1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 22 Dec 2015 20:01:22 +0100 Subject: [ticket/14378] Use consistent template variable paths PHPBB3-14378 --- phpBB/phpbb/install/controller/helper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index ed817f7396..2dad42b4b6 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -270,10 +270,10 @@ class helper '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_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/', + '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', -- cgit v1.2.1 From 73e6e5b77faadbb7676961bf38122d669de111db Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Dec 2015 17:50:29 +0100 Subject: [ticket/13454] Remove unused variables This is the first part of the changes. More to come. PHPBB3-13454 --- phpBB/phpbb/install/controller/install.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 8bf9062b08..b987d91c6a 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -19,7 +19,6 @@ use phpbb\install\helper\navigation\navigation_provider; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\Response; use phpbb\install\helper\iohandler\factory; -use phpbb\install\controller\helper; use phpbb\template\template; use phpbb\request\request_interface; use phpbb\install\installer; -- cgit v1.2.1 From a649768e17d25bcf55ae539420abe4eb4b7a1ef1 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Wed, 28 Oct 2015 15:00:11 +0100 Subject: [ticket/14262] Move convertor to controller PHPBB3-14262 --- phpBB/phpbb/install/controller/helper.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 2dad42b4b6..6859414236 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -160,12 +160,13 @@ class helper * Returns path from route name * * @param string $route_name + * @param array $parameters * * @return string */ - public function route($route_name) + public function route($route_name, $parameters = array()) { - $url = $this->router->generate($route_name); + $url = $this->router->generate($route_name, $parameters); return $url; } -- cgit v1.2.1 From debd1bb9d655106eb5454ac4687837c9323a99ae Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 2 Feb 2016 17:53:10 +0100 Subject: [ticket/14321] Clean up arcihve controller logic PHPBB3-14321 --- phpBB/phpbb/install/controller/archive_download.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/archive_download.php b/phpBB/phpbb/install/controller/archive_download.php index a0f0ba181d..eabc0a9976 100644 --- a/phpBB/phpbb/install/controller/archive_download.php +++ b/phpBB/phpbb/install/controller/archive_download.php @@ -46,9 +46,9 @@ class archive_download */ public function conflict_archive() { - $filename = $this->installer_config->get('update_file_conflict_archive', false); + $filename = $this->installer_config->get('update_file_conflict_archive', ''); - if (!$filename) + if (empty($filename)) { throw new http_exception(404, 'URL_NOT_FOUND'); } @@ -65,7 +65,7 @@ class archive_download { $filename = $this->installer_config->get('update_file_archive', ''); - if (!$filename) + if (empty($filename)) { throw new http_exception(404, 'URL_NOT_FOUND'); } -- cgit v1.2.1 From 37705353c53a391aa44da7a30f10ed824a442cfc Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 6 Feb 2016 14:10:48 +0100 Subject: [ticket/14460] Use the selected language with AJAX requests as well PHPBB3-14460 --- phpBB/phpbb/install/controller/helper.php | 7 +------ phpBB/phpbb/install/controller/install.php | 3 +-- phpBB/phpbb/install/controller/update.php | 3 +-- 3 files changed, 3 insertions(+), 10 deletions(-) (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 6859414236..ff7e691224 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -183,11 +183,6 @@ class helper if (!empty($submit)) { $lang = $this->phpbb_request->variable('language', ''); - - if (!empty($lang)) - { - $this->language_cookie = $lang; - } } // Retrieve language from cookie @@ -195,10 +190,10 @@ class helper if (empty($lang) && !empty($lang_cookie)) { $lang = $lang_cookie; - $this->language_cookie = $lang; } $lang = (!empty($lang) && strpos($lang, '/') === false) ? $lang : null; + $this->language_cookie = $lang; $this->render_language_select($lang); diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index b987d91c6a..92506872a3 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -123,6 +123,7 @@ class install // Set the appropriate input-output handler $this->installer->set_iohandler($this->iohandler_factory->get()); + $this->controller_helper->handle_language_select(); if ($this->request->is_ajax()) { @@ -142,8 +143,6 @@ class install // Determine whether the installation was started or not if (true) { - $this->controller_helper->handle_language_select(); - // Set active stage $this->menu_provider->set_nav_property( array('install', 0, 'introduction'), diff --git a/phpBB/phpbb/install/controller/update.php b/phpBB/phpbb/install/controller/update.php index 9fff11cae8..6b88827940 100644 --- a/phpBB/phpbb/install/controller/update.php +++ b/phpBB/phpbb/install/controller/update.php @@ -122,6 +122,7 @@ class update // Set the appropriate input-output handler $this->installer->set_iohandler($this->iohandler_factory->get()); + $this->controller_helper->handle_language_select(); // Render the intro page if ($this->request->is_ajax()) @@ -140,8 +141,6 @@ class update } else { - $this->controller_helper->handle_language_select(); - // Set active stage $this->menu_provider->set_nav_property( array('update', 0, 'introduction'), -- cgit v1.2.1 From 062358f8b1d9a7fa3d9be97f6b58e06fea7ca844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Sun, 28 Feb 2016 00:19:24 +0100 Subject: [ticket/14487] Try to handle connection timeouts PHPBB3-14487 --- phpBB/phpbb/install/controller/timeout_check.php | 80 ++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 phpBB/phpbb/install/controller/timeout_check.php (limited to 'phpBB/phpbb/install/controller') diff --git a/phpBB/phpbb/install/controller/timeout_check.php b/phpBB/phpbb/install/controller/timeout_check.php new file mode 100644 index 0000000000..1c90e3caf3 --- /dev/null +++ b/phpBB/phpbb/install/controller/timeout_check.php @@ -0,0 +1,80 @@ + + * @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 Symfony\Component\HttpFoundation\JsonResponse; + +class timeout_check +{ + /** + * @var helper + */ + protected $helper; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * Constructor + * + * @param helper $helper + * @param string $phpbb_root_path + */ + public function __construct(helper $helper, $phpbb_root_path) + { + $this->helper = $helper; + $this->phpbb_root_path = $phpbb_root_path; + } + + /** + * Controller for querying installer status + */ + public function status() + { + $lock_file = $this->phpbb_root_path . 'store/io_lock.lock'; + $response = new JsonResponse(); + + if (!file_exists($lock_file)) + { + $response->setData(array( + 'status' => 'fail', + )); + } + else + { + $fp = @fopen($lock_file, 'r'); + + if ($fp && flock($fp, LOCK_EX | LOCK_NB)) + { + $status = (filesize($lock_file) >= 2 && fread($fp, 2) === 'ok') ? 'continue' : 'fail'; + + $response->setData(array( + 'status' => $status, + )); + flock($fp, LOCK_UN); + fclose($fp); + } + else + { + $response->setData(array( + 'status' => 'running', + )); + } + } + + return $response; + } +} -- cgit v1.2.1