function content_copy_export in Content Construction Kit (CCK) 6
Same name and namespace in other branches
- 5 content_copy.module \content_copy_export()
- 6.3 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 modules/
content_copy/ content_copy.module - A form to export field definitions.
File
- modules/
content_copy/ content_copy.module, line 173 - Adds capability to import/export CCK field data definitions.
Code
function content_copy_export($form_values) {
// 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.
$node_state = array(
'values' => array(
'type_name' => $form_values['type_name'],
),
);
module_load_include('inc', 'node', 'content_types');
drupal_execute('node_type_form', $node_state, node_get_types('type', $form_values['type_name']));
module_load_include('inc', 'content', 'includes/content.admin');
module_load_include('inc', 'content', 'includes/content.crud');
// Get an array of groups to export.
// Record a macro for each group by submitting the group edit form.
if (!empty($form_values['groups']) && module_exists('fieldgroup')) {
$content_type = content_types($form_values['type_name']);
foreach ($form_values['groups'] as $group) {
$group_state = array(
'values' => array(
'group_name' => $group,
),
);
drupal_execute('fieldgroup_edit_group_form', $group_state, $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.
$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)) {
$field_state = array(
'values' => array(
'field_name' => $field_name,
),
);
drupal_execute('_content_admin_field', $field_state, $form_values['type_name'], $field_name);
}
}
// Convert the macro array into formatted text.
return content_copy_get_macro();
}