Skip to content

Commit db4cfa7

Browse files
committed
[ticket/13740] Add navigation bar support for the installer
Also added various UI elements and texts. [ci skip] PHPBB3-13740
1 parent 1b81bf5 commit db4cfa7

27 files changed

Lines changed: 495 additions & 54 deletions

phpBB/adm/style/install_header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ <h1>{L_INSTALL_PANEL}</h1>
4343
<li<!-- IF l_block1.S_SELECTED --> id="activemenu"<!-- ENDIF -->><a href="{l_block1.U_TITLE}"><span>{l_block1.L_TITLE}</span></a></li>
4444
<!-- END l_block1 -->
4545
<!-- BEGIN l_block2 -->
46-
<li<!-- IF l_block2.S_SELECTED --> id="activemenu"<!-- ENDIF -->><span<!-- IF l_block2.S_COMPLETE --> class="completed"<!-- ENDIF -->>{l_block2.L_TITLE}</span></li>
46+
<li<!-- IF l_block2.S_SELECTED --> id="activemenu"<!-- ENDIF -->><span<!-- IF l_block2.S_COMPLETE --> class="completed"<!-- ENDIF --> id="installer-stage-{l_block2.STAGE_NAME}">{l_block2.L_TITLE}</span></li>
4747
<!-- END l_block2 -->
4848
</ul>
4949
</div>

phpBB/adm/style/installer_form.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<form id="<!-- IF FORM_ID -->{FORM_ID}<!-- ELSE -->install_install<!-- ENDIF -->" method="POST" action="{U_ACTION}">
22
<!-- IF .options -->
3+
<!-- IF S_FORM_ELEM_COUNT > 1 -->
34
<fieldset>
5+
<!-- ENDIF -->
46

57
<!-- BEGIN options -->
68
<!-- IF options.S_LEGEND -->
@@ -40,7 +42,9 @@
4042
</dd>
4143
</dl>
4244
<!-- ELSE -->
45+
<!-- IF S_FORM_ELEM_COUNT > 1 -->
4346
</fieldset>
47+
<!-- ENDIF -->
4448
<fieldset class="submit-buttons">
4549
<legend>{L_SUBMIT}</legend>
4650
<input class="button1" type="submit" name="{options.KEY}" value="{options.TITLE}" />

phpBB/adm/style/installer_install.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!-- INCLUDE install_header.html -->
2-
<h1>{L_INSTALL}</h1>
3-
{CONTENT}
2+
<h1>{TITLE}</h1>
3+
<p>{CONTENT}</p>
44
<!-- IF SHOW_INSTALL_START_FORM -->
55
<form id="install_install" method="post" action="{U_ACTION}">
66
<fieldset class="submit-buttons">
77
<legend>{L_SUBMIT}</legend>
8-
<input name="install" type="submit" value="{L_INSTALL}" />
8+
<input class="button1" name="install" type="submit" value="{L_INSTALL}" />
99
</fieldset>
1010
</form>
1111
<!-- ENDIF -->

phpBB/assets/javascript/installer.js

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,45 @@
9595
interceptFormSubmit($form);
9696
}
9797

98+
/**
99+
* Handles navigation status updates
100+
*
101+
* @param navObj
102+
*/
103+
function updateNavbarStatus(navObj) {
104+
var navID, $stage, $stageListItem, $active;
105+
$active = $('#activemenu');
106+
107+
if (navObj.hasOwnProperty('finished')) {
108+
// This should be an Array
109+
var navItems = navObj.finished;
110+
111+
for (var i = 0; i < navItems.length; i++) {
112+
navID = 'installer-stage-' + navItems[i];
113+
$stage = $('#' + navID);
114+
$stageListItem = $stage.parent();
115+
116+
if ($active.length && $active.is($stageListItem)) {
117+
$active.removeAttr('id');
118+
}
119+
120+
$stage.addClass('completed');
121+
}
122+
}
123+
124+
if (navObj.hasOwnProperty('active')) {
125+
navID = 'installer-stage-' + navObj.active;
126+
$stage = $('#' + navID);
127+
$stageListItem = $stage.parent();
128+
129+
if ($active.length && !$active.is($stageListItem)) {
130+
$active.removeAttr('id');
131+
}
132+
133+
$stageListItem.attr('id', 'activemenu');
134+
}
135+
}
136+
98137
/**
99138
* Renders progress bar
100139
*
@@ -166,6 +205,10 @@
166205
if (responseObject.hasOwnProperty('progress')) {
167206
setProgress(responseObject.progress);
168207
}
208+
209+
if (responseObject.hasOwnProperty('nav')) {
210+
updateNavbarStatus(responseObject.nav);
211+
}
169212
}
170213

171214
/**
@@ -231,6 +274,14 @@
231274
}, 10);
232275
}
233276

277+
/**
278+
* Resets the polling timer
279+
*/
280+
function resetPolling() {
281+
clearInterval(pollTimer);
282+
nextReadPosition = 0;
283+
}
284+
234285
/**
235286
* Sets up timer for processing the streamed HTTP response
236287
*
@@ -240,15 +291,7 @@
240291
resetPolling();
241292
pollTimer = setInterval(function () {
242293
pollContent(xhReq);
243-
}, 500);
244-
}
245-
246-
/**
247-
* Resets the polling timer
248-
*/
249-
function resetPolling() {
250-
clearInterval(pollTimer);
251-
nextReadPosition = 0;
294+
}, 250);
252295
}
253296

