diff options
Diffstat (limited to 'modules/system')
-rw-r--r-- | modules/system/system.admin.inc | 17 | ||||
-rw-r--r-- | modules/system/system.api.php | 7 | ||||
-rw-r--r-- | modules/system/system.install | 6 | ||||
-rw-r--r-- | modules/system/system.module | 39 |
4 files changed, 46 insertions, 23 deletions
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index f2c278f77..e21c114ae 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -146,12 +146,11 @@ function system_admin_menu_block_page() { */ function system_admin_by_module() { - $modules = system_get_module_data(); + $module_info = system_get_info('module'); $menu_items = array(); $help_arg = module_exists('help') ? drupal_help_arg() : FALSE; - foreach ($modules as $file) { - $module = $file->name; + foreach ($module_info as $module => $info) { if ($module == 'help') { continue; } @@ -169,7 +168,7 @@ function system_admin_by_module() { // Sort. ksort($admin_tasks); - $menu_items[$file->info['name']] = array($file->info['description'], $admin_tasks); + $menu_items[$info['name']] = array($info['description'], $admin_tasks); } } return theme('system_admin_by_module', array('menu_items' => $menu_items)); @@ -200,7 +199,7 @@ function system_settings_overview() { */ function system_themes_form() { // Get current list of themes. - $themes = system_get_theme_data(); + $themes = system_rebuild_theme_data(); // Remove hidden themes from the display list. foreach ($themes as $theme_key => $theme) { @@ -396,7 +395,7 @@ function system_theme_settings($form, &$form_state, $key = '') { if ($key) { $settings = theme_get_settings($key); $var = str_replace('/', '_', 'theme_' . $key . '_settings'); - $themes = system_get_theme_data(); + $themes = system_rebuild_theme_data(); $features = $themes[$key]->info['features']; } else { @@ -643,7 +642,7 @@ function _system_is_incompatible(&$incompatible, $files, $file) { */ function system_modules($form, $form_state = array()) { // Get current list of modules. - $files = system_get_module_data(); + $files = system_rebuild_module_data(); // Remove hidden modules from display list. foreach ($files as $filename => $file) { @@ -834,7 +833,7 @@ function _system_modules_build_row($info, $extra) { * Display confirmation form for required modules. * * @param $modules - * Array of module file objects as returned from system_get_module_data(). + * Array of module file objects as returned from system_rebuild_module_data(). * @param $storage * The contents of $form_state['storage']; an array with two * elements: the list of required modules and the list of status @@ -891,7 +890,7 @@ function system_modules_submit($form, &$form_state) { // Get a list of all modules, it will be used to find which module requires // which. - $files = system_get_module_data(); + $files = system_rebuild_module_data(); // The modules to be enabled. $modules_to_be_enabled = array(); diff --git a/modules/system/system.api.php b/modules/system/system.api.php index e8e4f5935..186899273 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -720,9 +720,10 @@ function hook_mail_alter(&$message) { /** * Alter the information parsed from module and theme .info files * - * This hook is invoked in _system_get_module_data() and in _system_get_theme_data(). - * A module may implement this hook in order to add to or alter the data - * generated by reading the .info file with drupal_parse_info_file(). + * This hook is invoked in _system_rebuild_module_data() and in + * _system_rebuild_theme_data(). A module may implement this hook in order to + * add to or alter the data generated by reading the .info file with + * drupal_parse_info_file(). * * @param &$info * The .info file contents, passed by reference so that it can be altered. diff --git a/modules/system/system.install b/modules/system/system.install index 4febc30e8..08ecacd5e 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -345,12 +345,12 @@ function system_install() { } // Clear out module list and hook implementation statics before calling - // system_get_theme_data(). + // system_rebuild_theme_data(). module_list(TRUE); module_implements('', FALSE, TRUE); // Load system theme data appropriately. - system_get_theme_data(); + system_rebuild_theme_data(); // Inserting uid 0 here confuses MySQL -- the next user might be created as // uid 2 which is not what we want. So we insert the first user here, the @@ -2212,7 +2212,7 @@ function system_update_7021() { variable_del('site_footer'); // Rebuild theme data, so the new 'help' region is identified. - system_get_theme_data(); + system_rebuild_theme_data(); } /** diff --git a/modules/system/system.module b/modules/system/system.module index 8ddfea03f..483ea8643 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1847,12 +1847,35 @@ function system_update_files_database(&$files, $type) { } /** + * Returns an array of information about active modules or themes. + * + * This function returns the information from the {system} table corresponding + * to the cached contents of the .info file for each active module or theme. + * + * @param $type + * Either 'module' or 'theme'. + * @return + * An associative array of module or theme information keyed by name. + * + * @see system_rebuild_module_data() + * @see system_rebuild_theme_data() + */ +function system_get_info($type) { + $info = array(); + $result = db_query('SELECT name, info FROM {system} WHERE type = :type AND status = 1', array(':type' => $type)); + foreach ($result as $item) { + $info[$item->name] = unserialize($item->info); + } + return $info; +} + +/** * Helper function to scan and collect module .info data. * * @return * An associative array of module information. */ -function _system_get_module_data() { +function _system_rebuild_module_data() { // Find modules $modules = drupal_system_listing('/\.module$/', 'modules', 'name', 0); @@ -1903,13 +1926,13 @@ function _system_get_module_data() { } /** - * Collect data about all currently available modules. + * Rebuild, save, and return data about all currently available modules. * * @return * Array of all available modules and their data. */ -function system_get_module_data() { - $modules = _system_get_module_data(); +function system_rebuild_module_data() { + $modules = _system_rebuild_module_data(); ksort($modules); system_get_files_database($modules, 'module'); system_update_files_database($modules, 'module'); @@ -1939,7 +1962,7 @@ function system_get_module_data() { * @return * An associative array of themes information. */ -function _system_get_theme_data() { +function _system_rebuild_theme_data() { $themes_info = &drupal_static(__FUNCTION__, array()); if (empty($themes_info)) { @@ -2065,13 +2088,13 @@ function _system_get_theme_data() { } /** - * Collect data about all currently available themes. + * Rebuild, save, and return data about all currently available themes. * * @return * Array of all available themes and their data. */ -function system_get_theme_data() { - $themes = _system_get_theme_data(); +function system_rebuild_theme_data() { + $themes = _system_rebuild_theme_data(); ksort($themes); system_get_files_database($themes, 'theme'); system_update_files_database($themes, 'theme'); |