diff --git a/sources/admin/ManageAddonSettings.php b/sources/admin/ManageAddonSettings.php index bbd5c43bc2..51c0ad952c 100644 --- a/sources/admin/ManageAddonSettings.php +++ b/sources/admin/ManageAddonSettings.php @@ -383,7 +383,7 @@ function list_getIntegrationHooksCount() if (isset($_GET['filter'])) $context['filter'] = $_GET['filter']; - return get_integration_hooks_count($context['filter']); + return integration_hooks_count($context['filter']); } /** @@ -391,8 +391,8 @@ function list_getIntegrationHooksCount() * * @return array */ - function list_getIntegrationHooks() + function list_getIntegrationHooks($start, $per_page, $sort) { - return get_integration_hooks(); + return list_integration_hooks_data($start, $per_page, $sort); } } diff --git a/sources/subs/ManageAddonSettings.subs.php b/sources/subs/ManageAddonSettings.subs.php index 5d8def3db4..4ab57e8652 100644 --- a/sources/subs/ManageAddonSettings.subs.php +++ b/sources/subs/ManageAddonSettings.subs.php @@ -70,7 +70,7 @@ function list_integration_hooks_data($start, $per_page, $sort) if (is_file($file['dir'] . '/' . $file['name']) && substr($file['name'], -4) === '.php') { $fp = fopen($file['dir'] . '/' . $file['name'], 'rb'); - $fc = fread($fp, filesize($file['dir'] . '/' . $file['name'])); + $fc = strtr(fread($fp, filesize($file['dir'] . '/' . $file['name'])), array("\r" => '', "\n" => '')); fclose($fp); foreach ($temp_hooks as $hook => $functions) @@ -81,10 +81,14 @@ function list_integration_hooks_data($start, $per_page, $sort) if (strpos($hook_name, '::') !== false) { $function = explode('::', $hook_name); + $class = $function[0]; $function = $function[1]; } else + { + $class = ''; $function = $hook_name; + } $function = explode(':', $function); $function = $function[0]; @@ -95,11 +99,21 @@ function list_integration_hooks_data($start, $per_page, $sort) $temp_data['include'][basename($function)] = array('hook' => $hook, 'function' => $function); unset($temp_hooks[$hook][$function_o]); } - elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($function) . '(') !== false) + // Procedural functions as easy + elseif (empty($class) && strpos(str_replace(' (', '(', $fc), 'function ' . trim($function) . '(') !== false) + { + $hook_status[$hook][$hook_name]['exists'] = true; + $hook_status[$hook][$hook_name]['in_file'] = $file['name']; + // I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrate_*_include of that file can be disabled too) + $temp_data['function'][$file['name']][] = $function_o; + unset($temp_hooks[$hook][$function_o]); + } + // OOP a bit more difficult + elseif (!empty($class) && preg_match('~class\s*' . preg_quote(trim($class)) . '.*function\s*' . preg_quote(trim($function)) . '\s*\(~i', $fc) != 0) { $hook_status[$hook][$hook_name]['exists'] = true; $hook_status[$hook][$hook_name]['in_file'] = $file['name']; - // I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrare_*_include of that file can be disabled too) + // I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrate_*_include of that file can be disabled too) $temp_data['function'][$file['name']][] = $function_o; unset($temp_hooks[$hook][$function_o]); }