Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 34 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
WebInstallerInstall | |
0.00% |
0 / 34 |
|
0.00% |
0 / 4 |
210 | |
0.00% |
0 / 1 |
isSlow | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
42 | |||
startStage | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
endStage | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
30 |
1 | <?php |
2 | |
3 | /** |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation; either version 2 of the License, or |
7 | * (at your option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License along |
15 | * with this program; if not, write to the Free Software Foundation, Inc., |
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | * http://www.gnu.org/copyleft/gpl.html |
18 | * |
19 | * @file |
20 | * @ingroup Installer |
21 | */ |
22 | |
23 | namespace MediaWiki\Installer; |
24 | |
25 | use MediaWiki\Status\Status; |
26 | |
27 | class WebInstallerInstall extends WebInstallerPage { |
28 | |
29 | /** |
30 | * @return bool Always true. |
31 | */ |
32 | public function isSlow() { |
33 | return true; |
34 | } |
35 | |
36 | /** |
37 | * @return string|bool |
38 | */ |
39 | public function execute() { |
40 | if ( $this->getVar( '_UpgradeDone' ) ) { |
41 | return 'skip'; |
42 | } elseif ( $this->getVar( '_InstallDone' ) ) { |
43 | return 'continue'; |
44 | } elseif ( $this->parent->request->wasPosted() ) { |
45 | $this->startForm(); |
46 | $this->addHTML( "<ul>" ); |
47 | $results = $this->parent->performInstallation( |
48 | [ $this, 'startStage' ], |
49 | [ $this, 'endStage' ] |
50 | ); |
51 | $this->addHTML( "</ul>" ); |
52 | // PerformInstallation bails on a fatal, so make sure the last item |
53 | // completed before giving 'next.' Likewise, only provide back on failure |
54 | $lastStep = end( $results ); |
55 | $continue = $lastStep->isOK() ? 'continue' : false; |
56 | $back = $lastStep->isOK() ? false : 'back'; |
57 | $this->endForm( $continue, $back ); |
58 | } else { |
59 | $this->startForm(); |
60 | $this->addHTML( $this->parent->getInfoBox( wfMessage( 'config-install-begin' )->plain() ) ); |
61 | $this->endForm(); |
62 | } |
63 | |
64 | return true; |
65 | } |
66 | |
67 | /** |
68 | * @param string $step |
69 | */ |
70 | public function startStage( $step ) { |
71 | // Messages: config-install-database, config-install-tables, config-install-interwiki, |
72 | // config-install-stats, config-install-keys, config-install-sysop, config-install-mainpage |
73 | $this->addHTML( "<li>" . wfMessage( "config-install-$step" )->escaped() . |
74 | wfMessage( 'ellipsis' )->escaped() ); |
75 | |
76 | if ( $step == 'extension-tables' ) { |
77 | $this->startLiveBox(); |
78 | } |
79 | } |
80 | |
81 | /** |
82 | * @param string $step |
83 | * @param Status $status |
84 | */ |
85 | public function endStage( $step, $status ) { |
86 | if ( $step == 'extension-tables' ) { |
87 | $this->endLiveBox(); |
88 | } |
89 | $msg = $status->isOK() ? 'config-install-step-done' : 'config-install-step-failed'; |
90 | $html = wfMessage( 'word-separator' )->escaped() . wfMessage( $msg )->escaped(); |
91 | if ( !$status->isOK() ) { |
92 | $html = "<span class=\"error\">$html</span>"; |
93 | } |
94 | $this->addHTML( $html . "</li>\n" ); |
95 | if ( !$status->isGood() ) { |
96 | $this->parent->showStatusBox( $status ); |
97 | } |
98 | } |
99 | |
100 | } |