mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-24 02:48:56 +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,81 +544,59 @@ 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)
|
||||
$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);
|
||||
|
||||
foreach ($modules as $cur_module)
|
||||
{
|
||||
global $phpbb_extension_manager;
|
||||
|
||||
$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);
|
||||
|
||||
foreach ($modules as $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 = str_replace("phpbb_{$module_class}_info_", '', $cur_module) . '_info';
|
||||
if (file_exists($directory . $info_class . '.' . $phpEx))
|
||||
{
|
||||
include($directory . $module . '.' . $phpEx);
|
||||
include($directory . $info_class . '.' . $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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue