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 --- .../install/helper/iohandler/ajax_iohandler.php | 272 +++++++++++++++++++++ .../iohandler_not_implemented_exception.php | 19 ++ phpBB/phpbb/install/helper/iohandler/factory.php | 76 ++++++ .../install/helper/iohandler/iohandler_base.php | 158 ++++++++++++ .../helper/iohandler/iohandler_interface.php | 145 +++++++++++ 5 files changed, 670 insertions(+) create mode 100644 phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php create mode 100644 phpBB/phpbb/install/helper/iohandler/exception/iohandler_not_implemented_exception.php create mode 100644 phpBB/phpbb/install/helper/iohandler/factory.php create mode 100644 phpBB/phpbb/install/helper/iohandler/iohandler_base.php create mode 100644 phpBB/phpbb/install/helper/iohandler/iohandler_interface.php (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php new file mode 100644 index 0000000000..71571fecba --- /dev/null +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -0,0 +1,272 @@ + + * @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\helper\iohandler; + +/** + * Input-Output handler for the AJAX frontend + */ +class ajax_iohandler extends iohandler_base +{ + /** + * @var \phpbb\request\request_interface + */ + protected $request; + + /** + * @var \phpbb\template\template + */ + protected $template; + + /** + * @var string + */ + protected $form; + + /** + * @var bool + */ + protected $request_client_refresh; + + /** + * @var array + */ + protected $nav_data; + + /** + * Constructor + * + * @param \phpbb\request\request_interface $request HTTP request interface + * @param \phpbb\template\template $template Template engine + */ + public function __construct(\phpbb\request\request_interface $request, \phpbb\template\template $template) + { + $this->request = $request; + $this->template = $template; + $this->form = ''; + $this->nav_data = array(); + + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + public function get_input($name, $default, $multibyte = false) + { + return $this->request->variable($name, $default, $multibyte); + } + + /** + * {@inheritdoc} + */ + public function get_server_variable($name, $default = '') + { + return $this->request->server($name, $default); + } + + /** + * {@inheritdoc} + */ + public function get_header_variable($name, $default = '') + { + return $this->request->header($name, $default); + } + + /** + * {@inheritdoc} + */ + public function is_secure() + { + return $this->request->is_secure(); + } + + /** + * {@inheritdoc} + */ + public function add_user_form_group($title, $form) + { + // + // This code is pretty ugly... but works + // + + $this->template->assign_var('S_FORM_ELEM_COUNT', sizeof($form)); + + $this->template->assign_block_vars('options', array( + 'LEGEND' => $this->language->lang($title), + 'S_LEGEND' => true, + )); + + foreach ($form as $input_name => $input_options) + { + if (!isset($input_options['type'])) + { + continue; + } + + $tpl_ary = array(); + + $tpl_ary['TYPE'] = $input_options['type']; + $tpl_ary['TITLE'] = $this->language->lang($input_options['label']); + $tpl_ary['KEY'] = $input_name; + $tpl_ary['S_EXPLAIN'] = false; + + if (isset($input_options['default'])) + { + $default = $input_options['default']; + $default = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', array($this, 'lang_replace_callback'), $default); + $tpl_ary['DEFAULT'] = $default; + } + + if (isset($input_options['description'])) + { + $tpl_ary['TITLE_EXPLAIN'] = $this->language->lang($input_options['description']); + $tpl_ary['S_EXPLAIN'] = true; + } + + if (in_array($input_options['type'], array('select', 'radio'))) + { + for ($i = 0, $total = sizeof($input_options['options']); $i < $total; $i++) + { + if (isset($input_options['options'][$i]['label'])) + { + $input_options['options'][$i]['label'] = $this->language->lang($input_options['options'][$i]['label']); + } + } + + $tpl_ary['OPTIONS'] = $input_options['options']; + } + + $this->template->assign_block_vars('options', $tpl_ary); + } + + $this->template->set_filenames(array( + 'form_install' => 'installer_form.html', + )); + + $this->form = $this->template->assign_display('form_install'); + } + + /** + * {@inheritdoc} + */ + public function send_response() + { + $json_data_array = $this->prepare_json_array(); + $json_data = json_encode($json_data_array); + + // Try to push content to the browser + print (str_pad(' ', 4096) . "\n"); + print ($json_data . "\n\n"); + flush(); + } + + /** + * Prepares iohandler's data to be sent out to the client. + * + * @return array + */ + protected function prepare_json_array() + { + $json_array = array( + 'errors' => $this->errors, + 'warnings' => $this->warnings, + 'logs' => $this->logs, + ); + + if (!empty($this->form)) + { + $json_array['form'] = $this->form; + $this->form = ''; + } + + // If current task name is set, we push progress message to the client side + if (!empty($this->current_task_name)) + { + $json_array['progress'] = array( + 'task_name' => $this->current_task_name, + 'task_num' => $this->current_task_progress, + 'task_count' => $this->task_progress_count, + ); + } + + if (!empty($this->nav_data)) + { + $json_array['nav'] = $this->nav_data; + } + + $this->errors = array(); + $this->warnings = array(); + $this->logs = array(); + $this->nav_data = array(); + + if ($this->request_client_refresh) + { + $json_array['refresh'] = true; + $this->request_client_refresh = false; + } + + return $json_array; + } + + /** + * {@inheritdoc} + */ + public function set_progress($task_lang_key, $task_number) + { + parent::set_progress($task_lang_key, $task_number); + $this->send_response(); + } + + /** + * {@inheritdoc} + */ + public function request_refresh() + { + $this->request_client_refresh = true; + } + + /** + * {@inheritdoc} + */ + public function set_active_stage_menu($menu_path) + { + $this->nav_data['active'] = $menu_path[sizeof($menu_path) - 1]; + $this->send_response(); + } + + /** + * {@inheritdoc} + */ + public function set_finished_stage_menu($menu_path) + { + $this->nav_data['finished'][] = $menu_path[sizeof($menu_path) - 1]; + $this->send_response(); + } + + /** + * Callback function for language replacing + * + * @param array $matches + * @return string + */ + public function lang_replace_callback($matches) + { + if (!empty($matches[1])) + { + return $this->language->lang($matches[1]); + } + + return ''; + } +} diff --git a/phpBB/phpbb/install/helper/iohandler/exception/iohandler_not_implemented_exception.php b/phpBB/phpbb/install/helper/iohandler/exception/iohandler_not_implemented_exception.php new file mode 100644 index 0000000000..f2ddeda6f7 --- /dev/null +++ b/phpBB/phpbb/install/helper/iohandler/exception/iohandler_not_implemented_exception.php @@ -0,0 +1,19 @@ + + * @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\helper\iohandler\exception; + +class iohandler_not_implemented_exception extends \Exception +{ + +} diff --git a/phpBB/phpbb/install/helper/iohandler/factory.php b/phpBB/phpbb/install/helper/iohandler/factory.php new file mode 100644 index 0000000000..0af75b78ae --- /dev/null +++ b/phpBB/phpbb/install/helper/iohandler/factory.php @@ -0,0 +1,76 @@ + + * @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\helper\iohandler; + +use phpbb\install\helper\iohandler\exception\iohandler_not_implemented_exception; + +/** + * Input-output handler factory + */ +class factory +{ + /** + * @var \Symfony\Component\DependencyInjection\ContainerInterface + */ + protected $container; + + /** + * @var string + */ + protected $environment; + + /** + * Constructor + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container Dependency injection container + */ + public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container) + { + $this->container = $container; + $this->environment = null; + } + + /** + * @param string $environment The name of the input-output handler to use + */ + public function set_environment($environment) + { + $this->environment = $environment; + } + + /** + * Factory getter for iohandler + * + * @return \phpbb\install\helper\iohandler\iohandler_interface + * + * @throws \phpbb\install\helper\iohandler\exception\iohandler_not_implemented_exception + * When the specified iohandler_interface does not exists + */ + public function get() + { + switch ($this->environment) + { + case 'ajax': + return $this->container->get('installer.helper.iohandler_ajax'); + break; + case 'nojs': + // @todo replace this + return $this->container->get('installer.helper.iohandler_ajax'); + break; + default: + throw new iohandler_not_implemented_exception(); + break; + } + } +} diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php new file mode 100644 index 0000000000..f767ecf4e9 --- /dev/null +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php @@ -0,0 +1,158 @@ + + * @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\helper\iohandler; + +/** + * Base class for installer input-output handlers + */ +abstract class iohandler_base implements iohandler_interface +{ + /** + * Array of errors + * + * Errors should be added, when the installation cannot continue without + * user interaction. If the aim is to notify the user about something, please + * use a warning instead. + * + * @var array + */ + protected $errors; + + /** + * Array of warnings + * + * @var array + */ + protected $warnings; + + /** + * Array of logs + * + * @var array + */ + protected $logs; + + /** + * @var \phpbb\language\language + */ + protected $language; + + /** + * @var int + */ + protected $task_progress_count; + + /** + * @var int + */ + protected $current_task_progress; + + /** + * @var string + */ + protected $current_task_name; + + /** + * Constructor + */ + public function __construct() + { + $this->errors = array(); + $this->warnings = array(); + $this->logs = array(); + + $this->task_progress_count = 0; + $this->current_task_progress = 0; + $this->current_task_name = ''; + } + + /** + * Set language service + * + * @param \phpbb\language\language $language + */ + public function set_language(\phpbb\language\language $language) + { + $this->language = $language; + } + + /** + * {@inheritdoc} + */ + public function add_error_message($error_title, $error_description = false) + { + $this->errors[] = $this->translate_message($error_title, $error_description); + } + + /** + * {@inheritdoc} + */ + public function add_warning_message($warning_title, $warning_description = false) + { + $this->warnings[] = $this->translate_message($warning_title, $warning_description); + } + + /** + * {@inheritdoc} + */ + public function add_log_message($log_title, $log_description = false) + { + $this->logs[] = $this->translate_message($log_title, $log_description); + } + + /** + * {@inheritdoc} + */ + public function set_task_count($task_count) + { + $this->task_progress_count = $task_count; + } + + /** + * {@inheritdoc} + */ + public function set_progress($task_lang_key, $task_number) + { + if (!empty($task_lang_key)) + { + $this->current_task_name = $this->language->lang($task_lang_key); + $this->current_task_progress = $task_number; + } + } + + /** + * Localize message. + * + * Note: When an array is passed into the parameters below, it will be + * resolved as printf($param[0], $param[1], ...). + * + * @param array|string $title Title of the message + * @param array|string|bool $description Description of the message + * + * @return array Localized message in an array + */ + protected function translate_message($title, $description) + { + $message_array = array(); + + $message_array['title'] = call_user_func_array(array($this->language, 'lang'), (array) $title); + + if ($description !== false) + { + $message_array['description'] = call_user_func_array(array($this->language, 'lang'), (array) $description); + } + + return $message_array; + } +} diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php new file mode 100644 index 0000000000..c40fea24ce --- /dev/null +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -0,0 +1,145 @@ + + * @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\helper\iohandler; + +/** + * Input-Output handler interface for the installer + */ +interface iohandler_interface +{ + /** + * Renders or returns response message + */ + public function send_response(); + + /** + * Returns input variable + * + * @param string $name Name of the input variable to obtain + * @param mixed $default A default value that is returned if the variable was not set. + * This function will always return a value of the same type as the default. + * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters + * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks + * + * @return mixed Value of the input variable + */ + public function get_input($name, $default, $multibyte = false); + + /** + * Returns server variable + * + * This function should work the same as request_interterface::server(). + * + * @param string $name Name of the server variable + * @param mixed $default Default value to return when the requested variable does not exist + * + * @return mixed Value of the server variable + */ + public function get_server_variable($name, $default = ''); + + /** + * Wrapper function for request_interterface::header() + * + * @param string $name Name of the request header variable + * @param mixed $default Default value to return when the requested variable does not exist + * + * @return mixed + */ + public function get_header_variable($name, $default = ''); + + /** + * Returns true if the connection is encrypted + * + * @return bool + */ + public function is_secure(); + + /** + * Adds an error message to the rendering queue + * + * Note: When an array is passed into the parameters below, it will be + * resolved as printf($param[0], $param[1], ...). + * + * @param string|array $error_title Title of the error message. + * @param string|bool|array $error_description Description of the error (and possibly guidelines to resolve it), + * or false if the error description is not available. + */ + public function add_error_message($error_title, $error_description = false); + + /** + * Adds a warning message to the rendering queue + * + * Note: When an array is passed into the parameters below, it will be + * resolved as printf($param[0], $param[1], ...). + * + * @param string|array $warning_title Title of the warning message + * @param string|bool|array $warning_description Description of the warning (and possibly guidelines to resolve it), + * or false if the error description is not available + */ + public function add_warning_message($warning_title, $warning_description = false); + + /** + * Adds a log message to the rendering queue + * + * Note: When an array is passed into the parameters below, it will be + * resolved as printf($param[0], $param[1], ...). + * + * @param string|array $log_title Title of the log message + * @param string|bool|array $log_description Description of the log (and possibly guidelines to resolve it), + * or false if the error description is not available + */ + public function add_log_message($log_title, $log_description = false); + + /** + * Adds a requested data group to the rendering queue + * + * @param string $title Language variable with the title of the form + * @param array $form An array describing the required data (options etc) + */ + public function add_user_form_group($title, $form); + + /** + * Sets the number of tasks belonging to the installer in the current mode. + * + * @param int $task_count Number of tasks + */ + public function set_task_count($task_count); + + /** + * Sets the progress information + * + * @param string $task_lang_key Language key for the name of the task + * @param int $task_number Position of the current task in the task queue + */ + public function set_progress($task_lang_key, $task_number); + + /** + * Sends refresh request to the client + */ + public function request_refresh(); + + /** + * Marks stage as active in the navigation bar + * + * @param array $menu_path Array to the navigation elem + */ + public function set_active_stage_menu($menu_path); + + /** + * Marks stage as completed in the navigation bar + * + * @param array $menu_path Array to the navigation elem + */ + public function set_finished_stage_menu($menu_path); +} -- cgit v1.2.1 From 06f4ebce1b1cc8ecd5ddd84f7d2705007a685de3 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 31 May 2015 17:19:42 +0200 Subject: [ticket/13740] CLI installer and fixes [ci skip] PHPBB3-13740 --- .../install/helper/iohandler/ajax_iohandler.php | 2 + .../install/helper/iohandler/cli_iohandler.php | 235 +++++++++++++++++++++ phpBB/phpbb/install/helper/iohandler/factory.php | 7 +- .../install/helper/iohandler/iohandler_base.php | 34 ++- .../helper/iohandler/iohandler_interface.php | 27 ++- 5 files changed, 300 insertions(+), 5 deletions(-) create mode 100644 phpBB/phpbb/install/helper/iohandler/cli_iohandler.php (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 71571fecba..85cb2ca753 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -182,6 +182,7 @@ class ajax_iohandler extends iohandler_base 'errors' => $this->errors, 'warnings' => $this->warnings, 'logs' => $this->logs, + 'success' => $this->success, ); if (!empty($this->form)) @@ -208,6 +209,7 @@ class ajax_iohandler extends iohandler_base $this->errors = array(); $this->warnings = array(); $this->logs = array(); + $this->success = array(); $this->nav_data = array(); if ($this->request_client_refresh) diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php new file mode 100644 index 0000000000..d990f48925 --- /dev/null +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -0,0 +1,235 @@ + + * @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\helper\iohandler; + +use phpbb\install\exception\installer_exception; +use Symfony\Component\Console\Helper\ProgressBar; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\OutputStyle; + +/** + * Input-Output handler for the CLI frontend + */ +class cli_iohandler extends iohandler_base +{ + /** + * @var OutputInterface + */ + protected $output; + + /** + * @var OutputStyle + */ + protected $io; + + /** + * @var array + */ + protected $input_values = array(); + + /** + * @var ProgressBar + */ + protected $progress_bar; + + /** + * Set the style and output used to display feedback; + * + * @param OutputStyle $style + */ + public function set_style(OutputStyle $style, OutputInterface $output) + { + $this->io = $style; + $this->output = $output; + } + + /** + * {@inheritdoc} + */ + public function get_input($name, $default, $multibyte = false) + { + $result = $default; + + if (isset($this->input_values[$name])) + { + $result = $this->input_values[$name]; + } + + + if ($multibyte) + { + return utf8_normalize_nfc($result); + } + + return $result; + } + + public function set_input($name, $value) + { + $this->input_values[$name] = $value; + } + + /** + * {@inheritdoc} + */ + public function get_server_variable($name, $default = '') + { + return $default; + } + + /** + * {@inheritdoc} + */ + public function get_header_variable($name, $default = '') + { + return $default; + } + + /** + * {@inheritdoc} + */ + public function is_secure() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function add_user_form_group($title, $form) + { + throw new installer_exception('MISSING_DATA'); + } + + /** + * {@inheritdoc} + */ + public function send_response() + { + } + + /** + * {@inheritdoc + */ + public function add_error_message($error_title, $error_description = false) + { + $this->io->newLine(); + + $message = $this->translate_message($error_title, $error_description); + $this->io->error($message['title'] . "\n" . $message['description']); + + if ($this->progress_bar !== null) + { + $this->io->newLine(2); + $this->progress_bar->display(); + } + } + + /** + * {@inheritdoc + */ + public function add_warning_message($warning_title, $warning_description = false) + { + $this->io->newLine(); + + $message = $this->translate_message($warning_title, $warning_description); + $this->io->warning($message['title'] . "\n" . $message['description']); + + if ($this->progress_bar !== null) + { + $this->io->newLine(2); + $this->progress_bar->display(); + } + } + + /** + * {@inheritdoc + */ + public function add_log_message($log_title, $log_description = false) + { + if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) + { + $this->output->writeln(sprintf('[%3d/%-3d] ---- %s', $this->current_task_progress, $this->task_progress_count, $this->translate_message($log_title, $log_description)['title'])); + } + } + + /** + * {@inheritdoc + */ + public function add_success_message($error_title, $error_description = false) + { + $this->io->newLine(); + + $message = $this->translate_message($error_title, $error_description); + $this->io->success($message['title'] . "\n" . $message['description']); + + if ($this->progress_bar !== null) + { + $this->io->newLine(2); + $this->progress_bar->display(); + } + } + + public function set_task_count($task_count) + { + parent::set_task_count($task_count); + + if ($this->output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) + { + $this->progress_bar = $this->io->createProgressBar($task_count); + $this->progress_bar->setFormat( + " %current:3s%/%max:-3s% %bar% %percent:3s%%\n" . + " %message%\n"); + $this->progress_bar->setBarWidth(60); + + if (!defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->progress_bar->setEmptyBarCharacter('░'); // light shade character \u2591 + $this->progress_bar->setProgressCharacter(''); + $this->progress_bar->setBarCharacter('▓'); // dark shade character \u2593 + } + $this->progress_bar->setMessage(''); + $this->io->newLine(2); + $this->progress_bar->start(); + } + } + + public function set_progress($task_lang_key, $task_number) + { + parent::set_progress($task_lang_key, $task_number); + + if ($this->progress_bar !== null) + { + $this->progress_bar->setProgress($this->current_task_progress); + $this->progress_bar->setMessage($this->current_task_name); + } + else + { + $this->output->writeln(sprintf('[%3d/%-3d] %s', $this->current_task_progress, $this->task_progress_count, $this->current_task_name)); + } + } + + /** + * {@inheritdoc} + */ + public function finish_progress($message_lang_key) + { + parent::finish_progress($message_lang_key); + + if ($this->progress_bar !== null) + { + $this->progress_bar->finish(); + $this->progress_bar = null; + } + } +} diff --git a/phpBB/phpbb/install/helper/iohandler/factory.php b/phpBB/phpbb/install/helper/iohandler/factory.php index 0af75b78ae..7081af06a5 100644 --- a/phpBB/phpbb/install/helper/iohandler/factory.php +++ b/phpBB/phpbb/install/helper/iohandler/factory.php @@ -59,7 +59,7 @@ class factory */ public function get() { - switch ($this->environment) + if ($this->container->has('installer.helper.iohandler_' . $this->environment)) { case 'ajax': return $this->container->get('installer.helper.iohandler_ajax'); @@ -68,9 +68,14 @@ class factory // @todo replace this return $this->container->get('installer.helper.iohandler_ajax'); break; + case 'cli': + return $this->container->get('installer.helper.iohandler_cli'); + break; default: throw new iohandler_not_implemented_exception(); break; } + + throw new iohandler_not_implemented_exception(); } } diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php index f767ecf4e9..006411f1e3 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php @@ -43,6 +43,13 @@ abstract class iohandler_base implements iohandler_interface */ protected $logs; + /** + * Array of success messages + * + * @var array + */ + protected $success; + /** * @var \phpbb\language\language */ @@ -71,6 +78,7 @@ abstract class iohandler_base implements iohandler_interface $this->errors = array(); $this->warnings = array(); $this->logs = array(); + $this->success = array(); $this->task_progress_count = 0; $this->current_task_progress = 0; @@ -111,6 +119,14 @@ abstract class iohandler_base implements iohandler_interface $this->logs[] = $this->translate_message($log_title, $log_description); } + /** + * {@inheritdoc} + */ + public function add_success_message($success_title, $success_description = false) + { + $this->success[] = $this->translate_message($success_title, $success_description); + } + /** * {@inheritdoc} */ @@ -124,11 +140,27 @@ abstract class iohandler_base implements iohandler_interface */ public function set_progress($task_lang_key, $task_number) { + $this->current_task_name = ''; + if (!empty($task_lang_key)) { $this->current_task_name = $this->language->lang($task_lang_key); - $this->current_task_progress = $task_number; } + + $this->current_task_progress = $task_number; + } + + /** + * {@inheritdoc} + */ + public function finish_progress($message_lang_key) + { + if (!empty($message_lang_key)) + { + $this->current_task_name = $this->language->lang($message_lang_key); + } + + $this->current_task_progress = $this->task_progress_count; } /** diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php index c40fea24ce..44b409bb0a 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -85,7 +85,7 @@ interface iohandler_interface * * @param string|array $warning_title Title of the warning message * @param string|bool|array $warning_description Description of the warning (and possibly guidelines to resolve it), - * or false if the error description is not available + * or false if the warning description is not available */ public function add_warning_message($warning_title, $warning_description = false); @@ -96,11 +96,25 @@ interface iohandler_interface * resolved as printf($param[0], $param[1], ...). * * @param string|array $log_title Title of the log message - * @param string|bool|array $log_description Description of the log (and possibly guidelines to resolve it), - * or false if the error description is not available + * @param string|bool|array $log_description Description of the log, + * or false if the log description is not available */ public function add_log_message($log_title, $log_description = false); + /** + * Adds a success message to the rendering queue + * + * Note: When an array is passed into the parameters below, it will be + * resolved as printf($param[0], $param[1], ...). + * + * @param string|array $success_title Title of the success message + * @param string|bool|array $success_description Description of the success, + * or false if the success description is not available + * + * @return null + */ + public function add_success_message($success_title, $success_description = false); + /** * Adds a requested data group to the rendering queue * @@ -142,4 +156,11 @@ interface iohandler_interface * @param array $menu_path Array to the navigation elem */ public function set_finished_stage_menu($menu_path); + + /** + * Finish the progress bar + * + * @param string $message_lang_key Language key for the message + */ + public function finish_progress($message_lang_key); } -- cgit v1.2.1 From 249345d9cc6d6bff380436d6e05f24918d762c0d Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 27 Jun 2015 17:10:42 +0200 Subject: [ticket/13740] Clean up CLI merge [ci skip] PHPBB3-13740 --- .../install/helper/iohandler/cli_iohandler.php | 21 +++++++++++++++++++++ phpBB/phpbb/install/helper/iohandler/factory.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index d990f48925..f711abe431 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -232,4 +232,25 @@ class cli_iohandler extends iohandler_base $this->progress_bar = null; } } + + /** + * {@inheritdoc} + */ + public function request_refresh() + { + } + + /** + * {@inheritdoc} + */ + public function set_active_stage_menu($menu_path) + { + } + + /** + * {@inheritdoc} + */ + public function set_finished_stage_menu($menu_path) + { + } } diff --git a/phpBB/phpbb/install/helper/iohandler/factory.php b/phpBB/phpbb/install/helper/iohandler/factory.php index 7081af06a5..52d24e49b2 100644 --- a/phpBB/phpbb/install/helper/iohandler/factory.php +++ b/phpBB/phpbb/install/helper/iohandler/factory.php @@ -59,7 +59,7 @@ class factory */ public function get() { - if ($this->container->has('installer.helper.iohandler_' . $this->environment)) + switch ($this->environment) { case 'ajax': return $this->container->get('installer.helper.iohandler_ajax'); -- cgit v1.2.1 From 8bfd29e86dac675919d3572aac3ba5891d9d844e Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 30 Jun 2015 18:54:46 +0200 Subject: [ticket/13740] Clean up CLI CS PHPBB3-13740 --- phpBB/phpbb/install/helper/iohandler/cli_iohandler.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index f711abe431..f9c19f6d85 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -14,7 +14,6 @@ namespace phpbb\install\helper\iohandler; use phpbb\install\exception\installer_exception; -use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\OutputStyle; @@ -39,7 +38,7 @@ class cli_iohandler extends iohandler_base protected $input_values = array(); /** - * @var ProgressBar + * @var \Symfony\Component\Console\Helper\ProgressBar */ protected $progress_bar; @@ -66,7 +65,6 @@ class cli_iohandler extends iohandler_base $result = $this->input_values[$name]; } - if ($multibyte) { return utf8_normalize_nfc($result); @@ -160,7 +158,8 @@ class cli_iohandler extends iohandler_base { if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) { - $this->output->writeln(sprintf('[%3d/%-3d] ---- %s', $this->current_task_progress, $this->task_progress_count, $this->translate_message($log_title, $log_description)['title'])); + $message = $this->translate_message($log_title, $log_description); + $this->output->writeln(sprintf('[%3d/%-3d] ---- %s', $this->current_task_progress, $this->task_progress_count, $message['title'])); } } @@ -193,11 +192,13 @@ class cli_iohandler extends iohandler_base " %message%\n"); $this->progress_bar->setBarWidth(60); - if (!defined('PHP_WINDOWS_VERSION_BUILD')) { + if (!defined('PHP_WINDOWS_VERSION_BUILD')) + { $this->progress_bar->setEmptyBarCharacter('░'); // light shade character \u2591 $this->progress_bar->setProgressCharacter(''); $this->progress_bar->setBarCharacter('▓'); // dark shade character \u2593 } + $this->progress_bar->setMessage(''); $this->io->newLine(2); $this->progress_bar->start(); -- 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/helper/iohandler/cli_iohandler.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index f9c19f6d85..bf68f363c3 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -45,7 +45,8 @@ class cli_iohandler extends iohandler_base /** * Set the style and output used to display feedback; * - * @param OutputStyle $style + * @param OutputStyle $style + * @param OutputInterface $output */ public function set_style(OutputStyle $style, OutputInterface $output) { -- 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/helper/iohandler/ajax_iohandler.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 85cb2ca753..ce1112c7a1 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -96,10 +96,6 @@ class ajax_iohandler extends iohandler_base */ public function add_user_form_group($title, $form) { - // - // This code is pretty ugly... but works - // - $this->template->assign_var('S_FORM_ELEM_COUNT', sizeof($form)); $this->template->assign_block_vars('options', array( @@ -166,8 +162,8 @@ class ajax_iohandler extends iohandler_base $json_data = json_encode($json_data_array); // Try to push content to the browser - print (str_pad(' ', 4096) . "\n"); - print ($json_data . "\n\n"); + print(str_pad(' ', 4096) . "\n"); + print($json_data . "\n\n"); flush(); } -- cgit v1.2.1 From fbd5929606169d3f780f0a59760c171b20bd906d Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 23 Jul 2015 20:50:33 +0200 Subject: [ticket/13740] Login admin when install finished PHPBB3-13740 --- .../install/helper/iohandler/ajax_iohandler.php | 23 ++++++++++++++++++++++ .../install/helper/iohandler/cli_iohandler.php | 7 +++++++ .../helper/iohandler/iohandler_interface.php | 8 ++++++++ 3 files changed, 38 insertions(+) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index ce1112c7a1..fa628f3365 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -43,6 +43,11 @@ class ajax_iohandler extends iohandler_base */ protected $nav_data; + /** + * @var array + */ + protected $cookies; + /** * Constructor * @@ -55,6 +60,7 @@ class ajax_iohandler extends iohandler_base $this->template = $template; $this->form = ''; $this->nav_data = array(); + $this->cookies = array(); parent::__construct(); } @@ -214,6 +220,12 @@ class ajax_iohandler extends iohandler_base $this->request_client_refresh = false; } + if (!empty($this->cookies)) + { + $json_array['cookies'] = $this->cookies; + $this->cookies = array(); + } + return $json_array; } @@ -252,6 +264,17 @@ class ajax_iohandler extends iohandler_base $this->send_response(); } + /** + * {@inheritdoc} + */ + public function set_cookie($cookie_name, $cookie_value) + { + $this->cookies[] = array( + 'name' => $cookie_name, + 'value' => $cookie_value + ); + } + /** * Callback function for language replacing * diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index bf68f363c3..c5b2bb06bc 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -255,4 +255,11 @@ class cli_iohandler extends iohandler_base public function set_finished_stage_menu($menu_path) { } + + /** + * {@inheritdoc} + */ + public function set_cookie($cookie_name, $cookie_value) + { + } } diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php index 44b409bb0a..5f5f8499d6 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -163,4 +163,12 @@ interface iohandler_interface * @param string $message_lang_key Language key for the message */ public function finish_progress($message_lang_key); + + /** + * Sends and sets cookies + * + * @param string $cookie_name Name of the cookie to set + * @param string $cookie_value Value of the cookie to set + */ + public function set_cookie($cookie_name, $cookie_value); } -- 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 --- .../install/helper/iohandler/ajax_iohandler.php | 119 +++++++++++++++++++-- .../install/helper/iohandler/cli_iohandler.php | 24 ++++- .../install/helper/iohandler/iohandler_base.php | 4 +- .../helper/iohandler/iohandler_interface.php | 19 +++- 4 files changed, 151 insertions(+), 15 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index fa628f3365..1342ffa30f 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -13,11 +13,19 @@ namespace phpbb\install\helper\iohandler; +use phpbb\path_helper; +use phpbb\routing\router; + /** * Input-Output handler for the AJAX frontend */ class ajax_iohandler extends iohandler_base { + /** + * @var path_helper + */ + protected $path_helper; + /** * @var \phpbb\request\request_interface */ @@ -28,6 +36,16 @@ class ajax_iohandler extends iohandler_base */ protected $template; + /** + * @var router + */ + protected $router; + + /** + * @var string + */ + protected $file_status; + /** * @var string */ @@ -48,19 +66,30 @@ class ajax_iohandler extends iohandler_base */ protected $cookies; + /** + * @var array + */ + protected $download; + /** * Constructor * + * @param path_helper $path_helper * @param \phpbb\request\request_interface $request HTTP request interface * @param \phpbb\template\template $template Template engine + * @param router $router Router */ - public function __construct(\phpbb\request\request_interface $request, \phpbb\template\template $template) + public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router) { + $this->path_helper = $path_helper; $this->request = $request; + $this->router = $router; $this->template = $template; $this->form = ''; $this->nav_data = array(); $this->cookies = array(); + $this->download = array(); + $this->file_status = ''; parent::__construct(); } @@ -102,13 +131,13 @@ class ajax_iohandler extends iohandler_base */ public function add_user_form_group($title, $form) { - $this->template->assign_var('S_FORM_ELEM_COUNT', sizeof($form)); - $this->template->assign_block_vars('options', array( 'LEGEND' => $this->language->lang($title), 'S_LEGEND' => true, )); + $not_button_form = false; + foreach ($form as $input_name => $input_options) { if (!isset($input_options['type'])) @@ -117,6 +146,7 @@ class ajax_iohandler extends iohandler_base } $tpl_ary = array(); + $not_button_form = ($input_options['type'] !== 'submit' || $not_button_form); $tpl_ary['TYPE'] = $input_options['type']; $tpl_ary['TITLE'] = $this->language->lang($input_options['label']); @@ -136,7 +166,7 @@ class ajax_iohandler extends iohandler_base $tpl_ary['S_EXPLAIN'] = true; } - if (in_array($input_options['type'], array('select', 'radio'))) + if (in_array($input_options['type'], array('select', 'radio'), true)) { for ($i = 0, $total = sizeof($input_options['options']); $i < $total; $i++) { @@ -149,9 +179,12 @@ class ajax_iohandler extends iohandler_base $tpl_ary['OPTIONS'] = $input_options['options']; } - $this->template->assign_block_vars('options', $tpl_ary); + $block_name = ($input_options['type'] === 'submit') ? 'submit_buttons' : 'options'; + $this->template->assign_block_vars($block_name, $tpl_ary); } + $this->template->assign_var('S_NOT_ONLY_BUTTON_FORM', $not_button_form); + $this->template->set_filenames(array( 'form_install' => 'installer_form.html', )); @@ -185,14 +218,27 @@ class ajax_iohandler extends iohandler_base 'warnings' => $this->warnings, 'logs' => $this->logs, 'success' => $this->success, + 'download' => $this->download, ); + $this->errors = array(); + $this->warnings = array(); + $this->logs = array(); + $this->success = array(); + $this->download = array(); + if (!empty($this->form)) { $json_array['form'] = $this->form; $this->form = ''; } + if (!empty($this->file_status)) + { + $json_array['file_status'] = $this->file_status; + $this->file_status = ''; + } + // If current task name is set, we push progress message to the client side if (!empty($this->current_task_name)) { @@ -201,19 +247,20 @@ class ajax_iohandler extends iohandler_base 'task_num' => $this->current_task_progress, 'task_count' => $this->task_progress_count, ); + + if ($this->restart_progress_bar) + { + $json_array['progress']['restart'] = 1; + $this->restart_progress_bar = false; + } } if (!empty($this->nav_data)) { $json_array['nav'] = $this->nav_data; + $this->nav_data = array(); } - $this->errors = array(); - $this->warnings = array(); - $this->logs = array(); - $this->success = array(); - $this->nav_data = array(); - if ($this->request_client_refresh) { $json_array['refresh'] = true; @@ -275,6 +322,56 @@ class ajax_iohandler extends iohandler_base ); } + /** + * {@inheritdoc} + */ + public function add_download_link($route, $title, $msg = null) + { + $link_properties = array( + 'href' => $this->router->generate($route), + 'title' => $this->language->lang($title), + 'download' => $this->language->lang('DOWNLOAD'), + ); + + if ($msg !== null) + { + $link_properties['msg'] = htmlspecialchars_decode($this->language->lang($msg)); + } + + $this->download[] = $link_properties; + } + + /** + * {@inheritdoc} + */ + public function render_update_file_status($status_array) + { + $this->template->assign_vars(array( + 'T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . 'adm/images/', + )); + + foreach ($status_array as $block => $list) + { + foreach ($list as $filename) + { + $dirname = dirname($filename); + + $this->template->assign_block_vars($block, array( + 'STATUS' => $block, + 'FILENAME' => $filename, + 'DIR_PART' => (!empty($dirname) && $dirname !== '.') ? dirname($filename) . '/' : false, + 'FILE_PART' => basename($filename), + )); + } + } + + $this->template->set_filenames(array( + 'file_status' => 'installer_update_file_status.html', + )); + + $this->file_status = $this->template->assign_display('file_status'); + } + /** * Callback function for language replacing * diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index c5b2bb06bc..abdd730d2e 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -181,9 +181,12 @@ class cli_iohandler extends iohandler_base } } - public function set_task_count($task_count) + /** + * {@inheritdoc} + */ + public function set_task_count($task_count, $restart = false) { - parent::set_task_count($task_count); + parent::set_task_count($task_count, $restart); if ($this->output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) { @@ -206,6 +209,9 @@ class cli_iohandler extends iohandler_base } } + /** + * {@inheritdoc} + */ public function set_progress($task_lang_key, $task_number) { parent::set_progress($task_lang_key, $task_number); @@ -262,4 +268,18 @@ class cli_iohandler extends iohandler_base public function set_cookie($cookie_name, $cookie_value) { } + + /** + * {@inheritdoc} + */ + public function add_download_link($route, $title, $msg = null) + { + } + + /** + * {@inheritdoc} + */ + public function render_update_file_status($status_array) + { + } } diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php index 006411f1e3..530cb4766b 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php @@ -80,6 +80,7 @@ abstract class iohandler_base implements iohandler_interface $this->logs = array(); $this->success = array(); + $this->restart_progress_bar = false; $this->task_progress_count = 0; $this->current_task_progress = 0; $this->current_task_name = ''; @@ -130,9 +131,10 @@ abstract class iohandler_base implements iohandler_interface /** * {@inheritdoc} */ - public function set_task_count($task_count) + public function set_task_count($task_count, $restart = false) { $this->task_progress_count = $task_count; + $this->restart_progress_bar = $restart; } /** diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php index 5f5f8499d6..00aab3283e 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -127,8 +127,9 @@ interface iohandler_interface * Sets the number of tasks belonging to the installer in the current mode. * * @param int $task_count Number of tasks + * @param bool $restart Whether or not to restart the progress bar, false by default */ - public function set_task_count($task_count); + public function set_task_count($task_count, $restart = false); /** * Sets the progress information @@ -164,6 +165,22 @@ interface iohandler_interface */ public function finish_progress($message_lang_key); + /** + * Adds a download link + * + * @param string $route Route for the link + * @param string $title Language key for the title + * @param string|null|array $msg Language key for the message + */ + public function add_download_link($route, $title, $msg = null); + + /** + * Renders the status of update files + * + * @param array $status_array Array containing files in groups to render + */ + public function render_update_file_status($status_array); + /** * Sends and sets cookies * -- cgit v1.2.1 From 1b9ae803c5cf887c8acc2e7580ccb6fe76522d58 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Dec 2015 13:53:44 +0100 Subject: [ticket/14345] Check if description exists in message ary PHPBB3-14345 --- phpBB/phpbb/install/helper/iohandler/cli_iohandler.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index abdd730d2e..dae5d339a5 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -126,7 +126,8 @@ class cli_iohandler extends iohandler_base $this->io->newLine(); $message = $this->translate_message($error_title, $error_description); - $this->io->error($message['title'] . "\n" . $message['description']); + $message_string = $message['title'] . "\n" . (!empty($message['description']) ? $message['description'] : ''); + $this->io->error($message_string); if ($this->progress_bar !== null) { @@ -143,7 +144,8 @@ class cli_iohandler extends iohandler_base $this->io->newLine(); $message = $this->translate_message($warning_title, $warning_description); - $this->io->warning($message['title'] . "\n" . $message['description']); + $message_string = $message['title'] . "\n" . (!empty($message['description']) ? $message['description'] : ''); + $this->io->warning($message_string); if ($this->progress_bar !== null) { @@ -172,7 +174,8 @@ class cli_iohandler extends iohandler_base $this->io->newLine(); $message = $this->translate_message($error_title, $error_description); - $this->io->success($message['title'] . "\n" . $message['description']); + $message_string = $message['title'] . "\n" . (!empty($message['description']) ? $message['description'] : ''); + $this->io->success($message_string); if ($this->progress_bar !== null) { -- cgit v1.2.1 From 41b4fee6557c34d9ff534e7c1693d4e84e166ce1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Dec 2015 16:59:04 +0100 Subject: [ticket/14345] Move new line to ternary comparison PHPBB3-14345 --- phpBB/phpbb/install/helper/iohandler/cli_iohandler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index dae5d339a5..4d0341ef12 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -126,7 +126,7 @@ class cli_iohandler extends iohandler_base $this->io->newLine(); $message = $this->translate_message($error_title, $error_description); - $message_string = $message['title'] . "\n" . (!empty($message['description']) ? $message['description'] : ''); + $message_string = $message['title'] . (!empty($message['description']) ? "\n" . $message['description'] : ''); $this->io->error($message_string); if ($this->progress_bar !== null) @@ -144,7 +144,7 @@ class cli_iohandler extends iohandler_base $this->io->newLine(); $message = $this->translate_message($warning_title, $warning_description); - $message_string = $message['title'] . "\n" . (!empty($message['description']) ? $message['description'] : ''); + $message_string = $message['title'] . (!empty($message['description']) ? "\n" . $message['description'] : ''); $this->io->warning($message_string); if ($this->progress_bar !== null) @@ -174,7 +174,7 @@ class cli_iohandler extends iohandler_base $this->io->newLine(); $message = $this->translate_message($error_title, $error_description); - $message_string = $message['title'] . "\n" . (!empty($message['description']) ? $message['description'] : ''); + $message_string = $message['title'] . (!empty($message['description']) ? "\n" . $message['description'] : ''); $this->io->success($message_string); if ($this->progress_bar !== null) -- cgit v1.2.1 From 6188a8777950ffeaa80593d815600c84911ac932 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Dec 2015 23:36:49 +0100 Subject: [ticket/14344] Improve output of HTML errors trigged during install PHPBB3-14344 --- phpBB/phpbb/install/helper/iohandler/cli_iohandler.php | 4 ++++ phpBB/phpbb/install/helper/iohandler/iohandler_base.php | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index 4d0341ef12..89f3594378 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -125,6 +125,10 @@ class cli_iohandler extends iohandler_base { $this->io->newLine(); + if (strpos($error_title, '
') !== false) + { + $error_title = strip_tags(str_replace('
', "\n", $error_title)); + } $message = $this->translate_message($error_title, $error_description); $message_string = $message['title'] . (!empty($message['description']) ? "\n" . $message['description'] : ''); $this->io->error($message_string); diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php index 530cb4766b..8dee5390a9 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php @@ -101,6 +101,10 @@ abstract class iohandler_base implements iohandler_interface */ public function add_error_message($error_title, $error_description = false) { + if (strpos($error_title, '
') !== false) + { + $error_title = strip_tags(htmlspecialchars_decode($error_title)); + } $this->errors[] = $this->translate_message($error_title, $error_description); } -- cgit v1.2.1 From 2fe81c1ccb20035c9d66503726a7ff8df8b7fd78 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 20 Dec 2015 22:20:56 +0100 Subject: [ticket/14373] Do not pass arrays to strpos() PHPBB3-14373 --- phpBB/phpbb/install/helper/iohandler/iohandler_base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php index 8dee5390a9..7271fe9bc0 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php @@ -101,7 +101,7 @@ abstract class iohandler_base implements iohandler_interface */ public function add_error_message($error_title, $error_description = false) { - if (strpos($error_title, '
') !== false) + if (!is_array($error_title) && strpos($error_title, '
') !== false) { $error_title = strip_tags(htmlspecialchars_decode($error_title)); } -- 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 --- .../install/helper/iohandler/ajax_iohandler.php | 31 +++++++++++++++++++++- .../install/helper/iohandler/cli_iohandler.php | 7 +++++ .../install/helper/iohandler/iohandler_base.php | 8 ++++++ .../helper/iohandler/iohandler_interface.php | 18 +++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 1342ffa30f..31474ae4e9 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -71,6 +71,11 @@ class ajax_iohandler extends iohandler_base */ protected $download; + /** + * @var array + */ + protected $redirect_url; + /** * Constructor * @@ -89,6 +94,7 @@ class ajax_iohandler extends iohandler_base $this->nav_data = array(); $this->cookies = array(); $this->download = array(); + $this->redirect_url = array(); $this->file_status = ''; parent::__construct(); @@ -130,6 +136,14 @@ class ajax_iohandler extends iohandler_base * {@inheritdoc} */ public function add_user_form_group($title, $form) + { + $this->form = $this->generate_form_render_data($title, $form); + } + + /** + * {@inheritdoc} + */ + public function generate_form_render_data($title, $form) { $this->template->assign_block_vars('options', array( 'LEGEND' => $this->language->lang($title), @@ -189,7 +203,7 @@ class ajax_iohandler extends iohandler_base 'form_install' => 'installer_form.html', )); - $this->form = $this->template->assign_display('form_install'); + return $this->template->assign_display('form_install'); } /** @@ -273,6 +287,12 @@ class ajax_iohandler extends iohandler_base $this->cookies = array(); } + if (!empty($this->redirect_url)) + { + $json_array['redirect'] = $this->redirect_url; + $this->redirect_url = array(); + } + return $json_array; } @@ -372,6 +392,15 @@ class ajax_iohandler extends iohandler_base $this->file_status = $this->template->assign_display('file_status'); } + /** + * {@inheritdoc} + */ + public function redirect($url, $use_ajax = false) + { + $this->redirect_url = array('url' => $url, 'use_ajax' => $use_ajax); + $this->send_response(); + } + /** * Callback function for language replacing * diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index 89f3594378..7945904524 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -289,4 +289,11 @@ class cli_iohandler extends iohandler_base public function render_update_file_status($status_array) { } + + /** + * {@inheritdoc} + */ + public function redirect($url, $use_ajax = false) + { + } } diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php index 7271fe9bc0..fed4bc101f 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php @@ -169,6 +169,14 @@ abstract class iohandler_base implements iohandler_interface $this->current_task_progress = $this->task_progress_count; } + /** + * {@inheritdoc} + */ + public function generate_form_render_data($title, $form) + { + return ''; + } + /** * Localize message. * diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php index 00aab3283e..6b3839506f 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -123,6 +123,16 @@ interface iohandler_interface */ public function add_user_form_group($title, $form); + /** + * Returns the rendering information for the form + * + * @param string $title Language variable with the title of the form + * @param array $form An array describing the required data (options etc) + * + * @return string Information to render the form + */ + public function generate_form_render_data($title, $form); + /** * Sets the number of tasks belonging to the installer in the current mode. * @@ -174,6 +184,14 @@ interface iohandler_interface */ public function add_download_link($route, $title, $msg = null); + /** + * Redirects the user to a new page + * + * @param string $url URL to redirect to + * @param bool $use_ajax Whether or not to use AJAX redirect + */ + public function redirect($url, $use_ajax = false); + /** * Renders the status of update files * -- 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/helper/iohandler/factory.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/factory.php b/phpBB/phpbb/install/helper/iohandler/factory.php index 52d24e49b2..1e8395760a 100644 --- a/phpBB/phpbb/install/helper/iohandler/factory.php +++ b/phpBB/phpbb/install/helper/iohandler/factory.php @@ -75,7 +75,5 @@ class factory throw new iohandler_not_implemented_exception(); break; } - - throw new iohandler_not_implemented_exception(); } } -- cgit v1.2.1 From 955b9ede33c5696173a760ea271ec32d79e843b9 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 11 Feb 2016 13:18:30 +0100 Subject: [ticket/14462] Further speed improvements - Cache the secondary container - Only initialize tasks/modules that are being used - Add timeout error message in the AJAX UI PHPBB3-14462 --- .../install/helper/iohandler/ajax_iohandler.php | 63 ++++++++++++++++------ .../install/helper/iohandler/cli_iohandler.php | 2 +- .../helper/iohandler/iohandler_interface.php | 4 +- 3 files changed, 51 insertions(+), 18 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 31474ae4e9..8c62ec7bd0 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -209,9 +209,15 @@ class ajax_iohandler extends iohandler_base /** * {@inheritdoc} */ - public function send_response() + public function send_response($no_more_output = false) { - $json_data_array = $this->prepare_json_array(); + $json_data_array = $this->prepare_json_array($no_more_output); + + if (empty($json_data_array)) + { + return; + } + $json_data = json_encode($json_data_array); // Try to push content to the browser @@ -223,23 +229,43 @@ class ajax_iohandler extends iohandler_base /** * Prepares iohandler's data to be sent out to the client. * + * @param bool $no_more_output Whether or not there will be more output in this response + * * @return array */ - protected function prepare_json_array() + protected function prepare_json_array($no_more_output = false) { - $json_array = array( - 'errors' => $this->errors, - 'warnings' => $this->warnings, - 'logs' => $this->logs, - 'success' => $this->success, - 'download' => $this->download, - ); + $json_array = array(); + + if (!empty($this->errors)) + { + $json_array['errors'] = $this->errors; + $this->errors = array(); + } + + if (!empty($this->warnings)) + { + $json_array['warnings'] = $this->warnings; + $this->warnings = array(); + } - $this->errors = array(); - $this->warnings = array(); - $this->logs = array(); - $this->success = array(); - $this->download = array(); + if (!empty($this->logs)) + { + $json_array['logs'] = $this->logs; + $this->logs = array(); + } + + if (!empty($this->success)) + { + $json_array['success'] = $this->success; + $this->success = array(); + } + + if (!empty($this->download)) + { + $json_array['download'] = $this->download; + $this->download = array(); + } if (!empty($this->form)) { @@ -293,6 +319,11 @@ class ajax_iohandler extends iohandler_base $this->redirect_url = array(); } + if ($no_more_output) + { + $json_array['over'] = true; + } + return $json_array; } @@ -398,7 +429,7 @@ class ajax_iohandler extends iohandler_base public function redirect($url, $use_ajax = false) { $this->redirect_url = array('url' => $url, 'use_ajax' => $use_ajax); - $this->send_response(); + $this->send_response(true); } /** diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index 7945904524..94550d2db0 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -114,7 +114,7 @@ class cli_iohandler extends iohandler_base /** * {@inheritdoc} */ - public function send_response() + public function send_response($no_more_output = false) { } diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php index 6b3839506f..f22f33d9cb 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -20,8 +20,10 @@ interface iohandler_interface { /** * Renders or returns response message + * + * @param bool $no_more_output Whether or not there will be more output in this output unit */ - public function send_response(); + public function send_response($no_more_output = false); /** * Returns input variable -- 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 --- .../install/helper/iohandler/ajax_iohandler.php | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 8c62ec7bd0..c168d26425 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -41,6 +41,11 @@ class ajax_iohandler extends iohandler_base */ protected $router; + /** + * @var string + */ + protected $phpbb_root_path; + /** * @var string */ @@ -76,6 +81,11 @@ class ajax_iohandler extends iohandler_base */ protected $redirect_url; + /** + * @var resource + */ + protected $file_lock_pointer; + /** * Constructor * @@ -83,8 +93,9 @@ class ajax_iohandler extends iohandler_base * @param \phpbb\request\request_interface $request HTTP request interface * @param \phpbb\template\template $template Template engine * @param router $router Router + * @param string $root_path Path to phpBB's root */ - public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router) + public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, $root_path) { $this->path_helper = $path_helper; $this->request = $request; @@ -96,6 +107,7 @@ class ajax_iohandler extends iohandler_base $this->download = array(); $this->redirect_url = array(); $this->file_status = ''; + $this->phpbb_root_path = $root_path; parent::__construct(); } @@ -432,6 +444,33 @@ class ajax_iohandler extends iohandler_base $this->send_response(true); } + /** + * Acquires a file lock + */ + public function acquire_lock() + { + $lock_file = $this->phpbb_root_path . 'store/io_lock.lock'; + $this->file_lock_pointer = @fopen($lock_file, 'w+'); + + if ($this->file_lock_pointer) + { + flock($this->file_lock_pointer, LOCK_EX); + } + } + + /** + * Release file lock + */ + public function release_lock() + { + if ($this->file_lock_pointer) + { + fwrite($this->file_lock_pointer, 'ok'); + flock($this->file_lock_pointer, LOCK_UN); + fclose($this->file_lock_pointer); + } + } + /** * Callback function for language replacing * -- cgit v1.2.1 From 1629e6aaf36092241eaf6c745af5c3b38f8182b3 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 5 May 2016 17:05:17 +0200 Subject: [ticket/14628] Supports translatable error messages in the CLI installer PHPBB3-14628 --- phpBB/phpbb/install/helper/iohandler/cli_iohandler.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index 94550d2db0..2a41cb10ba 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -124,13 +124,14 @@ class cli_iohandler extends iohandler_base public function add_error_message($error_title, $error_description = false) { $this->io->newLine(); + $message = $this->translate_message($error_title, $error_description); + $message_string = $message['title'] . (!empty($message['description']) ? "\n" . $message['description'] : ''); - if (strpos($error_title, '
') !== false) + if (strpos($message_string, '
') !== false) { - $error_title = strip_tags(str_replace('
', "\n", $error_title)); + $message_string = strip_tags(str_replace('
', "\n", $message_string)); } - $message = $this->translate_message($error_title, $error_description); - $message_string = $message['title'] . (!empty($message['description']) ? "\n" . $message['description'] : ''); + $this->io->error($message_string); if ($this->progress_bar !== null) -- cgit v1.2.1 From a37f10ae0951f16b115f4a175cc546a515cf7937 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sat, 20 Aug 2016 22:40:37 +0200 Subject: [ticket/14742] Increase user feedback by improving progress bar We now count and display each step that was done by increasing the task count. PHPBB3-14742 --- phpBB/phpbb/install/helper/iohandler/cli_iohandler.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index 2a41cb10ba..196cdcdaab 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -198,6 +198,16 @@ class cli_iohandler extends iohandler_base if ($this->output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) { + if ($this->progress_bar !== null) + { + // Symfony's ProgressBar is immutable regarding task_count, so delete the old and create a new one. + $this->progress_bar->clear(); + } + else + { + $this->io->newLine(2); + } + $this->progress_bar = $this->io->createProgressBar($task_count); $this->progress_bar->setFormat( " %current:3s%/%max:-3s% %bar% %percent:3s%%\n" . @@ -212,7 +222,6 @@ class cli_iohandler extends iohandler_base } $this->progress_bar->setMessage(''); - $this->io->newLine(2); $this->progress_bar->start(); } } -- cgit v1.2.1 From 23f5b6debdd24cc1caefd3bb8cd6da96a88abe9a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Nov 2016 22:22:38 +0100 Subject: [ticket/14875] Add method for untrimmed input to ajax iohandler Due to the pre-encoded input and the escaping of the input, the string has to be decoded twice for the password. PHPBB3-14875 --- phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index c168d26425..591a19b7c1 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -120,6 +120,22 @@ class ajax_iohandler extends iohandler_base return $this->request->variable($name, $default, $multibyte); } + /** + * Returns untrimmed input variable + * + * @param string $name Name of the input variable to obtain + * @param mixed $default A default value that is returned if the variable was not set. + * This function will always return a value of the same type as the default. + * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters + * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks + * + * @return mixed Value of the untrimmed input variable + */ + public function get_untrimmed_input($name, $default, $multibyte = false) + { + return $this->request->untrimmed_variable($name, $default, $multibyte); + } + /** * {@inheritdoc} */ -- cgit v1.2.1 From 9aa017d0f7ce13a11114cbae24b694e935931342 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 25 Nov 2016 22:15:13 +0100 Subject: [ticket/14875] Add method for raw input to request and add to installer A method for retrieving raw input has been added to the request class. This will be used in the installer to retrieve the datatabase password while also allowing utf8 characters. Not escaping the input is ok in this case as it won't be put anywhere in this raw form and only be used to populate the entry for the password field in config.php. PHPBB3-14875 --- .../install/helper/iohandler/ajax_iohandler.php | 20 ++++++-------------- .../phpbb/install/helper/iohandler/cli_iohandler.php | 14 ++++++++++++++ .../install/helper/iohandler/iohandler_interface.php | 11 +++++++++++ 3 files changed, 31 insertions(+), 14 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 591a19b7c1..2db6750f3f 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -27,7 +27,7 @@ class ajax_iohandler extends iohandler_base protected $path_helper; /** - * @var \phpbb\request\request_interface + * @var \phpbb\request\request */ protected $request; @@ -90,12 +90,12 @@ class ajax_iohandler extends iohandler_base * Constructor * * @param path_helper $path_helper - * @param \phpbb\request\request_interface $request HTTP request interface + * @param \phpbb\request\request $request HTTP request interface * @param \phpbb\template\template $template Template engine * @param router $router Router * @param string $root_path Path to phpBB's root */ - public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, $root_path) + public function __construct(path_helper $path_helper, \phpbb\request\request $request, \phpbb\template\template $template, router $router, $root_path) { $this->path_helper = $path_helper; $this->request = $request; @@ -121,19 +121,11 @@ class ajax_iohandler extends iohandler_base } /** - * Returns untrimmed input variable - * - * @param string $name Name of the input variable to obtain - * @param mixed $default A default value that is returned if the variable was not set. - * This function will always return a value of the same type as the default. - * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters - * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks - * - * @return mixed Value of the untrimmed input variable + * {@inheritdoc} */ - public function get_untrimmed_input($name, $default, $multibyte = false) + public function get_raw_input($name, $default) { - return $this->request->untrimmed_variable($name, $default, $multibyte); + return $this->request->raw_variable($name, $default); } /** diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index 196cdcdaab..4117a3dfd3 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -74,6 +74,20 @@ class cli_iohandler extends iohandler_base return $result; } + /** + * {@inheritdoc} + */ + public function get_raw_input($name, $default) + { + return $this->get_input($name, $default, true); + } + + /** + * Set input variable + * + * @param string $name Name of input variable + * @param mixed $value Value of input variable + */ public function set_input($name, $value) { $this->input_values[$name] = $value; diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php index f22f33d9cb..f0e0e99bbb 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -38,6 +38,17 @@ interface iohandler_interface */ public function get_input($name, $default, $multibyte = false); + /** + * Returns raw input variable + * + * @param string $name Name of the input variable to obtain + * @param mixed $default A default value that is returned if the variable was not set. + * This function will always return a value of the same type as the default. + * + * @return mixed Value of the raw input variable + */ + public function get_raw_input($name, $default); + /** * Returns server variable * -- cgit v1.2.1 From 9bdd002f584de78475362067b777749486504172 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 2 Dec 2016 11:36:07 +0100 Subject: [ticket/14875] Move raw_variable() method to request_interface PHPBB3-14875 --- phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php | 6 +++--- phpBB/phpbb/install/helper/iohandler/iohandler_interface.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index 2db6750f3f..a40d457466 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -27,7 +27,7 @@ class ajax_iohandler extends iohandler_base protected $path_helper; /** - * @var \phpbb\request\request + * @var \phpbb\request\request_interface */ protected $request; @@ -90,12 +90,12 @@ class ajax_iohandler extends iohandler_base * Constructor * * @param path_helper $path_helper - * @param \phpbb\request\request $request HTTP request interface + * @param \phpbb\request\request_interface $request HTTP request interface * @param \phpbb\template\template $template Template engine * @param router $router Router * @param string $root_path Path to phpBB's root */ - public function __construct(path_helper $path_helper, \phpbb\request\request $request, \phpbb\template\template $template, router $router, $root_path) + public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, $root_path) { $this->path_helper = $path_helper; $this->request = $request; diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php index f0e0e99bbb..440748901c 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php @@ -52,7 +52,7 @@ interface iohandler_interface /** * Returns server variable * - * This function should work the same as request_interterface::server(). + * This function should work the same as request_interface::server(). * * @param string $name Name of the server variable * @param mixed $default Default value to return when the requested variable does not exist @@ -62,7 +62,7 @@ interface iohandler_interface public function get_server_variable($name, $default = ''); /** - * Wrapper function for request_interterface::header() + * Wrapper function for request_interface::header() * * @param string $name Name of the request header variable * @param mixed $default Default value to return when the requested variable does not exist -- cgit v1.2.1 From f2fde5e7a32943017f7f22b070c974f161d14d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Wed, 7 Dec 2016 21:01:47 +0100 Subject: [ticket/14897] Add $restart_progress_bar to iohandler base PHPBB3-14897 --- phpBB/phpbb/install/helper/iohandler/iohandler_base.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php index fed4bc101f..1797a6c9ad 100644 --- a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php +++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php @@ -70,6 +70,11 @@ abstract class iohandler_base implements iohandler_interface */ protected $current_task_name; + /** + * @var bool + */ + protected $restart_progress_bar; + /** * Constructor */ -- cgit v1.2.1 From d84834db88ea54bc33a323457236943a56399747 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 23 Jul 2017 21:09:30 +0200 Subject: [ticket/15293] Prevent continuing to database update on incomplete file update PHPBB3-15293 --- phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/phpbb/install/helper/iohandler') diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index a40d457466..bce0149890 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -186,6 +186,7 @@ class ajax_iohandler extends iohandler_base $tpl_ary['TITLE'] = $this->language->lang($input_options['label']); $tpl_ary['KEY'] = $input_name; $tpl_ary['S_EXPLAIN'] = false; + $tpl_ary['DISABLED'] = isset($input_options['disabled']) ? $input_options['disabled'] : false; if (isset($input_options['default'])) { @@ -219,6 +220,11 @@ class ajax_iohandler extends iohandler_base $this->template->assign_var('S_NOT_ONLY_BUTTON_FORM', $not_button_form); + if (!$not_button_form) + { + $this->template->destroy_block_vars('options'); + } + $this->template->set_filenames(array( 'form_install' => 'installer_form.html', )); -- cgit v1.2.1