'. t('Drupal assigns each module a weight. For most operations involving any module that defines a particular hook, the modules are invoked in order first by weight, then by name.') .'
'; $output .= ''. t('This module adds a weight column to the modules table at !modules, allowing weights to be viewed and edited. Once activated, a weight column appears on the modules table. To change a module weight, edit its value and press "Save configuration". Any user who can submit the !modules form will be able to change module weights.', array('!modules' => l('admin/build/modules', 'admin/build/modules'))) .'
'; break; } return $output; } function module_weights_menu() { $menu['admin/settings/util/module_weights'] = array( 'title' => 'Module Weights', 'description' => 'Module weight information.', 'page callback' => 'drupal_get_form', 'page arguments' => array('module_weights_settings'), 'access arguments' => array('administer site configuration'), 'type' => MENU_LOCAL_TASK, ); return $menu; } /** * Add weight header. */ function module_weights_system_module_headers_alter(&$header) { array_unshift($header, 'Weight'); } function module_weights_system_module_weights_alter(&$row, $module, &$form) { array_unshift($row, drupal_render($form['weights'][$module])); // CLEANUP what we added in hook_form_alter(). unset($form['weights'][$module]); } /** * Helper function to fetch and cache module weights. */ function fetch_module_weights($name = NULL) { static $module_weights = array(); if (empty($module_weights)) { $query = "SELECT filename, name, type, owner, status, throttle, bootstrap, schema_version, weight FROM {system} WHERE type = 'module' ORDER BY name"; $result = db_query($query); while ($row = db_fetch_object($result)) { $module_weights[$row->name] = $row->weight; } } if ($name === NULL) { return $module_weights; } elseif (isset($module_weights[$name])) { return $module_weights[$name]; } else { return NULL; } } function module_weights_form_alter(&$form, $form_state, $form_id) { switch ($form_id) { // The admin modules page. case 'system_modules': $weights = fetch_module_weights(); $form['weights'] = array('#tree' => TRUE); foreach ($weights as $name => $weight) { // We add "w_" to the name so as not to upset system module. $form['description'][$name]['weights']["w_$name"] = array( '#type' => 'textfield', '#default_value' => $weight, '#title' => t('Module weight'), '#size' => 4, '#prefix' => '