From e3cd54731c55c62f7ee2985065d3e42511824677 Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Wed, 9 Jan 2008 23:15:44 +0000 Subject: [PATCH] MDL-12894 Fixing language string mess (language packs containing \n) & moved them to the controllers, also fixed a few typos and a || instead of && bug. This all relates to the CLI installer. --- admin/cliupgrade.php | 41 +++++++++++++++++++++++++++--- install/stringnames.txt | 1 - lang/en_utf8/install.php | 55 ++++++++++++++++++++-------------------- lib/installlib.php | 25 ++++++++++++------ lib/weblib.php | 4 +-- 5 files changed, 84 insertions(+), 42 deletions(-) diff --git a/admin/cliupgrade.php b/admin/cliupgrade.php index 08757be749..c8a7b710c4 100644 --- a/admin/cliupgrade.php +++ b/admin/cliupgrade.php @@ -177,6 +177,7 @@ if ( realpath($_SERVER['argv'][0]) == __FILE__ && count($args)>1) { //detect erros in the options if (PEAR::isError($console_opt)) { console_write(STDOUT,'invalidargumenthelp'); + console_write(STDOUT, "\n", '', false); die(); } @@ -187,6 +188,7 @@ $options=get_options($console_opt); if (is_array($options)) { if(array_key_exists('help',$options)){ console_write(STDOUT,'usagehelp'); + console_write(STDOUT, "\n", '', false); die ; } } @@ -231,7 +233,11 @@ if (!file_exists(dirname(dirname(__FILE__)) . '/config.php')) { //welcome message if ($verbose > CLI_NO) { + console_write(STDOUT, "\n", '', false); + console_write(STDOUT, "\n", '', false); console_write(STDOUT,'welcometext','install'); + console_write(STDOUT, "\n", '', false); + console_write(STDOUT, "\n", '', false); } //============================================================================// //Language selection for the installation @@ -239,14 +245,19 @@ if (!file_exists(dirname(dirname(__FILE__)) . '/config.php')) { if ( ( $interactive == CLI_FULL ) || ($interactive == CLI_SEMI && ( !isset($INSTALL['lang'])) ) ) { $langs=get_installer_list_of_languages(); + console_write(STDOUT, "\n", '', false); + console_write(STDOUT, "\n", '', false); console_write(STDOUT,'selectlanguage','install'); + console_write(STDOUT, "\n", '', false); console_write(STDOUT,'availablelangs','install'); + console_write(STDOUT, "\n", '', false); //output available languages foreach ( $langs as $language ) { console_write(STDOUT,"\t",'',false); console_write(STDOUT,$language,'',false); console_write(STDOUT,"\n",'',false); } + console_write(STDOUT, "\n", '', false); console_write(STDOUT,'yourchoice','install'); $short_code_langs = get_short_codes($langs); @@ -261,7 +272,9 @@ if (!file_exists(dirname(dirname(__FILE__)) . '/config.php')) { if ($verbose == CLI_NO) { $silent=true; }else{ + console_write(STDOUT, "\n", '', false); console_write(STDOUT,'checkingphpsettings','install'); + console_write(STDOUT, "\n", '', false); } /// Check that PHP is of a sufficient version check_compatibility(inst_check_php_version(), get_string('phpversion', 'install'), get_string('phpversionerror', 'install'),false,$silent); @@ -288,7 +301,11 @@ if (!file_exists(dirname(dirname(__FILE__)) . '/config.php')) { if ( ( $interactive == CLI_FULL ) || ($interactive == CLI_SEMI && ( !isset($INSTALL['dirroot']) || !isset($INSTALL['wwwroot']) || !isset($INSTALL['dataroot']) ) ) ) { + console_write(STDOUT, "\n", '', false); + console_write(STDOUT, "\n", '', false); console_write(STDOUT,'locationanddirectories','install'); + console_write(STDOUT, "\n", '', false); + console_write(STDOUT, "\n", '', false); } //input the web directory @@ -338,7 +355,11 @@ if (!file_exists(dirname(dirname(__FILE__)) . '/config.php')) { // Database section heading if ( ( $interactive == CLI_FULL ) || ($interactive == CLI_SEMI && ( !isset($INSTALL['dbhost']) || !isset($INSTALL['dbname']) || !isset($INSTALL['dbtype']) || !isset($INSTALL['dbuser']) || !isset($INSTALL['dbpass']) || !isset($INSTALL['prefix']) ) ) ) { + console_write(STDOUT, "\n", '', false); + console_write(STDOUT, "\n", '', false); console_write(STDOUT,'databasesettingsformoodle','install'); + console_write(STDOUT, "\n", '', false); + console_write(STDOUT, "\n", '', false); } //Input dialogs @@ -352,7 +373,9 @@ if (!file_exists(dirname(dirname(__FILE__)) . '/config.php')) { } if ( ( $interactive == CLI_FULL ) || ($interactive == CLI_SEMI && ( !isset($INSTALL['dbtype']) ))) { $dbtypes=array('mysql','oci8po','postgres7','mssql','mssql_n','odbc_mssql'); + console_write(STDOUT, "\n", '', false); console_write(STDOUT,'availabledbtypes','install'); + console_write(STDOUT, "\n", '', false); foreach ($dbtypes as $dbtype) { console_write(STDOUT,"\t",'',false); console_write(STDOUT,$dbtype,'install'); @@ -458,7 +481,7 @@ if (!file_exists(dirname(dirname(__FILE__)) . '/config.php')) { $db->SetFetchMode(ADODB_FETCH_ASSOC); if (! $dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname'])) { - $errormsg= get_string('cannotconnecttodb','install'); + $errormsg= get_string('cannotconnecttodb','install') . "\n"; } else { /// We have been able to connect properly, just test the database encoding now. /// It must be Unicode for 1.8 installations. @@ -507,7 +530,7 @@ if (!file_exists(dirname(dirname(__FILE__)) . '/config.php')) { if ($dbconnected) { /// Execute environment check, printing results if (!check_moodle_environment($INSTALL['release'], $environment_results, false)) { - $errormsg = get_string('errorsinenvironment', 'install'); + $errormsg = get_string('errorsinenvironment', 'install') . "\n"; } } else { /// We never should reach this because DB has been tested before arriving here @@ -531,6 +554,8 @@ if (!file_exists(dirname(dirname(__FILE__)) . '/config.php')) { if ( ( $interactive == CLI_FULL ) || ($interactive == CLI_SEMI && ( !isset($INSTALL['downloadlangaugepack']) ))) { $site_langs=get_list_of_languages(); if (!key_exists($INSTALL['lang'],$site_langs)) { + console_write(STDOUT, "\n", '', false); + console_write(STDOUT, "\n", '', false); console_write(STDOUT,'downloadlanguagepack','install'); $download_lang_pack=read_yes_no(); if($download_lang_pack == 'yes'){ @@ -574,7 +599,7 @@ if (!file_exists(dirname(dirname(__FILE__)) . '/config.php')) { } } - if ( $verbose > CLI_NO && $downloadsuccess) { + if ( $verbose > CLI_NO && !empty($downloadsuccess)) { //print success message if language pack download is successful console_write(STDOUT,'downloadsuccess'); print_newline(); @@ -603,6 +628,7 @@ if (!file_exists(dirname(dirname(__FILE__)) . '/config.php')) { if ($verbose > CLI_NO) { console_write(STDOUT,'creatingconfigfile','install'); + console_write(STDOUT, "\n", '', false); } $str = ' CLI_NO) { console_write(STDOUT,'configfilecreated','install'); + console_write(STDOUT, "\n", '', false); } } else { - console_write(STDERR,'writeconfigfilefailed','install'); + console_write(STDOUT,'configfilenotwritten','install'); + console_write(STDOUT, "\n", '', false); + console_write(STDOUT, "\n", '', false); + console_write(STDERR, $str, '', false); } if ( $verbose ) { console_write(STDOUT,'installationiscomplete','install'); + console_write(STDOUT, "\n", '', false); } } @@ -657,6 +688,7 @@ if (!file_exists(dirname(dirname(__FILE__)) . '/config.php')) { if ( file_exists(dirname(dirname(__FILE__)) . '/config.php')) { // This is what happens if there is no upgrade.... //console_write(STDERR,'configurationfileexist','install'); + //console_write(STDOUT, "\n", '', false); //die; @@ -1305,6 +1337,7 @@ if ( file_exists(dirname(dirname(__FILE__)) . '/config.php')) { if ( $verbose > CLI_NO ) { print_newline(); console_write(STDOUT,'upgradingcompleted'); + console_write(STDOUT, "\n", '', false); } } diff --git a/install/stringnames.txt b/install/stringnames.txt index 766dfa00cc..97e6864a62 100644 --- a/install/stringnames.txt +++ b/install/stringnames.txt @@ -208,7 +208,6 @@ thisdirection thislanguage unicoderecommended unicoderequired -unsafedirname upgradingactivitymodule upgradingbackupdb upgradingblocksdb diff --git a/lang/en_utf8/install.php b/lang/en_utf8/install.php index 31875b4b8f..97a348dcab 100644 --- a/lang/en_utf8/install.php +++ b/lang/en_utf8/install.php @@ -1,7 +1,7 @@ User: your database username
Password: your database password
Tables Prefix: optional prefix to use for all table names'; -$string['databasesettingsformoodle']='\n\nDatabase settings for Moodle\n\n'; +$string['databasesettingsformoodle']='Database settings for Moodle'; $string['databasesettingshead'] = 'Now you need to configure the database where most Moodle data will be stored. This database must already have been created and a username and password created to access it.'; @@ -186,13 +186,13 @@ $string['download'] = 'Download'; $string['downloadlanguagebutton'] = 'Download the "$a" language pack'; $string['downloadlanguagehead'] = 'Download language pack'; $string['downloadlanguagenotneeded'] = 'You may continue the installation process using the default language pack, \"$a\".'; -$string['downloadlanguagepack']='\n\nDo you want to download language pack now(yes/no) :'; +$string['downloadlanguagepack']='Do you want to download language pack now(yes/no) :'; $string['downloadlanguagesub'] = 'You now have the option of downloading a language pack and continuing the installation process in this language.

If you are unable to download the language pack, the installation process will continue in English. (Once the installation process is complete, you will have the opportunity to download and install additional language packs.)'; $string['downloadsuccess'] = 'Language Pack Downloaded Successfuly'; $string['doyouagree'] = 'Do you agree ? (yes/no):'; $string['environmenthead'] = 'Checking your environment ...'; $string['environmentsub'] = 'We are checking if the various components of your system meet the system requirements'; -$string['errorsinenvironment'] ='Errors in the environment !\n'; +$string['errorsinenvironment'] ='Errors in the environment!'; $string['fail'] = 'Fail'; $string['fileuploads'] = 'File Uploads'; $string['fileuploadserror'] = 'This should be on'; @@ -231,24 +231,24 @@ $string['inputdatadirectory']='Data Directory :'; $string['inputwebadress']='Web address :'; $string['inputwebdirectory']='Moodle Directory :'; $string['installation'] = 'Installation'; -$string['installationiscomplete'] = 'Installtion is completed !\n'; +$string['installationiscomplete'] = 'Installation is completed!'; $string['invalidargumenthelp']=' Error: Invalid argument(s) Usage: \$php cliupgrade.php OPTIONS - Use --help option to get more help\n'; + Use --help option to get more help'; $string['invalidemail'] = 'Invalid Email'; $string['invalidhost'] = 'Invalid Host '; -$string['invalidint']='Error: value is not an integer \n'; -$string['invalidintrange'] = 'Error: Value is outside valid range\n'; +$string['invalidint']='Error: value is not an integer'; +$string['invalidintrange'] = 'Error: Value is outside valid range'; $string['invalidpath'] = 'Invalid Path '; -$string['invalidsetelement']= 'Error: Value given is not in the given options \n'; +$string['invalidsetelement']= 'Error: Value given is not in the given options'; $string['invalidtextvalue'] = 'Invalid Text Value'; $string['invalidurl'] = 'Invalid URL '; -$string['invalidvalueforlanguage']='Invalid value for --lang option. Type --help for more help\n'; -$string['invalidyesno'] = 'Error: value is not a valid yes/no argument \n'; +$string['invalidvalueforlanguage']='Invalid value for --lang option. Type --help for more help'; +$string['invalidyesno'] = 'Error: value is not a valid yes/no argument'; $string['langdownloaderror'] = 'Unfortunately the language \"$a\" was not installed. The installation process will continue in English.'; $string['langdownloadok'] = 'The language \"$a\" was installed successfully. The installation process will continue in this language.'; -$string['locationanddirectories']= '\n\nLocation and directories \n\n'; +$string['locationanddirectories']= 'Location and directories'; $string['magicquotesruntime'] = 'Magic Quotes Run Time'; $string['magicquotesruntimeerror'] = 'This should be off'; $string['magicquotesruntimehelp'] = '

Magic quotes runtime should be turned off for Moodle to function properly.

@@ -310,7 +310,7 @@ $string['safemodehelp'] = '

Moodle may have a variety of problems with safe mo to just find a new web hosting company for your Moodle site.

You can try continuing the install if you like, but expect a few problems later on.

'; -$string['selectlanguage']='\n\nSelecting a language for installation\n'; +$string['selectlanguage']='Selecting a language for installation'; $string['sessionautostart'] = 'Session Auto Start'; $string['sessionautostarterror'] = 'This should be off'; $string['sessionautostarthelp'] = '

Moodle requires session support and will not function without it.

@@ -323,12 +323,11 @@ $string['siteshortname'] = 'Site short name :'; $string['sitesummary'] ='Site summary :'; $string['skipdbencodingtest'] = 'Skip DB Encoding Test'; $string['tableprefix']='Table prefix :'; -$string['unsafedirname'] = 'Error: Unsafe characters in directory name. valid characters are a-zA-Z0-9_-\n'; $string['upgradingactivitymodule']= 'Upgrading Activity Module'; $string['upgradingbackupdb'] = 'Upgrading Backup Database'; $string['upgradingblocksdb'] = 'Upgrading Blocks Database'; $string['upgradingblocksplugin'] = 'Upgrading Blocks Plugin'; -$string['upgradingcompleted'] = 'Upgrading completed...\n'; +$string['upgradingcompleted'] = 'Upgrading completed...'; $string['upgradingcourseformatplugin'] = 'Upgrading Course Format Pluggin'; $string['upgradingenrolplugin'] = 'Upgrading Enrol Plugin'; $string['upgradinggradeexportplugin'] = 'Upgrading Grade Export Plugin'; @@ -340,7 +339,8 @@ $string['upgradingqtypeplugin'] = 'Upgrading Question/type Plugin'; $string['upgradingrpcfunctions'] = 'Upgrading RPC Functions'; $string['usagehelp']=' Synopsis: -\$php cliupgrade.php OPTIONS\n +\$php cliupgrade.php OPTIONS + OPTIONS --lang Valid installed language for installation. Default is English(en) --webaddr Web address for the Moodle site @@ -364,9 +364,10 @@ OPTIONS --adminusername Username for the admin. Default is admin --adminpassword Password for the admin. Default is admin --adminemail Email address of admin. Default is root@localhost ---help print out this help\n +--help print out this help + Usage: -\$php cliupgrade.php --lang=en --webaddr=http://www.example.com --moodledir=/var/www/html/moodle --datadir=/var/moodledata --dbtype=mysql --dbhost=localhost --dbname=moodle --dbuser=root --prefix=mdl --agreelicense=yes --confirmrelease=yes --sitefullname=\"Example Moodle Site\" --siteshortname=moodle --sitesummary=siteforme --adminfirstname=Admin --adminlastname=User --adminusername=admin --adminpassword=admin --adminemail=admin@example.com --verbose=1 --interactivelevel=2 \n'; +\$php cliupgrade.php --lang=en --webaddr=http://www.example.com --moodledir=/var/www/html/moodle --datadir=/var/moodledata --dbtype=mysql --dbhost=localhost --dbname=moodle --dbuser=root --prefix=mdl --agreelicense=yes --confirmrelease=yes --sitefullname=\"Example Moodle Site\" --siteshortname=moodle --sitesummary=siteforme --adminfirstname=Admin --adminlastname=User --adminusername=admin --adminpassword=admin --adminemail=admin@example.com --verbose=1 --interactivelevel=2'; $string['versionerror'] = 'User aborted due to version Error '; $string['welcomep10'] = '$a->installername ($a->installerversion)'; $string['welcomep20'] = 'You are seeing this page because you have successfully installed and @@ -382,10 +383,10 @@ $string['welcomep60'] = 'The following pages will lead you through some easy to configure and set up Moodle on your computer. You may accept the default settings or, optionally, amend them to suit your own needs.'; $string['welcomep70'] = 'Click the \"Next\" button below to continue with the set up of Moodle.'; -$string['welcometext']='\n\n---Welcome to moodle commandline installer---\n\n'; +$string['welcometext']='---Welcome to moodle commandline installer---'; $string['writetoconfigfilefaild'] = 'Error: Write to config file failed '; $string['wwwroot'] = 'Web address'; $string['wwwrooterror'] = 'The \'Web Address\' does not appear to be valid - this Moodle installation doesn\'t appear to be there. The value below has been reset.'; -$string['yourchoice']='\nYour choice :'; +$string['yourchoice']='Your choice :'; ?> diff --git a/lib/installlib.php b/lib/installlib.php index d14cf1138c..90ed04c53a 100644 --- a/lib/installlib.php +++ b/lib/installlib.php @@ -240,6 +240,7 @@ function validate_option_values($options){ if (isset($values['lang'])) { if (!valid_language($INSTALL['lang'])) { console_write(STDERR,'invalidvalueforlanguage'); + console_write(STDOUT, "\n", '', false); } } if (isset($values['webdir'])) { @@ -370,7 +371,7 @@ function console_write($stream,$identifier,$module='install',$use_string_lib=tru fwrite($stream,$identifier); } if ($stream == STDERR) { - fwrite($stream,get_string('aborting',$module)); + fwrite($stream, "\n\n" . get_string('aborting',$module) . "\n\n"); die; } } @@ -397,6 +398,7 @@ function read_int() { return $input; } else { console_write(STDERR,'invalidint'); + console_write(STDOUT, "\n", '', false); } } //=========================================================================// @@ -413,6 +415,7 @@ function read_int_range($start,$end) { return $input; } else { console_write(STDERR,'invalidintrange'); + console_write(STDOUT, "\n", '', false); } } @@ -432,6 +435,7 @@ function read_yes_no() { } } else { console_write(STDERR,'invalidyesno'); + console_write(STDOUT, "\n", '', false); } } @@ -459,6 +463,7 @@ function read_element($set=array()) { return $input; } else { console_write(STDERR,'invalidsetelement'); + console_write(STDOUT, "\n", '', false); } } //=========================================================================// @@ -576,18 +581,22 @@ function inst_check_php_version() { * @param array $env, of type object */ function print_environment_status($env = array()) { - console_write(STDOUT,"Status\t\tInfo\t\tPart\n\r",'',false); + console_write(STDOUT, get_string('name') . "\t\t\t" . get_string('info') . "\t" . get_string('status') . "\n\r", '', false); + //console_write(STDOUT,"Status\t\tInfo\t\tPart\n\r",'',false); foreach ( $env as $object) { - + console_write(STDOUT,$object->part,'',false); + console_write(STDOUT,"\t\t",'',false); + if (!empty($object->info)) { + console_write(STDOUT, $object->info, '', false); + } else { + console_write(STDOUT, "\t", '', false); + } + console_write(STDOUT, "\t\t", '', false); if ($object->status == 1 ) { console_write(STDOUT,'ok','',false); } else { console_write(STDOUT,'fail','',false); } - console_write(STDOUT,"\t\t",'',false); - console_write(STDOUT,$object->info,'',false); - console_write(STDOUT,"\t\t",'',false); - console_write(STDOUT,$object->part,'',false); console_write(STDOUT,"\n\r",'',false); } } @@ -627,6 +636,6 @@ function print_environment_status_detailed($env = array()) { */ function print_newline() { - console_write(STDOUT,'newline','install'); + console_write(STDOUT, "\n", '', false); } ?> diff --git a/lib/weblib.php b/lib/weblib.php index f414c197ef..344d9db2c7 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2354,7 +2354,7 @@ function print_header ($title='', $heading='', $navigation='', $focus='', if ($return) { return $output; } else { - console_write(STDOUT,$output,'',false); + console_write(STDOUT,$output . "\n",'',false); return; } } @@ -5762,7 +5762,7 @@ function error ($message, $link='') { global $CFG, $SESSION, $THEME; $message = clean_text($message); // In case nasties are in here - if (defined('CLI_UPGRADE') || CLI_UPGRADE) { + if (defined('CLI_UPGRADE') && CLI_UPGRADE) { console_write(STDERR,$message,'',false); die ; } -- 2.39.5