MediaWiki master
SqliteConnectForm.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Installer;
4
7
12
13 public function getHtml() {
14 return $this->getTextBox(
15 'wgSQLiteDataDir',
16 'config-sqlite-dir', [],
17 $this->webInstaller->getHelpBox( 'config-sqlite-dir-help' )
18 ) .
19 $this->getTextBox(
20 'wgDBname',
21 'config-db-name',
22 [],
23 $this->webInstaller->getHelpBox( 'config-sqlite-name-help' )
24 );
25 }
26
30 public function submit() {
31 $this->setVarsFromRequest( [ 'wgSQLiteDataDir', 'wgDBname' ] );
32
33 # Try realpath() if the directory already exists
34 $dir = $this->realpath( $this->getVar( 'wgSQLiteDataDir' ) );
35 $result = $this->getSqliteUtils()->checkDataDir( $dir );
36 if ( $result->isOK() ) {
37 # Try expanding again in case we've just created it
38 $dir = $this->realpath( $dir );
39 $this->setVar( 'wgSQLiteDataDir', $dir );
40 }
41 # Table prefix is not used on SQLite, keep it empty
42 $this->setVar( 'wgDBprefix', '' );
43
44 return $result;
45 }
46
54 private function realpath( $path ) {
55 return realpath( $path ) ?: $path;
56 }
57
58 private function getSqliteUtils() {
59 return new SqliteUtils;
60 }
61
62}
getVar( $var, $default=null)
Get a variable, taking local defaults into account.
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.
setVar( $name, $value)
Set a variable.
getHtml()
Get HTML for a web form that configures this database.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:54