Index: webform.module =================================================================== --- webform.module (revision 135) +++ webform.module (working copy) @@ -2393,22 +2393,38 @@ static $component_list, $enabled_list; if (!isset($component_list) || $reset) { + // put a custom hook here that will allow us to load custom component.inc files + $custom_components = module_invoke_all('load_webform_components'); $component_list = array(); $enabled_list = array(); - $path = drupal_get_path('module', 'webform') .'/components'; - $files = file_scan_directory($path, '^.*\.inc$'); - foreach ($files as $filename => $file) { - $enabled = variable_get('webform_enable_'. $file->name, 1); - if ($return_all || $enabled) { - module_load_include('inc', 'webform', 'components/'. $file->name); - $component_list[$file->name] = t($file->name); + // for each hook, check if it's returned sensible data, and load if so + foreach ($custom_components as $module_components) { + if (is_array($module_components['components'])) { + $component_list = array_merge($component_list, $module_components['components']); } - if ($enabled) { - $enabled_list[$file->name] = t($file->name); + if (is_array($module_components['enabled'])) { + $enabled_list = array_merge($enabled_list, $module_components['enabled']); } } } - // Ensure only wanted components are returned, even all are loaded. return $return_all ? $component_list : array_intersect_assoc($component_list, $enabled_list); } + +function webform_load_webform_components($module = 'webform') { + $component_list = array(); + $enabled_list = array(); + $path = drupal_get_path('module',$module).'/components'; + $files = file_scan_directory($path, '^.*\.inc$'); + foreach ($files as $filename => $file) { + $enabled = variable_get('webform_enable_'.$file->name, 1); + if ($return_all || $enabled) { + include_once($filename); + $component_list[$file->name] = t($file->name); + } + if ($enabled) { + $enabled_list[$file->name] = t($file->name); + } + } + return array(array('components' => $component_list, 'enabled' => $enabled_list)); +}