Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 31 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| DatabaseSettingsForm | |
0.00% |
0 / 31 |
|
0.00% |
0 / 4 |
90 | |
0.00% |
0 / 1 |
| getHtml | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| submit | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getWebUserBox | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
12 | |||
| submitWebUserBox | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Installer; |
| 4 | |
| 5 | use MediaWiki\Html\Html; |
| 6 | use MediaWiki\Status\Status; |
| 7 | |
| 8 | /** |
| 9 | * @internal |
| 10 | */ |
| 11 | class DatabaseSettingsForm extends DatabaseForm { |
| 12 | |
| 13 | /** |
| 14 | * Get HTML for a web form that retrieves settings used for installation. |
| 15 | * $this->parent can be assumed to be a WebInstaller. |
| 16 | * If the DB type has no settings beyond those already configured with |
| 17 | * getConnectForm(), this should return false. |
| 18 | * @return string|false |
| 19 | */ |
| 20 | public function getHtml() { |
| 21 | return false; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Set variables based on the request array, assuming it was submitted via |
| 26 | * the form return by getSettingsForm(). |
| 27 | * |
| 28 | * @return Status |
| 29 | */ |
| 30 | public function submit() { |
| 31 | return Status::newGood(); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Get a standard web-user fieldset |
| 36 | * @param string|false $noCreateMsg Message to display instead of the creation checkbox. |
| 37 | * Set this to false to show a creation checkbox (default). |
| 38 | * |
| 39 | * @return string |
| 40 | */ |
| 41 | protected function getWebUserBox( $noCreateMsg = false ) { |
| 42 | $wrapperStyle = $this->getVar( '_SameAccount' ) ? 'display: none' : ''; |
| 43 | $s = "<span class=\"cdx-card\"><span class=\"cdx-card__text\">" . |
| 44 | Html::element( |
| 45 | 'span', |
| 46 | [ 'class' => 'cdx-card__text__title' ], |
| 47 | wfMessage( 'config-db-web-account' )->text() |
| 48 | ) . |
| 49 | $this->getCheckBox( |
| 50 | '_SameAccount', 'config-db-web-account-same', |
| 51 | [ 'class' => 'hideShowRadio cdx-checkbox__input', 'rel' => 'dbOtherAccount' ] |
| 52 | ) . |
| 53 | Html::openElement( 'div', [ 'id' => 'dbOtherAccount', 'style' => $wrapperStyle ] ) . |
| 54 | $this->getTextBox( 'wgDBuser', 'config-db-username' ) . |
| 55 | $this->getPasswordBox( 'wgDBpassword', 'config-db-password' ) . |
| 56 | $this->webInstaller->getHelpBox( 'config-db-web-help' ); |
| 57 | if ( $noCreateMsg ) { |
| 58 | $s .= Html::warningBox( wfMessage( $noCreateMsg )->parse(), 'config-warning-box' ); |
| 59 | } else { |
| 60 | $s .= $this->getCheckBox( '_CreateDBAccount', 'config-db-web-create' ); |
| 61 | } |
| 62 | $s .= Html::closeElement( 'div' ) . "</span></span></span>"; |
| 63 | |
| 64 | return $s; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Submit the form from getWebUserBox(). |
| 69 | * |
| 70 | * @return Status |
| 71 | */ |
| 72 | public function submitWebUserBox() { |
| 73 | $this->setVarsFromRequest( |
| 74 | [ 'wgDBuser', 'wgDBpassword', '_SameAccount', '_CreateDBAccount' ] |
| 75 | ); |
| 76 | |
| 77 | if ( $this->getVar( '_SameAccount' ) ) { |
| 78 | $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) ); |
| 79 | $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) ); |
| 80 | } |
| 81 | |
| 82 | if ( $this->getVar( '_CreateDBAccount' ) && strval( $this->getVar( 'wgDBpassword' ) ) == '' ) { |
| 83 | return Status::newFatal( 'config-db-password-empty', $this->getVar( 'wgDBuser' ) ); |
| 84 | } |
| 85 | |
| 86 | return Status::newGood(); |
| 87 | } |
| 88 | |
| 89 | } |