content_copy_export

Versions
5
content_copy_export($form_id, $form_values)
6
content_copy_export($form_values)

Process the export, get field admin forms for all requested fields and save the form values as formatted text.

▾ 3 functions call content_copy_export()

content_copy_deploy in contributions/deploy/modules/content_copy_deploy/content_copy_deploy.module
Deploy content deployment 'hook'.
content_copy_export_form in contributions/cck/modules/content_copy/content_copy.module
A form to export field definitions.
content_copy_service_export in contributions/deploy/services/content_copy_service/content_copy_service.inc
Content copy export service callback

Code

contributions/cck/modules/content_copy/content_copy.module, line 209

<?php
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.
  $groups = array();
  if (!empty($form_values['groups']) && module_exists('fieldgroup')) {
    $groups = array_filter($form_values['groups']);
    foreach ($groups as $group) {
      $group_state = array('values' => array('group_name' => $group));
      drupal_execute('fieldgroup_group_edit_form', $group_state, $form_values['type_name'], $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.
  if (!empty($form_values['fields'])) {
    $type = content_types($form_values['type_name']);
    $fields = array_filter($form_values['fields']);
    foreach ($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' => content_field_instance_collapse($field));
        $field_state['values']['op'] = t('Save field settings');
        if (module_exists('fieldgroup')) {
          // Avoid undefined index error by always creating this.
          $field_state['values']['group'] = '';
          $group_name = fieldgroup_get_group($form_values['type_name'], $field_name);
          if (in_array($group_name, $groups)) {
            $field_state['values']['group'] = $group_name;
          }
        }
        drupal_execute('content_field_edit_form', $field_state, $form_values['type_name'], $field_name);
      }
    }
  }

  // Convert the macro array into formatted text.
  $output = content_copy_get_macro();

  // Add weights of non-CCK fields.
  if ($extra = variable_get('content_extra_weights_'. $form_values['type_name'], array())) {
    $output .= "\$content['extra']  = ". var_export((array) $extra, TRUE) .";\n";
  }

  return $output;
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.