MediaWiki master
MysqlConnectForm.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Installer;
4
7
15 public function getHtml() {
16 return $this->getTextBox(
17 'wgDBserver',
18 'config-db-host',
19 [],
20 $this->webInstaller->getHelpBox( 'config-db-host-help' )
21 ) .
22 $this->getCheckBox( 'wgDBssl', 'config-db-ssl' ) .
23 "<span class=\"cdx-card\"><span class=\"cdx-card__text\">" .
25 'span',
26 [ 'class' => 'cdx-card__text__title' ],
27 wfMessage( 'config-db-wiki-settings' )->text()
28 ) .
29 "<span class=\"cdx-card__text__description\">" .
30 $this->getTextBox( 'wgDBname', 'config-db-name', [ 'dir' => 'ltr' ],
31 $this->webInstaller->getHelpBox( 'config-db-name-help' ) ) .
32 $this->getTextBox( 'wgDBprefix', 'config-db-prefix', [ 'dir' => 'ltr' ],
33 $this->webInstaller->getHelpBox( 'config-db-prefix-help' ) ) .
34 "</span></span></span>" .
35 $this->getInstallUserBox();
36 }
37
38 public function submit() {
39 // Get variables from the request.
40 $newValues = $this->setVarsFromRequest( [ 'wgDBserver', 'wgDBname', 'wgDBprefix', 'wgDBssl' ] );
41
42 // Validate them.
43 $status = Status::newGood();
44 if ( !strlen( $newValues['wgDBserver'] ) ) {
45 $status->fatal( 'config-missing-db-host' );
46 }
47 if ( !strlen( $newValues['wgDBname'] ) ) {
48 $status->fatal( 'config-missing-db-name' );
49 } elseif ( !preg_match( '/^[a-z0-9+_-]+$/i', $newValues['wgDBname'] ) ) {
50 $status->fatal( 'config-invalid-db-name', $newValues['wgDBname'] );
51 }
52 if ( !preg_match( '/^[a-z0-9_-]*$/i', $newValues['wgDBprefix'] ) ) {
53 $status->fatal( 'config-invalid-db-prefix', $newValues['wgDBprefix'] );
54 }
55 if ( !$status->isOK() ) {
56 return $status;
57 }
58
59 // Submit user box
60 $status = $this->submitInstallUserBox();
61 if ( !$status->isOK() ) {
62 return $status;
63 }
64
65 // Try to connect
66 $status = $this->dbInstaller->getConnection( DatabaseInstaller::CONN_CREATE_DATABASE );
67 if ( !$status->isOK() ) {
68 return $status;
69 }
70
71 // Check version
72 return MysqlInstaller::meetsMinimumRequirement( $status->getDB() );
73 }
74}
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
This class is a collection of static functions that serve two purposes:
Definition Html.php:56
getInstallUserBox()
Get a standard install-user fieldset.
submitInstallUserBox()
Submit a standard install user fieldset.
getCheckBox( $var, $label, $attribs=[], $helpData="")
Get a labelled checkbox to configure a local boolean variable.
setVarsFromRequest( $varNames)
Convenience function to set variables based on form data.
getTextBox( $var, $label, $attribs=[], $helpData="")
Get a labelled text box to configure a local variable.
submit()
Set variables based on the request array, assuming it was submitted via the form returned by getConne...
static meetsMinimumRequirement(IDatabase $conn)
Whether the provided version meets the necessary requirements for this type.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:54
const CONN_CREATE_DATABASE
A connection for creating DBs, suitable for pre-installation.
element(SerializerNode $parent, SerializerNode $node, $contents)