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 @@ SilverStripe CMS / Framework Installation - + + @@ -119,15 +74,15 @@ Note: It seems as though SilverStripe is already installed here. If you ask me to install, I will overwrite the .htaccess and mysite/_config.php files.
- +

- + - +

- onclick="toggleDisabledFields(this);"> + >
@@ -160,7 +115,7 @@
-
- - - > - -
-
- - - > - -
-
- - - > - -
-
- - - - -
+
@@ -240,13 +214,13 @@
- > + >
- > + >
@@ -273,7 +247,7 @@
- @@ -327,24 +301,5 @@ else echo 'localhost

SilverStripe Open Source CMS / Framework | Copyright © 2010 SilverStripe Limited

- diff --git a/dev/install/install.css b/dev/install/install.css index 70233e203..646039b51 100644 --- a/dev/install/install.css +++ b/dev/install/install.css @@ -152,6 +152,10 @@ table.testResults { margin-right: 5px; } +.dbfields { + margin: 10px; +} + #database_credentials { margin: 0; line-height: 1; diff --git a/dev/install/install.js b/dev/install/install.js new file mode 100644 index 000000000..e60f7fed3 --- /dev/null +++ b/dev/install/install.js @@ -0,0 +1,38 @@ +$(document).ready(function() { + + /** + * Toggle field readonly modes, if check configuration comes from + * _ss_environment (values populated on reload). + */ + $('#use_environment').click(function(e) { + if(!$(this).is(':checked')) { + $('.configured-by-env').removeAttr('disabled'); + } else { + $('.configured-by-env').attr('disabled', 'disabled'); + } + }); + + /** + * Hide all existing database warnings, and show only current one + */ + $('#database_selection li').click(function(e) { + $('.dbfields').hide(); + // only show fields if there's no db error + if(!$('.databaseError', this).length) $('.dbfields', this).show(); + $('.databaseError').hide(); + $('.databaseError', this).show(); + }); + // Select first + $('#database_selection li input:checked').parents('li:first').click(); + + /** + * Install button + */ + $('#ReIn').click(function() { + $('#install_button').attr('disabled', !$(this).is(':checked')); + }) + $('#install_button').click(function() { + $('#saving_top').hide(); + $(this).val('Installing SilverStripe...'); + }) +}); \ No newline at end of file