diff options
author | Gerhard Killesreiter <killes_www_drop_org@227.no-reply.drupal.org> | 2006-02-27 15:04:45 +0000 |
---|---|---|
committer | Gerhard Killesreiter <killes_www_drop_org@227.no-reply.drupal.org> | 2006-02-27 15:04:45 +0000 |
commit | bf8b6a531a1af5c9ca7a53d4c3c2678328b44ef9 (patch) | |
tree | a2dd85128fbf63e8764358a8778d99f05f31d938 /includes | |
parent | aeead6cf9c7fa9eeb820391099257c683f54e066 (diff) | |
download | brdo-bf8b6a531a1af5c9ca7a53d4c3c2678328b44ef9.tar.gz brdo-bf8b6a531a1af5c9ca7a53d4c3c2678328b44ef9.tar.bz2 |
#46617, Restore some module listings, partially applied, I've omitted places where I felt that sortign by weight would be wanted.
We can discuss those on the issue. Patch by chx.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/module.inc | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/includes/module.inc b/includes/module.inc index faf33eac9..3e05d62a2 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -36,15 +36,19 @@ function module_iterate($function, $argument = '') { * @param $bootstrap * Whether to return the reduced set of modules loaded in "bootstrap mode" * for cached pages. See bootstrap.inc. + * @param $sort + * By default, modules are ordered by weight and filename, settings this option + * to TRUE, module list will be ordered by module name. * @return * An associative array whose keys and values are the names of all loaded * modules. */ -function module_list($refresh = FALSE, $bootstrap = TRUE) { - static $list; +function module_list($refresh = FALSE, $bootstrap = TRUE, $sort = FALSE) { + static $list, $sorted_list; if ($refresh) { $list = array(); + $sorted_list = NULL; } if (!$list) { @@ -68,6 +72,13 @@ function module_list($refresh = FALSE, $bootstrap = TRUE) { } } } + if ($sort) { + if (!isset($sorted_list)) { + $sorted_list = $list; + ksort($sorted_list); + } + return $sorted_list; + } return $list; } @@ -125,15 +136,18 @@ function module_hook($module, $hook) { * * @param $hook * The name of the hook (e.g. "help" or "menu"). + * @param $sort + * By default, modules are ordered by weight and filename, settings this option + * to TRUE, module list will be ordered by module name. * @return * An array with the names of the modules which are implementing this hook. */ -function module_implements($hook) { +function module_implements($hook, $sort = FALSE) { static $implementations; if (!isset($implementations[$hook])) { $implementations[$hook] = array(); - $list = module_list(); + $list = module_list(FALSE, TRUE, $sort); foreach ($list as $module) { if (module_hook($module, $hook)) { $implementations[$hook][] = $module; |