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