summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bulk_export/bulk_export.module29
1 files changed, 17 insertions, 12 deletions
diff --git a/bulk_export/bulk_export.module b/bulk_export/bulk_export.module
index ea37a4d..0d02a0e 100644
--- a/bulk_export/bulk_export.module
+++ b/bulk_export/bulk_export.module
@@ -65,7 +65,7 @@ function bulk_export_export() {
drupal_set_title(t('Bulk export results'));
$output = '';
$module_code = '';
- $api_code = '';
+ $api_code = array();
$dependencies = array();
foreach ($form_state['code'] as $module => $api_info) {
if ($module == 'general') {
@@ -73,9 +73,13 @@ function bulk_export_export() {
}
else {
foreach ($api_info as $api => $info) {
- $api_code .= " if (\$module == '$module' && \$api == '$api') {\n";
- $api_code .= " return array('version' => $info[version]);\n";
- $api_code .= " }\n";
+ $api_hook = ctools_plugin_api_get_hook($module, $api);
+ if (empty($api_code[$api_hook])) {
+ $api_code[$api_hook] = '';
+ }
+ $api_code[$api_hook] .= " if (\$module == '$module' && \$api == '$api') {\n";
+ $api_code[$api_hook] .= " return array('version' => $info[version]);\n";
+ $api_code[$api_hook] .= " }\n";
$dependencies[$module] = TRUE;
$file = $form_state['module'] . '.' . $api . '.inc';
@@ -93,14 +97,15 @@ function bulk_export_export() {
// Add hook_ctools_plugin_api at the top of the module code, if there is any.
if ($api_code) {
- $api_hook = ctools_plugin_api_get_hook($module, $api);
- $api = "/**\n";
- $api .= " * Implements hook_$api_hook().\n";
- $api .= " */\n";
- $api .= "function $form_state[module]_$api_hook(\$module, \$api) {\n";
- $api .= $api_code;
- $api .= "}\n";
- $module_code = $api . $module_code;
+ foreach ($api_code as $api_hook => $text) {
+ $api = "/**\n";
+ $api .= " * Implements hook_$api_hook().\n";
+ $api .= " */\n";
+ $api .= "function $form_state[module]_$api_hook(\$module, \$api) {\n";
+ $api .= $text;
+ $api .= "}\n";
+ $module_code = $api . $module_code;
+ }
}
if ($module_code) {