diff options
author | CHItA <mate.bartus@gmail.com> | 2015-06-11 19:32:11 +0200 |
---|---|---|
committer | Mate Bartus <mate.bartus@gmail.com> | 2015-07-08 01:28:02 +0200 |
commit | db4cfa7df62d5911bc5a0edcdc59236c39aede08 (patch) | |
tree | 35c6a99c900a0b9a3fa5db0e8d60e39045ed6591 /phpBB/install/helper | |
parent | 1b81bf5b2370c045a6369705d2a11a2b35fe2281 (diff) | |
download | forums-db4cfa7df62d5911bc5a0edcdc59236c39aede08.tar forums-db4cfa7df62d5911bc5a0edcdc59236c39aede08.tar.gz forums-db4cfa7df62d5911bc5a0edcdc59236c39aede08.tar.bz2 forums-db4cfa7df62d5911bc5a0edcdc59236c39aede08.tar.xz forums-db4cfa7df62d5911bc5a0edcdc59236c39aede08.zip |
[ticket/13740] Add navigation bar support for the installer
Also added various UI elements and texts.
[ci skip]
PHPBB3-13740
Diffstat (limited to 'phpBB/install/helper')
-rw-r--r-- | phpBB/install/helper/config.php | 49 | ||||
-rw-r--r-- | phpBB/install/helper/iohandler/ajax_iohandler.php | 51 | ||||
-rw-r--r-- | phpBB/install/helper/iohandler/factory.php | 4 | ||||
-rw-r--r-- | phpBB/install/helper/iohandler/iohandler_interface.php | 19 | ||||
-rw-r--r-- | phpBB/install/helper/navigation/install_navigation.php | 24 | ||||
-rw-r--r-- | phpBB/install/helper/navigation/navigation_provider.php | 27 |
6 files changed, 170 insertions, 4 deletions
diff --git a/phpBB/install/helper/config.php b/phpBB/install/helper/config.php index 0c04b5e950..5c1348c06d 100644 --- a/phpBB/install/helper/config.php +++ b/phpBB/install/helper/config.php @@ -13,6 +13,8 @@ namespace phpbb\install\helper; +use phpbb\install\exception\installer_config_not_writable_exception; + /** * Stores common settings and installation status */ @@ -65,6 +67,13 @@ class config protected $system_data; /** + * Array containing navigation bar information + * + * @var array + */ + protected $navigation_data; + + /** * Constructor */ public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, \phpbb\php\ini $php_ini, $phpbb_root_path) @@ -74,6 +83,7 @@ class config $this->phpbb_root_path = $phpbb_root_path; // Set up data arrays + $this->navigation_data = array(); $this->installer_config = array(); $this->system_data = array(); $this->progress_data = array( @@ -206,6 +216,7 @@ class config $this->installer_config = $unserialized_data['installer_config']; $this->progress_data = $unserialized_data['progress_data']; + $this->navigation_data = $unserialized_data['navigation_data']; } /** @@ -217,6 +228,7 @@ class config $save_array = array( 'installer_config' => $this->installer_config, 'progress_data' => $this->progress_data, + 'navigation_data' => $this->navigation_data, ); // Create file content @@ -225,7 +237,12 @@ class config $file_content .= "\n"; // Dump file_content to disk - $fp = fopen($this->install_config_file, 'w'); + $fp = @fopen($this->install_config_file, 'w'); + if (!$fp) + { + throw new installer_config_not_writable_exception(); + } + fwrite($fp, $file_content); fclose($fp); } @@ -286,6 +303,36 @@ class config } /** + * Marks stage as completed in the navigation bar + * + * @param array $nav_path Array to the navigation elem + */ + public function set_finished_navigation_stage($nav_path) + { + $this->navigation_data['finished'][] = $nav_path; + } + + /** + * Marks stage as active in the navigation bar + * + * @param array $nav_path Array to the navigation elem + */ + public function set_active_navigation_stage($nav_path) + { + $this->navigation_data['active'] = $nav_path; + } + + /** + * Returns navigation data + * + * @return array + */ + public function get_navigation_data() + { + return $this->navigation_data; + } + + /** * Filling up system_data array */ protected function setup_system_data() diff --git a/phpBB/install/helper/iohandler/ajax_iohandler.php b/phpBB/install/helper/iohandler/ajax_iohandler.php index 960dd615b5..71571fecba 100644 --- a/phpBB/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/install/helper/iohandler/ajax_iohandler.php @@ -34,6 +34,16 @@ class ajax_iohandler extends iohandler_base protected $form; /** + * @var bool + */ + protected $request_client_refresh; + + /** + * @var array + */ + protected $nav_data; + + /** * Constructor * * @param \phpbb\request\request_interface $request HTTP request interface @@ -44,6 +54,7 @@ class ajax_iohandler extends iohandler_base $this->request = $request; $this->template = $template; $this->form = ''; + $this->nav_data = array(); parent::__construct(); } @@ -89,6 +100,8 @@ class ajax_iohandler extends iohandler_base // 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, @@ -187,9 +200,21 @@ class ajax_iohandler extends iohandler_base ); } + 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; } @@ -204,6 +229,32 @@ class ajax_iohandler extends iohandler_base } /** + * {@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 diff --git a/phpBB/install/helper/iohandler/factory.php b/phpBB/install/helper/iohandler/factory.php index 0b59e5ec63..0af75b78ae 100644 --- a/phpBB/install/helper/iohandler/factory.php +++ b/phpBB/install/helper/iohandler/factory.php @@ -64,6 +64,10 @@ class factory 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/install/helper/iohandler/iohandler_interface.php b/phpBB/install/helper/iohandler/iohandler_interface.php index 387a8617b9..c40fea24ce 100644 --- a/phpBB/install/helper/iohandler/iohandler_interface.php +++ b/phpBB/install/helper/iohandler/iohandler_interface.php @@ -123,4 +123,23 @@ interface iohandler_interface * @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); } diff --git a/phpBB/install/helper/navigation/install_navigation.php b/phpBB/install/helper/navigation/install_navigation.php index 3e29e55038..1389f11fa0 100644 --- a/phpBB/install/helper/navigation/install_navigation.php +++ b/phpBB/install/helper/navigation/install_navigation.php @@ -21,7 +21,29 @@ class install_navigation implements navigation_interface 'install' => array( 'label' => 'INSTALL', 'route' => 'phpbb_installer_install', - 'order' => 0, + 'order' => 1, + array( + 'introduction' => array( + 'label' => 'INTRODUCTION_TITLE', + 'stage' => true, + 'order' => 0, + ), + 'requirements' => array( + 'label' => 'STAGE_REQUIREMENTS', + 'stage' => true, + 'order' => 1, + ), + 'obtain_data' => array( + 'label' => 'STAGE_OBTAIN_DATA', + 'stage' => true, + 'order' => 2, + ), + 'install' => array( + 'label' => 'STAGE_INSTALL', + 'stage' => true, + 'order' => 3, + ), + ), ), ); } diff --git a/phpBB/install/helper/navigation/navigation_provider.php b/phpBB/install/helper/navigation/navigation_provider.php index ddb2509348..1f58cbea83 100644 --- a/phpBB/install/helper/navigation/navigation_provider.php +++ b/phpBB/install/helper/navigation/navigation_provider.php @@ -13,6 +13,8 @@ namespace phpbb\install\helper\navigation; +use phpbb\di\service_collection; + /** * Installers navigation provider */ @@ -26,9 +28,9 @@ class navigation_provider /** * Constructor * - * @param \phpbb\di\service_collection $plugins + * @param service_collection $plugins */ - public function __construct(\phpbb\di\service_collection $plugins) + public function __construct(service_collection $plugins) { $this->menu_collection = array(); @@ -60,6 +62,27 @@ class navigation_provider } /** + * Set a property in the navigation array + * + * @param array $nav_element Array to the navigation elem + * @param array $property_array Array with the properties to set + */ + public function set_nav_property($nav_element, $property_array) + { + $array_pointer = array(); + $array_root_pointer = &$array_pointer; + foreach ($nav_element as $array_path) + { + $array_pointer[$array_path] = array(); + $array_pointer = &$array_pointer[$array_path]; + } + + $array_pointer = $property_array; + + $this->merge($array_root_pointer, $this->menu_collection); + } + + /** * Recursive array merge * * This function is necessary to be able to replace the options of |