diff options
| author | Nathan Guse <nathaniel.guse@gmail.com> | 2013-05-12 18:49:23 -0500 |
|---|---|---|
| committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-05-12 18:49:23 -0500 |
| commit | f93a750f28ca4ca502a880d44a45a72c340b6e38 (patch) | |
| tree | afe00006f9eb500db1550b90f5e3576669946240 /phpBB/includes/acp/acp_modules.php | |
| parent | a42693e66d2dc6a8d7998afccabe3eedfcf30613 (diff) | |
| parent | bd6cebfe3882d5df810eb1725a10cd64f5473240 (diff) | |
| download | forums-f93a750f28ca4ca502a880d44a45a72c340b6e38.tar forums-f93a750f28ca4ca502a880d44a45a72c340b6e38.tar.gz forums-f93a750f28ca4ca502a880d44a45a72c340b6e38.tar.bz2 forums-f93a750f28ca4ca502a880d44a45a72c340b6e38.tar.xz forums-f93a750f28ca4ca502a880d44a45a72c340b6e38.zip | |
Merge remote-tracking branch 'remotes/Marc/ticket/11465' into develop
# By Marc Alexander (8) and Joas Schilling (3)
# Via Marc Alexander
* remotes/Marc/ticket/11465:
[ticket/11465] Increase count of disabled extensions to 5 in functional test
[ticket/11465] Add disabled ext to allow proper testing of get_module_infos()
[ticket/11465] Add tests for optional arguments of get_module_infos()
[ticket/11465] Add comments explaining the tests
[ticket/11465] Check if class exists before including info file
[ticket/11465] Correctly set the root path for the test
[ticket/11465] The info file does not have _info suffix
[ticket/11465] Add phpBB module to test
[ticket/11465] Move require_once() in unit test to the top of the file
[ticket/11465] Add unit tests for acp_modules::get_module_infos()
[ticket/11465] Use extension finder when adding extensions' acp modules
Diffstat (limited to 'phpBB/includes/acp/acp_modules.php')
| -rw-r--r-- | phpBB/includes/acp/acp_modules.php | 73 |
1 files changed, 26 insertions, 47 deletions
diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 7c2ea86122..ab416fb406 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -544,81 +544,60 @@ class acp_modules */ function get_module_infos($module = '', $module_class = false, $use_all_available = false) { - global $phpbb_root_path, $phpEx; + global $phpbb_extension_manager, $phpbb_root_path, $phpEx; $module_class = ($module_class === false) ? $this->module_class : $module_class; $directory = $phpbb_root_path . 'includes/' . $module_class . '/info/'; $fileinfo = array(); - if (!$module) - { - global $phpbb_extension_manager; - - $finder = $phpbb_extension_manager->get_finder(); + $finder = $phpbb_extension_manager->get_finder(); - $modules = $finder - ->extension_suffix('_module') - ->extension_directory("/$module_class") - ->core_path("includes/$module_class/info/") - ->core_prefix($module_class . '_') - ->get_classes(true, $use_all_available); + $modules = $finder + ->extension_suffix('_module') + ->extension_directory("/$module_class") + ->core_path("includes/$module_class/info/") + ->core_prefix($module_class . '_') + ->get_classes(true, $use_all_available); - foreach ($modules as $module) + foreach ($modules as $cur_module) + { + // Skip entries we do not need if we know the module we are + // looking for + if ($module && strpos($cur_module, $module) === false) { - $info_class = preg_replace('/_module$/', '_info', $module); - - // If the class does not exist it might be following the old - // format. phpbb_acp_info_acp_foo needs to be turned into - // acp_foo_info and the respective file has to be included - // manually because it does not support auto loading - if (!class_exists($info_class)) - { - $info_class = str_replace("phpbb_{$module_class}_info_", '', $module) . '_info'; - if (file_exists($directory . $info_class . '.' . $phpEx)) - { - include($directory . $info_class . '.' . $phpEx); - } - } - - if (class_exists($info_class)) - { - $info = new $info_class(); - $module_info = $info->module(); - - $main_class = (isset($module_info['filename'])) ? $module_info['filename'] : $module; - - $fileinfo[$main_class] = $module_info; - } + continue; } - ksort($fileinfo); - } - else - { - $info_class = preg_replace('/_module$/', '_info', $module); + $info_class = preg_replace('/_module$/', '_info', $cur_module); + // If the class does not exist it might be following the old + // format. phpbb_acp_info_acp_foo needs to be turned into + // acp_foo_info and the respective file has to be included + // manually because it does not support auto loading if (!class_exists($info_class)) { - $info_class = $module . '_info'; - if (!class_exists($info_class) && file_exists($directory . $module . '.' . $phpEx)) + $info_class_file = str_replace("phpbb_{$module_class}_info_", '', $cur_module); + $info_class = $info_class_file . '_info'; + if (!class_exists($info_class) && file_exists($directory . $info_class_file . '.' . $phpEx)) { - include($directory . $module . '.' . $phpEx); + include($directory . $info_class_file . '.' . $phpEx); } } - // Get module title tag if (class_exists($info_class)) { $info = new $info_class(); $module_info = $info->module(); - $main_class = (isset($module_info['filename'])) ? $module_info['filename'] : $module; + $main_class = (isset($module_info['filename'])) ? $module_info['filename'] : $cur_module; $fileinfo[$main_class] = $module_info; } } + ksort($fileinfo); + return $fileinfo; } |
