mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-26 13:04:13 +02:00
[feature/extension-manager] Allow old non-prefix basenames to work for lookups
These module basenames are hardcoded in a bunch of places so they need to continue to work unless we want to rewrite all of them. PHPBB3-10323
This commit is contained in:
@ -221,13 +221,15 @@ class p_master
|
|||||||
// We need to prefix the functions to not create a naming conflict
|
// We need to prefix the functions to not create a naming conflict
|
||||||
|
|
||||||
// Function for building 'url_extra'
|
// Function for building 'url_extra'
|
||||||
$url_func = '_module_' . $row['module_basename'] . '_url';
|
$short_name = $this->get_short_name($row['module_basename']);
|
||||||
|
|
||||||
|
$url_func = '_module_' . $short_name . '_url';
|
||||||
|
|
||||||
// Function for building the language name
|
// Function for building the language name
|
||||||
$lang_func = '_module_' . $row['module_basename'] . '_lang';
|
$lang_func = '_module_' . $short_name . '_lang';
|
||||||
|
|
||||||
// Custom function for calling parameters on module init (for example assigning template variables)
|
// Custom function for calling parameters on module init (for example assigning template variables)
|
||||||
$custom_func = '_module_' . $row['module_basename'];
|
$custom_func = '_module_' . $short_name;
|
||||||
|
|
||||||
$names[$row['module_basename'] . '_' . $row['module_mode']][] = true;
|
$names[$row['module_basename'] . '_' . $row['module_mode']][] = true;
|
||||||
|
|
||||||
@ -275,6 +277,11 @@ class p_master
|
|||||||
*/
|
*/
|
||||||
function loaded($module_basename, $module_mode = false)
|
function loaded($module_basename, $module_mode = false)
|
||||||
{
|
{
|
||||||
|
if (!$this->is_full_class($module_basename))
|
||||||
|
{
|
||||||
|
$module_basename = $this->p_class . '_' . $module_basename;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($this->loaded_cache))
|
if (empty($this->loaded_cache))
|
||||||
{
|
{
|
||||||
$this->loaded_cache = array();
|
$this->loaded_cache = array();
|
||||||
@ -381,6 +388,11 @@ class p_master
|
|||||||
$id = request_var('icat', '');
|
$id = request_var('icat', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($id && !is_numeric($id) && !$this->is_full_class($id))
|
||||||
|
{
|
||||||
|
$id = $this->p_class . '_' . $id;
|
||||||
|
}
|
||||||
|
|
||||||
$category = false;
|
$category = false;
|
||||||
foreach ($this->module_ary as $row_id => $item_ary)
|
foreach ($this->module_ary as $row_id => $item_ary)
|
||||||
{
|
{
|
||||||
@ -389,9 +401,9 @@ class p_master
|
|||||||
// If this is a module and no mode selected, select first mode
|
// If this is a module and no mode selected, select first mode
|
||||||
// If no category or module selected, go active for first module in first category
|
// If no category or module selected, go active for first module in first category
|
||||||
if (
|
if (
|
||||||
(($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && (($item_ary['mode'] == $mode && !$item_ary['cat']) || ($icat && $item_ary['cat']))) ||
|
(($item_ary['name'] === $id || $item_ary['name'] === $this->p_class . '_' . $id || $item_ary['id'] === (int) $id) && (($item_ary['mode'] == $mode && !$item_ary['cat']) || ($icat && $item_ary['cat']))) ||
|
||||||
($item_ary['parent'] === $category && !$item_ary['cat'] && !$icat && $item_ary['display']) ||
|
($item_ary['parent'] === $category && !$item_ary['cat'] && !$icat && $item_ary['display']) ||
|
||||||
(($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && !$mode && !$item_ary['cat']) ||
|
(($item_ary['name'] === $id || $item_ary['name'] === $this->p_class . '_' . $id || $item_ary['id'] === (int) $id) && !$mode && !$item_ary['cat']) ||
|
||||||
(!$id && !$mode && !$item_ary['cat'] && $item_ary['display'])
|
(!$id && !$mode && !$item_ary['cat'] && $item_ary['display'])
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -445,7 +457,6 @@ class p_master
|
|||||||
{
|
{
|
||||||
if (!file_exists("$module_path/{$this->p_name}.$phpEx"))
|
if (!file_exists("$module_path/{$this->p_name}.$phpEx"))
|
||||||
{
|
{
|
||||||
|
|
||||||
trigger_error("Cannot find module $module_path/{$this->p_name}.$phpEx", E_USER_ERROR);
|
trigger_error("Cannot find module $module_path/{$this->p_name}.$phpEx", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,7 +518,8 @@ class p_master
|
|||||||
// Users are able to call the main method after this function to be able to assign additional parameters manually
|
// Users are able to call the main method after this function to be able to assign additional parameters manually
|
||||||
if ($execute_module)
|
if ($execute_module)
|
||||||
{
|
{
|
||||||
$this->module->main($this->p_name, $this->p_mode);
|
$short_name = preg_replace("#^{$this->p_class}_#", '', $this->p_name);
|
||||||
|
$this->module->main($short_name, $this->p_mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,7 +558,7 @@ class p_master
|
|||||||
// If we find a name by this id and being enabled we have our active one...
|
// If we find a name by this id and being enabled we have our active one...
|
||||||
foreach ($this->module_ary as $row_id => $item_ary)
|
foreach ($this->module_ary as $row_id => $item_ary)
|
||||||
{
|
{
|
||||||
if (($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && $item_ary['display'])
|
if (($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && $item_ary['display'] || $item_ary['name'] === $this->p_class . '_' . $id)
|
||||||
{
|
{
|
||||||
if ($mode === false || $mode === $item_ary['mode'])
|
if ($mode === false || $mode === $item_ary['mode'])
|
||||||
{
|
{
|
||||||
@ -840,7 +852,7 @@ class p_master
|
|||||||
{
|
{
|
||||||
foreach ($this->module_ary as $row_id => $item_ary)
|
foreach ($this->module_ary as $row_id => $item_ary)
|
||||||
{
|
{
|
||||||
if (($item_ary['name'] === $id || $item_ary['id'] === (int) $id) && (!$mode || $item_ary['mode'] === $mode))
|
if (($item_ary['name'] === $id || $item_ary['name'] === $this->p_class . '_' . $id || $item_ary['id'] === (int) $id) && (!$mode || $item_ary['mode'] === $mode))
|
||||||
{
|
{
|
||||||
$this->module_ary[$row_id]['display'] = (int) $display;
|
$this->module_ary[$row_id]['display'] = (int) $display;
|
||||||
}
|
}
|
||||||
@ -878,4 +890,20 @@ class p_master
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_short_name($basename)
|
||||||
|
{
|
||||||
|
if (substr($basename, 0, 6) === 'phpbb_')
|
||||||
|
{
|
||||||
|
return $basename;
|
||||||
|
}
|
||||||
|
|
||||||
|
// strip xcp_ prefix from old classes
|
||||||
|
return substr($basename, strlen($this->p_class) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_full_class($basename)
|
||||||
|
{
|
||||||
|
return (substr($basename, 0, 6) === 'phpbb_' || substr($basename, 0, strlen($this->p_class) + 1) === $this->p_class . '_');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user