function module_weights_settings in Util 6.3
Same name and namespace in other branches
- 6.2 module_weights.module \module_weights_settings()
Implements hook_settings().
1 string reference to 'module_weights_settings'
- module_weights_menu in ./
module_weights.module - Implements hook_menu().
File
- ./
module_weights.module, line 170 - Allows module weights to be viewed and edited.
Code
function module_weights_settings() {
drupal_add_css(drupal_get_path('module', 'module_weights') . '/module_weights.css');
$form = array();
$form['module_weights_warning'] = array(
'#type' => 'radios',
'#options' => array(
0 => t('None'),
1 => t('Verbose'),
),
'#default_value' => variable_get('module_weights_warning', 0),
'#title' => t('Missing module warning'),
'#description' => t('If a module file cannot be found, would you like a warning to be issued?'),
);
$weighted = $missing = array();
$header = array(
t('Module'),
t('Weight'),
);
$result = db_query("SELECT name, weight, filename, status FROM {system} WHERE TYPE = 'module' ORDER BY name");
while ($row = db_fetch_object($result)) {
if (!file_exists($row->filename)) {
$desc = $row->name;
if ($row->status) {
drupal_set_message(t('@name module file (@file) could not be found, but is still marked as "enabled!"', array(
'@name' => $row->name,
'@file' => $row->filename,
)), 'warning');
$desc .= '*';
}
$missing[] = $desc;
}
if ($row->weight != 0) {
$weighted[] = array(
$row->name,
array(
'data' => $row->weight,
'align' => 'right',
),
);
}
}
if ($missing) {
if (module_exists('system_table_cleaner')) {
$desc = t('These module files could not be found and mess up the modules administration page. The system table needs to be <a href="!url">cleaned up</a>.', array(
'!url' => url('admin/settings/systems-table-cleaner'),
));
}
else {
$desc = t('These module files could not be found and mess up the modules administration page. The system table needs to be cleaned up. The <a href="!url">System Table Cleaner</a> module can be used for this.', array(
'!url' => 'http://drupal.org/project/system_table_cleaner',
));
}
$form['missing'] = array(
'#type' => 'fieldset',
'#title' => t('Missing module files'),
'#description' => $desc,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['missing']['list'] = array(
'#type' => 'markup',
'#value' => theme('item_list', $missing),
);
}
$form['weights'] = array(
'#type' => 'fieldset',
'#title' => t('Weighted modules'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['weights']['list'] = array(
'#type' => 'markup',
'#value' => theme('table', $header, $weighted, array(
'style' => 'width: auto;',
)),
);
return system_settings_form($form);
}