mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-25 11:28:55 +00:00
[ticket/11465] Use extension finder when adding extensions' acp modules
The method acp_modules::get_module_infos() needs to use the extension finder whenever it is looking for a module's info file. While transitioning to the new extension system, only the initial search for all module info files was changed to the new system. Due to this it is not possible to add an extension's acp/mcp/ucp module manually in the ACP. This patch will always use the extension finder for the acp module's info files and therefore properly find the needed file. Additionally, the code has been cleaned up a little bit. PHPBB3-11465
This commit is contained in:
parent
8b464e87f0
commit
aefca4b40f
1 changed files with 26 additions and 48 deletions
|
@ -544,17 +544,13 @@ 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();
|
||||
|
||||
$modules = $finder
|
||||
|
@ -564,9 +560,16 @@ class acp_modules
|
|||
->core_prefix($module_class . '_')
|
||||
->get_classes(true, $use_all_available);
|
||||
|
||||
foreach ($modules as $module)
|
||||
foreach ($modules as $cur_module)
|
||||
{
|
||||
$info_class = preg_replace('/_module$/', '_info', $module);
|
||||
// Skip entries we do not need if we know the module we are
|
||||
// looking for
|
||||
if ($module && strpos($cur_module, $module) === false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$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
|
||||
|
@ -574,7 +577,7 @@ class acp_modules
|
|||
// manually because it does not support auto loading
|
||||
if (!class_exists($info_class))
|
||||
{
|
||||
$info_class = str_replace("phpbb_{$module_class}_info_", '', $module) . '_info';
|
||||
$info_class = str_replace("phpbb_{$module_class}_info_", '', $cur_module) . '_info';
|
||||
if (file_exists($directory . $info_class . '.' . $phpEx))
|
||||
{
|
||||
include($directory . $info_class . '.' . $phpEx);
|
||||
|
@ -586,38 +589,13 @@ class acp_modules
|
|||
$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);
|
||||
}
|
||||
else
|
||||
{
|
||||
$info_class = preg_replace('/_module$/', '_info', $module);
|
||||
|
||||
if (!class_exists($info_class))
|
||||
{
|
||||
$info_class = $module . '_info';
|
||||
if (!class_exists($info_class) && file_exists($directory . $module . '.' . $phpEx))
|
||||
{
|
||||
include($directory . $module . '.' . $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;
|
||||
|
||||
$fileinfo[$main_class] = $module_info;
|
||||
}
|
||||
}
|
||||
|
||||
return $fileinfo;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue