From: dongsheng Date: Thu, 10 Apr 2008 02:56:25 +0000 (+0000) Subject: MDL-14129, creating error string X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4fd532ea9d968f262915467033b7e29f6593e431;p=moodle.git MDL-14129, creating error string --- diff --git a/admin/lang.php b/admin/lang.php index 582b0ac136..84930877df 100644 --- a/admin/lang.php +++ b/admin/lang.php @@ -52,11 +52,11 @@ } if (!has_capability('moodle/site:langeditmaster', $context, $USER->id, false) && (!$uselocal)) { - print_error('cannoteditmasterlang'); + print_error('cannoteditmasterlang', 'error'); } if ((!has_capability('moodle/site:langeditlocal', $context, $USER->id, false)) && ($uselocal)) { - print_error('cannotcustomizelocallang'); + print_error('cannotcustomizelocallang', 'error'); } $strlanguage = get_string("language"); @@ -164,7 +164,7 @@ $stringfiles += lang_extra_locations(); } if (count($stringfiles) == 0) { - print_error("Could not find English language pack!"); + print_error('cannotfindlang', 'error', '', 'English'); } } elseif ($mode == 'helpfiles') { $helpfiles = lang_help_standard_locations(); @@ -172,7 +172,7 @@ $helpfiles += lang_help_extra_locations(); } if (count($helpfiles) == 0) { - print_error("Could not find help files in the English language pack!"); + print_error("cannotfindhelp", 'error', '', 'English'); } } @@ -334,7 +334,7 @@ echo $o; if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) { - print_error("Could not find English language help files!"); + print_error("cannotfindhelp", 'error', '', 'English'); } foreach ($files as $filekey => $file) { // check all the help files. @@ -346,7 +346,7 @@ } if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) { - print_error("Could not find English language docs files!"); + print_error("cannotfinddoc", 'error', '', 'English'); } foreach ($files as $filekey => $file) { // check all the docs files. if (!file_exists("$langdir/docs/$file")) { @@ -366,7 +366,7 @@ if (!file_exists($langbase) ){ if (!lang_make_directory($langbase) ){ - print_error('ERROR: Could not create base lang directory ' . $langbase); + print_error('cannotcreatelangbase', 'error'); } else { echo '
Created directory '. $langbase .'
'."
\n"; @@ -374,7 +374,7 @@ } if (!$uselocal && !file_exists($langdir)) { if (!lang_make_directory($langdir)) { - print_error('ERROR: Could not create directory '.$langdir); + print_error('cannotcreatelangdir', 'error'); } else { echo '
Created directory '. $langdir .'
'."
\n"; @@ -393,7 +393,7 @@ if ($currentfile <> '') { if (!$fileinfo = lang_get_file_info($currentfile, $stringfiles)) { - print_error('Unable to find info for: '.$currentfile); + print_error('cannotfindinfo', 'error', '', $currentfile); } // check the filename is set up correctly, prevents bugs similar to MDL-10920 $location = $fileinfo['location']; @@ -403,7 +403,7 @@ if ($location || $plugin) { // file in an extra location if ($currentfile != "{$prefix}{$plugin}.php") { - print_error("Non-core filename mismatch. The file $currentfile should be {$prefix}{$plugin}.php"); + print_error('filemismatch', 'error', '', array($currectfile, $prefix, $plugin)); } if (!$uselocal) { notify($streditingnoncorelangfile); @@ -412,7 +412,7 @@ } else { // file in standard location if ($currentfile != $filename) { - print_error("Core filename mismatch. The file $currentfile should be $filename"); + print_error('filemismatch', 'error', '', array($currectfile, $filename, '')); } } @@ -466,7 +466,7 @@ if (lang_save_file($saveinto, $currentfile, $newstrings, $uselocal, $packstring)) { notify(get_string("changessaved")." ($saveinto/$currentfile)", "notifysuccess"); } else { - print_error("Could not save the file '$saveinto/$currentfile'!", '', "lang.php?mode=compare&currentfile=$currentfile"); + print_error('cannotsavefile', 'error', 'lang.php?mode=compare&currentfile=$currentfile', array($saveinto, $currentfile)); } unset($packstring); } @@ -715,7 +715,7 @@ if (lang_help_save_file($saveto, $currentfile, $_POST['filedata'])) { notify(get_string("changessaved")." ($saveto/$currentfile)", "notifysuccess"); } else { - print_error("Could not save the file '$currentfile'!", '', "lang.php?mode=helpfiles&currentfile=$currentfile&sesskey=$USER->sesskey"); + print_error('cannotsavefile', 'error', 'lang.php?mode=compare&currentfile=$currentfile', array($saveinto, $currentfile)); } } diff --git a/admin/langimport.php b/admin/langimport.php index d5d3d2d1f1..02b57d3b60 100755 --- a/admin/langimport.php +++ b/admin/langimport.php @@ -30,7 +30,7 @@ //reset and diagnose lang cache permissions @unlink($CFG->dataroot.'/cache/languages'); if (file_exists($CFG->dataroot.'/cache/languages')) { - print_error('Language cache can not be deleted, please fix permissions in dataroot/cache/languages!'); + print_error('cannotdeletelangcache', 'error'); } get_list_of_languages(true); //refresh lang cache @@ -131,7 +131,7 @@ if (!$availablelangs = get_remote_list_of_languages()) { - print_error('cannotdownloadlanguageupdatelist'); + print_error('cannotdownloadlanguageupdatelist', 'error'); } //and build an associative array diff --git a/admin/maintenance.php b/admin/maintenance.php index 6f0498d3eb..071a873254 100644 --- a/admin/maintenance.php +++ b/admin/maintenance.php @@ -10,7 +10,7 @@ //Check folder exists if (! make_upload_directory(SITEID)) { // Site folder - print_error("Could not create site folder. The site administrator needs to fix the file permissions"); + print_error('cannotcreatesitedir', 'error'); } $filename = $CFG->dataroot.'/'.SITEID.'/maintenance.html'; diff --git a/admin/modules.php b/admin/modules.php index 8c53465b2d..ae83eb8a1b 100644 --- a/admin/modules.php +++ b/admin/modules.php @@ -34,7 +34,7 @@ if (!empty($hide) and confirm_sesskey()) { if (!$module = get_record("modules", "name", $hide)) { - print_error("Module doesn't exist!"); + print_error('moduledoesnotexist', 'error'); } set_field("modules", "visible", "0", "id", $module->id); // Hide main module // Remember the visibility status in visibleold @@ -57,7 +57,7 @@ if (!empty($show) and confirm_sesskey()) { if (!$module = get_record("modules", "name", $show)) { - print_error("Module doesn't exist!"); + print_error('moduledoesnotexist', 'error'); } set_field("modules", "visible", "1", "id", $module->id); // Show main module set_field('course_modules', 'visible', '1', 'visibleold', @@ -89,11 +89,11 @@ } else { // Delete everything!! if ($delete == "forum") { - print_error("You can not delete the forum module!!"); + print_error("cannotdeleteforummudule", 'forum'); } if (!$module = get_record("modules", "name", $delete)) { - print_error("Module doesn't exist!"); + print_error('moduledoesnotexist', 'error'); } // OK, first delete all the relevant instances from all course sections @@ -180,7 +180,7 @@ /// Get and sort the existing modules if (!$modules = get_records("modules")) { - print_error("No modules found!!"); // Should never happen + print_error('moduledoesnotexist', 'error'); } foreach ($modules as $module) {