From b8523467c71bbcbbac672490f5332a8ade3870ea Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 30 May 2009 19:02:04 +0000 Subject: [PATCH] MDL-15249 towards localized cli installer --- admin/cli/install.php | 24 +++++++++++------------- lang/en_utf8/admin.php | 3 +++ lang/en_utf8/install.php | 3 +++ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/admin/cli/install.php b/admin/cli/install.php index 9692c2a6b2..0410afa018 100644 --- a/admin/cli/install.php +++ b/admin/cli/install.php @@ -114,7 +114,7 @@ $CFG->httpsthemewww = $CFG->wwwroot; $CFG->dataroot = str_replace('\\', '/', dirname(dirname(dirname(__FILE__))).'/moodledata'); $CFG->docroot = 'http://docs.moodle.org'; $CFG->directorypermissions = 00777; -//$CFG->running_installer = true; +//$CFG->running_installer = true; //TODO: uncomment when install lang packs are regenerated $parts = explode('/', str_replace('\\', '/', dirname(dirname(__FILE__)))); $CFG->admin = array_pop($parts); @@ -336,8 +336,6 @@ if ($CFG->lang != 'en_utf8') { } } } -unset($CFG->running_installer); // we use full lang packs from now on - // ask for db type - show only drivers available if ($interactive) { @@ -467,11 +465,15 @@ if ($interactive) { cli_separator(); if (!$options['agree-license']) { echo "Do you agree to Moodle license blah blah blah?\n"; //TODO: localize and use real license - $input = cli_input('Type yes or y if you agree, ctrl+c if not', '', array('yes', 'y')); // TODO: localize including yes/y + $prompt = get_string('cliyesnoprompt', 'admin'); + $input = cli_input($prompt, '', array('n', 'y')); + if ($input == get_string('clianswerno', 'admin')) { + exit(1); + } } } else { if (!$options['agree-license']) { - cli_error('You must aggree to license by specifying --agree-license'); //TODO: localize + cli_error(get_string('climustagreelicense', 'install')); } } @@ -485,9 +487,6 @@ if (($fh = fopen($configfile, 'w')) !== false) { if (!file_exists($configfile)) { cli_error('Can not create config file.'); -} else if ($interactive) { - cli_separator(); - echo "config.php created\n"; } // return back to original dir before executing setup.php chich changes the dir again @@ -508,7 +507,7 @@ $CFG->release = ""; require($CFG->dirroot.'/version.php'); if ($DB->get_tables() ) { - cli_error('Database tables already present, cli installation can not continue.'); + cli_error(get_string('clitablesexist', 'install')); } if (!$DB->setup_is_unicodedb()) { @@ -520,7 +519,7 @@ if (!$DB->setup_is_unicodedb()) { if ($interactive) { cli_separator(); - echo get_string('databasesetup')."\n"; + cli_heading(get_string('databasesetup')); } // install core @@ -548,6 +547,5 @@ admin_apply_default_settings(NULL, true); admin_apply_default_settings(NULL, true); set_config('registerauth', ''); -echo "yay!!!\n"; - -exit(0); // 0 means success \ No newline at end of file +echo get_string('cliinstallfinished', 'install')."\n"; +exit(0); // 0 means success diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 5e0965a432..e8d256caef 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -59,9 +59,12 @@ $string['choosefiletoedit'] = 'Choose file to edit'; $string['clamfailureonupload'] = 'On clam AV failure'; $string['cleanup'] = 'Cleanup'; $string['cliincorrectvalueerror'] = 'Error, incorrect value \"$a->value\" for \"$a->option\"'; +$string['clianswerno'] = 'n'; +$string['cliansweryes'] = 'y'; $string['cliincorrectvalueretry'] = 'Incorrect value, please retry'; $string['clitypevalue'] = 'type value'; $string['clitypevaluedefault'] = 'type value, press Enter to use default value ($a)'; +$string['cliyesnoprompt'] = 'type y (means yes) or n (means no)'; $string['cliunknowoption'] = "Unrecognized options:\n \$a\n. Please use --help option."; $string['commonfiltersettings'] = 'Common filter settings'; $string['commonsettings'] = 'Common settings'; diff --git a/lang/en_utf8/install.php b/lang/en_utf8/install.php index c86daca80a..a360790423 100644 --- a/lang/en_utf8/install.php +++ b/lang/en_utf8/install.php @@ -23,7 +23,10 @@ $string['chooselanguagehead'] = 'Choose a language'; $string['chooselanguagesub'] = 'Please choose a language for the installation. This language will also be used as the default language for the site, though it may be changed later.'; $string['cliadminpassword'] = 'New admin user password'; $string['clialreadyinstalled'] = 'File config.php already exists, please use admin/cli/upgrade.php if you want to upgrade your site.'; +$string['cliinstallfinished'] = 'Installation completed successfully.'; $string['cliinstallheader'] = 'Moodle $a command line installation program'; +$string['climustagreelicense'] = 'In non interactive mode you must aggree to license by specifying --agree-license option'; +$string['clitablesexist'] = 'Database tables already present, cli installation can not continue.'; $string['compatibilitysettings'] = 'Checking your PHP settings ...'; $string['compatibilitysettingshead'] = 'Checking your PHP settings ...'; $string['compatibilitysettingssub'] = 'Your server should pass all these tests to make Moodle run properly'; -- 2.39.5