MediaWiki
master
Toggle main menu visibility
WebInstallerDBConnect.php
Go to the documentation of this file.
1
<?php
2
8
9
namespace
MediaWiki\Installer;
10
11
use MediaWiki\Html\Html;
12
use MediaWiki\Status\Status;
13
14
class
WebInstallerDBConnect
extends
WebInstallerPage
{
15
19
public
function
execute
() {
20
if
( $this->
getVar
(
'_ExistingDBSettings'
) ) {
21
return
'skip'
;
22
}
23
24
$r = $this->parent->request;
25
if
( $r->wasPosted() ) {
26
$status = $this->
submit
();
27
28
if
( $status->isGood() ) {
29
$this->
setVar
(
'_UpgradeDone'
,
false
);
30
31
return
'continue'
;
32
}
else
{
33
$this->parent->showStatusBox( $status );
34
}
35
}
36
37
$this->
startForm
();
38
39
$types =
"<ul class=\"config-settings-block\">\n"
;
40
$defaultType = $this->
getVar
(
'wgDBtype'
);
41
42
// Messages: config-dbsupport-mysql, config-dbsupport-postgres, config-dbsupport-sqlite
43
$dbSupport =
''
;
44
foreach
(
Installer::getDBTypes
() as $type ) {
45
$dbSupport .=
wfMessage
(
"config-dbsupport-$type"
)->plain() .
"\n"
;
46
}
47
$this->
addHTML
( $this->parent->getInfoBox(
48
wfMessage
(
'config-support-info'
, trim( $dbSupport ) )->plain() ) );
49
50
// It's possible that the library for the default DB type is not compiled in.
51
// In that case, instead select the first supported DB type in the list.
52
$compiledDBs = $this->parent->getCompiledDBs();
53
if
( !in_array( $defaultType, $compiledDBs ) ) {
54
$defaultType = $compiledDBs[0];
55
}
56
$types .=
"</ul>"
;
57
58
$settings =
''
;
59
foreach
( $compiledDBs as $type ) {
60
$installer = $this->parent->getDBInstaller( $type );
61
$types .=
"<div class=\"cdx-radio\"><div class=\"cdx-radio__wrapper\">"
;
62
$id =
"DBType_$type"
;
63
$types .=
64
Html::radio(
65
'DBType'
,
66
$type == $defaultType,
67
[
68
'id'
=> $id,
69
'class'
=> [
'cdx-radio__input'
,
'dbRadio'
],
70
'rel'
=>
"DB_wrapper_$type"
,
71
'value'
=> $type,
72
]
73
) .
74
"\u{00A0}<span class=\"cdx-radio__icon\"></span>"
.
75
Html::label( $installer->getReadableName(), $id, [
'class'
=>
'cdx-radio__label'
] );
76
$types .=
"</div></div>"
;
77
// Messages: config-header-mysql, config-header-postgres, config-header-sqlite
78
$settings .= Html::openElement(
79
'div'
,
80
[
81
'id'
=>
'DB_wrapper_'
. $type,
82
'class'
=>
'dbWrapper'
83
]
84
) .
85
Html::element
(
'h3'
, [],
wfMessage
(
'config-header-'
. $type )->text() ) .
86
$installer->getConnectForm( $this->parent )->getHtml() .
87
"</div>\n"
;
88
89
}
90
91
$this->
addHTML
( $this->parent->label(
'config-db-type'
,
false
, $types ) . $settings );
92
$this->
endForm
();
93
94
return
null
;
95
}
96
100
public
function
submit
() {
101
$r = $this->parent->request;
102
$type = $r->getVal(
'DBType'
);
103
if
( !$type ) {
104
return
Status::newFatal(
'config-invalid-db-type'
);
105
}
106
$this->
setVar
(
'wgDBtype'
, $type );
107
$installer = $this->parent->getDBInstaller( $type );
108
if
( !$installer ) {
109
return
Status::newFatal(
'config-invalid-db-type'
);
110
}
111
112
return
$installer->getConnectForm( $this->parent )->submit();
113
}
114
115
}
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition
GlobalFunctions.php:548
MediaWiki\Installer\Installer\getDBTypes
static getDBTypes()
Get a list of known DB types.
Definition
Installer.php:545
MediaWiki\Installer\WebInstallerDBConnect
Definition
WebInstallerDBConnect.php:14
MediaWiki\Installer\WebInstallerDBConnect\submit
submit()
Definition
WebInstallerDBConnect.php:100
MediaWiki\Installer\WebInstallerDBConnect\execute
execute()
Definition
WebInstallerDBConnect.php:19
MediaWiki\Installer\WebInstallerPage
Abstract class to define pages for the web installer.
Definition
WebInstallerPage.php:19
MediaWiki\Installer\WebInstallerPage\endForm
endForm( $continue='continue', $back='back')
Definition
WebInstallerPage.php:72
MediaWiki\Installer\WebInstallerPage\getVar
getVar( $var, $default=null)
Definition
WebInstallerPage.php:140
MediaWiki\Installer\WebInstallerPage\setVar
setVar( $name, $value)
Definition
WebInstallerPage.php:148
MediaWiki\Installer\WebInstallerPage\addHTML
addHTML( $html)
Definition
WebInstallerPage.php:51
MediaWiki\Installer\WebInstallerPage\startForm
startForm()
Definition
WebInstallerPage.php:55
MediaWiki\Html\element
element(SerializerNode $parent, SerializerNode $node, $contents)
Definition
HtmlHelperTrait.php:38
includes
Installer
WebInstallerDBConnect.php
Generated on
for MediaWiki by
1.18.0