From 70fce32f661efe5d9f3300aaa65c6131790c0199 Mon Sep 17 00:00:00 2001 From: emanuele Date: Wed, 10 Jul 2013 21:51:40 +0200 Subject: [PATCH 1/2] Fix for integration hooks page Signed-off-by: emanuele --- sources/admin/ManageAddonSettings.php | 6 +++--- sources/subs/ManageAddonSettings.subs.php | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) 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..ffc6b1caf5 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,7 +99,17 @@ 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 integrare_*_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']; From e90e14c983bfc0709499ad05b9b4217e42613a53 Mon Sep 17 00:00:00 2001 From: emanuele Date: Sun, 14 Jul 2013 15:45:25 +0200 Subject: [PATCH 2/2] Typo - thanks Eurich Signed-off-by: emanuele --- sources/subs/ManageAddonSettings.subs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/subs/ManageAddonSettings.subs.php b/sources/subs/ManageAddonSettings.subs.php index ffc6b1caf5..4ab57e8652 100644 --- a/sources/subs/ManageAddonSettings.subs.php +++ b/sources/subs/ManageAddonSettings.subs.php @@ -104,7 +104,7 @@ function list_integration_hooks_data($start, $per_page, $sort) { $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]); } @@ -113,7 +113,7 @@ function list_integration_hooks_data($start, $per_page, $sort) { $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]); }