Merge "Add support for fragments to WikiMap"
[lhc/web/wiklou.git] / mw-config / index.php
1 <?php
2 /**
3 * New version of MediaWiki web-based config/installation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 // Bail on old versions of PHP, or if composer has not been run yet to install
24 // dependencies. Using dirname( __FILE__ ) here because __DIR__ is PHP5.3+.
25 require_once dirname( __FILE__ ) . '/../includes/PHPVersionCheck.php';
26 wfEntryPointCheck( 'mw-config/index.php' );
27
28 define( 'MW_CONFIG_CALLBACK', 'Installer::overrideConfig' );
29 define( 'MEDIAWIKI_INSTALL', true );
30
31 // Resolve relative to regular MediaWiki root
32 // instead of mw-config subdirectory.
33 chdir( dirname( __DIR__ ) );
34 require dirname( __DIR__ ) . '/includes/WebStart.php';
35
36 wfInstallerMain();
37
38 function wfInstallerMain() {
39 global $wgRequest, $wgLang, $wgMetaNamespace, $wgCanonicalNamespaceNames;
40
41 $installer = InstallerOverrides::getWebInstaller( $wgRequest );
42
43 if ( !$installer->startSession() ) {
44
45 if ( $installer->request->getVal( "css" ) ) {
46 // Do not display errors on css pages
47 $installer->outputCss();
48 exit;
49 }
50
51 $errors = $installer->getPhpErrors();
52 $installer->showError( 'config-session-error', $errors[0] );
53 $installer->finish();
54 exit;
55 }
56
57 $fingerprint = $installer->getFingerprint();
58 if ( isset( $_SESSION['installData'][$fingerprint] ) ) {
59 $session = $_SESSION['installData'][$fingerprint];
60 } else {
61 $session = array();
62 }
63
64 if ( !is_null( $wgRequest->getVal( 'uselang' ) ) ) {
65 $langCode = $wgRequest->getVal( 'uselang' );
66 } elseif ( isset( $session['settings']['_UserLang'] ) ) {
67 $langCode = $session['settings']['_UserLang'];
68 } else {
69 $langCode = 'en';
70 }
71 $wgLang = Language::factory( $langCode );
72
73 $installer->setParserLanguage( $wgLang );
74
75 $wgMetaNamespace = $wgCanonicalNamespaceNames[NS_PROJECT];
76
77 $session = $installer->execute( $session );
78
79 $_SESSION['installData'][$fingerprint] = $session;
80
81 }