MediaWiki
REL1_40
WebInstallerDBConnect.php
Go to the documentation of this file.
1
<?php
2
3
use
MediaWiki\Html\Html
;
4
25
class
WebInstallerDBConnect
extends
WebInstallerPage
{
26
30
public
function
execute
() {
31
if
( $this->
getVar
(
'_ExistingDBSettings'
) ) {
32
return
'skip'
;
33
}
34
35
$r = $this->parent->request;
36
if
( $r->wasPosted() ) {
37
$status = $this->
submit
();
38
39
if
( $status->isGood() ) {
40
$this->
setVar
(
'_UpgradeDone'
,
false
);
41
42
return
'continue'
;
43
}
else
{
44
$this->parent->showStatusBox( $status );
45
}
46
}
47
48
$this->
startForm
();
49
50
$types =
"<ul class=\"config-settings-block\">\n"
;
51
$settings =
''
;
52
$defaultType = $this->
getVar
(
'wgDBtype'
);
53
54
// Messages: config-dbsupport-mysql, config-dbsupport-postgres, config-dbsupport-sqlite
55
$dbSupport =
''
;
56
foreach
(
Installer::getDBTypes
() as
$type
) {
57
$dbSupport .=
wfMessage
(
"config-dbsupport-$type"
)->plain() .
"\n"
;
58
}
59
$this->
addHTML
( $this->parent->getInfoBox(
60
wfMessage
(
'config-support-info'
, trim( $dbSupport ) )->plain() ) );
61
62
// It's possible that the library for the default DB type is not compiled in.
63
// In that case, instead select the first supported DB type in the list.
64
$compiledDBs = $this->parent->getCompiledDBs();
65
if
( !in_array( $defaultType, $compiledDBs ) ) {
66
$defaultType = $compiledDBs[0];
67
}
68
69
foreach
( $compiledDBs as
$type
) {
70
$installer = $this->parent->getDBInstaller(
$type
);
71
$types .=
72
'<li>'
.
73
Xml::radioLabel(
74
$installer->getReadableName(),
75
'DBType'
,
76
$type
,
77
"DBType_$type"
,
78
$type
== $defaultType,
79
[
'class'
=>
'dbRadio'
,
'rel'
=>
"DB_wrapper_$type"
]
80
) .
81
"</li>\n"
;
82
83
// Messages: config-header-mysql, config-header-postgres, config-header-sqlite
84
$settings .= Html::openElement(
85
'div'
,
86
[
87
'id'
=>
'DB_wrapper_'
.
$type
,
88
'class'
=>
'dbWrapper'
89
]
90
) .
91
Html::element(
'h3'
, [],
wfMessage
(
'config-header-'
.
$type
)->text() ) .
92
$installer->getConnectForm() .
93
"</div>\n"
;
94
}
95
96
$types .=
"</ul><br style=\"clear: left\"/>\n"
;
97
98
$this->
addHTML
( $this->parent->label(
'config-db-type'
,
false
, $types ) . $settings );
99
$this->
endForm
();
100
101
return
null
;
102
}
103
107
public
function
submit
() {
108
$r = $this->parent->request;
109
$type
= $r->getVal(
'DBType'
);
110
if
( !
$type
) {
111
return
Status::newFatal(
'config-invalid-db-type'
);
112
}
113
$this->
setVar
(
'wgDBtype'
,
$type
);
114
$installer = $this->parent->getDBInstaller(
$type
);
115
if
( !$installer ) {
116
return
Status::newFatal(
'config-invalid-db-type'
);
117
}
118
119
return
$installer->submitConnectForm();
120
}
121
122
}
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition
GlobalFunctions.php:893
Installer\getDBTypes
static getDBTypes()
Get a list of known DB types.
Definition
Installer.php:551
MediaWiki\Html\Html
This class is a collection of static functions that serve two purposes:
Definition
Html.php:55
WebInstallerDBConnect
Definition
WebInstallerDBConnect.php:25
WebInstallerDBConnect\submit
submit()
Definition
WebInstallerDBConnect.php:107
WebInstallerDBConnect\execute
execute()
Definition
WebInstallerDBConnect.php:30
WebInstallerPage
Abstract class to define pages for the web installer.
Definition
WebInstallerPage.php:32
WebInstallerPage\startForm
startForm()
Definition
WebInstallerPage.php:71
WebInstallerPage\setVar
setVar( $name, $value)
Definition
WebInstallerPage.php:162
WebInstallerPage\endForm
endForm( $continue='continue', $back='back')
Definition
WebInstallerPage.php:88
WebInstallerPage\addHTML
addHTML( $html)
Definition
WebInstallerPage.php:67
WebInstallerPage\getVar
getVar( $var, $default=null)
Definition
WebInstallerPage.php:154
$type
$type
Definition
testCompression.php:53
includes
installer
WebInstallerDBConnect.php
Generated on Thu Jun 27 2024 14:02:57 for MediaWiki by
1.10.0