function content_copy_export in Content Construction Kit (CCK) 5
Same name and namespace in other branches
- 6.3 modules/content_copy/content_copy.module \content_copy_export()
- 6 modules/content_copy/content_copy.module \content_copy_export()
- 6.2 modules/content_copy/content_copy.module \content_copy_export()
Process the export, get field admin forms for all requested fields and save the form values as formatted text.
1 call to content_copy_export()
- content_copy_export_form in ./
content_copy.module - A form to export field definitions.
File
- ./
content_copy.module, line 177 - Adds capability to import/export cck field data definitions.
Code
function content_copy_export($form_id, $form_values) {
include_once './' . drupal_get_path('module', 'content') . '/content_admin.inc';
include_once './' . drupal_get_path('module', 'content') . '/content_crud.inc';
include_once './' . drupal_get_path('module', 'node') . '/content_types.inc';
// Set a global variable to tell when to intervene with form_alter().
$GLOBALS['content_copy']['status'] = 'export';
// Get the content type info by submitting the content type form.
drupal_execute('node_type_form', array(), node_get_types('type', $form_values['type_name']));
// Get an array of groups to export.
// Record a macro for each group by submitting the group edit form.
// TODO come back and do this without using drupal_execute().
if (is_array($form_values['groups']) && module_exists('fieldgroup')) {
$content_type = content_types($form_values['type_name']);
foreach ($form_values['groups'] as $group) {
drupal_execute('fieldgroup_edit_group_form', array(), $content_type, $group, 'edit');
}
}
// Get an array of fields to export
// Record a macro for each field by submitting the field settings form.
// Omit fields from the export if their module is not currently installed
// otherwise the system will generate errors when the macro tries to execute their forms.
// TODO come back and do this without using drupal_execute().
$type = content_types($form_values['type_name']);
foreach ((array) $form_values['fields'] as $field_name) {
$field = $type['fields'][$field_name];
$field_types = _content_field_types();
$field_module = $field_types[$field['type']]['module'];
$widget_types = _content_widget_types();
$widget_module = $widget_types[$field['widget']['type']]['module'];
if (!empty($field_module) && module_exists($field_module) && !empty($widget_module) && module_exists($widget_module)) {
$values = content_field_instance_collapse($field);
drupal_execute('_content_admin_field', $values, $form_values['type_name'], $field_name);
}
}
// Convert the macro array into formatted text.
return content_copy_get_macro();
}