MediaWiki master
SqliteConnectForm.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Installer;
4
6
11
12 public function getHtml() {
13 return $this->getTextBox(
14 'wgSQLiteDataDir',
15 'config-sqlite-dir', [],
16 $this->webInstaller->getHelpBox( 'config-sqlite-dir-help' )
17 ) .
18 $this->getTextBox(
19 'wgDBname',
20 'config-db-name',
21 [],
22 $this->webInstaller->getHelpBox( 'config-sqlite-name-help' )
23 );
24 }
25
29 public function submit() {
30 $this->setVarsFromRequest( [ 'wgSQLiteDataDir', 'wgDBname' ] );
31
32 # Try realpath() if the directory already exists
33 $dir = SqliteInstaller::realpath( $this->getVar( 'wgSQLiteDataDir' ) );
34 $result = SqliteInstaller::checkDataDir( $dir );
35 if ( $result->isOK() ) {
36 # Try expanding again in case we've just created it
37 $dir = SqliteInstaller::realpath( $dir );
38 $this->setVar( 'wgSQLiteDataDir', $dir );
39 }
40 # Table prefix is not used on SQLite, keep it empty
41 $this->setVar( 'wgDBprefix', '' );
42
43 return $result;
44 }
45
46}
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.
static checkDataDir( $dir)
Check if the data directory is writable or can be created.
static realpath( $path)
Safe wrapper for PHP's realpath() that fails gracefully if it's unable to canonicalize the path.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:54