diff --git a/admin/modules.php b/admin/modules.php index 5b07d2ba075..2a3c8f24065 100644 --- a/admin/modules.php +++ b/admin/modules.php @@ -74,7 +74,11 @@ echo $OUTPUT->header(); echo $OUTPUT->heading($stractivities); - $strmodulename = get_string("modulename", "$delete"); + if (file_exists("$CFG->dirroot/mod/$delete/lang/en/$delete.php")) { + $strmodulename = get_string("modulename", "$delete"); + } else { + $strmodulename = $delete; + } if (!$confirm) { echo $OUTPUT->confirm(get_string("moduledeleteconfirm", "", $strmodulename), "modules.php?delete=$delete&confirm=1", "modules.php"); @@ -102,20 +106,10 @@ /// Get and sort the existing modules - if (!$modules = $DB->get_records("modules")) { + if (!$modules = $DB->get_records('modules', array(), 'name ASC')) { print_error('moduledoesnotexist', 'error'); } - foreach ($modules as $module) { - $strmodulename = get_string("modulename", "$module->name"); - // Deal with modules which are lacking the language string - if ($strmodulename == '[[modulename]]') { - $strmodulename = $module->name; - } - $modulebyname[$strmodulename] = $module; - } - ksort($modulebyname, SORT_LOCALE_STRING); - /// Print the table of all modules // construct the flexible table ready to display $table = new flexible_table(MODULE_TABLE); @@ -126,10 +120,17 @@ $table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide'); $table->setup(); - foreach ($modulebyname as $modulename => $module) { + foreach ($modules as $module) { - // took out hspace="\10\", because it does not validate. don't know what to replace with. - $icon = "pix_url('icon', $module->name) . "\" class=\"icon\" alt=\"\" />"; + if (!file_exists("$CFG->dirroot/mod/$module->name/lib.php")) { + $strmodulename = ''.$module->name.' ('.get_string('missingfromdisk').')'; + $missing = true; + } else { + // took out hspace="\10\", because it does not validate. don't know what to replace with. + $icon = "pix_url('icon', $module->name) . "\" class=\"icon\" alt=\"\" />"; + $strmodulename = $icon.' '.get_string('modulename', $module->name); + $missing = false; + } $delete = "name&sesskey=".sesskey()."\">$strdelete"; @@ -149,14 +150,17 @@ $countlink = "$count"; } - if ($module->visible) { + if ($missing) { + $visible = ''; + $class = ''; + } else if ($module->visible) { $visible = "name&sesskey=".sesskey()."\" title=\"$strhide\">". "pix_url('i/hide') . "\" class=\"icon\" alt=\"$strhide\" />"; - $class = ""; + $class = ''; } else { $visible = "name&sesskey=".sesskey()."\" title=\"$strshow\">". "pix_url('i/show') . "\" class=\"icon\" alt=\"$strshow\" />"; - $class = " class=\"dimmed_text\""; + $class = ' class="dimmed_text"'; } if ($module->name == "forum") { $delete = ""; @@ -164,13 +168,9 @@ $class = ""; } - $extra = ''; - if (!file_exists("$CFG->dirroot/mod/$module->name/lib.php")) { - $extra = ' ('.get_string('missingfromdisk').')'; - } $table->add_data(array( - ''.$icon.' '.$modulename.$extra.'', + ''.$strmodulename.'', $countlink, ''.$module->version.'', $visible,