'value',
'#value' => $op,
);
$form['node'] = array(
'#type' => 'value',
'#value' => $node,
);
/* Form steps */
if ($op == 'choose_destination_type') {
$type = node_type_get_name($node);
// Remember current node type, used in theme_ function
$form['current_type'] = array(
'#markup' => $type,
);
// Get available content types
$types = node_convert_return_access_node_types('to');
if ($types != FALSE) {
$key = array_search($form['current_type']['#markup'], $types);
// Delete the current content type from the list
if ($key !== FALSE) {
unset($types[$key]);
}
$options = $types;
// Populate the select with possible content types
$form['destination_type'] = array(
'#type' => 'select',
'#options' => $options,
'#title' => t("To what content type should this node be converted"),
);
}
else {
// Just used as a message, not sure if it's the best implementation
$form['destination_type'] = array(
'#markup' => t("You don't have access to any node types."),
);
}
}
elseif ($op == 'choose_destination_fields') {
// $source_fields = content_types($node->type);
// Get source type fields
$source_fields = field_info_instances('node', $node->type);
$fields_info = field_info_fields();
// In case there are no fields, just convert the node type
if (count($source_fields) == 0) {
$no_fields = TRUE;
}
// Otherwise
else {
$no_fields = FALSE;
// Get destination type fields
$dest_fields = field_info_instances('node', $form_state['storage']['destination_type']);
$i = 0;
foreach ($source_fields as $source_field_name => $source_field) {
$i++;
$options = array();
$options['discard'] = 'discard';
$options[APPEND_TO_BODY] = t('Append to body');
$options[REPLACE_BODY] = t('Replace body');
// Insert destination type fields into $options that are of the same type as the source.
foreach ($dest_fields as $dest_field_name => $dest_value) {
if ($fields_info[$source_field_name]['type'] == $fields_info[$dest_field_name]['type']) {
$options[$dest_value['field_name']] = $dest_value['field_name'];
}
}
// Remember the source fields to be converted
$form['source_field_' . $i] = array(
'#type' => 'value',
'#value' => $source_field['field_name'],
);
$form['container_' . $i] = array(
'#type' => 'container',
'#suffix' => '
'
);
// The select populated with possible destination fields for each source field
// If the destination node type has the same field as the source node type, the default value is set to it.
$form['container_' . $i]['dest_field_' . $i] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => $source_field['field_name'],
'#title' => check_plain($source_field['field_name']) . " " . t("should be inserted into"),
);
// Print the current value of the source field
$temp_value = node_convert_format_field_value($node, $fields_info[$source_field_name]);
$form['container_' . $i]['current_field_value_' . $i] = array(
'#type' => 'item',
'#markup' => '