Commit 4fd532ea authored by dongsheng's avatar dongsheng
Browse files

MDL-14129, creating error string

parent 13b565dc
......@@ -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 '<div class="notifysuccess">Created directory '.
$langbase .'</div>'."<br />\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 '<div class="notifysuccess">Created directory '.
$langdir .'</div>'."<br />\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&amp;currentfile=$currentfile");
print_error('cannotsavefile', 'error', 'lang.php?mode=compare&amp;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&amp;currentfile=$currentfile&amp;sesskey=$USER->sesskey");
print_error('cannotsavefile', 'error', 'lang.php?mode=compare&amp;currentfile=$currentfile', array($saveinto, $currentfile));
}
}
......
......@@ -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
......
......@@ -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';
......
......@@ -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) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment