MediaWiki master
DatabaseForm.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Installer;
4
8abstract class DatabaseForm {
11
13 $this->webInstaller = $webInstaller;
14 $this->dbInstaller = $dbInstaller;
15 }
16
23 protected function getVar( $var, $default = null ) {
24 return $this->dbInstaller->getVar( $var, $default );
25 }
26
32 protected function setVar( $name, $value ) {
33 $this->dbInstaller->setVar( $name, $value );
34 }
35
40 protected function getName() {
41 return $this->dbInstaller->getName();
42 }
43
54 protected function getTextBox( $var, $label, $attribs = [], $helpData = "" ) {
55 $name = $this->getName() . '_' . $var;
56 $value = $this->getVar( $var );
57 if ( !isset( $attribs ) ) {
58 $attribs = [];
59 }
60
61 return $this->webInstaller->getTextBox( [
62 'var' => $var,
63 'label' => $label,
64 'attribs' => $attribs,
65 'controlName' => $name,
66 'value' => $value,
67 'help' => $helpData
68 ] );
69 }
70
82 protected function getPasswordBox( $var, $label, $attribs = [], $helpData = "" ) {
83 $name = $this->getName() . '_' . $var;
84 $value = $this->getVar( $var );
85 if ( !isset( $attribs ) ) {
86 $attribs = [];
87 }
88
89 return $this->webInstaller->getPasswordBox( [
90 'var' => $var,
91 'label' => $label,
92 'attribs' => $attribs,
93 'controlName' => $name,
94 'value' => $value,
95 'help' => $helpData
96 ] );
97 }
98
108 protected function getCheckBox( $var, $label, $attribs = [], $helpData = "" ) {
109 $name = $this->getName() . '_' . $var;
110 $value = $this->getVar( $var );
111
112 return $this->webInstaller->getCheckBox( [
113 'var' => $var,
114 'label' => $label,
115 'attribs' => $attribs,
116 'controlName' => $name,
117 'value' => $value,
118 'help' => $helpData
119 ] );
120 }
121
134 protected function getRadioSet( $params ) {
135 $params['controlName'] = $this->getName() . '_' . $params['var'];
136 $params['value'] = $this->getVar( $params['var'] );
137
138 return $this->webInstaller->getRadioSet( $params );
139 }
140
148 protected function setVarsFromRequest( $varNames ) {
149 return $this->webInstaller->setVarsFromRequest( $varNames, $this->getName() . '_' );
150 }
151
152}
array $params
The job parameters.
__construct(WebInstaller $webInstaller, DatabaseInstaller $dbInstaller)
getVar( $var, $default=null)
Get a variable, taking local defaults into account.
getCheckBox( $var, $label, $attribs=[], $helpData="")
Get a labelled checkbox to configure a local boolean variable.
getPasswordBox( $var, $label, $attribs=[], $helpData="")
Get a labelled password box to configure a local variable.
setVarsFromRequest( $varNames)
Convenience function to set variables based on form data.
getRadioSet( $params)
Get a set of labelled radio buttons.
getTextBox( $var, $label, $attribs=[], $helpData="")
Get a labelled text box to configure a local variable.
setVar( $name, $value)
Set a variable.
getName()
Return the internal name, e.g.
Base class for DBMS-specific installation helper classes.
Class for the core installer web interface.