install.inc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * @file
  4. * SQLite specific install functions
  5. */
  6. class DatabaseTasks_sqlite extends DatabaseTasks {
  7. protected $pdoDriver = 'sqlite';
  8. public function name() {
  9. return st('SQLite');
  10. }
  11. /**
  12. * Minimum engine version.
  13. */
  14. public function minimumVersion() {
  15. return '3.3.7';
  16. }
  17. public function getFormOptions($database) {
  18. $form = parent::getFormOptions($database);
  19. // Remove the options that only apply to client/server style databases.
  20. unset($form['username'], $form['password'], $form['advanced_options']['host'], $form['advanced_options']['port']);
  21. // Make the text more accurate for SQLite.
  22. $form['database']['#title'] = st('Database file');
  23. $form['database']['#description'] = st('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', array('@drupal' => drupal_install_profile_distribution_name()));
  24. $default_database = conf_path(FALSE, TRUE) . '/files/.ht.sqlite';
  25. $form['database']['#default_value'] = empty($database['database']) ? $default_database : $database['database'];
  26. return $form;
  27. }
  28. public function validateDatabaseSettings($database) {
  29. // Perform standard validation.
  30. $errors = parent::validateDatabaseSettings($database);
  31. // Verify the database is writable.
  32. $db_directory = new SplFileInfo(dirname($database['database']));
  33. if (!$db_directory->isWritable()) {
  34. $errors[$database['driver'] . '][database'] = st('The directory you specified is not writable by the web server.');
  35. }
  36. return $errors;
  37. }
  38. }