254297
/**

phpBB/config/installer/container/services_install_controller.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ services:
2323
class: phpbb\install\controller\install
2424
arguments:
2525
- @phpbb.installer.controller.helper
26+
- @installer.helper.config
2627
- @installer.helper.iohandler_factory
28+
- @installer.navigation.provider
29+
- @language
2730
- @template
2831
- @request
2932
- @installer.installer.install

phpBB/config/installer/container/services_install_requirements.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ services:
1313
- @installer.helper.database
1414
- @installer.helper.iohandler
1515

16+
# Please note, that the name of this module is hard coded in the installer service
1617
installer.module.requirements_install:
1718
class: phpbb\install\module\requirements\module
1819
parent: installer.module_base

phpBB/install/controller/helper.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,25 @@ protected function render_navigation()
157157
{
158158
// @todo Sort navs by order
159159

160-
foreach ($entry[0] as $sub_entry)
160+
foreach ($entry[0] as $name => $sub_entry)
161161
{
162-
$this->template->assign_block_vars('l_block1', array(
163-
'L_TITLE' => $this->language->lang($sub_entry['label']),
164-
'S_SELECTED' => (isset($sub_entry['route']) && $sub_entry['route'] === $this->request->get('_route')),
165-
'U_TITLE' => $this->route($sub_entry['route']),
166-
));
162+
if (isset($sub_entry['stage']) && $sub_entry['stage'] === true)
163+
{
164+
$this->template->assign_block_vars('l_block2', array(
165+
'L_TITLE' => $this->language->lang($sub_entry['label']),
166+
'S_SELECTED' => (isset($sub_entry['selected']) && $sub_entry['selected'] === true),
167+
'S_COMPLETE' => (isset($sub_entry['completed']) && $sub_entry['completed'] === true),
168+
'STAGE_NAME' => $name,
169+
));
170+
}
171+
else
172+
{
173+
$this->template->assign_block_vars('l_block1', array(
174+
'L_TITLE' => $this->language->lang($sub_entry['label']),
175+
'S_SELECTED' => (isset($sub_entry['route']) && $sub_entry['route'] === $this->request->get('_route')),
176+
'U_TITLE' => $this->route($sub_entry['route']),
177+
));
178+
}
167179
}
168180
}
169181
}

phpBB/install/controller/install.php

Lines changed: 87 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,59 +13,89 @@
1313

1414
namespace phpbb\install\controller;
1515

16+
use phpbb\install\helper\config;
17+
use phpbb\install\helper\navigation\navigation_provider;
1618
use Symfony\Component\HttpFoundation\StreamedResponse;
19+
use Symfony\Component\HttpFoundation\Response;
20+
use phpbb\install\helper\iohandler\factory;
21+
use phpbb\install\controller\helper;
22+
use phpbb\template\template;
23+
use phpbb\request\request_interface;
24+
use phpbb\install\installer;
25+
use phpbb\language\language;
1726

1827
/**
1928
* Controller for installing phpBB
2029
*/
2130
class install
2231
{
2332
/**
24-
* @var \phpbb\install\controller\helper
33+
* @var helper
2534
*/
2635
protected $controller_helper;
2736

2837
/**
29-
* @var \phpbb\install\helper\iohandler\factory
38+
* @var config
39+
*/
40+
protected $installer_config;
41+
42+
/**
43+
* @var factory
3044
*/
3145
protected $iohandler_factory;
3246

3347
/**
34-
* @var \phpbb\template\template
48+
* @var navigation_provider
49+
*/
50+
protected $menu_provider;
51+
52+
/**
53+
* @var language
54+
*/
55+
protected $language;
56+
57+
/**
58+
* @var template
3559
*/
3660
protected $template;
3761

3862
/**
39-
* @var \phpbb\request\request_interface
63+
* @var request_interface
4064
*/
4165
protected $request;
4266

4367
/**
44-
* @var \phpbb\install\installer
68+
* @var installer
4569
*/
4670
protected $installer;
4771

4872
/**
4973
* Constructor
5074
*
51-
* @param helper $helper
52-
* @param \phpbb\install\helper\iohandler\factory $factory
53-
* @param \phpbb\request\request_interface $request
54-
* @param \phpbb\install\installer $installer
75+
* @param helper $helper
76+
* @param config $install_config
77+
* @param factory $factory
78+
* @param navigation_provider $nav_provider
79+
* @param language $language
80+
* @param request_interface $request
81+
* @param installer $installer
5582
*/
56-
public function __construct(helper $helper, \phpbb\install\helper\iohandler\factory $factory, \phpbb\template\template $template, \phpbb\request\request_interface $request, \phpbb\install\installer $installer)
83+
public function __construct(helper $helper, config $install_config, factory $factory, navigation_provider $nav_provider, language $language, template $template, request_interface $request, installer $installer)
5784
{
58-
$this->controller_helper = $helper;
59-
$this->iohandler_factory = $factory;
60-
$this->template = $template;
61-
$this->request = $request;
62-
$this->installer = $installer;
85+
$this->controller_helper = $helper;
86+
$this->installer_config = $install_config;
87+
$this->iohandler_factory = $factory;
88+
$this->menu_provider = $nav_provider;
89+
$this->language = $language;
90+
$this->template = $template;
91+
$this->request = $request;
92+
$this->installer = $installer;
6393
}
6494

6595
/**
6696
* Controller logic
6797
*
68-
* @return \Symfony\Component\HttpFoundation\Response|StreamedResponse
98+
* @return Response|StreamedResponse
6999
*/
70100
public function handle()
71101
{
@@ -86,13 +116,38 @@ public function handle()
86116
}
87117

88118
// Set the appropriate input-output handler
89-
//$this->installer->set_iohandler($this->iohandler_factory->get());
119+
$this->installer->set_iohandler($this->iohandler_factory->get());
90120

91-
if ($this->request->is_ajax())
121+
// Set up navigation
122+
$nav_data = $this->installer_config->get_navigation_data();
123+
/** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */
124+
$iohandler = $this->iohandler_factory->get();
125+
126+
// Set active navigation stage
127+
if (isset($nav_data['active']) && is_array($nav_data['active']))
92128
{
93-
// @todo: remove this line, and use the above
94-
$this->installer->set_iohandler($this->iohandler_factory->get());
129+
$iohandler->set_active_stage_menu($nav_data['active']);
130+
$this->menu_provider->set_nav_property($nav_data['active'], array(
131+
'selected' => true,
132+
'completed' => false,
133+
));
134+
}
135+
136+
// Set finished navigation stages
137+
if (isset($nav_data['finished']) && is_array($nav_data['finished']))
138+
{
139+
foreach ($nav_data['finished'] as $finished_stage)
140+
{
141+
$iohandler->set_finished_stage_menu($finished_stage);
142+
$this->menu_provider->set_nav_property($finished_stage, array(
143+
'selected' => false,
144+
'completed' => true,
145+
));
146+
}
147+
}
95148

149+
if ($this->request->is_ajax())
150+
{
96151
$installer = $this->installer;
97152
$response = new StreamedResponse();
98153
$response->setCallback(function() use ($installer) {
@@ -106,9 +161,20 @@ public function handle()
106161
// Determine whether the installation was started or not
107162
if (true)
108163
{
164+
// Set active stage
165+
$this->menu_provider->set_nav_property(
166+
array('install', 0, 'introduction'),
167+
array(
168+
'selected' => true,
169+
'completed' => false,
170+
)
171+
);
172+
109173
// If not, let's render the welcome page
110174
$this->template->assign_vars(array(
111-
'SHOW_INSTALL_START_FORM' => true,
175+
'SHOW_INSTALL_START_FORM' => true,
176+
'TITLE' => $this->language->lang('INSTALL_INTRO'),
177+
'CONTENT' => $this->language->lang('INSTALL_INTRO_BODY'),
112178
));
113179
return $this->controller_helper->render('installer_install.html', 'INSTALL');
114180
}

phpBB/install/controller/install_index.php renamed to phpBB/install/controller/installer_index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace phpbb\install\controller;
1515

16-
class install_index
16+
class installer_index
1717
{
1818
/**
1919
* @var helper
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
*
4+
* This file is part of the phpBB Forum Software package.
5+
*
6+
* @copyright (c) phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
* For full copyright and license information, please see
10+
* the docs/CREDITS.txt file.
11+
*
12+
*/
13+
14+
namespace phpbb\install\exception;
15+
16+
/**
17+
* Exception for the event when installer config is not writable to disk
18+
*/
19+
class installer_config_not_writable_exception extends installer_exception
20+
{
21+
22+
}

0 commit comments

Comments
 (0)