diff --git a/_register_database.php b/_register_database.php index 04718d053..11631d949 100644 --- a/_register_database.php +++ b/_register_database.php @@ -6,7 +6,7 @@ DatabaseAdapterRegistry::register( 'class' => 'MySQLDatabase', 'title' => 'MySQL 4.1+', 'helperPath' => 'sapphire/dev/install/MySQLDatabaseConfigurationHelper.php', - 'supported' => function_exists('mysql_connect') + 'supported' => function_exists('mysql_connect'), ) ); @@ -36,6 +36,19 @@ DatabaseAdapterRegistry::register( 'title' => 'SQLite 3.3+', 'helperPath' => 'sqlite3/code/SQLiteDatabaseConfigurationHelper.php', 'supported' => (class_exists('SQLite3') || class_exists('PDO')), - 'missingExtensionText' => 'The SQLite3 and PDO classes are not available. Please install or enable them and refresh this page.' + 'missingExtensionText' => 'The SQLite3 and PDO classes are not available. Please install or enable them and refresh this page.', + 'fields' => array( + 'path' => array( + 'title' => 'Database path', + 'default' => realpath(dirname($_SERVER['SCRIPT_FILENAME'])) . '/assets/.sqlitedb' + ), + 'database' => array( + 'title' => 'Database name', + 'default' => 'SS_mysite', + 'attributes' => array( + "onchange" => "this.value = this.value.replace(/[\/\\:*?"<>|. \t]+/g,'');" + ) + ) + ) ) ); diff --git a/dev/install/DatabaseAdapterRegistry.php b/dev/install/DatabaseAdapterRegistry.php index 60020e714..abf0324cc 100644 --- a/dev/install/DatabaseAdapterRegistry.php +++ b/dev/install/DatabaseAdapterRegistry.php @@ -10,6 +10,31 @@ */ class DatabaseAdapterRegistry { + static $default_fields = array( + 'server' => array( + 'title' => 'Database server', + 'envVar' => 'SS_DATABASE_SERVER', + 'default' => 'localhost' + ), + 'username' => array( + 'title' => 'Database username', + 'envVar' => 'SS_DATABASE_USERNAME', + 'default' => 'root' + ), + 'password' => array( + 'title' => 'Database password', + 'envVar' => 'SS_DATABASE_PASSWORD', + 'default' => 'password' + ), + 'database' => array( + 'title' => 'Database name', + 'default' => 'SS_mysite', + 'attributes' => array( + "onchange" => "this.value = this.value.replace(/[\/\\:*?"<>|. \t]+/g,'');" + ) + ), + ); + /** * Internal array of registered database adapters */ @@ -32,6 +57,9 @@ class DatabaseAdapterRegistry { $config['missingModuleText'] = $missingModuleText; $config['missingExtensionText'] = $missingExtensionText; + // set default fields if none are defined already + if(!isset($config['fields'])) $config['fields'] = self::$default_fields; + self::$adapters[$config['class']] = $config; } diff --git a/dev/install/config-form.html b/dev/install/config-form.html index 938886f67..790ea3774 100644 --- a/dev/install/config-form.html +++ b/dev/install/config-form.html @@ -3,53 +3,8 @@
- + - +