Generate a list of all the available modules, as well as update the system list.
1 call to system_module_listing()
- system_modules in modules/
system.module - Menu callback; displays a listing of all modules.
File
- modules/
system.module, line 457 - Configuration system that lets administrators modify the workings of the site.
Code
function system_module_listing() {
// Get current list of modules
$files = system_listing('\\.module$', 'modules', 'name', 0);
// Extract current files from database.
system_get_files_database($files, 'module');
ksort($files);
$required = array(
'block',
'filter',
'system',
'user',
'watchdog',
);
$throttle_required = array_merge($required, array(
'throttle',
));
$header = array(
t('Name'),
t('Description'),
t('Enabled'),
);
if (module_exist('throttle')) {
$header[] = t('Throttle');
}
foreach ($files as $filename => $file) {
drupal_get_filename('module', $file->name, $file->filename);
drupal_load('module', $file->name);
$file->description = module_invoke($file->name, 'help', 'admin/modules#description');
// log the critical hooks implemented by this module
$bootstrap = 0;
foreach (bootstrap_hooks() as $hook) {
if (module_hook($file->name, $hook)) {
$bootstrap = 1;
break;
}
}
// Update the contents of the system table:
db_query("DELETE FROM {system} WHERE name = '%s' AND type = '%s'", $file->name, 'module');
db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $file->name, $file->description, 'module', $file->filename, $file->status, $file->throttle, $bootstrap);
$row = array(
$file->name,
$file->description,
array(
'data' => in_array($file->name, $required) ? form_hidden("status][{$file->name}", 1) . t('required') : form_checkbox('', "status][{$file->name}", 1, $file->status),
'align' => 'center',
),
);
if (module_exist('throttle')) {
$row[] = array(
'data' => in_array($file->name, $throttle_required) ? form_hidden("throttle][{$file->name}", 0) . t('required') : form_checkbox(NULL, "throttle][{$file->name}", 1, $file->throttle, NULL),
'align' => 'center',
);
}
$rows[] = $row;
}
$output = theme('table', $header, $rows);
$output .= form_hidden('type', 'module');
return $output;
}